Browse Source

设备入库bug修复

刘洋 1 year ago
parent
commit
d1184f0b65

+ 24 - 15
src/views/sop/components/dynamic-form-item/device-table/device-in-table.vue

@@ -65,7 +65,7 @@
   </div>
   </div>
 </template>
 </template>
 <script setup name="DEVICEINTABLE">
 <script setup name="DEVICEINTABLE">
-import { computed, ref, watch } from 'vue';
+import { computed, ref, watch, onMounted } from 'vue';
 import EditColumnDialog from './edit-column-dialog.vue';
 import EditColumnDialog from './edit-column-dialog.vue';
 import { deviceCanIn } from '@/api/sop';
 import { deviceCanIn } from '@/api/sop';
 import bus from '@/utils/bus';
 import bus from '@/utils/bus';
@@ -203,22 +203,31 @@ const initTableData = () => {
     emitChange();
     emitChange();
   });
   });
 };
 };
-watch(
-  () => props.modelValue,
-  (val, oldval) => {
-    if (!val) {
-      initTableData();
-      return;
-    }
-    if (val === oldval) return;
-    const vals = val || [];
-    tableData.value = vals;
+onMounted(() => {
+  const val = props.modelValue;
+  if (!val || (Array.isArray(props.modelValue) && !val.length)) {
+    initTableData();
+  } else {
+    tableData.value = val;
     emitChange();
     emitChange();
-  },
-  {
-    immediate: true,
   }
   }
-);
+});
+// watch(
+//   () => props.modelValue,
+//   (val, oldval) => {
+//     if (!val) {
+//       initTableData();
+//       return;
+//     }
+//     if (val === oldval) return;
+//     const vals = val || [];
+//     tableData.value = vals;
+//     emitChange();
+//   },
+//   {
+//     immediate: true,
+//   }
+// );
 
 
 watch(
 watch(
   tableData,
   tableData,