ProcessLocationZoneList.vue
7.84 KB
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<template>
<a-card :bordered="false" class="j-inner-table-wrapper">
<!-- 查询区域 -->
<div class="table-page-search-wrapper">
<a-form layout="inline" :model="queryParam">
<a-row :gutter="16">
<a-col :md="6" :sm="24">
<a-form-item label="工序编码">
<a-input
v-model="queryParam.processCode"
placeholder="请输入工序编码"
allowClear
@pressEnter="handleQuery"
/>
</a-form-item>
</a-col>
<a-col :md="6" :sm="24">
<a-form-item label="区域名称">
<a-input
v-model="queryParam.zoneName"
placeholder="请输入区域名称"
allowClear
@pressEnter="handleQuery"
/>
</a-form-item>
</a-col>
<a-col :md="6" :sm="24">
<a-form-item label="是否启用">
<j-dict-select-tag
v-model="queryParam.enable"
dictCode="yn"
placeholder="请选择"
allowClear
/>
</a-form-item>
</a-col>
<a-col :md="6" :sm="24" style="text-align: right">
<a-space>
<a-button type="primary" @click="handleQuery">查询</a-button>
<a-button @click="handleReset">重置</a-button>
</a-space>
</a-col>
</a-row>
</a-form>
</div>
<!-- 操作按钮 -->
<div class="table-operator" style="margin: 16px 0">
<a-button type="primary" icon="plus" @click="handleAdd">新增</a-button>
<a-button type="danger" icon="delete" :disabled="selectedRowKeys.length === 0" @click="batchDel">
批量删除
</a-button>
</div>
<!-- 表格 -->
<a-table
rowKey="id"
bordered
size="middle"
:loading="loading"
:columns="columns"
:dataSource="dataSource"
:pagination="pagination"
:rowSelection="rowSelection"
@change="handleTableChange"
>
<!-- 序号 -->
<span slot="index" slot-scope="text, record, index">
{{ index + 1 }}
</span>
<!-- 范围 -->
<span slot="range" slot-scope="text, record">
{{ formatRange(record.rowStart, record.rowEnd) }} /
{{ formatRange(record.columnStart, record.columnEnd) }} /
{{ formatRange(record.layerStart, record.layerEnd) }}
</span>
<!-- 是否 -->
<span slot="yn" slot-scope="text">
<a-tag :color="text === 1 ? 'green' : 'red'">
{{ text === 1 ? '是' : '否' }}
</a-tag>
</span>
<!-- 操作 -->
<span slot="action" slot-scope="text, record">
<a @click="handleEdit(record)">编辑</a>
<a-divider type="vertical" />
<a @click="handleDetail(record)">详情</a>
<a-divider type="vertical" />
<a-popconfirm title="确认删除?" @confirm="handleDelete(record.id)">
<a style="color:#f5222d">删除</a>
</a-popconfirm>
</span>
</a-table>
<!-- 弹窗 -->
<process-location-zone-modal ref="modalForm" @ok="modalFormOk" />
</a-card>
</template>
<script>
import { getAction, deleteAction } from '@/api/manage'
import ProcessLocationZoneModal from './modules/ProcessLocationZoneModal'
export default {
name: 'ProcessLocationZoneList',
components: { ProcessLocationZoneModal },
data() {
return {
url: {
list: '/processLocationZone/list',
delete: '/processLocationZone/delete',
deleteBatch: '/processLocationZone/deleteBatch'
},
queryParam: {
processCode: '',
zoneName: '',
enable: undefined
},
columns: [
{ title: '序号', width: 60, align: 'center', scopedSlots: { customRender: 'index' } },
{ title: '工序编码', dataIndex: 'processCode', align: 'center' },
{ title: '区域名称', dataIndex: 'zoneName', align: 'center' },
{ title: '巷道值', dataIndex: 'roadWayList', align: 'center' },
{ title: '优先级', dataIndex: 'priority', align: 'center', width: 80 },
{ title: '范围(行/列/层)', align: 'center', scopedSlots: { customRender: 'range' } },
// { title: '独占', dataIndex: 'isExclusive', width: 80, align: 'center', scopedSlots: { customRender: 'yn' } },
// { title: '是否溢出', dataIndex: 'allowOverflow', width: 80, align: 'center', scopedSlots: { customRender: 'yn' } },
{ title: '备注说明', dataIndex: 'remark', align: 'center' },
{ title: '启用', dataIndex: 'enable', width: 80, align: 'center', scopedSlots: { customRender: 'yn' } },
{ title: '操作', width: 160, align: 'center', fixed: 'right', scopedSlots: { customRender: 'action' } }
],
dataSource: [],
selectedRowKeys: [],
pagination: {
current: 1,
pageSize: 10,
pageSizeOptions: ['10', '20', '50', '100'],
showSizeChanger: true,
showQuickJumper: true,
showTotal: total => `共 ${total} 条`
},
loading: false
}
},
computed: {
rowSelection() {
return {
selectedRowKeys: this.selectedRowKeys,
onChange: keys => (this.selectedRowKeys = keys)
}
}
},
mounted() {
this.loadData()
},
methods: {
/** 加载数据 */
loadData() {
this.loading = true
getAction(this.url.list, this.buildParams())
.then(res => {
if (res.success) {
this.dataSource = res.result.records || []
this.pagination.total = res.result.total || 0
} else {
this.$message.error(res.message)
}
})
.finally(() => (this.loading = false))
},
/** 分页参数 */
buildParams() {
return {
...this.queryParam,
pageNo: this.pagination.current,
pageSize: this.pagination.pageSize
}
},
/** 分页变化 */
handleTableChange(pagination) {
this.pagination.current = pagination.current
this.pagination.pageSize = pagination.pageSize
this.loadData()
},
/** 查询 */
handleQuery() {
this.pagination.current = 1
this.loadData()
},
/** 重置 */
handleReset() {
this.queryParam = {
processCode: '',
zoneName: '',
enable: undefined
}
this.handleQuery()
},
/** 删除 */
handleDelete(id) {
deleteAction(this.url.delete, { id }).then(res => {
if (res.success) {
this.$message.success(res.message)
this.loadData()
} else {
this.$message.error(res.message)
}
})
},
/** 批量删除 */
batchDel() {
this.$confirm({
title: '确认删除',
content: '选中数据将被删除,是否继续?',
onOk: () => {
deleteAction(this.url.deleteBatch, { ids: this.selectedRowKeys.join(',') })
.then(res => {
if (res.success) {
this.$message.success(res.message)
this.selectedRowKeys = []
this.loadData()
} else {
this.$message.error(res.message)
}
})
}
})
},
/** 范围格式化 */
formatRange(start, end) {
if (!start && !end) return '不限'
return `${start || '-'} ~ ${end || '-'}`
},
/** 弹窗 */
handleAdd() {
this.$refs.modalForm.add()
},
handleEdit(record) {
this.$refs.modalForm.edit(record)
},
handleDetail(record) {
this.$refs.modalForm.edit(record)
this.$nextTick(() => {
this.$refs.modalForm.disableSubmit = true
})
},
modalFormOk() {
this.loadData()
}
}
}
</script>
<style scoped>
.table-page-search-wrapper {
padding: 16px;
background: #fafafa;
border-radius: 4px;
}
</style>