Kaynağa Gözat

优化table修改值卡顿问题---cjh

17767204043 3 yıl önce
ebeveyn
işleme
483f1fcf95
1 değiştirilmiş dosya ile 17 ekleme ve 15 silme
  1. 17 15
      src/views/BasicSettings/PartSettings/detail.vue

+ 17 - 15
src/views/BasicSettings/PartSettings/detail.vue

@@ -150,11 +150,11 @@
         >
           <template slot="partDetailProduct" slot-scope="{ index }">
             <Select
-              v-model="tableData[index].product_id"
+              v-model="newTable[index].product_id"
               transfer
               filterable
               clearable
-              @on-change="(e) => handleProduct(tableData[index], index, e)"
+              @on-change="(e) => handleProduct(newTable[index], index, e)"
               placeholder="全部"
             >
               <Option
@@ -167,14 +167,14 @@
           </template>
           <template slot="partDetailTitle" slot-scope="{ index }">
             <Select
-              v-model="tableData[index].parts_detail_id"
+              v-model="newTable[index].parts_detail_id"
               transfer
               @on-change="
-                (e) => handlePartDetailSelected(tableData[index], index, e, 1)
+                (e) => handlePartDetailSelected(newTable[index], index, e, 1)
               "
             >
               <Option
-                v-for="(item, index) in tableData[index].part_detail_list"
+                v-for="(item, index) in newTable[index].part_detail_list"
                 :key="index"
                 :label="item.spare_parts"
                 :value="item.id"
@@ -182,7 +182,7 @@
             </Select>
           </template>
           <template slot="measureSlot" slot-scope="{ index }">
-            <Select v-model="tableData[index].basics_measure_id" transfer>
+            <Select v-model="newTable[index].basics_measure_id" transfer>
               <Option
                 v-for="(item, index) in measure_list"
                 :key="index"
@@ -195,25 +195,25 @@
             <Input
               type="text"
               style="width: 80px"
-              v-model.lazy="tableData[index].num"
+              v-model.lazy="newTable[index].num"
             />
           </template>
           <template slot="minSlot" slot-scope="{ index }">
             <Input
               type="text"
               style="width: 80px"
-              v-model="tableData[index].min"
+              v-model="newTable[index].min"
             />
           </template>
           <template slot="maxSlot" slot-scope="{ index }">
             <Input
               type="text"
               style="width: 80px"
-              v-model="tableData[index].max"
+              v-model="newTable[index].max"
             />
           </template>
           <template slot="materialDetailSlot" slot-scope="{ index }">
-            <Select v-model="tableData[index].material_detail_id" transfer>
+            <Select v-model="newTable[index].material_detail_id" transfer>
               <Option
                 v-for="(item, index) in material"
                 :key="index"
@@ -226,12 +226,12 @@
             <div>
               <a
                 style="margin: 0 5px"
-                @click="handleSet(tableData[index], index, 2)"
+                @click="handleSet(newTable[index], index, 2)"
                 >复制</a
               >
               <a
                 style="margin: 0 5px"
-                @click="handleSet(tableData[index], index, 3)"
+                @click="handleSet(newTable[index], index, 3)"
                 >删除</a
               >
             </div>
@@ -415,6 +415,7 @@ export default {
   data() {
     // 这里存放数据
     return {
+      newTable:[{}],
       height: 0,
       rowHeight: 55,
       loading: true,
@@ -596,10 +597,10 @@ export default {
       switch (type) {
         case 1:
         case 2:
-          this.tableData.splice(index, 0, obj);
+          this.newTable.splice(index, 0, obj);
           break;
         case 3:
-          this.tableData.splice(index, 1);
+          this.newTable.splice(index, 1);
           break;
       }
     },
@@ -619,6 +620,7 @@ export default {
           this.tableData.map((v) => {
             v.change_state = false;
           });
+          this.newTable = this.tableData;
           //工艺属性分类赋值第一个
           this.handleProcessSelected(res.data.detail.process_id);
           //工艺属性分类赋值第二个
@@ -741,7 +743,7 @@ export default {
     },
     handleSaveData() {
       let state = false;
-      console.log(this.tableData);
+      this.tableData = this.newTable
       this.tableData.forEach((v) => {
         if (v.product_id != 0 && !v.parts_detail_id) {
           state = true;