From 6b32ec29b1cd3ed12845d543e18da18f8456cdda Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期二, 18 十月 2022 18:18:33 +0800
Subject: [PATCH] 1.安灯设置开发完成

---
 src/views/sbgl/djbz.vue |  488 +++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 391 insertions(+), 97 deletions(-)

diff --git a/src/views/sbgl/djbz.vue b/src/views/sbgl/djbz.vue
index e4d0130..06223a2 100644
--- a/src/views/sbgl/djbz.vue
+++ b/src/views/sbgl/djbz.vue
@@ -3,19 +3,19 @@
     <div class="body" :style="{height:mainHeight+'px'}">
       <div class="bodyTopButtonGroup" style="justify-content: space-between">
         <el-button type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">鏂板</el-button>
-        <el-button icon="el-icon-download" @click="upload">瀵煎叆</el-button>
+        <!--        <el-button icon="el-icon-download" @click="upload">瀵煎叆</el-button>-->
       </div>
 
       <div class="bodyTopFormGroup">
         <el-form
           ref="form"
           :model="form"
-          label-width="80px"
+          label-width="100px"
           inline
           style="display: flex;justify-content: space-between"
         >
           <div class="elForm">
-            <el-form-item label="鏍囧噯缂栫爜" style=" display: flex;">
+            <el-form-item label-width="70px" label="鏍囧噯缂栫爜" style=" display: flex;">
               <el-input v-model="form.checkstandcode" placeholder="璇疯緭鍏�" style="width: 200px" />
             </el-form-item>
             <el-form-item label="鏍囧噯鍚嶇О" style=" display: flex;">
@@ -32,18 +32,24 @@
               </el-select>
             </el-form-item>
           </div>
-          <div style="display: flex;align-items: start;margin-top: 5px;z-index: 2">
+          <div class="bodySearchReset" :style="{marginLeft:$store.state.app.sidebar.opened?'5%':'10%'}">
             <el-button type="primary" icon="el-icon-search" @click="search">鏌ヨ</el-button>
             <el-button type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>
           </div>
         </el-form>
+
+        <div
+          class="bodyTopFormExpand"
+        />
       </div>
 
       <div class="elTableDiv">
         <el-table
+          ref="tableDataRef"
           :data="tableData"
           :height="tableHeight+'px'"
           border
+          class="tableFixed"
           :row-class-name="tableRowClassName"
           :style="{width: 100+'%',height:tableHeight+'px',}"
           highlight-current-row
@@ -58,6 +64,7 @@
           <el-table-column
             prop="RowNum"
             width="50"
+            fixed
             label="搴忓彿"
           />
           <el-table-column
@@ -75,7 +82,13 @@
             prop="description"
             label="鏍囧噯鎻忚堪"
             sortable="custom"
-          />
+            show-tooltip-when-overflow
+          >
+            <template slot-scope="{row}">
+              <div v-if="row.description">{{ row.description }}</div>
+              <div v-else>/</div>
+            </template>
+          </el-table-column>
           <el-table-column
             prop="iscontr"
             label="鐐规绠℃帶"
@@ -142,7 +155,7 @@
         :page.sync="form.page"
         :limit.sync="form.rows"
         align="right"
-        layout="prev, pager, next,sizes"
+        layout="total,prev, pager, next,sizes"
         popper-class="select_bottom"
         @pagination="getDeviceCheckStandArdSearch"
       />
@@ -155,10 +168,10 @@
       :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" />璁惧鐐规鏍囧噯淇℃伅
+        <i class="el-icon-s-operation" style="color:#42b983;margin: -20px 10px 20px 0" />璁惧鐐规鏍囧噯淇℃伅锛�
       </div>
       <div style="margin: 0 30px;">
         <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
@@ -168,7 +181,7 @@
           <el-form-item label="鏍囧噯鍚嶇О" prop="name">
             <el-input v-model="dialogForm.name" style="width: 200px" />
           </el-form-item>
-          <el-form-item prop="SupUnit" label="鐐规绠℃帶">
+          <el-form-item required label="鐐规绠℃帶">
             <el-select
               v-model="dialogForm.enable"
               style="width: 200px"
@@ -257,6 +270,7 @@
           <el-table-column
             prop="checkitem_descr"
             label="鐐规瑕佹眰"
+            show-tooltip-when-overflow
           >
             <template slot-scope="{row}">
               <div v-if="row.isVisible===0">{{ row.checkitem_descr }}</div>
@@ -323,7 +337,12 @@
       <span slot="footer" class="dialog-footer">
         <div class="footerButton">
           <el-button @click="dialogVisibleCancel">鍙� 娑�</el-button>
-          <el-button type="primary" @click="dialogVisibleConfirm">纭� 瀹�</el-button>
+          <el-button
+            type="primary"
+            :loading="$store.state.app.buttonIsDisabled"
+            :disabled="$store.state.app.buttonIsDisabled"
+            @click="dialogVisibleConfirm"
+          >纭� 瀹�</el-button>
         </div>
       </span>
     </el-dialog>
@@ -350,6 +369,7 @@
           <i class="el-icon-s-operation" style="color:#42b983;" /> 璁惧鎵�灞炶溅闂撮泦鍚堬細
         </div>
         <div class="myCheckboxGroup">
+
           <div
             v-for="item in dialogFormEqp.eqpArr"
             :key="item.code"
@@ -373,10 +393,10 @@
       <el-divider />
       <div>
         <div style="margin-bottom:20px">
-          <i class="el-icon-s-operation" style="color:#42b983;" /> 瑙掕壊锛�
+          <i class="el-icon-s-operation" style="color:#42b983;" /> 璁惧淇℃伅锛�
         </div>
         <el-tree
-          ref="roleTree"
+          ref="epqTree"
           :data="dialogFormEqp.eqpTree"
           show-checkbox
           node-key="code"
@@ -391,7 +411,12 @@
       <span slot="footer" class="dialog-footer">
         <div class="footerButton">
           <el-button @click="eqpDialogVisibleCancel">鍙� 娑�</el-button>
-          <el-button type="primary" @click="eqpDialogVisibleConfirm">纭� 瀹�</el-button>
+          <el-button
+            type="primary"
+            :loading="$store.state.app.buttonIsDisabled"
+            :disabled="$store.state.app.buttonIsDisabled"
+            @click="eqpDialogVisibleConfirm"
+          >纭� 瀹�</el-button>
         </div>
       </span>
     </el-dialog>
@@ -415,37 +440,20 @@
 import { getCookie } from '@/utils/auth'
 import ImportPicker from '@/components/ImportPicker'
 import {
-  AddUpdateDeviceCheckStandArd,
+  AddUpdateDeviceCheckStandArd, DeleteDeviceCheckStaned,
   DeviceCheckItemSelect,
-  DeviceCheckStandArdSearch,
+  DeviceCheckStandArdSearch, DeviceCheckStanedAssociationEqp, SaveDeviceCheckStanedAssociationEqp,
   ViewDeviceCheckStanedSearch
 } from '@/api/sbgl'
+import $ from 'jquery'
+import { validateCode } from '@/utils/global'
 
-const SER_HZ = /^[\u4e00-\u9fa5]+$/
 export default {
   name: 'Zzjg',
   components: {
     Pagination, ImportPicker
   },
   data() {
-    const validateName = (rule, value, callback) => {
-      if (!value) {
-        return callback(new Error('璇疯緭鍏ョ紪鐮�'))
-      } else {
-        if (SER_HZ.test(value)) {
-          return callback(new Error('缂栫爜涓嶈兘涓轰腑鏂�'))
-        } else {
-          callback()
-        }
-      }
-    }
-    const validateTypeCode = (rule, value, callback) => {
-      if (!value) {
-        return callback(new Error('璇烽�夋嫨涓婄骇'))
-      } else {
-        callback()
-      }
-    }
     return {
       mainHeight: 0,
       tableHeight: 0,
@@ -472,13 +480,13 @@
         code: '',
         name: '',
         enable: 'Y',
-        description: ''// 涓婄骇鍗曚綅
+        description: ''
       },
       operation: '',
       dialogFormRules: {
 
         code: [
-          { required: true, validator: validateName, trigger: ['blur', 'change'] }
+          { required: true, validator: validateCode, trigger: ['blur', 'change'] }
         ],
         name: [
           { required: true, message: '璇疯緭鍏ユ爣鍑嗗悕绉�', trigger: ['blur', 'change'] }
@@ -488,15 +496,18 @@
         ]
       },
       tableDataDialog: [], // 琛ㄦ牸鏁版嵁
-      tableDataDialogSelected: [], // 宸查�塩ode
+      // tableDataDialogSelected: [], // 宸查�塩ode
       checkItemSelectArr: [],
-
+      checkItemIsCancel: true,
       dialogVisibleEqp: false,
 
       dialogFormEqp: {
         name: '',
-        eqpArr: [],
-        eqpTree: []
+        code: '',
+        eqpAll: [], // 杞﹂棿鍙婅澶囨墍鏈�
+        eqpArr: [], // 杞﹂棿闆嗗悎鎵�鏈�
+        eqpTree: [], // 璁惧鏍戝舰鎵�鏈�
+        eqpCodeSelectedArr: []// 璁惧鏍戝舰閫変腑
       },
       defaultPropsOfEqpTree: {
         value: 'code',
@@ -518,18 +529,25 @@
     }
   },
   created() {
-    this.getDeviceCheckStandArdSearch()
+    this.handleRequest()
   },
   mounted() {
     window.addEventListener('resize', this.getHeight)
     this.getHeight()
   },
   methods: {
+    handleRequest() {
+      this.getDeviceCheckStandArdSearch().then(res => {
+        if (res.code === '200') {
+          this.getDeviceCheckItemSelect()
+        }
+      })
+    },
     async getDeviceCheckStandArdSearch() {
-      console.log(this.form, 11)
       const res = await DeviceCheckStandArdSearch(this.form)
       this.tableData = res.data
       this.total = res.count
+      return { code: res.code }
     },
     // 鎺掑簭鏀瑰彉鏃�
     sortChange({ column, prop, order }) {
@@ -558,10 +576,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 +591,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,9 +639,12 @@
         cancelButtonText: '鍙栨秷',
         type: 'warning'
       }).then(() => {
-        DeleteOrganization({ orgid: row.code }).then(res => {
+        DeleteDeviceCheckStaned({ checkstand_code: row.code }).then(res => {
           if (res.code === '200') {
             this.$message.success('鍒犻櫎鎴愬姛!')
+            if (this.form.page > 1 && this.tableData.length === 1) {
+              this.form.page--
+            }
             this.getDeviceCheckStandArdSearch()
           }
         })
@@ -611,10 +652,7 @@
         this.$message.info('宸插彇娑堝垹闄�')
       })
     },
-    // 淇敼鍓嶈姹傛帴鍙�
-    // async    getViewDeviceCheckStanedSearch(checkstand_code) {
-    //   const { data: res } = await ViewDeviceCheckStanedSearch()
-    // },
+
     // 瀵硅瘽妗嗗叧闂簨浠�
     handleClose() {
       this.dialogForm.code = ''
@@ -622,6 +660,7 @@
       this.dialogForm.enable = 'Y'
       this.dialogForm.description = ''
       this.tableDataDialog = []
+      this.getDeviceCheckItemSelect()
       this.$refs.dialogForm.clearValidate()
     },
     // 瀵硅瘽妗嗗彇娑�
@@ -632,6 +671,15 @@
     dialogVisibleConfirm() {
       this.$refs.dialogForm.validate(valid => {
         if (valid) {
+          this.$store.state.app.buttonIsDisabled = true
+          // 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) => {
@@ -640,7 +688,7 @@
           Data.forEach((item, index) => {
             item.checkitem_seq = index + 1
           })
-          console.log(Data, 999)
+
           const data = {
             'code': this.dialogForm.code,
             'name': this.dialogForm.name,
@@ -648,12 +696,13 @@
             'description': this.dialogForm.description,
             'Data': Data
           }
-          console.log(data, 111)
+
           AddUpdateDeviceCheckStandArd(data, this.operation === 'add' ? 'Add' : 'Update').then(res => {
             if (res.code === '200') {
-              this.$message.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
               this.dialogVisible = false
+              this.$message.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
               this.getDeviceCheckStandArdSearch()
+              this.$store.state.app.buttonIsDisabled = false
             } else {
               this.$message.error(this.operation === 'add' ? '娣诲姞澶辫触锛�' : '淇敼澶辫触锛�')
             }
@@ -669,16 +718,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 +739,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 +774,44 @@
       })
     },
     delRow(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)
         }
@@ -755,7 +821,8 @@
     getHeight() {
       this.$nextTick(() => {
         this.mainHeight = window.innerHeight - 85
-        this.tableHeight = this.mainHeight - 200
+        this.tableHeight = this.mainHeight - 195
+        this.$refs.tableDataRef.doLayout()
       })
     },
     tableRowClassName({ row, rowIndex }) {
@@ -763,27 +830,239 @@
     },
     // 鍏宠仈璁惧
     checkeqpClick(row) {
-      this.dialogVisibleEqp = true
-    },
-    handleCloseEqp() {
+      const loading = this.$loading({
+        lock: true,
+        text: '姝e湪鍔犺浇鏁版嵁锛岃绋嶇瓑...',
+        spinner: 'el-icon-loading',
+        customClass: 'osloading',
+        background: 'rgba(0, 0, 0, 0.7)'
+      })
+      this.dialogFormEqp.name = row.name
+      this.dialogFormEqp.code = row.code
 
+      DeviceCheckStanedAssociationEqp({ checkstand_code: row.code }).then(res => {
+        if (res.code === '200') {
+          setTimeout(() => {
+            loading.close()
+            this.dialogFormEqp.eqpAll = res.data.filter(item => item.children.length > 0)
+
+            if (this.dialogFormEqp.eqpAll.length > 0) {
+              this.dialogFormEqp.eqpAll.forEach((item, index) => {
+                this.dialogFormEqp.eqpArr.push({
+                  code: item.code,
+                  name: item.name,
+                  type: item.type,
+                  isSelected1: index === 0,
+                  isSelected2: item.flag === 'Y'
+                })
+                if (item.flag === 'Y') {
+                  this.$nextTick(() => {
+                    $('input:checkbox').eq(index).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+                  })
+                }
+                if (item.children && item.children.length > 0) {
+                  item.children.forEach(it => {
+                    if (it.flag === 'Y') {
+                      this.dialogFormEqp.eqpCodeSelectedArr.push(it.code)
+                    }
+                  })
+                }
+              })
+              this.dialogFormEqp.eqpAll[0].name = '鍏ㄩ儴'
+              this.dialogFormEqp.eqpTree = [this.dialogFormEqp.eqpAll[0]]
+            }
+
+            this.dialogVisibleEqp = true
+
+            this.$nextTick(() => { // 鏍戝舰鍥炴樉
+              this.$refs.epqTree.setCheckedKeys(this.dialogFormEqp.eqpCodeSelectedArr)
+            })
+          }, 1000)
+        } else {
+          loading.close()
+        }
+      })
+    },
+    // 鍏宠仈璁惧瀵硅瘽妗嗗叧闂�
+    handleCloseEqp() {
+      this.$refs.epqTree.setCheckedKeys([])
+      this.dialogFormEqp.code = ''
+      this.dialogFormEqp.name = ''
+      this.dialogFormEqp.eqpAll = []
+      this.dialogFormEqp.eqpArr = []
+      this.dialogFormEqp.eqpTree = []
+      this.dialogFormEqp.eqpCodeSelectedArr = []
     },
     // 澶х洅瀛愮偣鍑�
-    myCheckboxClick() {
-
+    myCheckboxClick(val) {
+      this.dialogFormEqp.eqpArr.forEach((item, index) => {
+        item.isSelected1 = item.code === val.code
+        if (item.code === val.code) {
+          this.dialogFormEqp.eqpAll[index].name = '鍏ㄩ儴'
+          this.dialogFormEqp.eqpTree = [this.dialogFormEqp.eqpAll[index]]
+        }
+      })
+      this.$nextTick(() => { // 鏍戝舰鍥炴樉
+        this.$refs.epqTree.setCheckedKeys(this.dialogFormEqp.eqpCodeSelectedArr)
+      })
     },
     // 灏忕洅瀛愮偣鍑�
-    myCheckboxInputClick() {
-
+    myCheckboxInputClick(val) {
+      console.log(val)
+      val.isSelected2 = !val.isSelected2
+      if (val.isSelected2) { // 浠庢病閫変腑鍒伴�変腑
+        console.log('浠庢病閫変腑鍒伴�変腑')
+        this.dialogFormEqp.eqpAll.forEach((item, index) => {
+          if (item.code === val.code) {
+            if (item.children && item.children.length > 0) {
+              item.children.forEach(it => {
+                this.dialogFormEqp.eqpCodeSelectedArr.push(it.code)
+              })
+            }
+          }
+        })
+        console.log(this.dialogFormEqp.eqpCodeSelectedArr, 1)
+        this.$nextTick(() => { // 鏍戝舰鍥炴樉
+          this.$refs.epqTree.setCheckedKeys(this.dialogFormEqp.eqpCodeSelectedArr)
+        })
+      } else { // 浠庨�変腑鍒版病閫変腑
+        console.log('浠庨�変腑鍒版病閫変腑')
+        const temp = []
+        this.dialogFormEqp.eqpAll.forEach((item, index) => {
+          if (item.code === val.code) {
+            if (item.children && item.children.length > 0) {
+              item.children.forEach(it => {
+                temp.push(it.code)
+              })
+            }
+          }
+        })
+        this.dialogFormEqp.eqpCodeSelectedArr = [...this.dialogFormEqp.eqpCodeSelectedArr].filter(x => [...temp].every(y => y !== x))
+        this.$nextTick(() => { // 鏍戝舰鍥炴樉
+          this.$refs.epqTree.setCheckedKeys(this.dialogFormEqp.eqpCodeSelectedArr)
+        })
+      }
+      console.log(this.dialogFormEqp.eqpCodeSelectedArr, 999)
     },
-    checkBoxClick() {
+    // 鏍戝舰澶嶉�夋鐐瑰嚮浜嬩欢
+    checkBoxClick(obj, { checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys }) {
+      let checkedFatherCode = '' // 鎵惧埌 checkedFatherCode  鐖禼ode鍊�
+      console.log(obj, { checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys })
+      this.dialogFormEqp.eqpAll.forEach((item, index) => {
+        if (item.code === obj.code) {
+          checkedFatherCode = item.code
+        }
+        if (item.children && item.children.length > 0) {
+          item.children.forEach((it, ind) => {
+            if (it.code === obj.code) {
+              checkedFatherCode = item.code
+            }
+          })
+        }
+      })
+      console.log(checkedFatherCode, 1)
 
+      // 1.绗竴绉嶆儏鍐靛綋鏍戝舰   鍗婂彾 涓嶄负闆�   鍏ㄥ彾 涓嶄负闆�
+      if (halfCheckedKeys.length !== 0 && checkedKeys.length !== 0) {
+        console.log('// 1.绗竴绉嶆儏鍐靛綋鏍戝舰   鍗婂彾 涓嶄负闆�   鍏ㄥ彾 涓嶄负闆�')
+        this.dialogFormEqp.eqpArr.forEach((item, index) => {
+          if (item.code === checkedFatherCode) {
+            console.log(item.code, 777)
+            this.dialogFormEqp.eqpArr[index].isSelected2 = true
+            this.$nextTick(() => {
+              $('input:checkbox').eq(index).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+            })
+          }
+        })
+        this.dialogFormEqp.eqpCodeSelectedArr.forEach((item, index) => {
+          if (item === obj.code) {
+            this.dialogFormEqp.eqpCodeSelectedArr.splice(index, 1)
+          }
+        })
+        checkedKeys.forEach(item => {
+          this.dialogFormEqp.eqpCodeSelectedArr.push(item)
+        })
+        this.dialogFormEqp.eqpCodeSelectedArr = [...new Set(this.dialogFormEqp.eqpCodeSelectedArr)]
+      }
+      console.log(this.dialogFormEqp.eqpCodeSelectedArr, 666)
+      // 2.绗簩绉嶆儏鍐靛綋鏍戝舰   鍗婂彾 涓洪浂   鍏ㄥ彾 涓洪浂
+      if (halfCheckedKeys.length === 0 && checkedKeys.length === 0) {
+        console.log('// 2.绗簩绉嶆儏鍐靛綋鏍戝舰   鍗婂彾 涓洪浂   鍏ㄥ彾 涓洪浂')
+        const temp = []
+        this.dialogFormEqp.eqpArr.forEach((item, index) => {
+          if (item.code === checkedFatherCode) {
+            this.dialogFormEqp.eqpArr[index].isSelected2 = false
+            this.$nextTick(() => {
+              $('input:checkbox').eq(index).prop('checked', false)// 鑷畾涔夊崟閫夋鍥炴樉
+            })
+          }
+        })
+        this.dialogFormEqp.eqpAll.forEach((item, index) => {
+          if (item.code === checkedFatherCode) {
+            if (item.children && item.children.length > 0) {
+              item.children.forEach(it => {
+                temp.push(it.code)
+              })
+            }
+          }
+        })
+        this.dialogFormEqp.eqpCodeSelectedArr = [...this.dialogFormEqp.eqpCodeSelectedArr].filter(x => [...temp].every(y => y !== x))
+      }
+
+      // 3.绗笁绉嶇鎯呭喌褰撴爲褰�   鍗婂彾 涓洪浂   鍏ㄥ彾 涓嶄负闆�
+      if (halfCheckedKeys.length === 0 && checkedKeys.length !== 0) {
+        console.log('// 3.绗笁绉嶇鎯呭喌褰撴爲褰�   鍗婂彾 涓洪浂   鍏ㄥ彾 涓嶄负闆�')
+        this.dialogFormEqp.eqpArr.forEach((item, index) => {
+          if (item.code === checkedFatherCode) {
+            this.dialogFormEqp.eqpArr[index].isSelected2 = true
+            this.$nextTick(() => {
+              $('input:checkbox').eq(index).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+            })
+          }
+        })
+
+        this.dialogFormEqp.eqpAll.forEach((item, index) => {
+          if (item.code === checkedFatherCode) {
+            if (item.children && item.children.length > 0) {
+              item.children.forEach(it => {
+                this.dialogFormEqp.eqpCodeSelectedArr.push(it.code)
+              })
+            }
+          }
+        })
+      }
     },
+    // 鍙栨秷浜嬩欢
     eqpDialogVisibleCancel() {
       this.dialogVisibleEqp = false
     },
+    // 纭浜嬩欢
     eqpDialogVisibleConfirm() {
-      this.dialogVisibleEqp = false
+      // console.log(this.dialogFormEqp.eqpCodeSelectedArr, 888)
+      // this.dialogVisibleEqp = false
+      this.$store.state.app.buttonIsDisabled = true
+      const data = []
+      this.dialogFormEqp.eqpAll.forEach((item, index) => {
+        if (item.children && item.children.length > 0) {
+          item.children.forEach(it => {
+            if (this.dialogFormEqp.eqpCodeSelectedArr.includes(it.code)) {
+              data.push({
+                name: it.name,
+                code: it.code
+              })
+            }
+          })
+        }
+      })
+
+      SaveDeviceCheckStanedAssociationEqp(data, this.dialogFormEqp.code).then(res => {
+        if (res.code === '200') {
+          this.dialogVisibleEqp = false
+          this.$message.success('鍏宠仈鎴愬姛锛�')
+          this.getDeviceCheckStandArdSearch()
+          this.$store.state.app.buttonIsDisabled = false
+        }
+      })
     }
   }
 }
@@ -954,9 +1233,24 @@
   align-items: center;
   justify-content: center;
 }
+
+.tableFixed{
+  ::v-deep .el-table__fixed-right{
+    height: 100% !important;
+  }
+  ::v-deep .el-table__fixed{
+    height: 100% !important;
+  }
+}
 </style>
 <style>
+.osloading{
+  font-size: 26px !important;
+}
 
+.el-loading-text{
+  font-size: 26px !important;
+}
 .el-table .custom-row {
   background: #f8f8fa;
 }

--
Gitblit v1.9.3