gaoshp
2024-06-02 b46e6d2306515f94bf77c06e8d80ac76267e3ddb
src/views/mdc/MYTree.vue
@@ -1,7 +1,7 @@
<!--
 * @Date: 2024-04-18 19:53:35
 * @LastEditors: Sneed
 * @LastEditTime: 2024-04-21 10:37:48
 * @LastEditTime: 2024-05-26 15:49:11
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/mdc/MYTree.vue
-->
<template>
@@ -17,6 +17,16 @@
        showCheckbox: {
            type: Boolean,
            default: false
        },
        getAll: {
            type: Boolean,
            default: false
        },
        props: {
            type: Object,
            default: () => {
                return {}
            }
        }
    },
    data() {
@@ -30,7 +40,8 @@
                disabled: '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
@@ -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)
        },
    },
@@ -127,4 +142,7 @@
.active .el-tree-node__content {
    background: var(--el-color-primary) !important;
}
a.disabled {
    color: #ccc;
}
</style>