From e58bfa85f175d789445f479f55c87619c43fd7c0 Mon Sep 17 00:00:00 2001 From: gaoshp <291585735@qq.com> Date: 星期三, 24 四月 2024 21:12:07 +0800 Subject: [PATCH] 过程参数 --- src/views/mdc/MYTree.vue | 35 ++++++++++++++++++++++++++--------- 1 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/views/mdc/MYTree.vue b/src/views/mdc/MYTree.vue index 0d290aa..687ad0d 100644 --- a/src/views/mdc/MYTree.vue +++ b/src/views/mdc/MYTree.vue @@ -1,13 +1,13 @@ <!-- * @Date: 2024-04-18 19:53:35 * @LastEditors: Sneed - * @LastEditTime: 2024-04-18 21:30:19 + * @LastEditTime: 2024-04-23 23:09:18 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/MYTree.vue --> <template> <el-tree ref="treeRef" v-bind="$attrs" :show-checkbox="showCheckbox" :current-node-key="currentNodeKey" node-key="id" :props="defalutProps" :data="data" @check-change="checkChange" @node-click="handleNodeClick" - highlight-current default-expand-all :render-content="renderContent"></el-tree> + highlight-current default-expand-all :expand-on-click-node="false" :render-content="renderContent"></el-tree> </template> <script> @@ -17,19 +17,27 @@ showCheckbox: { type: Boolean, default: false + }, + getAll: { + type: Boolean, + default: false } }, data() { return { pmsPng, firstWorkKey: '', - currentNodeKey: '', + currentNodeKey: [], defalutProps: { label: 'title', - children: 'children' + children: 'children', + disabled: 'disabled', + class: (data, node) => { + return this.value.includes(data.id) ? 'active' : '' + } }, data: [], - value: [] + value: [], } }, watch: { @@ -48,8 +56,8 @@ methods: { renderContent(h, { data }) { let img = data.groupTag == 'fms_beltline' - return h('span', { - + return h('a', { + disabled: data.disabled }, img ? h('img', { src: pmsPng @@ -65,6 +73,7 @@ this.data = this.formatData(data) this.$nextTick(() => { this.currentNodeKey = this.firstWorkKey + this.$emit('loaded', this.firstWorkKey) }) } }) @@ -79,6 +88,7 @@ let newData = [] if (!current) { newData = data.filter(item => item.parentId == 0).map(v => { + if (!v.isWorkstation) v.disabled = true v.children = this.formatData(data, v).sort((a, b) => { return b.sort - a.sort }) @@ -88,6 +98,7 @@ } else { let res = data.filter(v => v.parentId == current.id) res = res.map(item => { + if (!item.isWorkstation) item.disabled = true item.children = this.formatData(data, item).sort((a, b) => { return b.sort - a.sort }) @@ -99,7 +110,6 @@ return newData }, handleNodeClick(node) { - console.log(node) this.$nextTick(() => { if (node.isWorkstation) { this.currentNodeKey = node.id @@ -108,10 +118,17 @@ }, checkChange(data, data1, data2) { + if (this.getAll) { + return this.value = this.$refs.treeRef.getCheckedNodes().filter(v => v.isWorkstation) + } this.value = this.$refs.treeRef.getCheckedNodes().filter(v => v.isWorkstation).map(item => item.id) }, }, } </script> -<style lang="scss" scoped></style> \ No newline at end of file +<style lang="scss"> +.active .el-tree-node__content { + background: var(--el-color-primary) !important; +} +</style> \ No newline at end of file -- Gitblit v1.9.3