list.vue
10.3 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
<template>
<layout-body>
<layout-filter>
<filter-item :label="filters.id.label">
<Input v-model.trim="filters.id.model"
:placeholder="filters.id.holder" :maxlength="9"></Input>
</filter-item>
<filter-item :label="filters.expressNumber.label">
<Input v-model.trim="filters.expressNumber.model"
:placeholder="filters.expressNumber.holder"></Input>
</filter-item>
<filter-item :label="filters.productSkn.label">
<Input v-model.trim="filters.productSkn.model"
:placeholder="filters.productSkn.holder" :maxlength="9"></Input>
</filter-item>
<filter-item :label="filters.sknFactoryCode.label">
<Input v-model.trim="filters.sknFactoryCode.model"
:placeholder="filters.sknFactoryCode.holder"></Input>
</filter-item>
<filter-item :label="filters.skuFactoryCode.label">
<Input v-model.trim="filters.skuFactoryCode.model"
:placeholder="filters.skuFactoryCode.holder"></Input>
</filter-item>
<filter-item :label="filters.createTime.label">
<Date-picker v-model="filters.createTime.model"
type="datetimerange" format="yyyy-MM-dd" placeholder="选择日期和时间">
</Date-picker>
</filter-item>
<filter-item :label="filters.auditStatus.label">
<Select v-model.trim="filters.auditStatus.model">
<Option v-for="option in filters.auditStatus.options"
:value="option.value"
:key="option.value">{{option.label}}</Option>
</Select>
</filter-item>
<filter-item>
<Button type="primary" @click="filterSearch">筛选</Button>
<Button @click="clearFilters">清空条件</Button>
</filter-item>
</layout-filter>
<layout-action>
<Button type="primary" @click="onClickCreate">创建入库单</Button>
</layout-action>
<layout-list>
<Table border :columns="tableCols" :data="tableData"></Table>
<Page :total="pageData.total" :current="pageData.current"
@on-change="pageChange" :page-size="20" show-total></Page>
</layout-list>
<create-modal ref="createModal" @on-success="getOrders"></create-modal>
<Modal ref="modal"
v-model="modal.show"
:title="modal.title"
@on-ok="modal.onSuccess">
<p>{{modal.content}}</p>
</Modal>
</layout-body>
</template>
<script>
import _ from 'lodash';
import list from './store/list';
import CreateModal from './components/create-modal';
import InvoiceService from 'services/repository/invoice-service';
export default {
created() {
this.invoiceService = new InvoiceService();
},
data() {
return list.call(this);
},
mounted() {
this.getOrders();
},
methods: {
onClickCreate() {
this.$refs.createModal.show();
},
onClickEdit(params) {
this.$router.push({
name: 'repository.invoice.edit',
params: {
id: params.row.id
},
query: {
brandId: params.row.brandId
}
});
},
onClickInfo(params) {
this.$router.push({
name: 'repository.invoice.info',
params: {
id: params.row.id
},
query: {
brandId: params.row.brandId
}
});
},
onClickCommit(params) {
this.modal.show = true;
this.modal.title = '提交操作提醒';
this.modal.content = `确定提交入库单号为 ${params.row.id} 发货入库单`;
this.modal.onSuccess = () => {
this.invoiceService.commitOrder(params.row.id).then((result) => {
if (result.code === 200) {
this.$Message.info('操作成功');
this.getOrders();
} else {
this.$Message.error(result.message);
}
});
};
},
onClickDelete(params) {
this.modal.show = true;
this.modal.title = '删除操作提醒';
this.modal.content = `确定删除入库单号为 ${params.row.id} 发货入库单`;
this.modal.onSuccess = () => {
this.invoiceService.deleteOrder(params.row.id).then((result) => {
if (result.code === 200) {
this.$Message.info('操作成功');
this.getOrders();
} else {
this.$Message.info(result.message);
}
});
};
},
onClickDeliver(params) {
this.$router.push({
name: 'repository.invoice.deliver',
params: {
id: params.row.id,
}
});
},
pageChange(val) {
this.pageData.current = val;
this.getOrders();
},
clearFilters() {
this.filters.id.model = null;
this.filters.expressNumber.model = null;
this.filters.productSkn.model = null;
this.filters.sknFactoryCode.model = null;
this.filters.skuFactoryCode.model = null;
this.filters.createTime.model = null;
this.filters.auditStatus.model = -1;
this.pageData.current = 1;
this.pageData.total = 0;
this.getOrders();
},
filtersParams() {
let params = {};
if (this.filters.id.model) {
if (this.isNumber(this.filters.id.model)) {
params.id = this.filters.id.model;
} else {
return Promise.reject('入库单必须为数字');
}
}
if (this.filters.expressNumber.model) {
params.expressNumber = this.filters.expressNumber.model;
}
if (this.filters.productSkn.model) {
if (this.isNumber(this.filters.productSkn.model)) {
params.productSkn = this.filters.productSkn.model;
} else {
return Promise.reject('skn必须为数字');
}
}
if (this.filters.sknFactoryCode.model) {
params.sknFactoryCode = this.filters.sknFactoryCode.model;
}
if (this.filters.skuFactoryCode.model) {
params.skuFactoryCode = this.filters.skuFactoryCode.model;
}
if (this.filters.auditStatus.model !== -1) {
params.auditStatus = this.filters.auditStatus.model;
}
if (this.startTime && this.endTime) {
params.startTime = this.startTime;
params.endTime = this.endTime;
}
params.pageSize = this.pageData.pageSize;
params.pageNo = this.pageData.current;
return Promise.resolve(params);
},
getOrders() {
this.$Loading.start();
return this.filtersParams().then((params) => {
return this.invoiceService.listOrder(params);
}).then((result) => {
if (result.code === 200) {
this.pageData.total = result.data.totalCount;
this.pageData.current = result.data.pageNo;
this.tableData = result.data.records;
} else {
this.pageData.total = 0;
this.pageData.current = 1;
this.tableData = [];
}
this.$Loading.finish();
}).catch((err) => {
this.$Message.error(err);
this.$Loading.finish();
});
},
filterSearch() {
this.pageData.current = 1;
this.getOrders();
},
showAuditStatus(status) {
switch (status) {
case 10:
return '未提交';
case 20:
return '待审核';
case 40:
return '通过';
case 41:
return '驳回';
default:
return '未提交';
}
},
onSuccess() {
},
isNumber(numStr) {
const isNumber = /^[0-9]+$/;
return isNumber.test(numStr);
}
},
computed: {
startTime() {
let createTime = this.filters.createTime.model;
if (_.isEmpty(createTime)) {
return 0;
} else {
return createTime[0] ? createTime[0].getTime() / 1000 : 0;
}
},
endTime() {
let createTime = this.filters.createTime.model;
if (_.isEmpty(createTime)) {
return 0;
} else {
return createTime[1] ? createTime[1].getTime() / 1000 : 0;
}
}
},
watch: {
},
components: {
CreateModal
}
};
</script>