Преглед изворни кода

修复字典删除项功能

汪钰 пре 3 година
родитељ
комит
cb2b899757
2 измењених фајлова са 27 додато и 8 уклоњено
  1. 25 6
      src/views/system/dictionary/components/dict-edit.vue
  2. 2 2
      vue.config.js

+ 25 - 6
src/views/system/dictionary/components/dict-edit.vue

@@ -325,7 +325,8 @@
         // 提交状态
         loading: false,
         // 是否是修改
-        isUpdate: false
+        isUpdate: false,
+        delectId: 1
       };
     },
     created() {},
@@ -336,8 +337,10 @@
           code: '',
           enable: 1,
           name: '',
-          sort: ''
+          sort: '',
+          delectId: this.delectId
         });
+        this.delectId = this.delectId + 1;
         this.filterArr();
       },
       //
@@ -346,14 +349,30 @@
       },
       removeArr(row) {
         console.log(row);
-        let falg = this.form.dictStaticSubmitPOList[row.$index].deleted === 0;
-        if (falg) {
-          this.form.dictStaticSubmitPOList[row.$index].deleted = 1;
+        if (row.row.id) {
+          this.form.dictStaticSubmitPOList.forEach((item) => {
+            if (item.id === row.row.id) {
+              item.deleted = 1;
+            }
+          });
           this.filterArr();
         } else {
-          this.form.dictStaticSubmitPOList.splice(row.$index, 1);
+          let index = this.form.dictStaticSubmitPOList.findIndex(
+            (item) => item.delectId === row.row.delectId
+          );
+          console.log(index);
+          this.form.dictStaticSubmitPOList.splice(index, 1); // 在数组的指定位置移除对应的元素。 返回移除的
           this.filterArr();
         }
+
+        // let falg = this.form.dictStaticSubmitPOList[row.$index].deleted === 0;
+        // if (falg) {
+        //   this.form.dictStaticSubmitPOList[row.$index].deleted = 1;
+        //   this.filterArr();
+        // } else {
+        //   this.form.dictStaticSubmitPOList.splice(row.$index, 1);
+        //   this.filterArr();
+        // }
       },
       handleSelectionChange() {},
       /* 保存编辑 */

+ 2 - 2
vue.config.js

@@ -17,8 +17,8 @@ module.exports = {
       '/api': {
         // target: 'http://192.168.3.51:18086', // 跨域请求的地址
         // target: 'http://192.168.3.35:8080', // kang杨威
-        // target: 'http://192.168.3.25:8080', // 黄峥嵘
-        target: 'http://192.168.3.41:8080', // 何江鹏
+        target: 'http://192.168.3.25:8080', // 黄峥嵘
+        // target: 'http://192.168.3.41:8080', // 何江鹏
 
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {