gaoshp
2024-04-17 ca3903e09980b98a1a46af0c339e9ca00fa04ccd
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!--
 * @Author: lzhe lzhe@example.com
 * @Date: 2024-03-26 10:28:33
 * @LastEditors: lzhe lzhe@example.com
 * @LastEditTime: 2024-04-17 17:52:50
 * @FilePath: /smart-web/src/views/master/person/main/index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
    <div class="aposcope-main">
        <div class="aposcope-left">
            <div class="left-title">工位</div>
            <el-tree :data="tableData" row-key="id" default-expand-all :expand-on-click-node="false" :props="defalutProps" @node-click="handleNodeClick" ref="treeRef"/>
        </div>
        <div class="aposcope-right">
            <div>
                <!-- <el-button type="primary" @click="addData">+ 添加</el-button> -->
                <!-- <el-button type="danger" plain @click="delData">删除</el-button> -->
                <!-- <el-date-picker
                  v-model="value2"
                  type="datetimerange"
                  :picker-options="pickerOptions"
                  range-separator="至"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  align="right">
                </el-date-picker> -->
            </div>
            <el-table ref="searchDataListRef" :data="searchDataList" border style="width: 100%;margin-top: 20px;" class="multipleTableRef" @selection-change="searchHandleSelectionChange">
                <el-table-column type="selection" width="55" />
                <el-table-column prop="moduleCode" label="工位名称"></el-table-column>
                <el-table-column prop="controllerCode" label="状态"></el-table-column>
                <el-table-column prop="scopeName" label="描述"></el-table-column>
                <el-table-column prop="httpMethod" label="持续时长"></el-table-column>
                <el-table-column prop="scopePath" label="状态时间"></el-table-column>
                <el-table-column prop="scopePath" label="反馈时间"></el-table-column>
                <el-table-column fixed="right" label="操作">
                    <template #default="scope">
                        <el-button text type="primary" size="small" @click="showDrawer(scope.row, scope.$index)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </div>
    </div>
</template>
<script>
    export default {
        name: "state-feedback",
        data(){
            return {
                searchData: {
                    menuId: "",
                    size: "15",
                    current: "1"
                },
                searchDataList: [],  //右侧数据list
                aList: [],
                defalutProps: {
                    label: 'title',
                      children: 'children',
                    isLeaf: 'hasChildren'
                },
                parentId: "0",
                tableData: [],
                searchSelection: []
            }
        },
        created(){
            
        },
        mounted(){
            this.getTreeList();
        },
        components: {
 
        },
        methods: {
            searchHandleSelectionChange(selection) {
                this.searchSelection = selection;
            },
            handleClose(done) {
                done();
            },
            handleNodeClick(data) {
                // var obj = {
                //     groupCategory: 1,
                //     groupType: "group_workstation"
                // }
                // this.$HTTP.post("/api/blade-cps/group/groupWorkstation/type",obj).then(res=> {
                //     if(res.code == 200) {
                //         this.searchDataList = res.data.records;
                //     }
                // })
            },
            buildTree(items) {  
              const idMap = {};  
              const tree = [];  
              
              // 第一步:创建id到对象的映射  
              items.forEach(item => {  
                idMap[item.id] = { ...item, children: [] };  
              });  
              
              // 第二步:构建树形结构  
              items.forEach(item => {  
                const currentNode = idMap[item.id];  
                  
                // 如果parentId为0,说明是根节点  
                if (item.parentId === 0) {  
                  tree.push(currentNode);  
                } else {  
                  // 否则,查找父节点,并将当前节点添加到父节点的children数组中  
                  const parentId = item.parentId;  
                  if (idMap[parentId]) {  
                    idMap[parentId].children.push(currentNode);  
                  }  
                }  
              });  
              
              return tree;  
            },
            getTreeList(flag) {
                var obj = {
                    groupCategory: 1,
                    groupType: "group_workstation"
                }
                this.$HTTP.post("/api/blade-cps/group/groupWorkstation/type",obj).then(res=> {
                    if(res.code == 200) {
                        if (res.code == 200) {
                            this.tableData = this.buildTree(res.data);
                            console.log(this.buildTree(res.data))
                        }
                    }
                })
            },
            loadNode(node, resolve, reject) {
                if(node.data.id) {
                    this.parentId = node.data.id;
                }else {
                    this.parentId = '0';
                }
                this.$HTTP.get("/api/blade-system/menu/lazy-list",{parentId: this.parentId}).then(res=> {
                    if(res.code == 200) {
                        res.data.forEach(node => {
                            node.hasChildren = !node.hasChildren;
                        });
                        resolve(res.data);
                    }
                })
            },
            addData() {
                
            },
            delData() {
                if(this.searchSelection.length == 0) {
                    this.$message({
                      message: '请选择至少一条数据',
                      type: 'warning'
                    });
                    return;
                }
                var selStr = "";
                this.searchSelection.map(item=> {
                    selStr += item.id + ","
                })
                selStr = selStr.replace(/,$/, '');
                var that = this;
            }
        }
    }
</script>
 
<style scoped>
.aposcope-main {
    display: flex;
    min-height: 100%;
    margin: 8px;
}
.aposcope-left {
    width: 240px;
    margin-right: 8px;
    padding: 4px;
    background-color: #fff;
}
.aposcope-right {
    flex: 1;
    padding: 8px;
    background-color: #fff;
}
.left-title {
    font-size: 16px;
    text-align: center;
    height: 38px;
    line-height: 38px;
    border-bottom: 1px solid #e2e2e2;
    background-color: #409eff;
    color: #fff;
    border-radius: 2px 2px 0 0;
}
.right-content {
    text-align: center;
}
.right-content img {
    width: 350px;
    height: 350px;
}
.right-content > div {
    font-size: 14px;;
}
.right-content > div span:nth-child(2) {
    margin-left: 8px;
    color: #409eff;
    cursor: pointer;
}
</style>