Browse Source

fix:修改单表组件删除时不会显问题

zcuishan 3 months ago
parent
commit
c99f82381a
1 changed files with 10 additions and 1 deletions
  1. 10 1
      src/components/Form/src/components/SubForm.vue

+ 10 - 1
src/components/Form/src/components/SubForm.vue

@@ -396,7 +396,16 @@
         data.value.push(dataObj);
       }
     });
-    console.log(data.value, 'valeu');
+    // 更改后
+    const listKey = list.map((x) => x[props.valueField]);
+    // 原数据
+    const sourceKey = data.value.map((x) => x[props.uniqueKey]);
+    //删除原数据中不存在的数据
+    sourceKey.map((item, index) => {
+      if (!listKey.includes(item)) {
+        data.value.splice(index, 1);
+      }
+    });
     emit('change', unref(data));
     emit('update:value', unref(data));
   };