1
lzhe
2024-05-12 d58f901f9614d6fd3ad2334a2e4592addb77d8fa
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
<!--
 * @Date: 2024-05-07 22:51:22
 * @LastEditors: Sneed
 * @LastEditTime: 2024-05-10 23:16:26
 * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/console/basic-data/material-warehousing-data/reservoir-location/reservoir-location.vue
-->
<template>
    <el-main style="height: 100%;">
        <el-card shadow="never" style="height: 100%;" body-style="height: 100%">
            <el-container>
                <el-aside width="200px" v-loading="showGrouploading">
                    <el-container>
                        <el-main>
                            <el-tree default-expand-all ref="group" node-key="id" :data="treeData" :props="props"
                                @node-click="nodeClick" highlight-current :current-node-key="params.areaId"></el-tree>
                        </el-main>
                        <el-footer>
                            <el-button @click="addArea" type="primary" icon="el-icon-plus" size="small">添加库区</el-button>
                        </el-footer>
                    </el-container>
                </el-aside>
                <el-container>
                    <el-header>
                        <el-button @click="table_add" type="primary" icon="el-icon-plus"></el-button>
                        <!-- <el-button type="primary">导入</el-button> -->
                        <import-table style="margin:0 8px" :exportUrl="exportUrl" :uploadUrl="uploadUrl"></import-table>
                        <el-button type="primary" @click="getExport">导出</el-button>
                        <el-popconfirm width="220" title="确定将选择的数据删除" @confirm="table_del([scope.row], '0')">
                            <template #reference>
                                <el-button :disabled="selection.length == 0" type="danger" plain
                                    icon="el-icon-delete"></el-button>
                            </template>
                        </el-popconfirm>
                        <el-input style="width: 240px;margin-left: auto;" v-model="params.keyWord"
                            placeholder="请输入检索内容"></el-input>
                        <el-button @click="search" style="margin-left: 8px;" type="primary"
                            icon="el-icon-search"></el-button>
                    </el-header>
                    <el-main>
                        <el-row style="margin-top: 10px;">
                            <el-col style="margin-top: 10px;">
                                <scTable ref="table" row-key="id" border @selection-change="handleSelectionChange"
                                    :params="params" :apiObj="apiObj" stripe @dataChange="dataChange">
                                    <el-table-column type="selection" width="55" />
                                    <el-table-column prop="warehouseCode" label="库位编号" />
                                    <el-table-column prop="warehouseName" label="库位名称" />
                                    <el-table-column prop="remark" label="备注" />
                                    <el-table-column prop="warehouseAreaName" label="所属库区名称" />
                                    <el-table-column prop="warehouseAreaCode" label="所属库区编号" />
                                    <el-table-column label="操作" fixed="right" align="left" 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 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-container>
            </el-container>
        </el-card>
        <el-dialog v-model="areaVisible" title="添加" width="500">
            <el-form :model="form" :rules="rules" ref="dialogForm" label-width="120px" label-position="center">
                <el-form-item label="库区编号" prop="code">
                    <el-input v-model="form.code" />
                </el-form-item>
                <el-form-item label="库区名称" prop="name">
                    <el-input v-model="form.name" />
                </el-form-item>
            </el-form>
            <template #footer>
                <div class="dialog-footer">
                    <el-button type="primary" @click="saveArea">
                        确定
                    </el-button>
                </div>
            </template>
        </el-dialog>
    </el-main>
</template>
 
<script>
import importTable from '@/layout/components/importTable.vue'
export default {
    components: {
        importTable,
    },
    data() {
        return {
            treeData: [],
            props: {
                label: 'label'
            },
            areaVisible: false,
            params: {
                areaId: 1,
                keyword: ''
            },
            form: {},
            rules: {
                name: [
                    { required: true, message: '必填' }
                ],
                code: [
                    { required: true, message: '必填' }
                ],
            },
            exportUrl: '/api/blade-cps/warehouse-station/export-template',
            uploadUrl: '/api/blade-cps/warehouse-station/import-station',
            selection: [],
            apiObj: {
                get: async (data) => {
                    let params = {
                        ...data,
                        ...this.params,
                    }
                    return await this.$HTTP.get(`/api/blade-cps/warehouse-station/page`, {}, { params }).then(res => {
                        return res
                    })
                }
            },
        }
    },
    mounted() {
        this.init()
    },
    methods: {
        init() {
            this.$HTTP.get(`/api/blade-cps/warehouse-area/tree`).then(res => {
                this.treeData = res.data
                this.nodeClick(res.data?.[0])
            })
        },
        nodeClick(node) {
            this.params.areaId = node.id
            this.$refs?.table?.reload(this.params)
        },
        addArea() {
            this.form = {}
            this.areaVisible = true
        },
        saveArea() {
            this.$refs.dialogForm.validate(async (valid) => {
                if (valid) {
                    this.$HTTP.post(`/api/blade-cps/warehouse-area/insert`, { ...this.form, parentId: 1 }).then(res => {
                        this.$message.success('操作成功')
                        this.areaVisible = false
                        this.init()
                    })
                }
            })
        },
        search() {
            this.$refs.table.reload()
        },
        table_add() {
 
        },
        table_del() {
 
        },
        table_edit() {
 
        },
        handleSelectionChange(selection) {
            this.selection = selection
        },
        getExport() {
            this.$HTTP.post(`/api/blade-cps/warehouse-station/export-station`, { ...this.params }).then(res => {
                if (res.code == 200) {
                    window.open(res.data.link);
                }
            }).catch(() => { })
        },
    },
}
</script>
 
<style lang="scss" scoped></style>