list.vue
4.94 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
<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.skuFactoryCode.label">
<Input v-model.trim="filters.skuFactoryCode.model"
:placeholder="filters.skuFactoryCode.holder"></Input>
</filter-item>
<filter-item>
<Button type="primary" @click="getExpress">筛选</Button>
<Button type="warning" @click="exportList">导出</Button>
<Button @click="clearFilters">清空条件</Button>
</filter-item>
</layout-filter>
<layout-list>
<Table border :columns="tableCols" :data="tableData"></Table>
<Page :total="pageData.total" :current="pageData.current"
@on-change="pageChange" :page-size="pageData.pageSize" show-total></Page>
</layout-list>
</layout-body>
</template>
<script>
import {list} from './store';
import ExpressService from 'services/repository/express-service';
export default {
created() {
this.expressService = new ExpressService();
},
data() {
return list.call(this);
},
mounted() {
this.getExpress();
},
methods: {
pageChange(val) {
this.pageData.current = val;
this.getExpress();
},
clearFilters() {
this.filters.id.model = null;
this.filters.expressNumber.model = null;
this.filters.productSkn.model = null;
this.filters.skuFactoryCode.model = null;
this.pageData.current = 1;
this.pageData.total = 0;
this.getExpress();
},
filtersParams() {
let params = {};
if (this.filters.id.model) {
if (this.isNumber(this.filters.id.model)) {
params.proReqFormId = 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.skuFactoryCode.model) {
params.skuFactoryCode = this.filters.skuFactoryCode.model;
}
params.pageSize = this.pageData.pageSize;
params.pageNo = this.pageData.current;
return Promise.resolve(params);
},
getExpress() {
this.$Loading.start();
return this.filtersParams().then((params) => {
return this.expressService.list(params);
}).then((result) => {
if (result.code === 200) {
this.pageData.total = result.data.totalCount;
this.pageData.current = result.data.pageNo;
this.tableData = result.data.records;
}
this.$Loading.finish();
}).catch((err) => {
this.$Loading.finish();
this.$Message.error(err);
});
},
info(data) {
this.$router.push({
name: 'repository.express.info',
params: {
id: data.expressNumber
},
query: {
time: data.createTime
}
});
},
exportList() {
this.expressService.exportList().then((url) => {
window.open(url, '_blank');
});
},
isNumber(numStr) {
const isNumber = /^[0-9]+$/;
return isNumber.test(numStr);
}
}
};
</script>