lzhe
2024-05-13 dd5bef0fd97322b5455401e106dc6382502ec81c
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<!--
 * @Date: 2024-05-12 20:02:31
 * @LastEditors: Sneed
 * @LastEditTime: 2024-05-13 22:35:52
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/console/tooling/Tray.vue
-->
<template>
    <el-container>
        <el-aside width="200px">
            <el-container>
                <el-main>
                    <el-tree default-expand-all ref="group" node-key="id" :data="treeData" :props="{
                        label: 'name',
                        disabled: 'isGroup'
                    }" @node-click="nodeClick">
                        <template #default="{ node, data }">
                            <span :class="data.isGroup ? 'active' : ''" class="custom-tree-node">
                                <span>{{
                                    node.label || data.code }}</span>
                            </span>
                        </template>
                    </el-tree>
                </el-main>
                <el-footer>
                    <el-button>添加托盘组</el-button>
                </el-footer>
            </el-container>
        </el-aside>
        <!-- <el-main> -->
        <el-container v-if="selectNode.id">
            <el-header>
                <el-button @click="table_add" type="primary" icon="el-icon-plus"></el-button>
                <import-table style="margin:0 8px" :exportUrl="exportUrl" :uploadUrl="uploadUrl"></import-table>
                <el-button type="danger" plain icon="el-icon-delete" @click="batchDel"></el-button>
                <el-input v-model="params.keyword" style="width: 240px;margin-left: auto;" placeholder="请输入检索内容"
                    clearable></el-input>
                <el-button @click="search" type="primary" icon="el-icon-search"></el-button>
            </el-header>
            <el-main>
                <el-row :gutter="20">
                    <el-col :span="10">
                        <scTable highlight-current-row @dataChange="dataChange" @row-click="rowClick" ref="table"
                            :params="params" :apiObj="apiObj" @selection-change="selectionChange" stripe>
                            <el-table-column type="selection" width="50"></el-table-column>
                            <el-table-column label="托盘编号" prop="code" width="120"></el-table-column>
                            <el-table-column label="托盘名称" prop="name" width="120"></el-table-column>
                            <el-table-column label="可用状态" prop="type" width="120"></el-table-column>
                            <el-table-column label="操作" fixed="right" align="right" width="160">
                                <template #default="scope">
                                    <el-button-group>
                                        <el-button text type="primary" size="small"
                                            @click="table_edit(scope.row, scope.$index)">编辑</el-button>
                                        <el-popconfirm title="确定删除吗?" @confirm="table_del([scope.row], '0')">
                                            <template #reference>
                                                <el-button text type="primary" size="small">删除</el-button>
                                            </template>
                                        </el-popconfirm>
                                    </el-button-group>
                                </template>
                            </el-table-column>
                        </scTable>
                    </el-col>
                    <el-col :span="14">
                        <h2>托盘信息</h2>
                        <div class="tuopan-info">
                            <el-row>
                                <el-col :span="12">
                                    托盘编号: {{ info.code }}
                                </el-col>
                                <el-col :span="12">
                                    托盘名称: {{ info.name || '-' }}
                                </el-col>
                                <el-col :span="12">
                                    托盘面数: {{ info.faceNumber || '-' }}
                                </el-col>
                                <el-col :span="12">
                                    可用状态: {{ info.availability === 1 ? '可用' : '冻结' }}
                                </el-col>
                                <el-col :span="12">
                                    托盘描述: {{ info.description || '-' }}
                                </el-col>
                                <el-col :span="12">
                                    托盘类别: {{ info.category || '-' }}
                                </el-col>
                                <el-col :span="12">
                                    托盘规格: {{ info.standardModel || '-' }}
                                </el-col>
                                <el-col :span="12">
                                    托盘组: {{ info.groupName || '-' }}
                                </el-col>
                                <el-col :span="12">
                                    托盘状态: {{ info.trayStatus === 1 ? '空载' : '负载' }}
                                </el-col>
                                <el-col :span="12">
                                    备注: {{ info.remark || '-' }}
                                </el-col>
                            </el-row>
                        </div>
 
                        <h2 style="margin-top: 14px;">托盘面列表</h2>
                        <div>
                            <el-button type="primary">新建托盘面</el-button>
                        </div>
                        <el-table :data="infoList" style="width: 100%">
                            <el-table-column label="托盘面编号" prop="code"></el-table-column>
                            <el-table-column label="托盘面名称" prop="name"></el-table-column>
                            <el-table-column label="关联夹具" prop="type"></el-table-column>
                            <el-table-column label="便宜程序编号" prop="type"></el-table-column>
                            <el-table-column label="便宜程序编号" prop="type"></el-table-column>
                            <el-table-column label="操作" fixed="right" align="right" width="160">
                                <template #default="scope">
                                    <el-button-group>
                                        <el-button text type="primary" size="small"
                                            @click="table_edit1(scope.row, scope.$index)">编辑</el-button>
                                        <el-popconfirm title="确定删除吗?" @confirm="table_del1([scope.row], '0')">
                                            <template #reference>
                                                <el-button text type="primary" size="small">删除</el-button>
                                            </template>
                                        </el-popconfirm>
                                    </el-button-group>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-col>
                </el-row>
            </el-main>
        </el-container>
        <!-- </el-main> -->
    </el-container>
</template>
 
<script>
import importTable from '@/layout/components/importTable.vue'
export default {
    components: {
        importTable
    },
    data() {
        return {
            treeData: [],
            params: {
                keyword: ''
            },
            info: {},
            infoList: [],
            selectNode: {},
            apiObj: {
                get: async (data) => {
                    let params = {
                        ...data,
                        ...this.params
                    }
                    return await this.$HTTP.get(`/api/blade-cps/tray/page/${this.selectNode.id}`, {}, { params }).then(res => {
                        return res
                    })
                }
            },
        }
    },
    watch: {
        'selectNode.id': {
            handler(val) {
                if (val) {
                    this.queryInfo()
                } else {
                    this.info = {}
                    this.infoList = []
                }
            }
        }
    },
    created() {
        this.init()
    },
    methods: {
        search() {
            this.$refs.table.reload(this.params)
        },
        init() {
            this.$HTTP.post(`/api/blade-cps/tray/tooling-tree`, {
                groupCategory: 1,
                groupType: "group_tray"
            }).then(res => {
                this.treeData = res.data
                this.selectNode = res.data[0]
            })
        },
        queryInfo() {
            if (!this.selectNode.id) return
            this.$refs?.table?.reload()
            // this.$HTTP.get(`/api/blade-cps/tray/${this.selectNode.id}`).then(res => {
            //     this.info = res.data
            // })
            // this.$HTTP.get(`/api/blade-cps/tray-surface/list/${this.selectNode.id}`).then(res => {
            //     this.info = res.data
            // })
        },
        dataChange(res, data) {
            this.rowClick(data?.[0])
        },
        rowClick(row) {
            console.log(row.id)
            this.queryChildInfo(row.id)
        },
        queryChildInfo(id) {
            if (!id) return
            this.$HTTP.get(`/api/blade-cps/tray/${id}`).then(res => {
                this.info = res.data
            })
            this.$HTTP.get(`/api/blade-cps/tray-surface/list/${id}`).then(res => {
                this.infoList = res.data
            })
        },
        nodeClick(node) {
            this.selectNode = node
        }
    }
}
</script>
 
<style lang="scss" scoped>
.custom-tree-node.active {
    color: #ccc;
}
 
.empty {
    justify-content: center;
}
 
.tuopan-info {
    display: flex;
}
</style>