repeatMethods.js
1.74 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
import {exportFn} from "@/common/constant";
export default {
methods: {
handleSearch() {
this.tableSearchForm = this.getParams()
this.$refs.listRef.refreshTable()
},
handleReset() {
this.searchForm = this.$options.data.call(this).searchForm
this.handleSearch()
},
handleExport(apiName) {
const params = this.getParams()
this.$apis.redenvelope[apiName](params).then(res => {
exportFn(res)
})
},
beforeSearchFn() {
return new Promise((resolve) => {
const { selectedArea } = this.searchForm;
// 清除旧的省市区 ID
this.searchForm.provincesId = '';
this.searchForm.cityId = '';
this.searchForm.districtsId = '';
// 根据 selectedArea 的长度设置相应的 ID
if (selectedArea) {
[this.searchForm.provincesId, this.searchForm.cityId, this.searchForm.districtsId] = selectedArea;
}
delete this.searchForm.selectedArea;
resolve();
});
},
getParams() {
let params = JSON.parse(JSON.stringify(this.searchForm))
return params
},
updateParams(params, paramKey, formKey, beginKey, endKey) {
if (params[paramKey]) {
params[beginKey] = this.searchForm[formKey][0];
params[endKey] = this.searchForm[formKey][1];
delete params[paramKey];
} else {
delete params[beginKey];
delete params[endKey];
}
return params
}
},
}