Browse Source

增加列

natasha 2 năm trước cách đây
mục cha
commit
152b4a0240
1 tập tin đã thay đổi với 68 bổ sung3 xóa
  1. 68 3
      src/views/adultInput.vue

+ 68 - 3
src/views/adultInput.vue

@@ -269,13 +269,13 @@
                 >
                   <div>
                     <span>{{ '第'+(rowIndex+1)+'行,第'+(lineIndex+1)+'列' }}</span>
-                    <div class="addoption" style="margin-left: 10px">
+                    <div class="addoption" style="margin-left: 10px" @click="handleRemoveCol(rowIndex,lineIndex,toindex)">
                         删除当前列
                     </div>
-                    <div class="addoption" style="margin-left: 10px">
+                    <div class="addoption" style="margin-left: 10px" @click="handleAddCol('front',rowIndex,lineIndex,toindex)">
                         在当前列前增加列
                     </div>
-                    <div class="addoption" style="margin-left: 10px">
+                    <div class="addoption" style="margin-left: 10px" @click="handleAddCol('behind',rowIndex,lineIndex,toindex)">
                         在当前列后增加列
                     </div>
                   </div>
@@ -1300,6 +1300,44 @@ export default {
       this.LineIndex = null;
       this.$forceUpdate();
     },
+    // 增加列
+    handleAddCol(type, index, rowindex, toindex){
+        let arr = {
+            text: ``,
+            is_add_module: true,
+            is_edit: true,
+        };
+        if (type == "front") {
+            //  加到当前列前面
+            if (rowindex == 0) {
+                this.question_list.cur_fn_data[toindex].table_list[index].splice(0, 0, arr);
+            } else {
+                this.question_list.cur_fn_data[toindex].table_list[index].splice(
+                    rowindex - 1,
+                    0,
+                    arr
+                );
+            }
+        } else {
+            //  加到当前列后面
+            this.question_list.cur_fn_data[toindex].table_list[index].splice(
+            rowindex + 1,
+            0,
+            arr
+            );
+        }
+        this.question_list.cur_fn_data[toindex].table_list.forEach(
+            (item, rowIndex) => {
+            item.forEach((it, colIndex) => {
+                it.text = `第${rowIndex + 1}行,第${colIndex + 1}列`;
+            });
+            }
+        );
+        this.TopicIndex = null;
+        this.RowIndex = null;
+        this.LineIndex = null;
+        this.$forceUpdate();
+    },
     // 删除行
     removeRow(index, toindex) {
       this.$confirm("确定要删除当前行吗?", "提示", {
@@ -1327,6 +1365,33 @@ export default {
         this.$forceUpdate();
       });
     },
+    // 删除列
+    handleRemoveCol(index, rowindex, toindex){
+        this.$confirm("确定要删除当前列吗?", "提示", {
+            confirmButtonText: "确定",
+            cancelButtonText: "取消",
+            type: "warning",
+        }).then(() => {
+            // 里面是不是剩下最后一列了
+            if (this.question_list.cur_fn_data[toindex].table_list[index].length == 1) {
+                this.question_list.cur_fn_data[toindex].table_list[index].splice(rowindex, 1);
+                this.question_list.cur_fn_data[toindex].table_list.splice(index, 1);
+            } else {
+                this.question_list.cur_fn_data[toindex].table_list[index].splice(rowindex, 1);
+            }
+            this.question_list.cur_fn_data[toindex].table_list.forEach(
+                (item, rowIndex) => {
+                    item.forEach((it, colIndex) => {
+                        it.text = `第${rowIndex + 1}行,第${colIndex + 1}列`;
+                    });
+                }
+            );
+            this.TopicIndex = null;
+            this.RowIndex = null;
+            this.LineIndex = null;
+            this.$forceUpdate();
+        });
+    },
     changeCurrentTreeID(val) {
       this.currentTreeID = val;
     },