gaoshp
2024-10-05 65972957e56a31778cc1633b1032ac16627665f3
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
<!--
 * @Date: 2024-10-05 09:51:45
 * @LastEditors: gaoshp
 * @LastEditTime: 2024-10-05 20:40:36
 * @FilePath: /cps-web/src/views/console/workstation/CollTable.vue
-->
<template>
    <div>
        <el-table :data="tabledata" height="200px">
            <el-table-column v-for="item in cols" :key="item.prop" :prop="item.prop" :label="item.label" width="120">
                <template #default="scope">
                    <span>{{ scope.row[item.prop] }}</span>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>
 
<script>
 
export default {
    props: {
        info: {
            type: Object,
            default() {
                return {}
            }
        }
    },
    watch: {
        info: {
            handler() {
                this.getList({
                    workstationId: this.info.id,
                })
            },
            deep: true,
            immediate: true
        }
    },
    data() {
        return {
            cols: [],
            tabledata: []
        }
    },
    methods: {
        refresh() {
            this.getList({
                workstationId: this.info.id,
            })
        },
        getList(params) {
            this.$HTTP.get(`/api/blade-cps/workstation/listDatapointsByWorkstationId`, {}, { params }).then(res => {
                try {
                    this.cols = JSON.parse(res.data.dpHead)
                } catch (error) {
                    this.cols = []
                }
                try {
                    this.tabledata = JSON.parse(res.data.dpConfig).map(v => {
                        v.status = null
                        return v
                    }) || [];
                } catch (error) {
                    this.tabledata = []
                }
            })
        },
    }
}
</script>
 
<style lang="scss" scoped></style>