spring
2025-03-19 07a41ade45c962e93a9d449ce1be0eec52e66a6a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<template>
    <div class="purchase-page">
        <div class="purchase-left">
            <el-input v-model="form.nodeName" placeholder="请输入节点名称" suffix-icon="el-icon-search" size="small" clearable
                @keyup.enter.native="searchFilter(treeData)" @blur="searchFilter(treeData)"
                @clear="searchFilter(treeData)">
            </el-input>
            <el-tree ref="tree" :data="treeData" :props="defaultProps" @node-click="handleNodeClick"
                :default-expanded-keys="expandedKeys" node-key="id">
            </el-tree>
        </div>
        <div class="purchase-right">
            <el-tabs v-model="activeName" @tab-click="handleClick" style="height: 100%;">
                <el-tab-pane label="总览" name="1" style="height: 100%;">
                    <ConsumableOverview v-if="activeName == '1'" ref="consumableOverviewRef" :contentsId="contentsId" style="height: 100%;"></ConsumableOverview>
                </el-tab-pane>
                <el-tab-pane label="合格供方名录" name="2">
                    <QualifiedSuppliers v-if="activeName == '2'" :contentsId="contentsId"></QualifiedSuppliers>
                </el-tab-pane>
                <el-tab-pane label="目录维护" name="3">
                    <Contents
                        v-if="activeName == '3'"
                        :id="contentsId"
                        :treeData="treeData"
                        @contentsUpdate="contentsUpdate"
                        from="供应树"
                    ></Contents>
                </el-tab-pane>
            </el-tabs>
        </div>
    </div>
</template>
<script>
import Contents from "@/components/do/a6.service-and-supply-purchase/contents.vue";
import ConsumableOverview from "@/components/caorui/6-6/ConsumableOverview/index.vue";
import QualifiedSuppliers from "@/components/caorui/6-6/QualifiedSuppliers/index.vue";
import {suppliersDirectoryContentsSuppliersDirectoryContentsListing } from "@/assets/api/api";
export default {
    components: {
        ConsumableOverview, QualifiedSuppliers, Contents
    },
    data() {
        return {
            contentsId: 0,
            activeName: "1",
            form: {
                nodeName: "",
            },
            treeData: [],
            expandedKeys: [],
            defaultProps: {
                children: "children",
                label: "nodeName",
            },
        }
    },
    mounted() {
        this.getTreeData();
    },
    methods: {
        searchFilter() {
            this.treeData = JSON.parse(JSON.stringify(this.treeData));
            this.expandedKeys = [];
            if (this.form.nodeName == "") {
                return;
            }
            const findNodesWithFiber = (nodes) => {
                nodes.forEach((node) => {
                    if (node.nodeName && node.nodeName.includes(this.form.nodeName)) {
                        this.expandedKeys.push(node.id);
                    }
                    if (node.children && node.children.length > 0) {
                        findNodesWithFiber(node.children);
                    }
                });
            };
            findNodesWithFiber(this.treeData);
        },
        // 目录维护更新
        contentsUpdate(val, flag = false) {
            if (val) {
                this.getTreeData();
                this.expandedKeys = [];
                if (flag) {
                    const findNodesWithFiber = (nodes) => {
                        nodes.forEach((item) => {
                            if (item.parentId == val) {
                                this.expandedKeys.push(item.id);
                            }
                            if (item.children && item.children.length > 0) {
                                findNodesWithFiber(item.children);
                            }
                        });
                    };
                    findNodesWithFiber(this.treeData);
                    this.expandedKeys = this.expandedKeys.filter((item) => item !== val);
                } else {
                    this.expandedKeys.push(val);
                }
            } else {
                this.getTreeData();
            }
        },
        // 查询所有目录
        getTreeData() {
            this.$axios
                .get(suppliersDirectoryContentsSuppliersDirectoryContentsListing)
                .then((res) => {
                    this.treeData = res.data;
                });
        },
        // 点击树节点
        handleNodeClick(data) {
            this.contentsId = data.id;
            // this.$refs.consumableOverviewRef.getTableData(data.id)
        },
        handleClick(tab, event) {
        },
    }
}
</script>
 
<style scoped>
.purchase-left {
    width: 250px;
    height: 100%;
    background: #fff;
    margin-right: 10px;
    border-radius: 16px;
    box-sizing: border-box;
    padding: 10px 16px;
    flex-shrink: 0;
}
 
.purchase-right {
    background: #fff;
    width: calc(100% - 15em);
    height: 100%;
    border-radius: 16px;
    box-sizing: border-box;
    padding: 10px 16px;
}
 
.purchase-page {
    display: flex;
    padding-top: 10px;
    padding-bottom: 10px;
    box-sizing: border-box;
    width: 100%;
}
>>>.el-tabs__content{
  height: calc(100% - 40px);
}
</style>