1
lzhe
2024-06-05 dcf9c9e0410fe1186239e3f8d6f7bdc789c08010
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
<!--
 * @Date: 2024-05-07 22:46:30
 * @LastEditors: Sneed
 * @LastEditTime: 2024-05-12 17:50:26
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/master/frock/tray-deposit/index.vue
-->
<template>
    <el-main style="height: 100%;">
        <el-card shadow="never" style="height: 100%;" body-style="height: 100%">
            <el-containter>
                <el-header>
                    <import-table style="margin:0 8px" :exportUrl="exportUrl" :uploadUrl="uploadUrl"></import-table>
                </el-header>
                <el-main>
                    <el-container>
                        <el-aside width="200px" v-loading="showGrouploading">
                            <el-tree default-expand-all ref="group" node-key="id" :data="treeData" :props="props"
                                @node-click="nodeClick">
                                <template #default="{ node, data }">
                                    <span class="custom-tree-node">
                                        <span :class="data.isArea ? 'treedisabled' : ''">{{
                                            node.label }}</span>
                                    </span>
                                </template>
                            </el-tree>
                        </el-aside>
                        <el-container>
                            <el-main v-if="selectNode?.id">
                                <el-row>
                                    <el-col :span="4">
                                        库位编号: {{ selectNode.warehouseCode }}
                                    </el-col>
                                    <el-col :span="4">
                                        库位名称: {{ selectNode.warehouseName }}
                                    </el-col>
                                    <el-col :span="4">
                                        库位描述: {{ selectNode.remark }}
                                    </el-col>
                                </el-row>
                                <el-row style="margin-top: 10px;">
                                    <el-col>
                                        <el-button @click="table_add" type="primary" icon="el-icon-plus">添加</el-button>
                                    </el-col>
                                    <el-col style="margin-top: 10px;">
                                        <scTable :pageSize="10000" ref="table" @selection-change="handleSelectionChange"
                                            row-key="id" border :params="params" :apiObj="apiObj" stripe
                                            @dataChange="dataChange">
                                            <!-- <el-table-column type="selection" width="55" /> -->
                                            <el-table-column prop="trayCode" label="托盘编号" />
                                            <el-table-column prop="trayName" label="托盘名称" />
                                            <el-table-column label="操作" fixed="right" align="left" width="160">
                                                <template #default="scope">
                                                    <el-button-group>
                                                        <el-popconfirm width="220" 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-row>
                            </el-main>
                            <el-main v-else>
                                <el-empty description="" />
                            </el-main>
                        </el-container>
                    </el-container>
                </el-main>
            </el-containter>
        </el-card>
        <el-dialog v-model="dialogVisible" title="添加" width="500">
            <el-tree show-checkbox default-expand-all ref="group1" node-key="id" :data="todoList" :props="{
                label: 'name',
                disabled: 'isGroup'
            }">
                <template #default="{ node, data }">
                    <span class="custom-tree-node">
                        <span>{{
                            node.label || data.code }}</span>
                    </span>
                </template>
            </el-tree>
            <template #footer>
                <div class="dialog-footer">
                    <el-button type="primary" @click="add">
                        确定
                    </el-button>
                </div>
            </template>
        </el-dialog>
    </el-main>
</template>
 
<script>
import importTable from '@/layout/components/importTable.vue'
export default {
    components: {
        importTable,
    },
    watch: {
        selectNode(val) {
            this.params.wareId = val?.id
            this.$refs?.table?.reload()
        }
    },
    data() {
        return {
            options: {
 
            },
            props: {
                label: 'name',
                disabled: 'isArea'
            },
            exportUrl: '/api/blade-cps/tray-storage/excel/template',
            uploadUrl: '/api/blade-cps/tray-storage/excel/import',
            treeData: [],
            selectNode: {},
            apiObj: {
                get: async (data) => {
                    let params = {
                        warehouseStationId: this.selectNode.id
                    }
                    return await this.$HTTP.get(`/api/blade-cps/tray-storage/list`, {}, { params }).then(res => {
                        return {
                            data: {
                                records: res.data,
                                total: res.data?.length,
                                summary: res.data?.summary,
                            },
                            msg: res.msg,
                            code: res.code
                        }
                    })
                }
            },
            params: {
                warehouseStationId: ''
            },
            todoList: [],
            dialogVisible: false,
        }
    },
    created() {
        this.init()
    },
    methods: {
        init() {
            this.$HTTP.get(`/api/blade-cps/tray-storage/tree`).then(res => {
                this.treeData = res.data
            })
            this.$HTTP.get(`/api/blade-cps/material-type/list`).then(res => {
                this.options.typeId = res.data.map(item => ({
                    label: item.name,
                    value: item.id
                }))
            })
            this.$HTTP.get(`/api/blade-system/dict/dictionary?code=material_property`).then(res => {
                this.options.property = res.data.map(item => ({
                    label: item.dictValue,
                    value: item.dictKey - 0
                }))
            })
        },
        nodeClick(node) {
            if (node.isArea) return
            this.queryInfo(node.id)
        },
        queryInfo(id) {
            this.$HTTP.get(`/api/blade-cps/warehouse-station/get/${id}`).then(res => {
                this.selectNode = res.data
            })
        },
        table_add() {
            this.$HTTP.post(`/api/blade-cps/tray/un-used-tray-tree`, { groupCategory: 1, groupType: 'group_tray' }).then(res => {
                if (res.data?.length > 0) {
                    this.todoList = res.data
                    this.dialogVisible = true
                } else {
                    this.$message.warning("暂无可添加托盘")
                }
            })
        },
        add() {
            let ids = this.$refs.group1.getCheckedNodes()
            console.log(ids)
            this.$HTTP.post(`/api/blade-cps/tray-storage`, { warehouseStationId: this.selectNode.id, trayIds: ids.map(v => v.id) }).then(res => {
                this.$message.success("操作成功")
                this.dialogVisible = false
                this.$refs.table.reload()
            })
        },
        table_del(ids) {
            this.$HTTP.delete(`/api/blade-cps/tray-storage`, { ids: ids.map(v => ({ id: v.id, othersId: v.trayId })) }).then(res => {
                this.$message.success("操作成功")
                this.$refs.table.reload()
            })
        }
    },
}
</script>
 
<style lang="scss" scoped>
.treedisabled {
    color: #ccc;
}
</style>