From cf9cde2c639572108a926ec8136cd7941198304f Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期一, 29 八月 2022 17:24:48 +0800
Subject: [PATCH] 1.完成点检标准增删查改,关联设备的开发
---
src/views/sbgl/djbz.vue | 243 ++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 222 insertions(+), 21 deletions(-)
diff --git a/src/views/sbgl/djbz.vue b/src/views/sbgl/djbz.vue
index 4ab6079..2dc802b 100644
--- a/src/views/sbgl/djbz.vue
+++ b/src/views/sbgl/djbz.vue
@@ -75,7 +75,13 @@
prop="description"
label="鏍囧噯鎻忚堪"
sortable="custom"
- />
+ show-tooltip-when-overflow
+ >
+ <template slot-scope="{row}">
+ <div v-if="row.description">{{ row.description }}</div>
+ <div v-else>/</div>
+ </template>
+ </el-table-column>
<el-table-column
prop="iscontr"
label="鐐规绠℃帶"
@@ -168,7 +174,7 @@
<el-form-item label="鏍囧噯鍚嶇О" prop="name">
<el-input v-model="dialogForm.name" style="width: 200px" />
</el-form-item>
- <el-form-item prop="SupUnit" label="鐐规绠℃帶">
+ <el-form-item required label="鐐规绠℃帶">
<el-select
v-model="dialogForm.enable"
style="width: 200px"
@@ -350,6 +356,7 @@
<i class="el-icon-s-operation" style="color:#42b983;" /> 璁惧鎵�灞炶溅闂撮泦鍚堬細
</div>
<div class="myCheckboxGroup">
+
<div
v-for="item in dialogFormEqp.eqpArr"
:key="item.code"
@@ -373,10 +380,10 @@
<el-divider />
<div>
<div style="margin-bottom:20px">
- <i class="el-icon-s-operation" style="color:#42b983;" /> 瑙掕壊锛�
+ <i class="el-icon-s-operation" style="color:#42b983;" /> 璁惧淇℃伅锛�
</div>
<el-tree
- ref="roleTree"
+ ref="epqTree"
:data="dialogFormEqp.eqpTree"
show-checkbox
node-key="code"
@@ -417,9 +424,10 @@
import {
AddUpdateDeviceCheckStandArd, DeleteDeviceCheckStaned,
DeviceCheckItemSelect,
- DeviceCheckStandArdSearch,
+ DeviceCheckStandArdSearch, DeviceCheckStanedAssociationEqp, SaveDeviceCheckStanedAssociationEqp,
ViewDeviceCheckStanedSearch
} from '@/api/sbgl'
+import $ from 'jquery'
const SER_HZ = /^[\u4e00-\u9fa5]+$/
export default {
@@ -495,8 +503,11 @@
dialogFormEqp: {
name: '',
- eqpArr: [],
- eqpTree: []
+ code: '',
+ eqpAll: [], // 杞﹂棿鍙婅澶囨墍鏈�
+ eqpArr: [], // 杞﹂棿闆嗗悎鎵�鏈�
+ eqpTree: [], // 璁惧鏍戝舰鎵�鏈�
+ eqpCodeSelectedArr: []// 璁惧鏍戝舰閫変腑
},
defaultPropsOfEqpTree: {
value: 'code',
@@ -528,7 +539,6 @@
},
methods: {
async getDeviceCheckStandArdSearch() {
- console.log(this.form, 11)
const res = await DeviceCheckStandArdSearch(this.form)
this.tableData = res.data
this.total = res.count
@@ -668,7 +678,7 @@
Data.forEach((item, index) => {
item.checkitem_seq = index + 1
})
- console.log(Data, 999)
+
const data = {
'code': this.dialogForm.code,
'name': this.dialogForm.name,
@@ -676,7 +686,7 @@
'description': this.dialogForm.description,
'Data': Data
}
- console.log(data, 111)
+
AddUpdateDeviceCheckStandArd(data, this.operation === 'add' ? 'Add' : 'Update').then(res => {
if (res.code === '200') {
this.$message.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
@@ -753,7 +763,6 @@
})
},
delRow(row) {
- console.log(row)
this.checkItemSelectArr.splice(0, 0, {
code: row.checkitem_code,
name: row.checkitem_name,
@@ -808,28 +817,220 @@
return 'custom-row'
},
// 鍏宠仈璁惧
- checkeqpClick(row) {
- this.dialogVisibleEqp = true
- },
- handleCloseEqp() {
+ async checkeqpClick(row) {
+ this.dialogFormEqp.name = row.name
+ this.dialogFormEqp.code = row.code
+ const { data: res } = await DeviceCheckStanedAssociationEqp({ checkstand_code: row.code })
+ this.dialogFormEqp.eqpAll = res
+
+ if (this.dialogFormEqp.eqpAll.length > 0) {
+ this.dialogFormEqp.eqpAll.forEach((item, index) => {
+ this.dialogFormEqp.eqpArr.push({
+ code: item.code,
+ name: item.name,
+ type: item.type,
+ isSelected1: index === 0,
+ isSelected2: item.flag === 'Y'
+ })
+ if (item.flag === 'Y') {
+ this.$nextTick(() => {
+ $('input:checkbox').eq(index).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+ })
+ }
+ if (item.children && item.children.length > 0) {
+ item.children.forEach(it => {
+ if (it.flag === 'Y') {
+ this.dialogFormEqp.eqpCodeSelectedArr.push(it.code)
+ }
+ })
+ }
+ })
+ this.dialogFormEqp.eqpAll[0].name = '鍏ㄩ儴'
+ this.dialogFormEqp.eqpTree = [this.dialogFormEqp.eqpAll[0]]
+ }
+
+ this.dialogVisibleEqp = true
+
+ this.$nextTick(() => { // 鏍戝舰鍥炴樉
+ this.$refs.epqTree.setCheckedKeys(this.dialogFormEqp.eqpCodeSelectedArr)
+ })
+ },
+ // 鍏宠仈璁惧瀵硅瘽妗嗗叧闂�
+ handleCloseEqp() {
+ this.$refs.epqTree.setCheckedKeys([])
+ this.dialogFormEqp.code = ''
+ this.dialogFormEqp.name = ''
+ this.dialogFormEqp.eqpAll = []
+ this.dialogFormEqp.eqpArr = []
+ this.dialogFormEqp.eqpTree = []
+ this.dialogFormEqp.eqpCodeSelectedArr = []
},
// 澶х洅瀛愮偣鍑�
- myCheckboxClick() {
-
+ myCheckboxClick(val) {
+ this.dialogFormEqp.eqpArr.forEach((item, index) => {
+ item.isSelected1 = item.code === val.code
+ if (item.code === val.code) {
+ this.dialogFormEqp.eqpAll[index].name = '鍏ㄩ儴'
+ this.dialogFormEqp.eqpTree = [this.dialogFormEqp.eqpAll[index]]
+ }
+ })
},
// 灏忕洅瀛愮偣鍑�
- myCheckboxInputClick() {
-
+ myCheckboxInputClick(val) {
+ console.log(val)
+ val.isSelected2 = !val.isSelected2
+ if (val.isSelected2) { // 浠庢病閫変腑鍒伴�変腑
+ console.log('浠庢病閫変腑鍒伴�変腑')
+ this.dialogFormEqp.eqpAll.forEach((item, index) => {
+ if (item.code === val.code) {
+ if (item.children && item.children.length > 0) {
+ item.children.forEach(it => {
+ this.dialogFormEqp.eqpCodeSelectedArr.push(it.code)
+ })
+ }
+ }
+ })
+ console.log(this.dialogFormEqp.eqpCodeSelectedArr, 1)
+ this.$nextTick(() => { // 鏍戝舰鍥炴樉
+ this.$refs.epqTree.setCheckedKeys(this.dialogFormEqp.eqpCodeSelectedArr)
+ })
+ } else { // 浠庨�変腑鍒版病閫変腑
+ console.log('浠庨�変腑鍒版病閫変腑')
+ const temp = []
+ this.dialogFormEqp.eqpAll.forEach((item, index) => {
+ if (item.code === val.code) {
+ if (item.children && item.children.length > 0) {
+ item.children.forEach(it => {
+ temp.push(it.code)
+ })
+ }
+ }
+ })
+ this.dialogFormEqp.eqpCodeSelectedArr = [...this.dialogFormEqp.eqpCodeSelectedArr].filter(x => [...temp].every(y => y !== x))
+ this.$nextTick(() => { // 鏍戝舰鍥炴樉
+ this.$refs.epqTree.setCheckedKeys(this.dialogFormEqp.eqpCodeSelectedArr)
+ })
+ }
+ console.log(this.dialogFormEqp.eqpCodeSelectedArr, 999)
},
- checkBoxClick() {
+ // 鏍戝舰澶嶉�夋鐐瑰嚮浜嬩欢
+ checkBoxClick(obj, { checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys }) {
+ let checkedFatherCode = '' // 鎵惧埌 checkedFatherCode 鐖禼ode鍊�
+ console.log(obj, { checkedNodes, checkedKeys, halfCheckedNodes, halfCheckedKeys })
+ this.dialogFormEqp.eqpAll.forEach((item, index) => {
+ if (item.code === obj.code) {
+ checkedFatherCode = item.code
+ }
+ if (item.children && item.children.length > 0) {
+ item.children.forEach((it, ind) => {
+ if (it.code === obj.code) {
+ checkedFatherCode = item.code
+ }
+ })
+ }
+ })
+ console.log(checkedFatherCode, 1)
+ // 1.绗竴绉嶆儏鍐靛綋鏍戝舰 鍗婂彾 涓嶄负闆� 鍏ㄥ彾 涓嶄负闆�
+ if (halfCheckedKeys.length !== 0 && checkedKeys.length !== 0) {
+ console.log('// 1.绗竴绉嶆儏鍐靛綋鏍戝舰 鍗婂彾 涓嶄负闆� 鍏ㄥ彾 涓嶄负闆�')
+ this.dialogFormEqp.eqpArr.forEach((item, index) => {
+ if (item.code === checkedFatherCode) {
+ console.log(item.code, 777)
+ this.dialogFormEqp.eqpArr[index].isSelected2 = true
+ this.$nextTick(() => {
+ $('input:checkbox').eq(index).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+ })
+ }
+ })
+ this.dialogFormEqp.eqpCodeSelectedArr.forEach((item, index) => {
+ if (item === obj.code) {
+ this.dialogFormEqp.eqpCodeSelectedArr.splice(index, 1)
+ }
+ })
+ checkedKeys.forEach(item => {
+ this.dialogFormEqp.eqpCodeSelectedArr.push(item)
+ })
+ this.dialogFormEqp.eqpCodeSelectedArr = [...new Set(this.dialogFormEqp.eqpCodeSelectedArr)]
+ }
+
+ // 2.绗簩绉嶆儏鍐靛綋鏍戝舰 鍗婂彾 涓洪浂 鍏ㄥ彾 涓洪浂
+ if (halfCheckedKeys.length === 0 && checkedKeys.length === 0) {
+ console.log('// 2.绗簩绉嶆儏鍐靛綋鏍戝舰 鍗婂彾 涓洪浂 鍏ㄥ彾 涓洪浂')
+ const temp = []
+ this.dialogFormEqp.eqpArr.forEach((item, index) => {
+ if (item.code === checkedFatherCode) {
+ this.dialogFormEqp.eqpArr[index].isSelected2 = false
+ this.$nextTick(() => {
+ $('input:checkbox').eq(index).prop('checked', false)// 鑷畾涔夊崟閫夋鍥炴樉
+ })
+ }
+ })
+ this.dialogFormEqp.eqpAll.forEach((item, index) => {
+ if (item.code === checkedFatherCode) {
+ if (item.children && item.children.length > 0) {
+ item.children.forEach(it => {
+ temp.push(it.code)
+ })
+ }
+ }
+ })
+ this.dialogFormEqp.eqpCodeSelectedArr = [...this.dialogFormEqp.eqpCodeSelectedArr].filter(x => [...temp].every(y => y !== x))
+ }
+
+ // 3.绗笁绉嶇鎯呭喌褰撴爲褰� 鍗婂彾 涓洪浂 鍏ㄥ彾 涓嶄负闆�
+ if (halfCheckedKeys.length === 0 && checkedKeys.length !== 0) {
+ console.log('// 3.绗笁绉嶇鎯呭喌褰撴爲褰� 鍗婂彾 涓洪浂 鍏ㄥ彾 涓嶄负闆�')
+ this.dialogFormEqp.eqpArr.forEach((item, index) => {
+ if (item.code === checkedFatherCode) {
+ this.dialogFormEqp.eqpArr[index].isSelected2 = true
+ this.$nextTick(() => {
+ $('input:checkbox').eq(index).prop('checked', true)// 鑷畾涔夊崟閫夋鍥炴樉
+ })
+ }
+ })
+
+ this.dialogFormEqp.eqpAll.forEach((item, index) => {
+ if (item.code === checkedFatherCode) {
+ if (item.children && item.children.length > 0) {
+ item.children.forEach(it => {
+ this.dialogFormEqp.eqpCodeSelectedArr.push(it.code)
+ })
+ }
+ }
+ })
+ }
},
+ // 鍙栨秷浜嬩欢
eqpDialogVisibleCancel() {
this.dialogVisibleEqp = false
},
+ // 纭浜嬩欢
eqpDialogVisibleConfirm() {
- this.dialogVisibleEqp = false
+ // console.log(this.dialogFormEqp.eqpCodeSelectedArr, 888)
+ // this.dialogVisibleEqp = false
+ const data = []
+ this.dialogFormEqp.eqpAll.forEach((item, index) => {
+ if (item.children && item.children.length > 0) {
+ item.children.forEach(it => {
+ if (this.dialogFormEqp.eqpCodeSelectedArr.includes(it.code)) {
+ data.push({
+ name: it.name,
+ code: it.code
+ })
+ }
+ })
+ }
+ })
+
+ SaveDeviceCheckStanedAssociationEqp(data, this.dialogFormEqp.code).then(res => {
+ if (res.code === '200') {
+ this.$message.success('鍏宠仈鎴愬姛锛�')
+ this.getDeviceCheckStandArdSearch()
+ this.dialogVisibleEqp = false
+ }
+ })
}
}
}
--
Gitblit v1.9.3