|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div>
|
|
|
3
|
+ <el-card :body-style="cardBodyStyle">
|
|
|
4
|
+ <el-form :model="query" label-width="auto" label-position="right">
|
|
|
5
|
+ <el-row :gutter="10">
|
|
|
6
|
+ <el-col :span="5">
|
|
|
7
|
+ <el-form-item label="所属库房" style="margin-bottom: 0px;">
|
|
|
8
|
+ <el-select
|
|
|
9
|
+ v-model="query.wareId"
|
|
|
10
|
+ placeholder="请选择库房"
|
|
|
11
|
+ clearable
|
|
|
12
|
+ style="width: 100%;"
|
|
|
13
|
+ @visible-change="handleWareSelectVisible"
|
|
|
14
|
+ >
|
|
|
15
|
+ <el-option
|
|
|
16
|
+ v-for="item in wareOptions"
|
|
|
17
|
+ :key="item.value"
|
|
|
18
|
+ :label="item.label"
|
|
|
19
|
+ :value="item.value"
|
|
|
20
|
+ />
|
|
|
21
|
+ </el-select>
|
|
|
22
|
+ </el-form-item>
|
|
|
23
|
+ </el-col>
|
|
|
24
|
+<!-- <el-col :span="5">-->
|
|
|
25
|
+<!-- <el-form-item label="分区名称" style="margin-bottom: 0px;">-->
|
|
|
26
|
+<!-- <el-input v-model="query.areaName" clearable placeholder="请输入分区名称" style="width: 100%;"></el-input>-->
|
|
|
27
|
+<!-- </el-form-item>-->
|
|
|
28
|
+<!-- </el-col>-->
|
|
|
29
|
+<!-- <el-col :span="5">-->
|
|
|
30
|
+<!-- <el-form-item label="分区编码" style="margin-bottom: 0px;">-->
|
|
|
31
|
+<!-- <el-input v-model="query.areaCode" clearable placeholder="请输入分区编码" style="width: 100%;"></el-input>-->
|
|
|
32
|
+<!-- </el-form-item>-->
|
|
|
33
|
+<!-- </el-col>-->
|
|
|
34
|
+ <el-col :span="9">
|
|
|
35
|
+ <el-form-item label="" style="margin-bottom: 0px; margin-top: 5px;">
|
|
|
36
|
+ <el-button type="primary" @click="handleSearch">查询</el-button>
|
|
|
37
|
+ <el-button type="success" @click="insertDialog">新增</el-button>
|
|
|
38
|
+ </el-form-item>
|
|
|
39
|
+ </el-col>
|
|
|
40
|
+ </el-row>
|
|
|
41
|
+ </el-form>
|
|
|
42
|
+ </el-card>
|
|
|
43
|
+
|
|
|
44
|
+ <ButtonBox @search="handleSearch" @add="insertDialog"></ButtonBox>
|
|
|
45
|
+
|
|
|
46
|
+ <el-card :body-style="cardBodyStyle">
|
|
|
47
|
+ <el-table :data="tableData" border highlight-current-row @selection-change="handleSelectionChange" :height="height">
|
|
|
48
|
+ <el-table-column type="selection" fixed></el-table-column>
|
|
|
49
|
+ <el-table-column type="index" label="序号" align="center" width="60">
|
|
|
50
|
+ <template #default="scope">
|
|
|
51
|
+ <span>{{ scope.$index + (currentPage - 1) * pageSize + 1 }}</span>
|
|
|
52
|
+ </template>
|
|
|
53
|
+ </el-table-column>
|
|
|
54
|
+ <el-table-column prop="wareName" label="所属库房" width="180" header-align="center" align="center" show-overflow-tooltip />
|
|
|
55
|
+ <el-table-column prop="areaName" label="分区名称" width="180" header-align="center" align="center" show-overflow-tooltip />
|
|
|
56
|
+ <el-table-column prop="areaCode" label="分区编码" width="180" header-align="center" align="center" show-overflow-tooltip />
|
|
|
57
|
+ <el-table-column label="操作" header-align="center" align="center" width="200" fixed="right">
|
|
|
58
|
+ <template #default="scope">
|
|
|
59
|
+ <el-button plain type="warning" @click="handleEdit(scope.row)">编辑</el-button>
|
|
|
60
|
+ <el-button plain type="danger" @click="handleRemove(scope.row)">删除</el-button>
|
|
|
61
|
+ </template>
|
|
|
62
|
+ </el-table-column>
|
|
|
63
|
+ </el-table>
|
|
|
64
|
+ </el-card>
|
|
|
65
|
+
|
|
|
66
|
+ <el-card :body-style="cardBodyStyle">
|
|
|
67
|
+ <el-pagination
|
|
|
68
|
+ :current-page="currentPage"
|
|
|
69
|
+ :page-size="pageSize"
|
|
|
70
|
+ :page-sizes="pageSizes"
|
|
|
71
|
+ :total="totalRows"
|
|
|
72
|
+ background="background"
|
|
|
73
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
74
|
+ @size-change="handleSizeChange"
|
|
|
75
|
+ @current-change="handleCurrentChange"
|
|
|
76
|
+ />
|
|
|
77
|
+ </el-card>
|
|
|
78
|
+
|
|
|
79
|
+ <el-dialog
|
|
|
80
|
+ class="diaClass"
|
|
|
81
|
+ :close-on-click-modal="false"
|
|
|
82
|
+ draggable
|
|
|
83
|
+ title="新增"
|
|
|
84
|
+ v-model="dialogVisible"
|
|
|
85
|
+ width="40%"
|
|
|
86
|
+ top="5vh"
|
|
|
87
|
+ @open="openDialog"
|
|
|
88
|
+ >
|
|
|
89
|
+ <el-card>
|
|
|
90
|
+ <el-form :model="form" label-width="120px" label-position="right" inline ref="ruleFormRef" :rules="rules">
|
|
|
91
|
+ <el-row>
|
|
|
92
|
+ <el-col :span="12">
|
|
|
93
|
+ <el-form-item label="所属库房" prop="wareId">
|
|
|
94
|
+ <el-select v-model="form.wareId" placeholder="请选择库房" style="width: 100%;">
|
|
|
95
|
+ <el-option
|
|
|
96
|
+ v-for="item in wareOptions"
|
|
|
97
|
+ :key="item.value"
|
|
|
98
|
+ :label="item.label"
|
|
|
99
|
+ :value="item.value"
|
|
|
100
|
+ />
|
|
|
101
|
+ </el-select>
|
|
|
102
|
+ </el-form-item>
|
|
|
103
|
+ </el-col>
|
|
|
104
|
+ <el-col :span="12">
|
|
|
105
|
+ <el-form-item label="分区名称" prop="areaName">
|
|
|
106
|
+ <el-input v-model="form.areaName" maxlength="100" placeholder="请输入分区名称"></el-input>
|
|
|
107
|
+ </el-form-item>
|
|
|
108
|
+ </el-col>
|
|
|
109
|
+ <el-col :span="12">
|
|
|
110
|
+ <el-form-item label="分区编码" prop="areaCode">
|
|
|
111
|
+ <el-input v-model="form.areaCode" maxlength="50" placeholder="请输入分区编码"></el-input>
|
|
|
112
|
+ </el-form-item>
|
|
|
113
|
+ </el-col>
|
|
|
114
|
+ </el-row>
|
|
|
115
|
+ </el-form>
|
|
|
116
|
+ </el-card>
|
|
|
117
|
+ <template #footer>
|
|
|
118
|
+ <div class="dialog-footer">
|
|
|
119
|
+ <el-button type="success" plain @click="handleInsert(ruleFormRef)">保存</el-button>
|
|
|
120
|
+ <el-button type="danger" plain @click="handleCancelSave">取消</el-button>
|
|
|
121
|
+ </div>
|
|
|
122
|
+ </template>
|
|
|
123
|
+ </el-dialog>
|
|
|
124
|
+
|
|
|
125
|
+ <el-dialog
|
|
|
126
|
+ class="diaClass"
|
|
|
127
|
+ :close-on-click-modal="false"
|
|
|
128
|
+ draggable
|
|
|
129
|
+ title="编辑"
|
|
|
130
|
+ v-model="dialogVisibleEdit"
|
|
|
131
|
+ width="40%"
|
|
|
132
|
+ top="5vh"
|
|
|
133
|
+ @open="openDialog"
|
|
|
134
|
+ >
|
|
|
135
|
+ <el-card :body-style="cardBodyStyle">
|
|
|
136
|
+ <el-form :model="form" label-width="120px" label-position="right" inline ref="ruleFormRef" :rules="rules">
|
|
|
137
|
+ <el-row>
|
|
|
138
|
+ <el-col :span="12">
|
|
|
139
|
+ <el-form-item label="所属库房" prop="wareId">
|
|
|
140
|
+ <el-select v-model="form.wareId" placeholder="请选择库房" style="width: 100%;">
|
|
|
141
|
+ <el-option
|
|
|
142
|
+ v-for="item in wareOptions"
|
|
|
143
|
+ :key="item.value"
|
|
|
144
|
+ :label="item.label"
|
|
|
145
|
+ :value="item.value"
|
|
|
146
|
+ />
|
|
|
147
|
+ </el-select>
|
|
|
148
|
+ </el-form-item>
|
|
|
149
|
+ </el-col>
|
|
|
150
|
+ <el-col :span="12">
|
|
|
151
|
+ <el-form-item label="分区名称" prop="areaName">
|
|
|
152
|
+ <el-input v-model="form.areaName" placeholder="请输入分区名称"></el-input>
|
|
|
153
|
+ </el-form-item>
|
|
|
154
|
+ </el-col>
|
|
|
155
|
+ <el-col :span="12">
|
|
|
156
|
+ <el-form-item label="分区编码" prop="areaCode">
|
|
|
157
|
+ <el-input v-model="form.areaCode" placeholder="请输入分区编码"></el-input>
|
|
|
158
|
+ </el-form-item>
|
|
|
159
|
+ </el-col>
|
|
|
160
|
+ </el-row>
|
|
|
161
|
+ </el-form>
|
|
|
162
|
+ </el-card>
|
|
|
163
|
+ <template #footer>
|
|
|
164
|
+ <div class="dialog-footer">
|
|
|
165
|
+ <el-button type="success" plain @click="handleSave(ruleFormRef)">保存</el-button>
|
|
|
166
|
+ <el-button type="danger" plain @click="handleCancelSave2">取消</el-button>
|
|
|
167
|
+ </div>
|
|
|
168
|
+ </template>
|
|
|
169
|
+ </el-dialog>
|
|
|
170
|
+ </div>
|
|
|
171
|
+</template>
|
|
|
172
|
+
|
|
|
173
|
+<script setup>
|
|
|
174
|
+import { getCurrentInstance, onMounted, reactive, ref } from 'vue'
|
|
|
175
|
+import tools from '@/tools'
|
|
|
176
|
+import ButtonBox from '@/components/ButtonBox.vue'
|
|
|
177
|
+
|
|
|
178
|
+const { proxy } = getCurrentInstance()
|
|
|
179
|
+
|
|
|
180
|
+const cardBodyStyle = ref(tools.style.card)
|
|
|
181
|
+
|
|
|
182
|
+const form = ref({
|
|
|
183
|
+ wareId: '',
|
|
|
184
|
+ areaName: '',
|
|
|
185
|
+ areaCode: ''
|
|
|
186
|
+})
|
|
|
187
|
+
|
|
|
188
|
+const query = ref({
|
|
|
189
|
+ wareId: '',
|
|
|
190
|
+ areaName: '',
|
|
|
191
|
+ areaCode: ''
|
|
|
192
|
+})
|
|
|
193
|
+
|
|
|
194
|
+const wareOptions = ref([])
|
|
|
195
|
+
|
|
|
196
|
+const tableData = ref([])
|
|
|
197
|
+const currentPage = ref(1)
|
|
|
198
|
+const totalRows = ref(0)
|
|
|
199
|
+const pageSizes = ref([10, 20, 30, 40])
|
|
|
200
|
+const pageSize = ref(10)
|
|
|
201
|
+
|
|
|
202
|
+const dialogVisible = ref(false)
|
|
|
203
|
+const dialogVisibleEdit = ref(false)
|
|
|
204
|
+const ruleFormRef = ref()
|
|
|
205
|
+
|
|
|
206
|
+const rules = reactive({
|
|
|
207
|
+ wareId: [{ required: true, message: '请选择所属库房', trigger: 'change' }],
|
|
|
208
|
+ areaName: [{ required: true, message: '请输入分区名称', trigger: 'blur' }],
|
|
|
209
|
+ areaCode: [{ required: true, message: '请输入分区编码', trigger: 'blur' }]
|
|
|
210
|
+})
|
|
|
211
|
+
|
|
|
212
|
+const multipleSelection = ref([])
|
|
|
213
|
+const height = ref(600)
|
|
|
214
|
+
|
|
|
215
|
+const handleWareSelectVisible = (visible) => {
|
|
|
216
|
+ fetchWareOptions()
|
|
|
217
|
+}
|
|
|
218
|
+
|
|
|
219
|
+const fetchWareOptions = () => {
|
|
|
220
|
+ proxy.$axios.get('sto/Ware/options','').then((response) => {
|
|
|
221
|
+ if (response.data.code === 0) {
|
|
|
222
|
+ wareOptions.value = response.data.data || []
|
|
|
223
|
+ } else {
|
|
|
224
|
+ ElMessage.error('获取库房信息失败!' + response.data.msg)
|
|
|
225
|
+ }
|
|
|
226
|
+ })
|
|
|
227
|
+}
|
|
|
228
|
+
|
|
|
229
|
+const getTableData = () => {
|
|
|
230
|
+ const params = {
|
|
|
231
|
+ page: currentPage.value,
|
|
|
232
|
+ rows: pageSize.value,
|
|
|
233
|
+ wareId: query.value.wareId,
|
|
|
234
|
+ areaName: query.value.areaName,
|
|
|
235
|
+ areaCode: query.value.areaCode,
|
|
|
236
|
+ json: JSON.stringify(query.value)
|
|
|
237
|
+ }
|
|
|
238
|
+ proxy.$axios.get('sto/Area/query', params).then((response) => {
|
|
|
239
|
+ // console.log(response.data)
|
|
|
240
|
+ if (response.data.code === 0) {
|
|
|
241
|
+ // alert(11)
|
|
|
242
|
+ tableData.value = response.data.data.records
|
|
|
243
|
+ totalRows.value = response.data.data.total
|
|
|
244
|
+ } else {
|
|
|
245
|
+ ElMessage.error('操作失败!' + response.data.msg)
|
|
|
246
|
+ }
|
|
|
247
|
+ })
|
|
|
248
|
+}
|
|
|
249
|
+
|
|
|
250
|
+const handleSearch = () => {
|
|
|
251
|
+ currentPage.value = 1
|
|
|
252
|
+ getTableData()
|
|
|
253
|
+}
|
|
|
254
|
+
|
|
|
255
|
+const handleSizeChange = (val) => {
|
|
|
256
|
+ pageSize.value = val
|
|
|
257
|
+ getTableData()
|
|
|
258
|
+}
|
|
|
259
|
+
|
|
|
260
|
+const handleCurrentChange = (val) => {
|
|
|
261
|
+ currentPage.value = val
|
|
|
262
|
+ getTableData()
|
|
|
263
|
+}
|
|
|
264
|
+
|
|
|
265
|
+const insertDialog = () => {
|
|
|
266
|
+ form.value = {
|
|
|
267
|
+ wareId: '',
|
|
|
268
|
+ areaName: '',
|
|
|
269
|
+ areaCode: ''
|
|
|
270
|
+ }
|
|
|
271
|
+ fetchWareOptions()
|
|
|
272
|
+ dialogVisible.value = true
|
|
|
273
|
+}
|
|
|
274
|
+
|
|
|
275
|
+const openDialog = () => {}
|
|
|
276
|
+
|
|
|
277
|
+const handleInsert = (formRef) => {
|
|
|
278
|
+ if (!formRef) return
|
|
|
279
|
+ formRef.validate((valid) => {
|
|
|
280
|
+ if (valid) {
|
|
|
281
|
+ const params = {
|
|
|
282
|
+ json: JSON.stringify(form.value)
|
|
|
283
|
+ }
|
|
|
284
|
+ proxy.$axios.post('sto/Area/save', params).then((response) => {
|
|
|
285
|
+ if (response.data.code == 0 || response.data.code === '0') {
|
|
|
286
|
+ ElMessage({
|
|
|
287
|
+ message: '保存成功',
|
|
|
288
|
+ type: 'success'
|
|
|
289
|
+ })
|
|
|
290
|
+ dialogVisible.value = false
|
|
|
291
|
+ handleSearch()
|
|
|
292
|
+ } else {
|
|
|
293
|
+ ElMessage({
|
|
|
294
|
+ type: 'error',
|
|
|
295
|
+ message: '操作失败' + response.data.msg
|
|
|
296
|
+ })
|
|
|
297
|
+ }
|
|
|
298
|
+ })
|
|
|
299
|
+ }
|
|
|
300
|
+ })
|
|
|
301
|
+}
|
|
|
302
|
+
|
|
|
303
|
+const handleSave = (formRef) => {
|
|
|
304
|
+ if (!formRef) return
|
|
|
305
|
+ formRef.validate((valid) => {
|
|
|
306
|
+ if (valid) {
|
|
|
307
|
+ const params = {
|
|
|
308
|
+ json: JSON.stringify(form.value)
|
|
|
309
|
+ }
|
|
|
310
|
+ proxy.$axios.post('sto/Area/save', params).then((response) => {
|
|
|
311
|
+ if (response.data.code == 0 || response.data.code === '0') {
|
|
|
312
|
+ ElMessage({
|
|
|
313
|
+ message: '保存成功',
|
|
|
314
|
+ type: 'success'
|
|
|
315
|
+ })
|
|
|
316
|
+ dialogVisibleEdit.value = false
|
|
|
317
|
+ handleSearch()
|
|
|
318
|
+ } else {
|
|
|
319
|
+ ElMessage({
|
|
|
320
|
+ type: 'error',
|
|
|
321
|
+ message: '操作失败' + response.data.msg
|
|
|
322
|
+ })
|
|
|
323
|
+ }
|
|
|
324
|
+ })
|
|
|
325
|
+ }
|
|
|
326
|
+ })
|
|
|
327
|
+}
|
|
|
328
|
+
|
|
|
329
|
+const handleCancelSave = () => {
|
|
|
330
|
+ dialogVisible.value = false
|
|
|
331
|
+}
|
|
|
332
|
+
|
|
|
333
|
+const handleCancelSave2 = () => {
|
|
|
334
|
+ dialogVisibleEdit.value = false
|
|
|
335
|
+}
|
|
|
336
|
+
|
|
|
337
|
+const handleEdit = (row) => {
|
|
|
338
|
+ const params = {
|
|
|
339
|
+ id: row.id
|
|
|
340
|
+ }
|
|
|
341
|
+ fetchWareOptions()
|
|
|
342
|
+ proxy.$axios.get('sto/Area/queryByPK', params).then((response) => {
|
|
|
343
|
+ if (response.data.code === 0) {
|
|
|
344
|
+ form.value = response.data.data
|
|
|
345
|
+ dialogVisibleEdit.value = true
|
|
|
346
|
+ } else {
|
|
|
347
|
+ ElMessage.error('操作失败!' + response.data.msg)
|
|
|
348
|
+ }
|
|
|
349
|
+ })
|
|
|
350
|
+}
|
|
|
351
|
+
|
|
|
352
|
+const handleRemove = (row) => {
|
|
|
353
|
+ const params = {
|
|
|
354
|
+ id: row.id
|
|
|
355
|
+ }
|
|
|
356
|
+ ElMessageBox.confirm('确定删除本条记录?', '提示', {
|
|
|
357
|
+ confirmButtonText: '确认',
|
|
|
358
|
+ cancelButtonText: '取消',
|
|
|
359
|
+ type: 'warning',
|
|
|
360
|
+ draggable: true
|
|
|
361
|
+ })
|
|
|
362
|
+ .then(() => {
|
|
|
363
|
+ proxy.$axios.get('sto/Area/remove', params).then((response) => {
|
|
|
364
|
+ if (response.data.code === 0) {
|
|
|
365
|
+ ElMessage({
|
|
|
366
|
+ type: 'success',
|
|
|
367
|
+ message: '删除成功!'
|
|
|
368
|
+ })
|
|
|
369
|
+ getTableData()
|
|
|
370
|
+ } else {
|
|
|
371
|
+ ElMessage.error('操作失败!' + response.data.msg)
|
|
|
372
|
+ }
|
|
|
373
|
+ })
|
|
|
374
|
+ })
|
|
|
375
|
+ .catch(() => {
|
|
|
376
|
+ ElMessage({
|
|
|
377
|
+ type: 'info',
|
|
|
378
|
+ message: '已取消'
|
|
|
379
|
+ })
|
|
|
380
|
+ })
|
|
|
381
|
+}
|
|
|
382
|
+
|
|
|
383
|
+const handleSelectionChange = (val) => {
|
|
|
384
|
+ multipleSelection.value = val
|
|
|
385
|
+}
|
|
|
386
|
+
|
|
|
387
|
+const updateViewportHeight = () => {
|
|
|
388
|
+ height.value = window.innerHeight * 0.65
|
|
|
389
|
+}
|
|
|
390
|
+
|
|
|
391
|
+onMounted(() => {
|
|
|
392
|
+ fetchWareOptions()
|
|
|
393
|
+ getTableData()
|
|
|
394
|
+ updateViewportHeight()
|
|
|
395
|
+})
|
|
|
396
|
+</script>
|
|
|
397
|
+
|
|
|
398
|
+<style scoped>
|
|
|
399
|
+::v-deep .diaClass .el-form-item {
|
|
|
400
|
+ width: 100%;
|
|
|
401
|
+}
|
|
|
402
|
+::v-deep .el-autocomplete {
|
|
|
403
|
+ width: 100%;
|
|
|
404
|
+}
|
|
|
405
|
+::v-deep .el-dialog__body {
|
|
|
406
|
+ background-color: #F2F6FC;
|
|
|
407
|
+}
|
|
|
408
|
+</style>
|
|
|
409
|
+
|