From 3ca8ce266bf5b06556d80c78b31405e7a54aa4e5 Mon Sep 17 00:00:00 2001
From: jinlin <jinlin>
Date: 星期一, 24 六月 2024 11:01:13 +0800
Subject: [PATCH] 修改

---
 web/src/views/modules/taskReliability/TaskPhaseModel.vue |   60 ++++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 44 insertions(+), 16 deletions(-)

diff --git a/web/src/views/modules/taskReliability/TaskPhaseModel.vue b/web/src/views/modules/taskReliability/TaskPhaseModel.vue
index 516193a..19dfd04 100644
--- a/web/src/views/modules/taskReliability/TaskPhaseModel.vue
+++ b/web/src/views/modules/taskReliability/TaskPhaseModel.vue
@@ -13,21 +13,21 @@
                 v-adaptive="{bottomOffset:30}" border
                 @cell-click="handleCellClick"
                 @selection-change="table.selectionChangeHandle">
-        <el-table-column prop="operatConditName" label="宸ュ喌鍚嶇О" width="100"/>
-        <el-table-column prop="operatConditDurationRate" label="宸ュ喌鏃堕暱姣�" align="right" width="160">
+        <el-table-column prop="operatConditName" label="宸ュ喌鍚嶇О" width="140" align="center"/>
+        <el-table-column prop="operatConditDurationRate" label="宸ュ喌鏃堕暱姣�" align="right" width="120">
           <template slot-scope="scope">
                     <span
                       v-if="editingCell && editingCell.row === scope.row && editingCell.column.property === scope.column.property">
                        <el-input ref="editInput"
                                  autosize v-model="scope.row.operatConditDurationRate"
-                                 placeholder="宸ュ喌鏃堕暱姣�"></el-input>
+                                 placeholder="宸ュ喌鏃堕暱姣�" @input="change()"></el-input>
                     </span>
             <span v-else>{{scope.row.operatConditDurationRate}}</span>
           </template>
         </el-table-column>
         <el-table-column align="center" label="閫夌敤">
           <template v-slot="{ row }">
-            <el-checkbox true-label="1" false-label="0" v-model="row.isCheck"></el-checkbox>
+            <el-checkbox true-label="1" false-label="0" v-model="row.isCheck" @change="change"></el-checkbox>
           </template>
         </el-table-column>
       </el-table>
@@ -36,6 +36,7 @@
 </template>
 
 <script>
+  import cloneDeep from 'lodash/cloneDeep'
 
   export default {
     name: 'TaskPhaseModel',
@@ -48,8 +49,11 @@
           operatConditId: '',
           operatConditDurationRate: '',
           dataList: [],
-          isCheck: ''
+          isCheck: '',
+          dataThreeList:[]
         },
+        lastSaveData: [],
+        isChange: false,
         editingCell: null,
         dataList: [],
         originalTableData: [],
@@ -66,7 +70,6 @@
       },
       //鎵归噺淇濆瓨
       async handleSaveRows() {
-        let time = null
         let operatConditDurationRate = null
         let flag = true
         let list = []
@@ -75,21 +78,20 @@
         for (let i = 0; i < this.dataForm.dataThreeList.length; i++) {
           operatConditDurationRate = this.dataForm.dataThreeList[i].operatConditDurationRate
           console.log(operatConditDurationRate)
+          if (this.dataForm.dataThreeList[i].operatConditDurationRate == null)
+            this.dataForm.dataThreeList[i].operatConditDurationRate = '0'
+          if (this.dataForm.dataThreeList[i].isCheck === '0')
+            this.dataForm.dataThreeList[i].operatConditDurationRate = '0'
           if (String(operatConditDurationRate).match(reg) == null && operatConditDurationRate !== null) {
             this.$alert("杈撳叆鐨勬暟鎹牸寮忔湁璇�")
             flag = false
           }
-          time = time + Number(this.dataForm.dataThreeList[i].operatConditDurationRate)
-          if (this.dataForm.dataThreeList[i].isCheck === '0' && this.dataForm.dataThreeList[i].operatConditDurationRate != null) {
-            this.$alert("鏈夋湭鍕鹃�夌殑宸ュ喌")
-            flag = false
-          } else if (this.dataForm.dataThreeList[i].isCheck === '1' && this.dataForm.dataThreeList[i].operatConditDurationRate == null) {
+          // time = time + Number(this.dataForm.dataThreeList[i].operatConditDurationRate)
+          if (this.dataForm.dataThreeList[i].isCheck === '1' && (this.dataForm.dataThreeList[i].operatConditDurationRate == null || this.dataForm.dataThreeList[i].operatConditDurationRate == 0)) {
             this.$alert("鏈夋湭濉啓鐨勫伐鍐垫椂闀�")
             flag = false
           }
-          if (this.dataForm.dataThreeList[i].isCheck === '1') {
-            list.push(this.dataForm.dataThreeList[i])
-          }
+          list.push(this.dataForm.dataThreeList[i])
         }
         this.dataForm.dataThreeList = list
         /*console.log(time, 'async handleSaveRows')
@@ -102,6 +104,8 @@
         }
         let res = await this.$http.post('/taskReliability/TaskPhaseModel/save', this.dataForm)
         if (res.success) {
+          this.isChange = false;
+          this.lastSaveData = cloneDeep(list)
           console.log(res.data)
           await this.$tip.success()
           this.originalData = null
@@ -118,6 +122,8 @@
           this.dataList[i].productId = this.dataForm.productId
           this.dataList[i].phaseId = this.dataForm.phaseId
         }
+        this.lastSaveData = cloneDeep(this.$refs.tableObj.dataList)
+        console.log(this.lastSaveData)
       },
       handleCellClick(row, column) {
         this.editingCell = {row, column}
@@ -127,8 +133,30 @@
           }
         })
         console.log(this.editingCell, 'this.editingCell')
-      }
-      ,
+      },
+      change() {
+        console.log(this.$refs.tableObj.dataList, "this.$refs.tableObj.dataList")
+        console.log(this.lastSaveData, "this.lastSaveData")
+
+        let r = JSON.stringify(this.$refs.tableObj.dataList);
+        let l = JSON.stringify(this.lastSaveData);
+        console.log(r,'this.$refs.tableObj.dataList[i]')
+        console.log(l,'this.lastSaveData[i]')
+        if (r!==l){
+          this.isChange = true
+          return
+        }
+          /* for (let i = 0; i < this.$refs.tableObj.dataList.length; i++) {
+             if (this.$refs.tableObj.dataList[i] != this.lastSaveData[i]) {
+               console.log(i,'no')
+               console.log(this.$refs.tableObj.dataList[i],'this.$refs.tableObj.dataList[i]')
+               console.log(this.lastSaveData[i],'this.lastSaveData[i]')
+               this.isChange = true
+               return
+             }
+           }*/
+          this.isChange = false
+      },
 
     }
   }

--
Gitblit v1.9.1