Przeglądaj źródła

feat: 试卷结构编辑新增大题调整

zhangjie 11 miesięcy temu
rodzic
commit
364194e4f6

+ 15 - 23
src/modules/mark/components/markParam/MarkParamStructure.vue

@@ -17,6 +17,10 @@
     </div>
 
     <div class="part-box part-box-pad mb-0">
+      <div v-if="structureEditable" class="box-justify mb-2">
+        <div></div>
+        <el-button type="primary" @click="toAddMain">新增大题</el-button>
+      </div>
       <el-table
         ref="TableList"
         :data="tableData"
@@ -211,15 +215,9 @@
           v-if="structureEditable"
           class-name="action-column"
           label="操作"
-          width="200px"
+          width="140px"
         >
           <template slot-scope="scope">
-            <el-button
-              class="btn-primary"
-              type="text"
-              @click="toAddMain(scope.row)"
-              >新增大题</el-button
-            >
             <el-button
               class="btn-primary"
               type="text"
@@ -396,22 +394,16 @@ export default {
     getNewMainNumber() {
       return maxNum(this.tableData.map((item) => item.mainNumber)) + 1;
     },
-    toAddMain(row) {
-      const startPos = this.tableData.findIndex((item) => item.key === row.key);
-      const nextMainStartPos = this.getNextMainStartPos(startPos, row.mainId);
-
-      this.tableData.splice(
-        nextMainStartPos,
-        0,
-        this.getNewRow({
-          mainId: this.$randomCode(),
-          mainNumber: this.getNewMainNumber(),
-          totalScore: row.totalScore,
-          questionType: row.questionType,
-          objective: row.objective,
-        })
-      );
-      this.$set(this.intervalScorePerTopic, row.mainId, undefined);
+    toAddMain() {
+      const newMainData = this.getNewRow({
+        mainId: this.$randomCode(),
+        mainNumber: this.getNewMainNumber(),
+        totalScore: undefined,
+        questionType: null,
+        objective: true,
+      });
+      this.tableData.push(newMainData);
+      this.$set(this.intervalScorePerTopic, newMainData.mainId, undefined);
     },
     updateMainData() {
       let curMainNumber = 0,