allot-list.vue
4.93 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
<template>
<layout-body>
<layout-filter>
<filter-item :label="filters.orderNo.label">
<Input v-model.trim="filters.orderNo.model"
:placeholder="filters.orderNo.holder"></Input>
</filter-item>
<filter-item :label="filters.orderTime.label">
<Date-picker type="daterange"
placeholder="选择日期"
@on-change="dateChange"
v-model="filters.orderTime.model">
</Date-picker>
</filter-item>
<filter-item>
<Button type="primary" @click="filterSearch">筛选</Button>
<Button @click="clearFilter">清空条件</Button>
<filter-tips type="warning" show-icon closable>请务必认真填写发货情况及物流信息,否则商品无法正常入库</filter-tips>
</filter-item>
</layout-filter>
<layout-list>
<Table border :columns="columns" :data="dataList"></Table>
<Page :total="page.total" :current="page.current"
@on-change="pageChange" :page-size="20" show-total></Page>
</layout-list>
</layout-body>
</template>
<script>
import _ from 'lodash';
import moment from 'moment';
import allotStore from './store';
import TradeService from 'services/trade/trade-service';
export default {
data() {
return allotStore.apply(this);
},
created() {
this.tradeService = new TradeService();
this.allotList(this.filterValues());
},
methods: {
filterValues() {
const values = {
pageNo: 1,
pageSize: 20
};
const filters = this.filters;
if (this.enableFilter) {
const keyMap = {
id: 'orderNo',
endTime: 'endTime',
startTime: 'startTime'
};
_.each(keyMap, (val, key) => {
values[key] = filters[val].model;
});
const sT = values.startTime;
const eT = values.endTime;
if (sT && moment(sT).isValid()) {
values.startTime = +moment(sT).format('X');
} else {
values.startTime = '';
}
if (eT && moment(eT).isValid()) {
values.endTime = +moment(eT).add(1, 'days').format('X');
} else {
values.endTime = '';
}
}
return values;
},
filterSearch() {
this.page.current = 1;
this.enableFilter = true;
this.allotList(this.filterValues());
},
clearFilter() {
this.page.current = 1;
this.enableFilter = false;
this.filters.orderNo.model = '';
this.filters.orderTime.model = '';
this.filters.startTime.model = '';
this.filters.endTime.model = '';
this.allotList(this.filterValues());
},
allotList(params) {
if (typeof params.id !== 'undefined' && !_.isFinite(+params.id)) {
this.$Message.error('调拨单号只能是数字', 3);
return;
}
this.$Loading.start();
this.tradeService.allotList(params)
.then(res => {
this.$Loading.finish();
this.resolveData(res.data);
});
},
reloadList() {
let params = {};
if (this.enableFilter) {
params = this.filterValues();
}
this.allotList(params);
this.page.current = 1;
},
resolveData(data) {
this.dataList = data.records;
this.page.total = data.totalCount;
},
pageChange(page) {
let params;
params = this.filterValues();
params.pageNo = page;
this.page.current = page;
this.allotList(params);
},
dateChange(date) {
this.filters.startTime.model = date[0];
this.filters.endTime.model = date[1];
},
goSend(no) {
this.$router.push({
name: 'trade.allot.undone',
query: { no }
});
}
},
components: {}
};
</script>
<style lang="scss">
.lack-column,
.cancel-column {
.red-text {
color: #f00;
}
}
</style>