From bb2ed2e56da26a6b79575f5be9f60ca2d90774d0 Mon Sep 17 00:00:00 2001
From: 小小儁爺 <1694218219@qq.com>
Date: 星期四, 01 八月 2024 17:17:32 +0800
Subject: [PATCH] 1.工序、工价界面优化

---
 src/views/basicSettings/processList.vue |  719 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 706 insertions(+), 13 deletions(-)

diff --git a/src/views/basicSettings/processList.vue b/src/views/basicSettings/processList.vue
index 8f94a8b..1ae3d42 100644
--- a/src/views/basicSettings/processList.vue
+++ b/src/views/basicSettings/processList.vue
@@ -3,7 +3,13 @@
     <div class="body" :style="{height:mainHeight+'px'}">
       <div class="bodyTopButtonGroup" style="justify-content: space-between">
         <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">鏂板</el-button>
-        <el-button v-waves type="success" icon="el-icon-download" @click="$router.push('./../systemSetting/dataImport?fileCode=15')">瀵煎叆</el-button>
+        <el-button
+          v-waves
+          type="success"
+          icon="el-icon-download"
+          @click="$router.push('./../systemSetting/dataImport?fileCode=15')"
+        >瀵煎叆
+        </el-button>
       </div>
 
       <div class="bodyTopFormGroup">
@@ -116,7 +122,7 @@
             sortable="custom"
           >
             <template slot-scope="{row}">
-              {{ row.flwtype==='Z'?'鑷埗':'澶栧崗' }}
+              {{ row.flwtype === 'Z' ? '鑷埗' : '澶栧崗' }}
             </template>
           </el-table-column>
           <el-table-column
@@ -129,13 +135,34 @@
               <el-tag v-if="row.enable==='N'" size="small" type="danger">鍋滅敤</el-tag>
             </template>
           </el-table-column>
+
+          <el-table-column
+            prop="is_eqp"
+            label="鍏宠仈宸ヤ綔绔�"
+            sortable="custom"
+          >
+            <template slot-scope="{row}">
+              <i
+                v-if="row.is_eqp==='Y'"
+                :style="{color:$store.state.settings.theme}"
+                class="el-icon-share"
+                @click="workClick(row)"
+              />
+              <i
+                v-if="row.is_eqp==='N'"
+                class="el-icon-share"
+                style="color: rgb(180 ,181, 185)"
+                @click="workClick(row)"
+              />
+            </template>
+          </el-table-column>
           <el-table-column
             prop="descr"
             label="鎻忚堪"
             sortable="custom"
           >
             <template slot-scope="{row}">
-              {{ row.descr?row.descr:'/' }}
+              {{ row.descr ? row.descr : '/' }}
             </template>
           </el-table-column>
           <el-table-column
@@ -189,17 +216,20 @@
       />
     </div>
 
+    <!--    鏂板缂栬緫-->
     <el-dialog
       v-el-drag-dialog
       :title="operation==='add'?'鏂板':'缂栬緫'"
       :visible.sync="dialogVisible"
       width="800px"
       :close-on-click-modal="false"
-      top="15vh"
+      top="10vh"
       @closed="handleClose"
       @close="handleClose"
     >
-      <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
+      <el-divider content-position="left">鍩烘湰淇℃伅</el-divider>
+
+      <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="110px">
         <el-form-item label="宸ュ簭缂栫爜" prop="stepcode">
           <el-input v-model="dialogForm.stepcode" :disabled="operation!=='add'" style="width: 200px" />
         </el-form-item>
@@ -212,7 +242,9 @@
             style="width:200px"
             placeholder="璇烽�夋嫨"
             :popper-append-to-body="false"
+            @change="steptypecodeChange"
           >
+
             <el-option
               v-for="item in steptypeArr"
               :key="item.code"
@@ -221,13 +253,52 @@
             />
           </el-select>
         </el-form-item>
-        <el-form-item required label="鐘舵��">
-          <el-radio-group v-model="dialogForm.enable">
+
+        <el-form-item v-if="dialogForm.steptypecode==='Z'" label="鎵�灞炶溅闂�">
+          <el-select
+            v-model="dialogForm.Wkshop"
+            style="width:200px"
+            placeholder="璇烽�夋嫨"
+            multiple
+            collapse-tags
+            :popper-append-to-body="false"
+            @change="WkshopChange"
+          >
+            <el-option
+              v-for="item in WkshopArr"
+              :key="item.torg_code"
+              :label="item.torg_name"
+              :value="item.torg_code"
+            />
+          </el-select>
+        </el-form-item>
+
+        <el-form-item v-if="dialogForm.steptypecode==='W'" label="寰�鏉ュ崟浣嶇被鍨�">
+          <el-select
+            v-model="dialogForm.CustomerType"
+            style="width:200px"
+            placeholder="璇烽�夋嫨"
+            multiple
+            collapse-tags
+            :popper-append-to-body="false"
+            @change="CustomerTypeChange"
+          >
+            <el-option
+              v-for="item in CustomerTypeArr"
+              :key="item.code"
+              :label="item.name"
+              :value="item.code"
+            />
+          </el-select>
+        </el-form-item>
+
+        <el-form-item required label="宸ュ簭鐘舵��">
+          <el-radio-group v-model="dialogForm.enable" style="width:200px">
             <el-radio label="Y">姝e父</el-radio>
             <el-radio label="N">鍋滅敤</el-radio>
           </el-radio-group>
         </el-form-item>
-        <el-form-item label="鎻忚堪">
+        <el-form-item label="宸ュ簭鎻忚堪">
           <el-input
             v-model="dialogForm.description"
             type="textarea"
@@ -235,6 +306,18 @@
           />
         </el-form-item>
       </el-form>
+
+      <el-divider content-position="left">宸ヤ綔绔�</el-divider>
+      <el-tree
+        ref="dialogTree"
+        :data="dialogTreeArr"
+        show-checkbox
+        node-key="code"
+        style="height: 280px;overflow: auto"
+        default-expand-all
+        :props="workTreeDefaultProps"
+      />
+
       <span slot="footer" class="dialog-footer">
         <div class="footerButton">
           <el-button v-waves @click="dialogVisibleCancel">鍙� 娑�</el-button>
@@ -249,15 +332,110 @@
       </span>
     </el-dialog>
 
+    <!--    鍏宠仈宸ヤ綔绔欏璇濇-->
+    <el-dialog
+      v-el-drag-dialog
+      title="鍏宠仈宸ヤ綔绔�"
+      :visible.sync="workDialogVisible"
+      width="50%"
+      top="15vh"
+      :close-on-click-modal="false"
+      class="workDialogVisible"
+      @closed="workHandleClose"
+      @close="workHandleClose"
+    >
+      <!--      @opened="handleOpenedRoles"-->
+
+      <div>
+        <i class="el-icon-s-comment" :style="{color:$store.state.settings.theme}" /> 宸ュ簭鍚嶇О锛歿{ workDialogForm.stepname }}
+      </div>
+      <el-divider />
+      <div>
+        <div style="margin-bottom:20px">
+          <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" /> 宸ヤ綔绔欓泦鍚堬細
+        </div>
+        <div class="myCheckboxGroup">
+          <div
+            v-for="item in workDialogForm.workGatherArr"
+            :key="item.code"
+            :style="{border:item.isSelected1?'1px solid '+$store.state.settings.theme :'1px solid #eee'}"
+            class="myCheckbox"
+            @click="myCheckboxClick(item)"
+          >
+            <!--            <input-->
+            <!--              class="myCheckboxInput"-->
+            <!--              type="checkbox"-->
+            <!--              :value="item.code"-->
+            <!--              name="gather"-->
+            <!--              :style="{color:item.isSelected2?'#42b983':'#fff'}"-->
+            <!--              @click="myCheckboxInputClick(item)"-->
+            <!--            >{{ item.name }}-->
+            <!--            鐖跺瓙鐐瑰嚮浜嬩欢涓嶅奖鍝�-->
+            <!--            onClick="event.cancelBubble = true"-->
+            <el-checkbox
+              :key="item.code"
+              v-model="item.isSelected2"
+              class="myCheckboxInput"
+              :value="item.code"
+              :name="item.name"
+              :label="item.name"
+              :checked="item.isSelected2"
+              @change="myCheckboxInputClick(item)"
+            />
+            <div class="myCheckboxInputLabel">{{ item.name }}</div>
+
+          </div>
+        </div>
+      </div>
+      <el-divider />
+      <div>
+        <div style="margin-bottom:20px">
+          <i class="el-icon-s-operation" :style="{color:$store.state.settings.theme}" /> 宸ヤ綔绔欙細
+        </div>
+        <el-tree
+          ref="workTree"
+          :data="workDialogForm.workTreeArr"
+          show-checkbox
+          node-key="code"
+          style="height: 280px;overflow: auto"
+          default-expand-all
+          :props="workTreeDefaultProps"
+          @check="checkBoxClick"
+        />
+        <!--        @check-change="checkChange"-->
+
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <div class="footerButton">
+          <el-button v-waves @click="workDialogVisibleCancel">鍙� 娑�</el-button>
+          <el-button
+            v-waves
+            type="primary"
+            :loading="$store.state.app.buttonIsDisabled"
+            :disabled="$store.state.app.buttonIsDisabled"
+            @click="workDialogVisibleConfirm"
+          >纭� 瀹�</el-button>
+        </div>
+      </span>
+    </el-dialog>
+
   </div>
 </template>
 
 <script>
 import Pagination from '@/components/Pagination'
-import { AddUpdateStep, DeleteStep, StepSearch } from '@/api/basicSettings'
+import { AddUpdateStep, DeleteStep, SaveStepAssociationEqp, StepAssociationEqp, StepSearch } from '@/api/basicSettings'
 import { validateCode } from '@/utils/global'
 import elDragDialog from '@/directive/el-drag-dialog'
 import waves from '@/directive/waves'
+import $ from 'jquery'
+import {
+  CustomerPermissions,
+  CustomerTypePermissions,
+  CustomerTypeSearchPermission,
+  TorgWkshop,
+  WkshopEqpPermissions
+} from '@/api/GeneralBasicData'
 
 export default {
   name: 'Zzjg',
@@ -274,8 +452,8 @@
         stepname: '', //
         enable: '', //
         steptypecode: '', // 宸ュ簭绫诲瀷
-        prop: 'stepcode', // 鎺掑簭瀛楁
-        order: 'asc', // 鎺掑簭瀛楁
+        prop: 'lm_date', // 鎺掑簭瀛楁
+        order: 'desc', // 鎺掑簭瀛楁
         page: 1, // 绗嚑椤�
         rows: 20 // 姣忛〉澶氬皯鏉�
       },
@@ -289,15 +467,20 @@
         { code: 'Y', name: '姝e父' },
         { code: 'N', name: '鍋滅敤' }
       ],
+      WkshopArr: [], // 杞﹂棿涓嬫媺鏁扮粍
+      CustomerTypeArr: [], // 寰�鏉ュ崟浣嶄笅鎷夋暟缁�
       dialogVisible: false,
       dialogForm: {
         id: '',
         stepcode: '', //
         stepname: '', //
+        Wkshop: '', //
+        CustomerType: '', //
         steptypecode: 'Z',
         description: '', // 鎻忚堪
         enable: 'Y'// 鐘舵��
       },
+      dialogTreeArr: [],
       operation: '',
       dialogFormRules: {
         stepcode: [
@@ -306,12 +489,31 @@
         stepname: [
           { required: true, message: '璇疯緭鍏ュ伐搴忓悕绉�', trigger: ['blur', 'change'] }
         ]
-      }
+      },
+      workDialogVisible: false,
+      workDialogForm: {
+        stepcode: '', // 宸ュ簭缂栫爜
+        stepname: '', // 宸ュ簭鍚嶇О
+        workArr: [], //  宸ヤ綔绔欐墍鏈夋暟缁�
+        workGatherArr: [], // 宸ヤ綔绔欓泦鍚堟暟缁�
+        workCodeSelectedGatherArr: [], // 宸ヤ綔绔欓�変腑闆嗗悎鐨刢ode鏁扮粍
+        workTreeArr: [], // 宸ヤ綔绔欐爲鏁扮粍
+        workTreeSelectedArr: []// 宸ヤ綔绔欐爲閫変腑鐨勬暟缁刢ode闆嗗悎
+      },
+      workTreeDefaultProps: {
+        value: 'code',
+        label: 'name',
+        children: 'children'
+      },
+
+      dialogTreeSelectedArr: []// 瀵硅瘽妗嗘爲褰㈤�変腑鍥炴樉鍊�
 
     }
   },
   created() {
     this.getStepSearch()
+    this.getTorgWkshop()
+    this.getCustomerTypePermissions()
   },
   mounted() {
     window.addEventListener('resize', this.getHeight)
@@ -323,6 +525,68 @@
       const res = await StepSearch(this.form)
       this.tableData = res.data
       this.total = res.count
+    },
+    // 鏌ヨ鍏徃鐨勮溅闂�
+    async getTorgWkshop() {
+      const { data: res } = await TorgWkshop()
+      this.WkshopArr = res
+    },
+    // 寰�鏉ュ崟浣嶇被鍨�
+    async getCustomerTypePermissions() {
+      const { data: res } = await CustomerTypePermissions()
+      this.CustomerTypeArr = res
+    },
+    // 鏌ョ湅寰�鏉ヨ祫鏂�
+    async getCustomerPermissions() {
+      const { data: res } = await CustomerPermissions()
+      this.dialogTreeArr = [
+        { code: '',
+          name: '鍏ㄩ儴',
+          children: res
+        }
+      ]
+    },
+
+    async steptypecodeChange(val) {
+      // if (val === 'W') { // 澶栧崗
+      //   this.dialogForm.CustomerType = []
+      //   // await this.getCustomerPermissions()
+      // } else { // 鑷埗
+      //   this.dialogForm.Wkshop = []
+      // }
+      this.dialogForm.CustomerType = []
+      this.dialogForm.Wkshop = []
+      this.dialogTreeArr = []
+    },
+
+    // 杞﹂棿鍊兼敼鍙樻椂瑙﹀彂
+    async WkshopChange(val) {
+      if (val.length === 0) {
+        this.dialogTreeArr = []
+        return
+      }
+      const { data: res } = await WkshopEqpPermissions({ wkshopcode: val.join(',') })
+      this.dialogTreeArr = [
+        { code: '',
+          name: '鍏ㄩ儴',
+          children: res
+        }
+      ]
+    },
+
+    // 寰�鏉ュ崟浣嶇被鍨嬪�兼敼鍙樻椂
+    async CustomerTypeChange(val) {
+      if (val.length === 0) {
+        this.dialogTreeArr = []
+        return
+      }
+      const { data: res } = await CustomerTypeSearchPermission({ customertypecode: val.join(',') })
+      this.dialogTreeArr = [
+        { code: '',
+          name: '鍏ㄩ儴',
+          children: res
+        }
+      ]
     },
 
     // 鎺掑簭鏀瑰彉鏃�
@@ -358,6 +622,33 @@
       this.dialogVisible = true
       this.dialogForm.OperType = 'Update'
 
+      const { data: res } = await StepAssociationEqp({ stepcode: row.stepcode })
+      // row.flwtype   //Z锛氳嚜鍒�  W锛氬鍗�
+      if (row.flwtype === 'Z') {
+        this.dialogForm.Wkshop = []
+        res.filter(i => i.type === 'E' && i.flag === 'Y').forEach(i => {
+          this.dialogForm.Wkshop.push(i.code)
+          i.children.forEach(j => {
+            if (j.flag === 'Y') {
+              this.dialogTreeSelectedArr.push(j.code)
+            }
+          })
+        })
+        await this.WkshopChange(this.dialogForm.Wkshop)
+      } else if (row.flwtype === 'W') {
+        this.dialogForm.CustomerType = []
+        // await this.steptypecodeChange(row.flwtype)
+        res.filter(i => i.type === 'W' && i.flag === 'Y').forEach(i => {
+          this.dialogForm.CustomerType.push(i.code)
+          i.children.forEach(j => {
+            if (j.flag === 'Y') {
+              this.dialogTreeSelectedArr.push(j.code)
+            }
+          })
+        })
+        await this.CustomerTypeChange(this.dialogForm.CustomerType)
+      }
+
       this.$nextTick(() => {
         this.dialogForm.id = row.id
         this.dialogForm.stepcode = row.stepcode
@@ -365,6 +656,8 @@
         this.dialogForm.description = row.descr
         this.dialogForm.enable = row.enable
         this.dialogForm.steptypecode = row.flwtype
+
+        this.$refs.dialogTree.setCheckedKeys(this.dialogTreeSelectedArr)
       })
     },
     // 鍒犻櫎鎸夐挳
@@ -395,6 +688,10 @@
       this.dialogForm.enable = 'Y'
       this.dialogForm.description = ''
       this.dialogForm.steptypecode = 'Z'
+      this.dialogTreeArr = []
+      this.dialogForm.Wkshop = []
+      this.dialogForm.CustomerType = []
+      this.dialogTreeSelectedArr = []
       this.$refs.dialogForm.clearValidate()
     },
     // 瀵硅瘽妗嗗彇娑�
@@ -406,8 +703,28 @@
       this.$refs.dialogForm.validate(valid => {
         if (valid) {
           // console.log(JSON.parse(JSON.stringify(this.dialogForm)))
+
+          const children = []
+          this.$refs.dialogTree.getCheckedKeys().filter(i => i.length > 0).forEach(i => {
+            children.push({
+              stepcode: this.dialogForm.stepcode,
+              eqpcode: i,
+              style: this.dialogForm.steptypecode
+            })
+          })
+
+          const data = {
+            'id': this.dialogForm.id,
+            'stepcode': this.dialogForm.stepcode,
+            'stepname': this.dialogForm.stepname,
+            'steptypecode': this.dialogForm.steptypecode,
+            'enable': this.dialogForm.enable,
+            'description': this.dialogForm.description,
+            children
+          }
+
           this.$store.state.app.buttonIsDisabled = true
-          AddUpdateStep(this.dialogForm).then(res => {
+          AddUpdateStep(data, this.operation === 'add' ? 'Add' : 'Update').then(res => {
             if (res.code === '200') {
               this.$notify.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
               this.dialogVisible = false
@@ -428,7 +745,383 @@
         this.tableHeight = this.mainHeight - 200
         this.$refs.tableDataRef.doLayout()
       })
+    },
+    /* 鍏宠仈宸ヤ綔绔欐ā鍧�*/
+    // 鍏宠仈宸ヤ綔绔欑偣鍑�
+    workClick(row) {
+      const loading = this.$loading({
+        lock: true,
+        text: '姝e湪鍔犺浇鏁版嵁锛岃绋嶇瓑...',
+        spinner: 'el-icon-loading',
+        customClass: 'osloading',
+        background: 'rgba(0, 0, 0, 0.7)'
+      })
+
+      this.workDialogForm.stepcode = row.stepcode
+      this.workDialogForm.stepname = row.stepname
+      StepAssociationEqp({ stepcode: this.workDialogForm.stepcode }).then(res => {
+        if (res.code === '200') {
+          setTimeout(() => {
+            loading.close()
+            this.workDialogVisible = true
+
+            this.workDialogForm.workArr = res.data.filter(item => item.children.length !== 0)
+
+            let workGatherArr = []
+            if (row.flwtype === 'W') { // 澶栧崗鎯呭喌涓�
+              workGatherArr = this.workDialogForm.workArr.filter(item => item.type === 'W')
+            } else if (row.flwtype === 'Z') { // 鑷埗鎯呭喌涓�
+              workGatherArr = this.workDialogForm.workArr.filter(item => item.type === 'E')
+            } else { // 鑷埗锛嬪鍗�
+              workGatherArr = this.workDialogForm.workArr
+            }
+            const nodeKey = []// 闇�瑕佹爲褰㈡暟鏄剧殑鍊�
+            workGatherArr.forEach((item, index) => {
+              this.workDialogForm.workGatherArr.push({
+                isSelected1: index === 0,
+                isSelected2: item.flag === 'Y',
+                code: item.code,
+                name: item.name,
+                type: item.type,
+                flag: item.flag
+              })
+              if (item.flag === 'Y' && item.children && item.children.length > 0) {
+                this.$nextTick(() => {
+                  $("input[name='gather']").eq(index).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+                })
+                item.children.forEach(it => {
+                  if (it.flag === 'Y') {
+                    nodeKey.push(it.code)
+                  }
+                })
+              }
+              if (index === 0) {
+                if (item.children && item.children.length > 0) {
+                  this.workDialogForm.workTreeArr = this.workDialogForm.workArr.filter(it => it.code === item.code)
+                  this.workDialogForm.workTreeArr[0].name = '鍏ㄩ儴'
+                }
+              }
+              // item.flag === 'Y'&&item
+            })
+
+            this.$nextTick(() => {
+              this.$refs.workTree.setCheckedKeys(nodeKey)
+            })
+            this.workDialogForm.workTreeSelectedArr = nodeKey
+          }, 1000)
+        } else {
+          loading.close()
+        }
+      })
+    },
+    // 澶х洅瀛愮偣鍑讳簨浠�
+    myCheckboxClick(val) {
+      console.log(val.code, 3)
+      // 鐐瑰嚮涓嶅悓鐨勭洅瀛愯繘琛岄�変腑鏍峰紡鍒囨崲
+      this.workDialogForm.workGatherArr.find(item => {
+        item.isSelected1 = item.code === val.code
+      })
+      this.workDialogForm.workTreeArr = this.workDialogForm.workArr.filter(item => item.code === val.code)
+      if (this.workDialogForm.workTreeArr[0].children && this.workDialogForm.workTreeArr[0].children.length > 0) {
+        this.workDialogForm.workTreeArr[0].name = '鍏ㄩ儴'
+      } else {
+        this.workDialogForm.workTreeArr = []
+      }
+
+      console.log(this.workDialogForm.workTreeArr, 8)
+    },
+    // 灏忕洅瀛愮偣鍑讳簨浠�
+    myCheckboxInputClick(val) {
+      val.isSelected2 = !!val.isSelected2
+      console.log(val.code, 1)
+      this.workDialogForm.workCodeSelectedGatherArr = [...new Set(this.workDialogForm.workCodeSelectedGatherArr)]
+      // 1.绗竴绉嶆儏鍐�  灏忕洅瀛愪粠娌¢�変腑鍒伴�変腑
+      if (val.isSelected2) {
+        console.log('1.绗竴绉嶆儏鍐�  灏忕洅瀛愪粠娌¢�変腑鍒伴�変腑')
+        this.workDialogForm.workCodeSelectedGatherArr.push(val.code)
+
+        this.workDialogForm.workArr.forEach((item, index) => {
+          if (item.code === val.code) {
+            item.flag = 'Y'
+            if (item.children && item.children.length > 0) {
+              item.children.forEach(it => {
+                it.flag = 'Y'
+                this.workDialogForm.workTreeSelectedArr.push(it.code)
+              })
+            }
+          }
+        })
+      }
+
+      // 2.绗簩绉嶆儏鍐�  灏忕洅瀛愪粠閫変腑鍒版病閫変腑
+      if (!val.isSelected2) {
+        console.log('2.绗簩绉嶆儏鍐�  灏忕洅瀛愪粠閫変腑鍒版病閫変腑')
+        this.workDialogForm.workCodeSelectedGatherArr = this.workDialogForm.workCodeSelectedGatherArr.filter(item => item !== val.code)
+        this.workDialogForm.workArr.forEach((item, index) => {
+          if (item.code === val.code) {
+            item.flag = 'N'
+            if (item.children && item.children.length > 0) {
+              item.children.forEach(it => {
+                it.flag = 'N'
+                this.workDialogForm.workTreeSelectedArr.forEach((i, ind) => {
+                  if (i === it.code) {
+                    this.workDialogForm.workTreeSelectedArr.splice(ind, 1)
+                  }
+                })
+              })
+            }
+          }
+        })
+      }
+      this.workDialogForm.workCodeSelectedGatherArr = [...new Set(this.workDialogForm.workCodeSelectedGatherArr)]
+
+      console.log(this.workDialogForm.workCodeSelectedGatherArr, 2)
+      console.log(this.workDialogForm.workTreeSelectedArr, 23)
+      // this.$refs.workTree.setCheckedKeys(this.workDialogForm.workCodeSelectedGatherArr)
+      this.$refs.workTree.setCheckedKeys(this.workDialogForm.workTreeSelectedArr)
+    },
+    // 鏍戝舰涓� 妗嗛�変腑
+    checkBoxClick(obj, { checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys }) {
+      console.log(obj, { checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys })
+
+      let checkedFatherCode = '' // 鎵惧埌 checkedFatherCode  鐖禼ode鍊�
+      this.workDialogForm.workArr.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
+            }
+          })
+        }
+      })
+
+      // 1.绗竴绉嶆儏鍐�  鍗婂彾涓洪浂  鍏ㄥ彾涓洪浂
+      if (checkedKeys.length === 0 && halfCheckedKeys.length === 0) {
+        console.log('1.绗竴绉嶆儏鍐�  鍗婂彾涓洪浂  鍏ㄥ彾涓洪浂')
+        console.log(obj.code, 10)
+        // this.workDialogForm.workCodeSelectedGatherArr = this.workDialogForm.workCodeSelectedGatherArr.filter(item => item !== obj.code)
+
+        this.workDialogForm.workGatherArr.forEach((item, index) => {
+          if (item.code === checkedFatherCode) {
+            this.workDialogForm.workGatherArr[index].isSelected2 = false
+
+            // item.isSelected1 = item.code === checkedFatherCode
+            this.workDialogForm.workCodeSelectedGatherArr = this.workDialogForm.workCodeSelectedGatherArr.filter(it => it !== checkedFatherCode)
+            this.$nextTick(() => {
+              // console.log($("input[name='gather']"))
+              $("input[name='gather']").eq(index).prop('checked', false)// 鑷畾涔夊崟閫夋鍥炴樉
+            })
+          }
+        })
+
+        this.workDialogForm.workArr.forEach((item, index) => {
+          if (item.code === checkedFatherCode) {
+            item.flag = 'N'
+            if (item.children && item.children.length > 0) {
+              item.children.forEach((it) => {
+                it.flag = 'N'
+                this.workDialogForm.workTreeSelectedArr.forEach((i, ind) => {
+                  if (i === it.code) {
+                    this.workDialogForm.workTreeSelectedArr.splice(ind, 1)
+                  }
+                })
+              })
+            }
+          }
+        })
+        console.log(this.workDialogForm.workCodeSelectedGatherArr, 11)
+        console.log(this.workDialogForm.workTreeSelectedArr, 18)
+      }
+
+      // 2.绗簩绉嶆儏鍐�  鍗婂彾涓嶄负闆�  鍏ㄥ彾涓嶄负闆�
+      if (checkedKeys.length !== 0 && halfCheckedKeys.length !== 0) {
+        console.log('2.绗簩绉嶆儏鍐�  鍗婂彾涓嶄负闆�  鍏ㄥ彾涓嶄负闆�')
+        console.log(obj.code, 13)
+        // console.log(this.$refs.workTree, 22)
+
+        this.workDialogForm.workGatherArr.forEach((item, index) => {
+          if (item.code === checkedFatherCode) {
+            this.workDialogForm.workGatherArr[index].isSelected2 = true
+            // this.workDialogForm.workCodeSelectedGatherArr.push(obj.code)
+            this.$nextTick(() => {
+              $("input[name='gather']").eq(index).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+            })
+          }
+        })
+
+        this.workDialogForm.workArr.forEach((item, index) => {
+          if (item.code === checkedFatherCode) {
+            item.flag = 'Y'
+            if (item.children && item.children.length > 0) {
+              item.children.forEach(it => {
+                if (it.code === obj.code) {
+                  console.log(it.code, 21)
+                  if (it.flag === 'Y' && it.code === obj.code) {
+                    it.flag = 'N'
+                    this.workDialogForm.workTreeSelectedArr.forEach((i, ind) => {
+                      if (i === it.code) {
+                        console.log(i, 333)
+                        this.workDialogForm.workTreeSelectedArr.splice(ind, 1)
+                      }
+                    })
+                  } else if (it.flag === 'N' && it.code === obj.code) {
+                    it.flag = 'Y'
+                    console.log(2222)
+                    this.workDialogForm.workTreeSelectedArr.push(it.code)
+                  }
+                }
+              })
+            }
+
+            console.log(this.workDialogForm.workTreeSelectedArr, 17)
+
+            // this.$nextTick(() => {
+            //   $("input[name='gather']").eq(index).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+            // })
+          }
+        })
+      }
+
+      // 3.绗笁绉嶆儏鍐�  鍗婂彾涓洪浂  鍏ㄥ彾涓嶄负闆�
+      if (checkedKeys.length !== 0 && halfCheckedKeys.length === 0) {
+        console.log('3.绗笁绉嶆儏鍐�  鍗婂彾涓洪浂  鍏ㄥ彾涓嶄负闆�')
+        console.log(obj.code, 12)
+        this.workDialogForm.workGatherArr.forEach((item, index) => {
+          if (item.code === checkedFatherCode) {
+            this.workDialogForm.workGatherArr[index].isSelected2 = true
+            this.workDialogForm.workCodeSelectedGatherArr.push(obj.code)
+            this.$nextTick(() => {
+              $("input[name='gather']").eq(index).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+            })
+          }
+        })
+
+        this.workDialogForm.workArr.forEach((item, index) => {
+          if (item.code === checkedFatherCode) {
+            item.flag = 'Y'
+            if (item.children && item.children.length > 0) {
+              item.children.forEach(it => {
+                it.flag = 'Y'
+                this.workDialogForm.workTreeSelectedArr.push(it.code)
+              })
+            }
+          }
+        })
+      }
+      this.workDialogForm.workTreeSelectedArr = [...new Set(this.workDialogForm.workTreeSelectedArr)]
+
+      this.$refs.workTree.setCheckedKeys(this.workDialogForm.workTreeSelectedArr)
+      console.log(this.workDialogForm.workTreeSelectedArr, 14)
+      console.log(this.workDialogForm.workArr, 15)
+    },
+    // 瀵硅瘽妗嗗叧闂簨浠�
+    workHandleClose() {
+      this.workDialogForm.workArr = []
+      this.workDialogForm.workGatherArr = []
+      this.workDialogForm.workTreeArr = []
+      this.$refs.workTree.setCheckedKeys([])
+    },
+    // 鍙栨秷
+    workDialogVisibleCancel() {
+      this.workDialogVisible = false
+    },
+    // 纭
+    async workDialogVisibleConfirm() {
+      this.workDialogForm.workTreeSelectedArr = [...new Set(this.workDialogForm.workTreeSelectedArr)]
+
+      const data = []
+      this.workDialogForm.workArr.forEach(item => {
+        if (item.flag === 'Y' && item.children && item.children.length > 0) {
+          item.children.forEach(it => { //  淇濆瓨鎺ュ彛鍙紶鏈�瀛愰」  name浼犵殑鏄痶ype
+            if (it.flag === 'Y') {
+              data.push({ code: it.code, name: it.type })
+            }
+          })
+        }
+      })
+      this.$store.state.app.buttonIsDisabled = true
+      console.log(this.workDialogForm.stepcode, 123)
+      const res = await SaveStepAssociationEqp(this.workDialogForm.stepcode, data)
+      if (res.code === '200') {
+        this.workDialogVisible = false
+        this.$message.success('淇濆瓨鎴愬姛锛�')
+        await this.getStepSearch()
+        this.$store.state.app.buttonIsDisabled = false
+      }
     }
   }
 }
 </script>
+<style lang="scss" scoped>
+$main_color: #42b983;
+.el-icon-share{
+  color: $main_color;
+  cursor: pointer;
+}
+.workDialogVisible {
+  .myCheckboxGroup {
+    display: flex;
+    flex-wrap: wrap;
+
+    .myCheckbox {
+      border: 1px solid #eee;
+      display: flex;
+      min-width: 100px;
+      padding: 10px;
+      margin: 10px 30px 0 0;
+      border-radius: 5px;
+      cursor: default;
+      position: relative;
+
+      .myCheckboxInput {
+        margin: 1px 5px 0 0;
+        cursor: pointer;
+      }
+
+      .myCheckboxInputLabel {
+        position: absolute;
+        left: 29px;
+        padding: 5px;
+        top: 6px;
+        color: transparent;
+      }
+
+    }
+
+    input[type=checkbox] {
+      cursor: pointer;
+      position: relative;
+      width: 14px;
+      height: 14px;
+      font-size: 14px;
+    }
+
+    input[type=checkbox]::after {
+      position: absolute;
+      top: 0;
+      color: $main_color;
+      width: 14px;
+      height: 14px;
+      display: inline-block;
+      visibility: visible;
+      padding-left: 0;
+      text-align: center;
+      content: ' ';
+      border-radius: 3px
+    }
+
+    input[type=checkbox]:checked::after {
+      content: "鉁�";
+      //content: "鈭�";
+      color: #fff;
+      font-size: 12px;
+      font-weight: bold;
+      background-color: $main_color;
+    }
+  }
+}
+
+</style>

--
Gitblit v1.9.3