undone.vue
11.4 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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<template>
<div class="un-done">
<LayoutFilter>
<FilterItem :label="filters.orderNo.label">
<Input v-model.trim.number="filters.orderNo.model"
:placeholder="filters.orderNo.holder"></Input>
</FilterItem>
<FilterItem :label="filters.prodCode.label">
<Input v-model.trim.number="filters.prodCode.model"
:placeholder="filters.prodCode.holder" :maxlength="9"></Input>
</FilterItem>
<FilterItem :label="filters.merChantCode.label">
<Input v-model.trim="filters.merChantCode.model"
:placeholder="filters.merChantCode.holder"></Input>
</FilterItem>
<FilterItem :label="filters.prodBarCode.label">
<Input v-model.trim="filters.prodBarCode.model"
:placeholder="filters.prodBarCode.holder"></Input>
</FilterItem>
<FilterItem :label="filters.orderTime.label">
<Date-picker type="daterange"
placeholder="选择日期"
@on-change="dateChange"
v-model="filters.orderTime.model">
</Date-picker>
</FilterItem>
<FilterItem :label="filters.prodStatus.label">
<Select v-model.trim="filters.prodStatus.model">
<Option v-for="option in filters.prodStatus.options"
:value="option.value"
:key="option.value">{{option.label}}</Option>
</Select>
</FilterItem>
<FilterItem>
<Button type="primary" @click="filterSearch">筛选</Button>
<Button type="primary" @click="exportList">导出</Button>
<Button @click="clearFilter">清空条件</Button>
</FilterItem>
</LayoutFilter>
<LayoutAction>
<Button type="primary" @click="showDeliverModal">发货</Button>
</LayoutAction>
<LayoutList>
<Table border :context="self" :columns="table.cols" :data="table.list"
:row-class-name="rowClassName" @on-selection-change="selectChange"></Table>
<Page :total="page.total" :current="page.current"
@on-change="pageChange" :page-size="20" show-total></Page>
</LayoutList>
<ModalDeliver
ref="deliverModal"
:deliver-rows="deliverRows"
@deliver-success="deliverSuccess">
</ModalDeliver>
<ModalStockOut
ref="stockOutModal"
@upload-success="uploadSuccess">
</ModalStockOut>
</div>
</template>
<script>
import _ from 'lodash';
import moment from 'moment';
import service from 'trade-service';
import dataStore from '../store/undone';
import { ModalDeliver, ModalStockOut } from 'components/modal';
import { CellPrdInfo, CellDispatch, CellDeliver, CellStockOut } from '../components';
export default {
name: 'TabUndone',
data() {
return {
self: this,
filters: {},
page: {},
table: {},
useFilter: false,
isExporting: false,
showOutStock: false,
deliverRows: []
};
},
created() {
const store = dataStore();
this.filters = store.filters;
this.page = store.page;
this.table = store.table;
this.productList(this.params());
},
methods: {
params() {
let params = {
pageNo: 1,
pageSize: 20,
statusList: [1]
};
if (!this.useFilter) {
return params;
}
_.assign(params, this.filterValues());
params = _.pickBy(params, (v) => {
return (v + '').length;
});
return params;
},
filterValues() {
const keyMap = {
proReqFormId: 'orderNo',
productSkn: 'prodCode',
sknFactoryCode: 'merChantCode',
skuFactoryCode: 'prodBarCode',
startTime: 'startTime',
endTime: 'endTime',
isOvertime: 'prodStatus'
};
let values = {};
let modelVal;
_.each(keyMap, (v, k) => {
modelVal = this.filters[v].model;
if ((modelVal + '').length) {
values[k] = this.filters[v].model;
}
});
if (typeof values.proReqFormId !== 'undefined' &&
!_.isFinite(+values.proReqFormId)) {
this.$Message.error('调拨单号只能是数字', 3);
return;
}
if (typeof values.productSkn !== 'undefined' &&
!_.isFinite(+values.productSkn)) {
this.$Message.error('SKN编码只能是数字', 3);
return;
}
const ot = values.isOvertime;
const start = values.startTime;
const end = values.endTime;
if (start && moment(start).isValid()) {
values.startTime = +moment(start).format('X');
} else {
values.startTime = '';
}
if (end && moment(end).isValid()) {
values.endTime = +moment(end).add(1, 'days').format('X');
} else {
values.endTime = '';
}
values.isOvertime = ot === -1 ? '' : (ot === 1 ? 'N' : 'Y'); // eslint-disable-line
return values;
},
productList(params) {
this.$Loading.start();
service.allotPurchaseList(params)
.then(res => {
this.$Loading.finish();
this.processData(res.data);
});
},
processData(data) {
const fmt = 'YYYY-MM-DD HH:mm:ss';
const list = data.records;
_.each(list, (v, i) => {
v._rowIndex = i; // 当前行index
v._colorName = v.factoryGoodsName || '';
v.createTime = moment.unix(v.createTime).format(fmt);
v._needDeliver = v.buyingNums - v.lackNum - v.shipmentsNums; // 当前需发数
});
this.table.list = list;
this.page.total = data.totalCount;
},
filterSearch() {
this.useFilter = true;
const params = this.params();
this.productList(params);
this.page.current = 1;
},
clearFilter() {
this.filters = dataStore().filters;
this.useFilter = false;
this.productList(this.params());
this.page.current = 1;
},
pageChange(page) {
let params = this.params();
params.pageNo = page;
this.productList(params);
this.page.current = page;
},
selectChange(rows) {
this.deliverRows = rows;
},
deliverChange(data) {
const index = data.index;
const value = data.value;
this.table.list[index]._inputDeliverNum = +value;
_.each(this.deliverRows, item => {
if (item._rowIndex === index) {
item._inputDeliverNum = value;
}
});
},
showDeliverModal() {
if (this.checkDeliver()) {
this.$refs.deliverModal.show();
}
},
checkDeliver() {
const rows = this.deliverRows;
const len = rows.length;
if (!len) {
this.$Message.error('请勾选要发货的订单');
return false;
}
let invalidRows = [];
_.each(rows, (v) => {
if (!_.isFinite(+v._inputDeliverNum) ||
!(+v._inputDeliverNum) ||
v._inputDeliverNum > v._needDeliver) {
invalidRows.push(v.productSku);
}
});
if (invalidRows.length) {
this.$Message.error('已选择的条目、请输入大于0且不大于当前需发数的发货数', 5);
return false;
}
return true;
},
deliverSuccess() {
this.$Message.success('发货成功');
this.productList(this.params());
this.page.current = 1;
},
setModel(k, v) {
this.filters[k].model = v;
},
dateChange(date) {
this.setModel('startTime', date[0]);
this.setModel('endTime', date[1]);
},
rowClassName(row) {
if (row.isOvertime === 'Y') {
return 'over-time';
}
return '';
},
lackNumChange(data) {
const i = data.index;
const v = data.value;
this.table.list[i].inputLackNum = +v;
},
showUploadModal(index) {
const row = this.table.list[index];
const inputLackNum = row.inputLackNum;
const needDeliver = row._needDeliver;
if (!inputLackNum || inputLackNum > needDeliver) {
this.$Message.error('请输入缺货数量,且缺货数量不能大于当前需发数', 3);
return;
}
this.$refs.stockOutModal.show(row);
},
uploadSuccess() {
this.$Message.success('上传缺货成功');
this.productList(this.params());
this.page.current = 1;
},
exportList() {
let params = {
statusList: 1
};
let filters = this.filterValues();
_.assign(params, filters);
params = _.pickBy(params, (v) => {
return (v + '').length;
});
let temp = [];
_.each(params, (val, key) => {
temp.push(`${key}=${val}`);
});
const href = `/Api/erp/allotExportList?${temp.join('&')}`;
window.open(href, '_blank');
}
},
components: {
CellPrdInfo,
CellDispatch,
CellDeliver,
CellStockOut,
ModalStockOut,
ModalDeliver
}
};
</script>
<style lang="scss">
.ivu-table .over-time td{
background-color: #fcecec;
}
.status-cell {
.is-overtime {
color: #ff0000;
font-weight: bold;
}
}
</style>