From 3931e2728f618d0090f129b2665bc1285c4440c3 Mon Sep 17 00:00:00 2001
From: gaoshp <291585735@qq.com>
Date: 星期日, 03 十一月 2024 17:27:32 +0800
Subject: [PATCH] update

---
 src/views/mdc/MYTree.vue |   47 +++++++++++++++++++++++++++++++++--------------
 1 files changed, 33 insertions(+), 14 deletions(-)

diff --git a/src/views/mdc/MYTree.vue b/src/views/mdc/MYTree.vue
index 9192086..93e9090 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-21 10:37:48
+ * @LastEditTime: 2024-06-16 16:21:59
  * @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 :expand-on-click-node="false" :render-content="renderContent"></el-tree>
+    <el-tree :expand-on-click-node="false" 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>
 </template>
 
 <script>
@@ -17,6 +17,16 @@
         showCheckbox: {
             type: Boolean,
             default: false
+        },
+        getAll: {
+            type: Boolean,
+            default: false
+        },
+        props: {
+            type: Object,
+            default: () => {
+                return {}
+            }
         }
     },
     data() {
@@ -27,10 +37,11 @@
             defalutProps: {
                 label: 'title',
                 children: 'children',
-                disabled: 'disabled',
+                disabled: this.showCheckbox ? '' : 'disabled',
                 class: (data, node) => {
                     return this.value.includes(data.id) ? 'active' : ''
-                }
+                },
+                ...this.props
             },
             data: [],
             value: [],
@@ -48,15 +59,15 @@
     },
     created() {
         this.getList()
-        this.customNodeClass = (data, node) => {
-            return this.currentNodeKey == node.id || this.value.includes(node.id) ? 'active' : ''
-        }
     },
     methods: {
-        renderContent(h, { data }) {
+        renderContent(h, { data, node }) {
             let img = data.groupTag == 'fms_beltline'
             return h('a', {
-                disabled: data.disabled
+                class: {
+                    disabled: this.props.disabled ? this.props.disabled(data, node) : data.disabled
+                },
+                disabled: this.props.disabled ? this.props.disabled(data, node) : data.disabled
             },
                 img ? h('img', {
                     src: pmsPng
@@ -64,7 +75,7 @@
                 data.title)
         },
         getList() {
-            this.$HTTP.post('/api/blade-cps/group/groupWorkstation/type', {
+            this.$HTTP.post('/api/smis/group/groupWorkstation/type', {
                 groupCategory: 1,
                 groupType: "group_workstation"
             }).then(({ code, data }) => {
@@ -73,6 +84,7 @@
                     this.$nextTick(() => {
                         this.currentNodeKey = this.firstWorkKey
                         this.$emit('loaded', this.firstWorkKey)
+                        this.$emit('request', data)
                     })
                 }
             })
@@ -117,6 +129,9 @@
 
         },
         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)
         },
     },
@@ -124,7 +139,11 @@
 </script>
 
 <style lang="scss">
-.active .el-tree-node__content {
-    background: var(--el-color-primary) !important;
+.is-current>.el-tree-node__content {
+    // background: var(--el-color-primary) !important;
+}
+
+a.disabled {
+    color: #ccc;
 }
 </style>
\ No newline at end of file

--
Gitblit v1.9.3