From 3cbb9eb9e6f594721239bde5754db6df924472a6 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期六, 27 八月 2022 10:33:06 +0800
Subject: [PATCH] 1.工序检验记录开发完成

---
 src/views/sbgl/djbz.vue |  138 ++++++++++++++++++++++++++++++---------------
 1 files changed, 92 insertions(+), 46 deletions(-)

diff --git a/src/views/sbgl/djbz.vue b/src/views/sbgl/djbz.vue
index e4d0130..4ab6079 100644
--- a/src/views/sbgl/djbz.vue
+++ b/src/views/sbgl/djbz.vue
@@ -155,8 +155,8 @@
       :close-on-click-modal="false"
       top="8vh"
       @closed="handleClose"
-      @close="handleClose"
     >
+      <!--      @close="handleClose"-->
       <div>
         <i class="el-icon-s-operation" style="color:#42b983;margin: -20px 10px 20px 0" />璁惧鐐规鏍囧噯淇℃伅
       </div>
@@ -415,7 +415,7 @@
 import { getCookie } from '@/utils/auth'
 import ImportPicker from '@/components/ImportPicker'
 import {
-  AddUpdateDeviceCheckStandArd,
+  AddUpdateDeviceCheckStandArd, DeleteDeviceCheckStaned,
   DeviceCheckItemSelect,
   DeviceCheckStandArdSearch,
   ViewDeviceCheckStanedSearch
@@ -488,9 +488,9 @@
         ]
       },
       tableDataDialog: [], // 琛ㄦ牸鏁版嵁
-      tableDataDialogSelected: [], // 宸查�塩ode
+      // tableDataDialogSelected: [], // 宸查�塩ode
       checkItemSelectArr: [],
-
+      checkItemIsCancel: true,
       dialogVisibleEqp: false,
 
       dialogFormEqp: {
@@ -523,6 +523,8 @@
   mounted() {
     window.addEventListener('resize', this.getHeight)
     this.getHeight()
+
+    this.getDeviceCheckItemSelect()
   },
   methods: {
     async getDeviceCheckStandArdSearch() {
@@ -558,10 +560,9 @@
     },
     // 閲嶇疆
     reset() {
-      this.form.OrgCode = ''
-      this.form.OrgName = ''
-      this.form.OrgType = ''
-      this.form.UserName = ''
+      this.form.checkstandcode = ''
+      this.form.checkstandname = ''
+      this.form.checkcontr = ''
       this.getDeviceCheckStandArdSearch()
     },
 
@@ -574,25 +575,46 @@
     add(operation) {
       this.operation = operation
       this.dialogVisible = true
-      this.getDeviceCheckItemSelect()
+      // this.getDeviceCheckItemSelect()
       this.$nextTick(() => {
         this.$refs.tableDataDialogRef.doLayout()
       })
     },
     // 淇敼鎸夐挳
     edit(operation, row) {
+      // this.getDeviceCheckItemSelect()
       this.operation = operation
+      this.getViewDeviceCheckStanedSearch(row.code)
       this.dialogVisible = true
-      this.getDeviceCheckItemSelect()
+
       this.$nextTick(() => {
         this.$refs.tableDataDialogRef.doLayout()
       })
-      this.$nextTick(() => {
-        this.dialogForm.code = row.code
-        this.dialogForm.name = row.name
-        this.dialogForm.enable = row.enable
-        this.dialogForm.description = row.description
+      // this.$nextTick(() => {
+      //   this.dialogForm.code = row.code
+      //   this.dialogForm.name = row.name
+      //   this.dialogForm.enable = row.enable
+      //   this.dialogForm.description = row.description
+      // })
+    },
+    // 淇敼鍓嶈姹傛帴鍙�
+    async getViewDeviceCheckStanedSearch(checkstand_code) {
+      const { data: res } = await ViewDeviceCheckStanedSearch({ checkstand_code })
+      this.tableDataDialog = res.Data
+
+      this.dialogForm.code = res.code
+      this.dialogForm.name = res.name
+      this.dialogForm.enable = res.enable
+      this.dialogForm.description = res.description
+
+      this.tableDataDialog.forEach(item => {
+        item.isVisible = 0
+        item.checkitem_code = item.code
+        item.checkitem_name = item.name
+        item.checkitem_descr = item.chkdesc
       })
+
+      this.checkItemSelectArr = [...this.checkItemSelectArr].filter(x => [...this.tableDataDialog].every(y => y.checkitem_code !== x.code))
     },
     // 鍒犻櫎鎸夐挳
     async del(row) {
@@ -601,7 +623,7 @@
         cancelButtonText: '鍙栨秷',
         type: 'warning'
       }).then(() => {
-        DeleteOrganization({ orgid: row.code }).then(res => {
+        DeleteDeviceCheckStaned({ checkstand_code: row.code }).then(res => {
           if (res.code === '200') {
             this.$message.success('鍒犻櫎鎴愬姛!')
             this.getDeviceCheckStandArdSearch()
@@ -611,10 +633,7 @@
         this.$message.info('宸插彇娑堝垹闄�')
       })
     },
-    // 淇敼鍓嶈姹傛帴鍙�
-    // async    getViewDeviceCheckStanedSearch(checkstand_code) {
-    //   const { data: res } = await ViewDeviceCheckStanedSearch()
-    // },
+
     // 瀵硅瘽妗嗗叧闂簨浠�
     handleClose() {
       this.dialogForm.code = ''
@@ -622,6 +641,7 @@
       this.dialogForm.enable = 'Y'
       this.dialogForm.description = ''
       this.tableDataDialog = []
+      this.getDeviceCheckItemSelect()
       this.$refs.dialogForm.clearValidate()
     },
     // 瀵硅瘽妗嗗彇娑�
@@ -632,6 +652,14 @@
     dialogVisibleConfirm() {
       this.$refs.dialogForm.validate(valid => {
         if (valid) {
+          // this.tableDataDialog.forEach((item, index) => { // 鍘绘帀姝e湪缂栬緫涓旀槸绌篶heckitem_code
+          //   if (item.isVisible === 1 && item.checkitem_code === '') {
+          //     this.tableDataDialog.splice(index, 1)
+          //   }
+          // })
+
+          this.tableDataDialog.filter(item => item.checkitem_code !== '')
+
           let Data = []
           // 鏁扮粍涓璞$浉鍚岀殑鍘婚噸
           Data = this.tableDataDialog.filter((currentValue, currentIndex, selfArr) => {
@@ -669,16 +697,6 @@
       row.checkitem_descr = res.description
       row.checkitem_code = res.code
       row.checkitem_name = res.name
-      // row.checkitem_descr = this.checkItemSelectArr.find(item => {
-      //   return item.code === val || item.name === val
-      // }).description
-      //
-      // row.checkitem_code = this.checkItemSelectArr.find(item => {
-      //   return item.code === val || item.name === val
-      // }).code
-      // row.checkitem_name = this.checkItemSelectArr.find(item => {
-      //   return item.code === val || item.name === val
-      // }).name
     },
     // 鏂板琛�
     addRow() {
@@ -700,12 +718,25 @@
         cycle: 'D',
         isVisible: 1
       })
+
+      this.checkItemIsCancel = false
     },
     editRow(row) {
-      this.tableDataDialogSelected.forEach((item, index) => {
-        if (item === row.checkitem_code) {
-          this.tableDataDialogSelected.splice(index, 1)
+      let flag = false
+      this.tableDataDialog.forEach((item, index) => {
+        if (item.isVisible === 1) {
+          flag = true
         }
+      })
+      if (flag) {
+        return this.$message.info('璇峰厛纭鎴栧彇娑堝叾瀹冭锛�')
+      }
+
+      this.checkItemIsCancel = false
+      this.checkItemSelectArr.splice(0, 0, {
+        code: row.checkitem_code,
+        name: row.checkitem_name,
+        description: row.checkitem_descr
       })
 
       this.tableDataDialog.forEach((item, index) => {
@@ -722,30 +753,45 @@
       })
     },
     delRow(row) {
+      console.log(row)
+      this.checkItemSelectArr.splice(0, 0, {
+        code: row.checkitem_code,
+        name: row.checkitem_name,
+        description: row.checkitem_descr
+      })
       this.tableDataDialog.forEach((item, index) => {
         if (item.checkitem_code === row.checkitem_code) {
           this.tableDataDialog.splice(index, 1)
         }
       })
-
-      this.tableDataDialogSelected.forEach((item, index) => {
-        if (item === row.checkitem_code) {
-          this.tableDataDialogSelected.splice(index, 1)
+    },
+    saveRow(row) {
+      if (row.checkitem_code === '' && row.checkitem_name === '') {
+        return this.$message.info('鐐规閮ㄤ綅涓嶈兘涓虹┖锛�')
+      }
+      row.isVisible = 0
+      this.checkItemSelectArr.forEach((item, index) => {
+        if (item.code === row.checkitem_code) {
+          this.checkItemSelectArr.splice(index, 1)
         }
       })
     },
-    saveRow(row) {
-      if (this.tableDataDialogSelected.includes(row.checkitem_code)) {
-        return this.$message.info('鐐规閮ㄤ綅涓嶈兘閫夋嫨鐩稿悓锛�')
-      }
-      this.tableDataDialogSelected.push(row.checkitem_code)
-      row.isVisible = 0
-      console.log(this.tableDataDialog)
-    },
     cancelRow(row) {
+      // this.checkItemSelectArr.forEach((item, index) => {
+      //   if (item.code === row.checkitem_code) {
+      if (this.checkItemIsCancel) {
+        this.checkItemSelectArr.splice(0, 0, {
+          code: row.checkitem_code,
+          name: row.checkitem_name,
+          description: row.checkitem_descr
+        })
+      }
+      this.JYIsCancel = true
+      // }
+      // })
+
       this.tableDataDialog.forEach((item, index) => {
         if (item.checkitem_code === row.checkitem_code && item.isVisible === 1) {
-          console.log(item)
           row.isVisible = 0
           this.tableDataDialog.splice(index, 1)
         }

--
Gitblit v1.9.3