From f6f4ee86f5e389230edd8df186553f50b17f3f6d Mon Sep 17 00:00:00 2001
From: 小小儁爺 <1694218219@qq.com>
Date: 星期三, 31 七月 2024 17:40:18 +0800
Subject: [PATCH] 1.新增组织机构类型2.工序关联设备、供应商

---
 src/api/basicSettings.js                     |   21 +
 src/views/basicSettings/processList.vue      |  659 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/views/basicSettings/organizationList.vue |   66 ++++
 src/api/GeneralBasicData.js                  |   27 ++
 4 files changed, 759 insertions(+), 14 deletions(-)

diff --git a/src/api/GeneralBasicData.js b/src/api/GeneralBasicData.js
index 6d1a61e..df40fdf 100644
--- a/src/api/GeneralBasicData.js
+++ b/src/api/GeneralBasicData.js
@@ -1,5 +1,32 @@
 import request from '@/utils/request'
 
+// 缁勭粐鏋舵瀯杞﹂棿鍩虹璧勬枡
+export function WkshopEqpPermissions(data) {
+  return request({
+    url: 'GeneralBasicData/WkshopEqpPermissions',
+    method: 'get',
+    params: data
+  })
+}
+
+// 缁勭粐鏋舵瀯杞﹂棿鍩虹璧勬枡
+export function TorgWkshop(data) {
+  return request({
+    url: 'GeneralBasicData/TorgWkshop',
+    method: 'get',
+    params: data
+  })
+}
+
+// 缁勭粐鏋舵瀯绫诲瀷璧勬枡
+export function TOrganTypeDate(data) {
+  return request({
+    url: 'GeneralBasicData/TOrganTypeDate',
+    method: 'get',
+    params: data
+  })
+}
+
 // 缁勭粐鏋舵瀯鏌ユ壘
 export function PrentOrganization(data) {
   return request({
diff --git a/src/api/basicSettings.js b/src/api/basicSettings.js
index e2da467..129c601 100644
--- a/src/api/basicSettings.js
+++ b/src/api/basicSettings.js
@@ -329,9 +329,9 @@
 }
 
 // 宸ュ簭鏂板缂栬緫
-export function AddUpdateStep(data) {
+export function AddUpdateStep(data, OperType) {
   return request({
-    url: 'BasicSetting/AddUpdateStep',
+    url: 'BasicSetting/AddUpdateStep?OperType=' + OperType,
     method: 'post',
     data
   })
@@ -515,3 +515,20 @@
   })
 }
 
+// 宸ュ簭瀹氫箟鍏宠仈宸ヤ綔绔欐煡璇�
+export function StepAssociationEqp(data) {
+  return request({
+    url: 'BasicSetting/StepAssociationEqp',
+    method: 'get',
+    params: data
+  })
+}
+
+// 宸ュ簭瀹氫箟鍏宠仈宸ヤ綔绔欐彁浜�
+export function SaveStepAssociationEqp(stepcode, data) {
+  return request({
+    url: 'BasicSetting/SaveStepAssociationEqp?stepcode=' + stepcode,
+    method: 'post',
+    data
+  })
+}
diff --git a/src/views/basicSettings/organizationList.vue b/src/views/basicSettings/organizationList.vue
index d821c74..0c8cdb7 100644
--- a/src/views/basicSettings/organizationList.vue
+++ b/src/views/basicSettings/organizationList.vue
@@ -20,6 +20,22 @@
             <el-form-item label="缁勭粐鍚嶇О" style=" display: flex;">
               <el-input v-model="form.storg_name" placeholder="璇疯緭鍏�" style="width: 200px" />
             </el-form-item>
+            <el-form-item label="缁勭粐绫诲瀷" prop="torgtype_code">
+              <el-select
+                v-model="form.torgtype_code"
+                filterable
+                :popper-append-to-body="false"
+                style="width: 200px"
+                placeholder="璇烽�夋嫨"
+              >
+                <el-option
+                  v-for="item in OrgTypeArr"
+                  :key="item.torgtype_code"
+                  :label="item.torgtype_name"
+                  :value="item.torgtype_code"
+                />
+              </el-select>
+            </el-form-item>
           </div>
           <div
             class="bodySearchReset"
@@ -79,6 +95,11 @@
           <el-table-column
             prop="torg_name"
             label="缁勭粐鍚嶇О"
+            sortable="custom"
+          />
+          <el-table-column
+            prop="torgtype_name"
+            label="缁勭粐绫诲瀷"
             sortable="custom"
           />
           <el-table-column
@@ -153,11 +174,28 @@
       @close="handleClose"
     >
       <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
+
         <el-form-item label="缁勭粐缂栫爜" prop="OrganCode">
           <el-input v-model="dialogForm.OrganCode" :disabled="operation!=='add'" style="width: 200px" />
         </el-form-item>
         <el-form-item label="缁勭粐鍚嶇О" prop="OrganName">
           <el-input v-model="dialogForm.OrganName" style="width: 200px" />
+        </el-form-item>
+        <el-form-item label="缁勭粐绫诲瀷" prop="torgtype_code">
+          <el-select
+            v-model="dialogForm.torgtype_code"
+            filterable
+            :popper-append-to-body="false"
+            style="width: 200px"
+            placeholder="璇烽�夋嫨"
+          >
+            <el-option
+              v-for="item in OrgTypeArr"
+              :key="item.torgtype_code"
+              :label="item.torgtype_name"
+              :value="item.torgtype_code"
+            />
+          </el-select>
         </el-form-item>
         <el-form-item label="鎵�灞炵粍缁�" prop="storgcode">
           <el-cascader
@@ -205,7 +243,7 @@
 import elDragDialog from '@/directive/el-drag-dialog'
 import waves from '@/directive/waves'
 import arrayToTree from 'array-to-tree'
-import { PrentOrganization } from '@/api/GeneralBasicData'
+import { PrentOrganization, TOrganTypeDate } from '@/api/GeneralBasicData'
 
 export default {
   name: 'Zzjg',
@@ -218,6 +256,7 @@
       mainHeight: 0,
       tableHeight: 0,
       form: {
+        torgtype_code: '',
         storg_code: '', // 缁勭粐鏋舵瀯缂栫爜
         storg_name: '' // 缁勭粐鏋舵瀯鍚嶇О
         // prop: 'lm_date', // 鎺掑簭瀛楁
@@ -229,6 +268,7 @@
       tableData: [],
       dialogVisible: false,
       dialogForm: {
+        torgtype_code: '', // 缁勭粐绫诲瀷
         OrganCode: '', // 缁勭粐缂栫爜
         OrganName: '', // 缁勭粐鍚嶇О
         leve: 0, // 灞傜骇缂栫爜
@@ -239,6 +279,9 @@
       },
       operation: '',
       dialogFormRules: {
+        torgtype_code: [
+          { required: true, message: '璇烽�夋嫨缁勭粐绫诲瀷', trigger: ['blur', 'change'] }
+        ],
         OrganCode: [
           { required: true, validator: validateCode, trigger: ['blur', 'change'] }
         ],
@@ -256,18 +299,31 @@
         label: 'torg_name'
       },
       Options: [],
-      cascaderOptions: []
+      cascaderOptions: [],
+      OrgTypeArr: [
+        // { label: '宸ュ巶', value: 'F' },
+        // { label: '閮ㄩ棬', value: 'D' },
+        // { label: '杞﹂棿', value: 'W' }
+        // { label: '绉戝', value: 'K' },
+        // { label: '鐢熶骇绾�', value: 'L' }
+      ]
 
     }
   },
   created() {
     this.getSTorgData()
+    this.getTOrganTypeDate()
   },
   mounted() {
     window.addEventListener('resize', this.getHeight)
     this.getHeight()
   },
   methods: {
+    // 鏌ヨ缁勭粐绫诲瀷
+    async   getTOrganTypeDate() {
+      const { data: res } = await TOrganTypeDate()
+      this.OrgTypeArr = res
+    },
     // 缁勭粐鏋舵瀯澶у垪琛ㄦ煡璇�
     async getSTorgData() {
       const res = await STorgData(this.form)
@@ -303,6 +359,7 @@
     },
     // 閲嶇疆
     reset() {
+      this.form.torgtype_code = ''
       this.form.storg_code = ''
       this.form.storg_name = ''
       this.getSTorgData()
@@ -322,6 +379,7 @@
       await this.getPrentOrganization()
       this.cascaderOptions = this.filterChildren(this.cascaderOptions, row.torg_code)
       this.$nextTick(() => {
+        this.dialogForm.torgtype_code = row.torgtype_code
         this.dialogForm.OrganCode = row.torg_code
         this.dialogForm.OrganName = row.torg_name
         this.dialogForm.leve = parseFloat(row.leve)
@@ -392,6 +450,7 @@
       this.dialogForm.OrganName = ''
       this.dialogForm.storgcode = ''
       this.dialogForm.parent_id = ''
+      this.dialogForm.torgtype_code = ''
       this.dialogForm.status = 'Y'
       this.dialogForm.leve = 0
       this.$refs.cascader.checkedValue = ''
@@ -434,6 +493,9 @@
         this.tableHeight = this.mainHeight - 137
         this.$refs.tableDataRef.doLayout()
       })
+    },
+    changeRadio(val) {
+
     }
   }
 }
diff --git a/src/views/basicSettings/processList.vue b/src/views/basicSettings/processList.vue
index 8f94a8b..1624cb1 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,16 +216,19 @@
       />
     </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-divider content-position="left">鍩烘湰淇℃伅</el-divider>
+
       <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: 200px" />
@@ -212,6 +242,7 @@
             style="width:200px"
             placeholder="璇烽�夋嫨"
             :popper-append-to-body="false"
+            @change="steptypecodeChange"
           >
             <el-option
               v-for="item in steptypeArr"
@@ -221,13 +252,34 @@
             />
           </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="鎵�灞炶溅闂�" required>
+          <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 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 +287,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 +313,104 @@
       </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, TorgWkshop, WkshopEqpPermissions } from '@/api/GeneralBasicData'
 
 export default {
   name: 'Zzjg',
@@ -289,15 +442,18 @@
         { code: 'Y', name: '姝e父' },
         { code: 'N', name: '鍋滅敤' }
       ],
+      WkshopArr: [], // 杞﹂棿涓嬫媺鏁扮粍
       dialogVisible: false,
       dialogForm: {
         id: '',
         stepcode: '', //
         stepname: '', //
+        Wkshop: '', //
         steptypecode: 'Z',
         description: '', // 鎻忚堪
         enable: 'Y'// 鐘舵��
       },
+      dialogTreeArr: [],
       operation: '',
       dialogFormRules: {
         stepcode: [
@@ -306,12 +462,30 @@
         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()
   },
   mounted() {
     window.addEventListener('resize', this.getHeight)
@@ -323,6 +497,45 @@
       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 getCustomerPermissions() {
+      const { data: res } = await CustomerPermissions()
+      this.dialogTreeArr = [
+        { code: '',
+          name: '鍏ㄩ儴',
+          children: res
+        }
+      ]
+    },
+
+    async steptypecodeChange(val) {
+      if (val === 'W') { // 澶栧崗
+        await this.getCustomerPermissions()
+      } else { // 鑷埗
+        this.dialogForm.Wkshop = []
+        this.dialogTreeArr = []
+      }
+    },
+
+    // 杞﹂棿鍊兼敼鍙樻椂瑙﹀彂
+    async WkshopChange(val) {
+      if (val.length === 0) {
+        return
+      }
+
+      const { data: res } = await WkshopEqpPermissions({ wkshopcode: val.join(',') })
+      this.dialogTreeArr = [
+        { code: '',
+          name: '鍏ㄩ儴',
+          children: res
+        }
+      ]
     },
 
     // 鎺掑簭鏀瑰彉鏃�
@@ -358,6 +571,30 @@
       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') {
+        await this.steptypecodeChange(row.flwtype)
+        res.filter(i => i.type === 'W' && i.flag === 'Y').forEach(i => {
+          i.children.forEach(j => {
+            if (j.flag === 'Y') {
+              this.dialogTreeSelectedArr.push(j.code)
+            }
+          })
+        })
+      }
+
       this.$nextTick(() => {
         this.dialogForm.id = row.id
         this.dialogForm.stepcode = row.stepcode
@@ -365,6 +602,8 @@
         this.dialogForm.description = row.descr
         this.dialogForm.enable = row.enable
         this.dialogForm.steptypecode = row.flwtype
+
+        this.$refs.dialogTree.setCheckedKeys(this.dialogTreeSelectedArr)
       })
     },
     // 鍒犻櫎鎸夐挳
@@ -395,6 +634,10 @@
       this.dialogForm.enable = 'Y'
       this.dialogForm.description = ''
       this.dialogForm.steptypecode = 'Z'
+      this.dialogTreeArr = []
+      this.dialogForm.Wkshop = []
+
+      this.dialogTreeSelectedArr = []
       this.$refs.dialogForm.clearValidate()
     },
     // 瀵硅瘽妗嗗彇娑�
@@ -406,8 +649,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 +691,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