From 1e9fa82cb2fe2c15f46bd1dd73f5c878c74b83b8 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期四, 04 八月 2022 15:35:50 +0800
Subject: [PATCH] 1.系统多账号登录问题2.采购订单页面样式修改及数据渲染

---
 src/views/zzmx/gxdy.vue |  661 +++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 622 insertions(+), 39 deletions(-)

diff --git a/src/views/zzmx/gxdy.vue b/src/views/zzmx/gxdy.vue
index d377590..7ab483b 100644
--- a/src/views/zzmx/gxdy.vue
+++ b/src/views/zzmx/gxdy.vue
@@ -17,7 +17,13 @@
               <el-input v-model="form.stepname" placeholder="璇疯緭鍏�" style="width: 200px" />
             </el-form-item>
             <el-form-item label="鍚敤鐘舵��" style=" display: flex;">
-              <el-select v-model="form.enable" :popper-append-to-body="false" style="width: 200px" placeholder="璇烽�夋嫨">
+              <el-select
+                v-model="form.enable"
+                filterable
+                :popper-append-to-body="false"
+                style="width: 200px"
+                placeholder="璇烽�夋嫨"
+              >
                 <el-option
                   v-for="item in enableArr"
                   :key="item.code"
@@ -29,6 +35,7 @@
             <el-form-item label="宸ュ簭绫诲瀷" style=" display: flex;">
               <el-select
                 v-model="form.steptypecode"
+                filterable
                 :popper-append-to-body="false"
                 style="width: 200px"
                 placeholder="璇烽�夋嫨"
@@ -54,7 +61,7 @@
       <el-divider />
       <div style="margin-left: 10px;display: flex">
         <el-button type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">鏂板</el-button>
-        <el-button type="primary" icon="el-icon-upload2" @click="upload">瀵煎叆</el-button>
+        <!--        <el-button type="primary" icon="el-icon-upload2" @click="upload">瀵煎叆</el-button>-->
       </div>
       <el-divider />
       <div class="elTableDiv">
@@ -77,19 +84,23 @@
             prop="RowNum"
             width="50"
             label="搴忓彿"
+            fixed
           />
           <el-table-column
             prop="stepcode"
             label="宸ュ簭缂栫爜"
+            min-width="150"
             sortable="custom"
           />
           <el-table-column
             prop="stepname"
+            min-width="150"
             label="宸ュ簭鍚嶇О"
             sortable="custom"
           />
           <el-table-column
             prop="flwtype"
+            min-width="150"
             label="宸ュ簭绫诲瀷"
             sortable="custom"
           >
@@ -102,42 +113,63 @@
           <el-table-column
             prop="descr"
             label="宸ュ簭鎻忚堪"
+            min-width="180"
             sortable="custom"
           />
           <el-table-column
+            prop="enable"
+            label="鍚敤鐘舵��"
+            sortable="custom"
+            width="110"
+          >
+            <template slot-scope="{row}">
+              <div v-if="row.enable==='Y'">鏄�</div>
+              <div v-if="row.enable==='N'">鍚�</div>
+            </template>
+          </el-table-column>
+          <el-table-column
             prop="lm_user"
             label="鍒涘缓浜哄憳"
+            width="110"
             sortable="custom"
           />
           <el-table-column
             prop="lm_date"
             label="鍒涘缓鏃堕棿"
+            width="160"
             sortable="custom"
           />
           <el-table-column
             label="鍏宠仈宸ヤ綔绔�"
+            prop="is_eqp"
+            width="110"
           >
             <template slot-scope="{row}">
               <div class="operationClass">
-                <i class="el-icon-share" @click="workClick(row)" />
+                <i v-if="row.is_eqp==='Y'" 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)" />
               </div>
             </template>
           </el-table-column>
           <el-table-column
             label="鍏宠仈缂洪櫡"
+            prop="is_defect"
+            width="110"
           >
             <template slot-scope="{row}">
               <div class="operationClass">
-                <i class="el-icon-share" @click="defectClick(row)" />
+                <i v-if="row.is_defect==='Y'" class="el-icon-share" @click="defectClick(row)" />
+                <i v-if="row.is_defect==='N'" class="el-icon-share" style="color:rgb(180 ,181, 185);" @click="defectClick(row)" />
               </div>
             </template>
           </el-table-column>
           <el-table-column
             label="鎿嶄綔"
+            fixed="right"
           >
             <template slot-scope="{row}">
               <div class="operationClass">
-                <el-button type="text" @click="edit('edit',row)">淇敼</el-button>
+                <el-button type="text" @click="edit('edit',row)">缂栬緫</el-button>
                 <el-button type="text" @click="del(row)">鍒犻櫎</el-button>
               </div>
             </template>
@@ -157,10 +189,11 @@
       />
     </div>
 
+    <!--鏂板淇敼瀵硅瘽妗�-->
     <el-dialog
-      :title="operation==='add'?'鏂板':'淇敼'"
+      :title="operation==='add'?'鏂板':'缂栬緫'"
       :visible.sync="dialogVisible"
-      width="50%"
+      width="800px"
       :close-on-click-modal="false"
       top="15vh"
       @closed="handleClose"
@@ -168,30 +201,44 @@
     >
       <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
         <el-form-item label="宸ュ簭缂栫爜" prop="stepcode">
-          <el-input v-model="dialogForm.stepcode" :disabled="operation!=='add'" style="width: 220px" />
+          <el-input v-model="dialogForm.stepcode" :disabled="operation!=='add'" style="width: 200px" />
         </el-form-item>
         <el-form-item label="宸ュ簭鍚嶇О" prop="stepname">
-          <el-input v-model="dialogForm.stepname" style="width: 220px" />
+          <el-input v-model="dialogForm.stepname" style="width: 200px" />
         </el-form-item>
+
         <el-form-item prop="steptypecode" label="宸ュ簭绫诲瀷">
-          <el-select
+          <el-radio-group
             v-model="dialogForm.steptypecode"
-            style="width: 220px"
-            placeholder="璇烽�夋嫨"
-            :popper-append-to-body="false"
+            style="width: 200px"
           >
-            <el-option
+            <el-radio
               v-for="item in steptypeArr"
               :key="item.code"
-              :label="item.name"
               :value="item.code"
+              :label="item.name"
             />
-          </el-select>
+          </el-radio-group>
+          <!--          <el-select-->
+          <!--            v-model="dialogForm.steptypecode"-->
+          <!--            filterable-->
+          <!--            style="width: 200px"-->
+          <!--            placeholder="璇烽�夋嫨"-->
+          <!--            :popper-append-to-body="false"-->
+          <!--          >-->
+          <!--            <el-option-->
+          <!--              v-for="item in steptypeArr"-->
+          <!--              :key="item.code"-->
+          <!--              :label="item.name"-->
+          <!--              :value="item.code"-->
+          <!--            />-->
+          <!--          </el-select>-->
         </el-form-item>
         <el-form-item prop="enable" label="鍚敤鐘舵��">
           <el-select
             v-model="dialogForm.enable"
-            style="width: 220px"
+            filterable
+            style="width: 200px"
             placeholder="璇烽�夋嫨"
             :popper-append-to-body="false"
           >
@@ -204,7 +251,7 @@
           </el-select>
         </el-form-item>
         <el-form-item label="宸ュ簭鎻忚堪" prop="description">
-          <el-input v-model="dialogForm.description" type="textarea" style="width: 220px" />
+          <el-input v-model="dialogForm.description" type="textarea" style="width: 200px" />
         </el-form-item>
       </el-form>
       <span slot="footer" class="dialog-footer">
@@ -214,18 +261,137 @@
         </div>
       </span>
     </el-dialog>
+
+    <!--    鍏宠仈宸ヤ綔绔欏璇濇-->
+    <el-dialog
+      title="鍏宠仈宸ヤ綔绔�"
+      :visible.sync="workDialogVisible"
+      width="50%"
+      top="15vh"
+      :fullscreen="isFullscreen"
+      :close-on-click-modal="false"
+      class="workDialogVisible"
+      @closed="workHandleClose"
+      @close="workHandleClose"
+    >
+      <!--      @opened="handleOpenedRoles"-->
+
+      <div>
+        <i class="el-icon-s-comment" style="color:#42b983;" /> 宸ュ簭鍚嶇О锛歿{ workDialogForm.stepname }}
+      </div>
+      <el-divider />
+      <div>
+        <div style="margin-bottom:20px">
+          <i class="el-icon-s-operation" style="color:#42b983;" /> 宸ヤ綔绔欓泦鍚堬細
+        </div>
+        <div class="myCheckboxGroup">
+          <div
+            v-for="item in workDialogForm.workGatherArr"
+            :key="item.code"
+            :style="{border:item.isSelected1?'1px solid #42b983':'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"-->
+          </div>
+        </div>
+      </div>
+      <el-divider />
+      <div>
+        <div style="margin-bottom:20px">
+          <i class="el-icon-s-operation" style="color:#42b983;" /> 宸ヤ綔绔欙細
+        </div>
+        <el-tree
+          ref="workTree"
+          :data="workDialogForm.workTreeArr"
+          show-checkbox
+          node-key="code"
+          style="height: 300px;"
+          default-expand-all
+          :props="workTreeDefaultProps"
+          @check="checkBoxClick"
+        />
+        <!--        @check-change="checkChange"-->
+
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <div class="footerButton">
+          <el-button @click="workDialogVisibleCancel">鍙� 娑�</el-button>
+          <el-button type="primary" @click="workDialogVisibleConfirm">纭� 瀹�</el-button>
+        </div>
+      </span>
+    </el-dialog>
+
+    <!--    鍏宠仈缂洪櫡瀵硅瘽妗�-->
+    <el-dialog
+      title="宸ュ簭鍏宠仈缂洪櫡"
+      :visible.sync="defectDialogVisible"
+      width="50%"
+      top="15vh"
+      :fullscreen="isFullscreen"
+      :close-on-click-modal="false"
+      class="defectDialogVisible"
+      @closed="defectHandleClose"
+      @close="defectHandleClose"
+    >
+      <!--      @opened="handleOpenedRoles"-->
+
+      <div style="margin-bottom: 20px">
+        <i class="el-icon-s-comment" style="color:#42b983;" /> 宸ュ簭鍚嶇О锛歿{ defectTreeName }}
+      </div>
+
+      <div>
+        <!--        <div style="margin-bottom:20px">-->
+        <!--          <i class="el-icon-s-operation" style="color:#42b983;" /> 宸ヤ綔绔欙細-->
+        <!--        </div>-->
+        <el-tree
+          ref="defectTree"
+          :data="defectTree"
+          show-checkbox
+          node-key="code"
+          style="height: 500px;"
+          default-expand-all
+          :props="workTreeDefaultProps"
+        />
+        <!--        @check="checkBoxClick"-->
+        <!--        @check-change="checkChange"-->
+
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <div class="footerButton">
+          <el-button @click="defectDialogVisibleCancel">鍙� 娑�</el-button>
+          <el-button type="primary" @click="defectDialogVisibleConfirm">纭� 瀹�</el-button>
+        </div>
+      </span>
+    </el-dialog>
+
   </div>
 </template>
 
 <script>
 import Pagination from '@/components/Pagination'
-import { AddUpdateOrganization, DeleteOrganization, OrganizationSearch, PrentOrganization } from '@/api/jcsz'
-import { getCookie } from '@/utils/auth'
-import { AddUpdateStep, DeleteStep, StepSearch } from '@/api/zzmx'
+import {
+  AddUpdateStep,
+  DeleteStep, SaveStepAssociationDefect,
+  SaveStepAssociationEqp,
+  StepAssociationDefect,
+  StepAssociationEqp,
+  StepSearch
+} from '@/api/zzmx'
+import $ from 'jquery'
 
 const SER_HZ = /^[\u4e00-\u9fa5]+$/
 export default {
-  name: 'Zzjg',
+  name: 'GXDY',
   components: {
     Pagination
   },
@@ -242,6 +408,7 @@
       }
     }
     return {
+      isFullscreen: false,
       mainHeight: 0,
       tableHeight: 0,
       form: {
@@ -261,18 +428,18 @@
       ],
       steptypeArr: [
         { code: 'Z', name: '鑷埗' },
-        { code: 'W', name: '澶栧崗' },
-        { code: 'Z;W', name: '鑷埗锛涘鍗�' }
+        { code: 'W', name: '澶栧崗' }
+        // { code: 'Z;W', name: '鑷埗锛涘鍗�' }
       ],
       total: 10,
       tableData: [],
       dialogVisible: false,
       dialogForm: {
-        'idid': '',
+        'id': '',
         'stepcode': '',
         'stepname': '',
-        'steptypecode': '',
-        'enable': '',
+        'steptypecode': '鑷埗',
+        'enable': 'Y',
         'description': '',
         'OperType': ''
       },
@@ -290,8 +457,26 @@
         enable: [
           { 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'
+      },
+      defectDialogVisible: false,
+      defectTreeCode: '',
+      defectTreeName: '',
+      defectTree: []
 
     }
   },
@@ -352,7 +537,7 @@
         this.dialogForm.id = row.id
         this.dialogForm.stepcode = row.stepcode
         this.dialogForm.stepname = row.stepname
-        this.dialogForm.steptypecode = row.flwtype
+        this.dialogForm.steptypecode = this.steptypeArr.find(item => item.code === row.flwtype).name
         this.dialogForm.description = row.descr
         this.dialogForm.enable = row.enable
       })
@@ -378,8 +563,8 @@
     handleClose() {
       this.dialogForm.stepcode = ''
       this.dialogForm.stepname = ''
-      this.dialogForm.steptypecode = ''
-      this.dialogForm.enable = ''
+      this.dialogForm.steptypecode = '鑷埗'
+      this.dialogForm.enable = 'Y'
       this.dialogForm.description = ''
       this.$refs.dialogForm.clearValidate()
     },
@@ -395,7 +580,7 @@
             id: this.dialogForm.id,
             stepcode: this.dialogForm.stepcode,
             stepname: this.dialogForm.stepname,
-            steptypecode: this.dialogForm.steptypecode,
+            steptypecode: this.steptypeArr.find(item => item.name === this.dialogForm.steptypecode).code,
             enable: this.dialogForm.enable,
             description: this.dialogForm.description,
             OperType: this.operation === 'add' ? 'Add' : 'Update'
@@ -417,18 +602,347 @@
       this.$nextTick(() => {
         this.mainHeight = window.innerHeight - 250
         this.tableHeight = this.mainHeight - 100
+        // this.isFullscreen = window.innerHeight < 800
+        if (window.innerHeight < 800) {
+          this.tableHeight = this.tableHeight - 50
+        }
       })
     },
     /* 鍏宠仈宸ヤ綔绔欐ā鍧�*/
     // 鍏宠仈宸ヤ綔绔欑偣鍑�
-    workClick(row) {
+    async workClick(row) {
+      this.workDialogVisible = true
+      this.workDialogForm.stepcode = row.stepcode
+      this.workDialogForm.stepname = row.stepname
+      const { data: res } = await StepAssociationEqp({ stepcode: this.workDialogForm.stepcode })
+      this.workDialogForm.workArr = res
+      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
+      }
+      // this.workDialogForm.workArr[1].children = []
+      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
+      })
+      console.log(nodeKey, 1)
+      this.$refs.workTree.setCheckedKeys(nodeKey)
+      this.workDialogForm.workTreeSelectedArr = nodeKey
 
+      console.log(this.workDialogForm.workGatherArr, 6)
+      console.log(this.workDialogForm.workTreeArr, 7)
     },
+    // 澶х洅瀛愮偣鍑讳簨浠�
+    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)]
+      console.log(this.workDialogForm.workTreeSelectedArr, 18)
+      console.log(this.workDialogForm.workArr, 20)
+      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 })
+            }
+          })
+        }
+      })
+      console.log(data)
+      const res = await SaveStepAssociationEqp(this.workDialogForm.stepcode, data)
+      if (res.code === '200') {
+        this.$message.success('淇濆瓨鎴愬姛锛�')
+        await this.getStepSearch()
+        this.workDialogVisible = false
+      }
+    },
     /* 鍏宠仈缂洪櫡*/
     //  鍏宠仈缂洪櫡鐐瑰嚮
-    defectClick(row) {
+    async defectClick(row) {
+      this.defectTreeCode = row.stepcode
+      this.defectTreeName = row.stepname
+      this.defectDialogVisible = true
 
+      const { data: res } = await StepAssociationDefect({ stepcode: row.stepcode })
+      // this.defectTree = res
+      this.defectTree.push({ code: 'QB', name: '鍏ㄩ儴', children: res, flag: 'N' })
+      console.log(this.defectTree, 6)
+      const nokeKey = []
+      this.defectTree[0].children.forEach(item => {
+        if (item.flag === 'Y') {
+          nokeKey.push(item.code)
+        }
+      })
+      console.log(nokeKey, 2)
+      this.$nextTick(() => {
+        this.$refs.defectTree.setCheckedKeys(nokeKey)
+      })
+    },
+    // 鍏抽棴
+    defectHandleClose() {
+      this.defectTree = []
+    },
+    // 鍙栨秷
+    defectDialogVisibleCancel() {
+      this.defectDialogVisible = false
+    },
+    // 纭
+    async defectDialogVisibleConfirm() {
+      const nodeKey = this.$refs.defectTree.getCheckedKeys()
+      const data = []
+      this.defectTree[0].children.forEach(item => {
+        if (nodeKey.includes(item.code)) {
+          console.log(item.code)
+          data.push({ code: item.code, name: item.name })
+        }
+      })
+      const res = await SaveStepAssociationDefect(this.defectTreeCode, data)
+      if (res.code === '200') {
+        this.$message.success('淇濆瓨鎴愬姛锛�')
+        await this.getStepSearch()
+        this.defectDialogVisible = false
+      }
     }
   }
 }
@@ -445,9 +959,11 @@
   border: none;
   padding: 0 20px;
 }
+
 ::v-deep .el-button--primary:hover {
   border: none;
 }
+
 ::v-deep .el-button--info {
   height: 30px;
   display: flex;
@@ -485,6 +1001,70 @@
   padding: 20px 100px !important;
 }
 
+.defectDialogVisible {
+  ::v-deep .el-dialog__body {
+    padding: 20px 20px !important;
+  }
+}
+
+.workDialogVisible {
+  ::v-deep .el-dialog__body {
+    padding: 20px 20px !important;
+  }
+
+  .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;
+
+      .myCheckboxInput {
+        margin: 1px 5px 0 0;
+        cursor: pointer;
+      }
+
+    }
+
+    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;
+    }
+  }
+}
+
 ::v-deep .el-radio__input.is-checked .el-radio__inner {
   background-color: $main_color;
   border-color: $main_color;
@@ -503,6 +1083,7 @@
   height: 30px;
   line-height: 30px;
 }
+
 ::v-deep .el-input__inner:focus {
   border-color: $main_color;
 }
@@ -579,17 +1160,19 @@
   border-color: $main_color;
 }
 
-::v-deep .el-select .el-input__inner:focus{
+::v-deep .el-select .el-input__inner:focus {
   border-color: $main_color;
 }
 
-::v-deep .el-select-dropdown__item.selected{
+::v-deep .el-select-dropdown__item.selected {
   color: $main_color;
 }
-::v-deep .el-checkbox__inner:hover{
+
+::v-deep .el-checkbox__inner:hover {
   border-color: $main_color;
 }
-::v-deep .el-textarea__inner:focus{
+
+::v-deep .el-textarea__inner:focus {
   border-color: $main_color;
 }
 

--
Gitblit v1.9.3