zhangjie 2 лет назад
Родитель
Сommit
0af4c1a603

+ 6 - 0
src/modules/paper/api.js

@@ -10,3 +10,9 @@ export const courseQueryApi = (name, enable) => {
     },
   });
 };
+
+//  build paper
+export const buildPaperApi = (datas) => {
+  // return $httpWithMsg.post(`${QUESTION_API}/paper/build`, datas);
+  return Promise.resolve(datas);
+};

+ 62 - 1
src/modules/paper/components/BuildPaperAuto.vue

@@ -4,17 +4,78 @@
       <h3><span>试卷结构设置</span></h3>
       <el-button type="primary" @click="toSelectStruct">选择试卷结构</el-button>
     </div>
+
+    <el-collapse v-model="activeNames" accordion>
+      <el-collapse-item
+        v-for="(detail, index) in details"
+        :key="detail.questionKey"
+        :name="index"
+      >
+        <div slot="title" class="subq-header">
+          <h3>{{ index + 1 }}、{{ subq.name }}</h3>
+          <div>
+            <el-button
+              size="mini"
+              type="text"
+              icon="el-icon-delete"
+              title="编辑"
+              @click.stop="editDetail(detail)"
+            ></el-button>
+            <el-button
+              size="mini"
+              type="text"
+              icon="el-icon-delete"
+              title="删除"
+              @click.stop="removeDetail(index)"
+            ></el-button>
+          </div>
+        </div>
+        <p class="detail-desc">
+          <rich-text :text-json="detail.remark"></rich-text>
+        </p>
+      </el-collapse-item>
+    </el-collapse>
+
+    <!-- ModifyDetailStruct -->
+    <modify-detail-struct
+      ref="ModifyDetailStruct"
+      :detail="curDetail"
+      @modified="detailModified"
+    ></modify-detail-struct>
   </div>
 </template>
 
 <script>
+import ModifyDetailStruct from "../components/ModifyDetailStruct.vue";
+
 export default {
   name: "BuildPaperAuto",
+  components: { ModifyDetailStruct },
   data() {
-    return {};
+    return {
+      details: [],
+      curDetail: {},
+    };
   },
   methods: {
     toSelectStruct() {},
+    addDetail() {
+      this.curDetail = {};
+    },
+    editDetail(curDetail) {
+      this.curDetail = curDetail;
+    },
+    removeDetail(index) {
+      console.log(index);
+    },
+    detailModified(data) {
+      const index = this.details.findIndex((item) => item.id === data.id);
+      if (index === -1) {
+        this.details.push(data);
+      } else {
+        this.details[index] = Object.assign({}, this.details[index], data);
+      }
+    },
   },
 };
 </script>

+ 2 - 2
src/modules/paper/components/BuildPaperSimple.vue

@@ -53,11 +53,11 @@
           <el-input-number
             v-model="scope.row.questionScore"
             placeholder="请输入抽取试题分值"
-            :step="1"
+            :step="0.5"
             :min="1"
             :max="999"
             :controls="false"
-            :precision="0"
+            :precision="0.1"
             step-strictly
           ></el-input-number>
         </template>

+ 53 - 29
src/modules/paper/components/ModifyDetailStruct.vue

@@ -9,7 +9,7 @@
   >
     <el-form
       ref="paperDetailStructForm"
-      :model="paperDetailStructForm"
+      :model="modalForm"
       :rules="rules"
       label-position="right"
       label-width="90px"
@@ -18,62 +18,79 @@
     >
       <el-form-item label="大题名称" prop="name">
         <el-input
-          v-model="paperDetailStructForm.name"
+          v-model="modalForm.name"
           class="dialog-input-width"
           placeholder="请输入题型名称"
         ></el-input>
       </el-form-item>
       <el-form-item label="大题描述" prop="remark">
         <v-editor
-          v-model="paperDetailStructForm.remark"
+          v-model="modalForm.remark"
           placeholder="请输入大题描述"
           :enable-formula="false"
         ></v-editor>
       </el-form-item>
+      <el-form-item label="题型" prop="questionType">
+        <question-type-select
+          v-model="modalForm.questionType"
+        ></question-type-select>
+      </el-form-item>
+      <el-form-item label="每题分值" prop="scorePerQuestion">
+        <el-input-number
+          v-model="modalForm.scorePerQuestion"
+          placeholder="请输入抽取试题分值"
+          :step="0.5"
+          :min="0.5"
+          :max="999"
+          :controls="false"
+          :precision="0.1"
+          step-strictly
+        ></el-input-number>
+      </el-form-item>
     </el-form>
     <div slot="footer">
-      <el-button
-        v-if="dialogType == 'ADD'"
-        type="primary"
-        @click="saveDetail('paperDetailStructForm')"
-        >保存</el-button
-      >
-      <el-button
-        v-else
-        type="primary"
-        @click="saveEditDetail('paperDetailStructForm')"
-        >保存</el-button
-      >
-      <el-button type="danger" plain @click="resetForm('paperDetailStructForm')"
-        >重置</el-button
-      >
-      <el-button
-        type="danger"
-        plain
-        @click="closeDialog('paperDetailStructForm')"
-        >返回</el-button
-      >
+      <el-button type="primary" @click="confirm">保存</el-button>
+      <el-button type="danger" plain @click="cancel">返回</el-button>
     </div>
   </el-dialog>
 </template>
 
 <script>
 const initModalForm = {
-  importType: "word",
-  courseId: "",
-  userPaper: false,
-  scoreCheck: false,
+  id: "",
+  name: "",
+  remark: "",
+  questionType: null,
+  scorePerQuestion: undefined,
 };
 export default {
   name: "ModifyDetailStruct",
+  props: {
+    detail: {
+      type: Object,
+      default() {
+        return {};
+      },
+    },
+  },
   data() {
     return {
       modalIsShow: false,
+      modalForm: { ...initModalForm },
+      rules: {
+        name: [
+          {
+            required: true,
+            message: "请输入大题名称",
+            trigger: "change",
+          },
+        ],
+      },
     };
   },
   methods: {
     visibleChange() {
-      this.modalForm = { ...initModalForm };
+      this.modalForm = this.$objAssign(initModalForm, this.detail);
       this.fileData = {};
     },
     cancel() {
@@ -82,6 +99,13 @@ export default {
     open() {
       this.modalIsShow = true;
     },
+    async confirm() {
+      const valid = await this.$refs.modalFormComp.validate().catch(() => {});
+      if (!valid) return;
+
+      this.$emit("modified", this.modalForm);
+      this.cancel();
+    },
   },
 };
 </script>

+ 626 - 0
src/modules/paper/datas/folderPropStruct.json

@@ -0,0 +1,626 @@
+[
+  {
+    "folderId": "11",
+    "folderName": "2021-2022第一学期期末考试试用1",
+    "properties": [
+      {
+        "coursePropertyName": "知识",
+        "distributeInfo": [
+          {
+            "propertyId": 576,
+            "classifyName": "向量代数与空间解析几何",
+            "questionDistributeInfo": [
+              {
+                "name": "难",
+                "count": 3
+              },
+              {
+                "name": "中",
+                "count": 4
+              },
+              {
+                "name": "易",
+                "count": 5
+              }
+            ],
+            "children": [
+              {
+                "propertyId": 577,
+                "classifyName": "向量及其线性运算",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 578,
+                "classifyName": "点的坐标与向量坐标",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 579,
+                "classifyName": "向量的乘法运算",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              }
+            ]
+          },
+          {
+            "propertyId": 585,
+            "classifyName": "多元函数微分法及其应用",
+            "questionDistributeInfo": [
+              {
+                "name": "难",
+                "count": 3
+              },
+              {
+                "name": "中",
+                "count": 4
+              },
+              {
+                "name": "易",
+                "count": 5
+              }
+            ],
+            "children": [
+              {
+                "propertyId": 586,
+                "classifyName": "多元函数的基本概念",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 587,
+                "classifyName": "多元函数的极限及连续性",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 588,
+                "classifyName": "偏导数与全微分",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              }
+            ]
+          }
+        ]
+      },
+      {
+        "coursePropertyName": "能力",
+        "distributeInfo": [
+          {
+            "propertyId": 596,
+            "classifyName": "重积分",
+            "questionDistributeInfo": [
+              {
+                "name": "难",
+                "count": 3
+              },
+              {
+                "name": "中",
+                "count": 4
+              },
+              {
+                "name": "易",
+                "count": 5
+              }
+            ],
+            "children": [
+              {
+                "propertyId": 597,
+                "classifyName": "重积分的概念与性质",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 598,
+                "classifyName": "直角坐标系下二重积分的计算",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 599,
+                "classifyName": "极坐标系下二重积分的计算",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              }
+            ]
+          },
+          {
+            "propertyId": 602,
+            "classifyName": "不定积分",
+            "questionDistributeInfo": [
+              {
+                "name": "难",
+                "count": 3
+              },
+              {
+                "name": "中",
+                "count": 4
+              },
+              {
+                "name": "易",
+                "count": 5
+              }
+            ],
+            "children": [
+              {
+                "propertyId": 603,
+                "classifyName": "不定积分的概念",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 604,
+                "classifyName": "换元积分法",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 605,
+                "classifyName": "分部积分法",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              }
+            ]
+          }
+        ]
+      }
+    ]
+  },
+  {
+    "folderId": "22",
+    "folderName": "2021-2022第一学期期末考试试用2",
+    "properties": [
+      {
+        "coursePropertyName": "知识",
+        "distributeInfo": [
+          {
+            "propertyId": 576,
+            "classifyName": "向量代数与空间解析几何",
+            "questionDistributeInfo": [
+              {
+                "name": "难",
+                "count": 3
+              },
+              {
+                "name": "中",
+                "count": 4
+              },
+              {
+                "name": "易",
+                "count": 5
+              }
+            ],
+            "children": [
+              {
+                "propertyId": 577,
+                "classifyName": "向量及其线性运算",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 578,
+                "classifyName": "点的坐标与向量坐标",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 579,
+                "classifyName": "向量的乘法运算",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              }
+            ]
+          },
+          {
+            "propertyId": 585,
+            "classifyName": "多元函数微分法及其应用",
+            "questionDistributeInfo": [
+              {
+                "name": "难",
+                "count": 3
+              },
+              {
+                "name": "中",
+                "count": 4
+              },
+              {
+                "name": "易",
+                "count": 5
+              }
+            ],
+            "children": [
+              {
+                "propertyId": 586,
+                "classifyName": "多元函数的基本概念",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 587,
+                "classifyName": "多元函数的极限及连续性",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 588,
+                "classifyName": "偏导数与全微分",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              }
+            ]
+          }
+        ]
+      },
+      {
+        "coursePropertyName": "能力",
+        "distributeInfo": [
+          {
+            "propertyId": 596,
+            "classifyName": "重积分",
+            "questionDistributeInfo": [
+              {
+                "name": "难",
+                "count": 3
+              },
+              {
+                "name": "中",
+                "count": 4
+              },
+              {
+                "name": "易",
+                "count": 5
+              }
+            ],
+            "children": [
+              {
+                "propertyId": 597,
+                "classifyName": "重积分的概念与性质",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 598,
+                "classifyName": "直角坐标系下二重积分的计算",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 599,
+                "classifyName": "极坐标系下二重积分的计算",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              }
+            ]
+          },
+          {
+            "propertyId": 602,
+            "classifyName": "不定积分",
+            "questionDistributeInfo": [
+              {
+                "name": "难",
+                "count": 3
+              },
+              {
+                "name": "中",
+                "count": 4
+              },
+              {
+                "name": "易",
+                "count": 5
+              }
+            ],
+            "children": [
+              {
+                "propertyId": 603,
+                "classifyName": "不定积分的概念",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 604,
+                "classifyName": "换元积分法",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              },
+              {
+                "propertyId": 605,
+                "classifyName": "分部积分法",
+                "questionDistributeInfo": [
+                  {
+                    "name": "难",
+                    "count": 3
+                  },
+                  {
+                    "name": "中",
+                    "count": 4
+                  },
+                  {
+                    "name": "易",
+                    "count": 5
+                  }
+                ]
+              }
+            ]
+          }
+        ]
+      }
+    ]
+  }
+]

+ 50 - 2
src/modules/paper/views/BuildPaper.vue

@@ -25,7 +25,13 @@
           >
         </div>
       </div>
-      <el-form class="part-filter-form" :model="modalForm" inline>
+      <el-form
+        ref="modalFormComp"
+        class="part-filter-form"
+        :model="modalForm"
+        :rules="rules"
+        inline
+      >
         <el-form-item prop="paperName" label="试卷名称">
           <el-input
             v-model="modalForm.paperName"
@@ -78,12 +84,14 @@
 import BuildPaperAuto from "../components/BuildPaperAuto.vue";
 import BuildPaperManual from "../components/BuildPaperManual.vue";
 import BuildPaperSimple from "../components/BuildPaperSimple.vue";
+import { buildPaperApi } from "../api";
 
 export default {
   name: "BuildPaper",
   components: { BuildPaperAuto, BuildPaperManual, BuildPaperSimple },
   data() {
     return {
+      loading: false,
       modalForm: {
         courseId: "",
         courseCode: "",
@@ -93,6 +101,27 @@ export default {
         topicRepeat: false,
         genModelType: "simple",
       },
+      rules: {
+        paperName: [
+          {
+            required: true,
+            message: "请输入试卷名称",
+            trigger: "change",
+          },
+          {
+            max: 100,
+            message: "试卷名称不能超过100个字",
+            trigger: "change",
+          },
+        ],
+        genNumber: [
+          {
+            required: true,
+            message: "请输入组卷套数",
+            trigger: "change",
+          },
+        ],
+      },
       modelTypes: [
         {
           code: "simple",
@@ -118,7 +147,26 @@ export default {
     this.modalForm.courseId = this.$route.params.courseId;
   },
   methods: {
-    confirm() {},
+    async confirm() {
+      let valid = await this.$refs.modalFormComp.validate().catch(() => {});
+      if (!valid) return;
+      valid = await this.$refs.BuildPaperDetail.validate().catch(() => {});
+      if (!valid) return;
+
+      if (this.loading) return;
+      this.loading = true;
+
+      let paperSet = this.$refs.BuildPaperDetail.getData();
+      const datas = {
+        ...this.modalForm,
+        paperSet,
+      };
+      const res = await buildPaperApi(datas).catch(() => {});
+      this.loading = false;
+      if (!res) return;
+
+      this.$message.success("组卷成功!");
+    },
     toback() {
       window.history.go(-1);
     },