list.vue
3.9 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
<template>
<layout-body>
<layout-filter>
<filter-item :label="filters.subject.label">
<Input v-model.trim="filters.subject.model"
:placeholder="filters.subject.holder"></Input>
</filter-item>
<filter-item :label="filters.emergency.label">
<Select v-model.trim="filters.emergency.model" clearable>
<Option v-for="option in filters.emergency.options"
:value="option.value"
:key="option.value">{{option.label}}</Option>
</Select>
</filter-item>
<filter-item :label="filters.brand.label">
<select-brand v-model="filters.brand.model"></select-brand>
</filter-item>
<filter-item :label="filters.status.label">
<Select v-model.trim="filters.status.model" clearable>
<Option v-for="option in filters.status.options"
:value="option.value"
:key="option.value">{{option.label}}</Option>
</Select>
</filter-item>
<filter-item>
<Button type="primary" @click="doSearch">筛选</Button>
<Button @click="reset">清空条件</Button>
</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 {list as diffList} from './store';
import {DiffService} from 'services/repository';
export default {
data() {
return diffList.apply(this);
},
created() {
this.DiffService = new DiffService();
this.search(this.params());
},
methods: {
search(params) {
this.$Loading.start();
this.DiffService.list(params)
.then(res => {
this.$Loading.finish();
this.dataList = res.data.records;
this.page.total = res.data.totalCount;
}, () => {
this.$Loading.finish();
});
},
params() {
const defVal = {
pageNo: 1,
pageSize: 20,
statuses: [3, 21, 22]
};
const keyMap = {
brandId: 'brand',
statuses: 'status',
subject: 'subject',
emergencyDegree: 'emergency'
};
if (this.enableFilter) {
let model;
_.each(keyMap, (val, key) => {
model = this.filters[val].model;
if (('' + model).length) {
if (key === 'statuses') {
defVal[key] = [model];
} else {
defVal[key] = model;
}
}
});
}
return defVal;
},
reset() {
_.each(this.filters, item => {
item.model = '';
});
this.page.current = 1;
this.enableFilter = false;
this.search(this.params());
},
doSearch() {
this.enableFilter = true;
this.search(this.params());
},
pageChange(no) {
let params;
params = this.params();
params.pageNo = no;
this.search(params);
this.page.current = no;
},
toDetail(id) {
this.$router.push({
query: { id },
name: 'repository.diff.detail',
});
}
}
};
</script>
<style lang="scss">
</style>