Authored by lzhy

优化代码

... ... @@ -117,52 +117,48 @@ export default {
this.search();
},
methods: {
//组织当前的搜索条件
filterValues() {
const values = {
pageNo: 1,
pageSize: 10,
};
const fields = this.filters;
const keysMap = {
beginTime: 'beginTime',
endTime: 'endTime',
timeFlag: 'timeFlag',
targetAccount: 'targetAccount',
orderCode: 'orderCode',
clearingType: 'clearingType',
subClearingType: 'subClearingType',
status: 'status',
};
_.each(keysMap, (val, key) => {
values[key] = fields[val].model;
const _this = this;
_.each(this.filters, (value, key) => {
_this.currentSearchParams[key] = value.model;
});
return values;
const { current, pageSize } = this.pageData;
this.currentSearchParams.pageNo = current;
this.currentSearchParams.pageSize = pageSize;
},
search() {
let params = {};
this.filters.timeFlag.model = '';
params = this.filterValues();
this.list(params);
this.pageData.current = 1;
},
reset() {
let params = {};
//重置筛选条件
resetFilter() {
//重置筛选框中的数据
_.each(this.filters, value => {
if (value.hasOwnProperty('model')) {
value.model = '';
}
});
params = this.filterValues();
this.list(params);
},
//点击搜索按钮动作
search() {
this.filters.timeFlag.model = '';
this.pageData.current = 1;
this.filterValues();
this.list();
},
//点击全部操作
reset() {
this.pageData.current = 1;
this.resetFilter();
this.filterValues();
this.list();
},
//点击快速查询操作
timeFlag(flag) {
let params = {};
this.resetFilter();
this.filters.timeFlag.model = flag;
params = this.filterValues();
this.list(params);
this.pageData.current = 1;
this.filterValues();
this.list();
},
//格式化时间
createTimeChange(time) {
if (!_.isArray(time)) {
time = time.split(' - ');
... ... @@ -175,16 +171,17 @@ export default {
this.filters.endTime.model = '';
}
},
//点击分页
pageChange(page) {
const params = this.filterValues();
params.pageNo = page;
this.pageData.current = page;
this.list(params);
this.currentSearchParams.pageNo = page;
this.list();
},
list(params) {
//获取列表数据
list() {
Promise.all([
this.financeService.shopWithdrawFreightList(params),
this.financeService.queryFreightBillSummary(params),
this.financeService.shopWithdrawFreightList(this.currentSearchParams),
this.financeService.queryFreightBillSummary(this.currentSearchParams),
]).then(result => {
this.tableData = _.get(result[0], 'data.records', []);
this.pageData.total = _.get(result[0], 'data.totalCount', 0);
... ... @@ -202,8 +199,9 @@ export default {
},
});
},
//导出列表
exportList() {
const queryString = { ...this.filterValues(), excelConf: 'shopFreightList' };
const queryString = { ...this.currentSearchParams, excelConf: 'shopFreightList' };
const params = qs.stringify(queryString, true);
const href = `${baseExportApi}${params}`;
window.open(href, '_blank');
... ...
... ... @@ -61,23 +61,6 @@
}}</Option>
</Select>
</div>
<!-- <div class="select-container">-->
<!-- <Input v-model.trim="filters.targetAccount.model" :placeholder="filters.targetAccount.label" />-->
<!-- </div>-->
<!-- <div class="select-container">-->
<!-- <Select v-model.trim="filters.clearingType.model" :placeholder="filters.clearingType.label">-->
<!-- <Option v-for="option in filters.clearingType.options" :key="option.value" :value="option.value">{{-->
<!-- option.label-->
<!-- }}</Option>-->
<!-- </Select>-->
<!-- </div>-->
<!-- <div class="select-container">-->
<!-- <Select v-model.trim="filters.subClearingType.model" :placeholder="filters.subClearingType.label">-->
<!-- <Option v-for="option in filters.subClearingType.options" :key="option.value" :value="option.value">{{-->
<!-- option.label-->
<!-- }}</Option>-->
<!-- </Select>-->
<!-- </div>-->
<div class="select-container">
<Input v-model.trim="filters.orderCode.model" :placeholder="filters.orderCode.label" />
</div>
... ... @@ -119,53 +102,48 @@ export default {
this.search();
},
methods: {
//组织当前的搜索条件
filterValues() {
const values = {
pageNo: 1,
pageSize: 10,
};
const fields = this.filters;
const keysMap = {
beginTime: 'beginTime',
endTime: 'endTime',
timeFlag: 'timeFlag',
status: 'status',
orderCode: 'orderCode',
productSku: 'productSku',
targetAccount: 'targetAccount',
clearingType: 'clearingType',
subClearingType: 'subClearingType',
};
_.each(keysMap, (val, key) => {
values[key] = fields[val].model;
const _this = this;
_.each(this.filters, (value, key) => {
_this.currentSearchParams[key] = value.model;
});
return values;
const { current, pageSize } = this.pageData;
this.currentSearchParams.pageNo = current;
this.currentSearchParams.pageSize = pageSize;
},
search() {
let params = {};
this.filters.timeFlag.model = '';
params = this.filterValues();
this.list(params);
this.pageData.current = 1;
},
reset() {
let params = {};
//重置筛选条件
resetFilter() {
//重置筛选框中的数据
_.each(this.filters, value => {
if (value.hasOwnProperty('model')) {
value.model = '';
}
});
params = this.filterValues();
this.list(params);
},
//点击搜索按钮动作
search() {
this.filters.timeFlag.model = '';
this.pageData.current = 1;
this.filterValues();
this.list();
},
//点击全部操作
reset() {
this.pageData.current = 1;
this.resetFilter();
this.filterValues();
this.list();
},
//点击快速查询操作
timeFlag(flag) {
let params = {};
this.resetFilter();
this.filters.timeFlag.model = flag;
params = this.filterValues();
this.list(params);
this.pageData.current = 1;
this.filterValues();
this.list();
},
//格式化时间
createTimeChange(time) {
if (!_.isArray(time)) {
time = time.split(' - ');
... ... @@ -178,16 +156,17 @@ export default {
this.filters.endTime.model = '';
}
},
//点击分页
pageChange(page) {
const params = this.filterValues();
params.pageNo = page;
this.pageData.current = page;
this.list(params);
this.currentSearchParams.pageNo = page;
this.list();
},
list(params) {
//获取列表数据
list() {
Promise.all([
this.financeService.shopWithdrawServiceList(params),
this.financeService.queryBillSummary(params),
this.financeService.shopWithdrawServiceList(this.currentSearchParams),
this.financeService.queryBillSummary(this.currentSearchParams),
]).then(result => {
this.tableData = _.get(result[0], 'data.records', []);
this.pageData.total = _.get(result[0], 'data.totalCount', 0);
... ... @@ -197,8 +176,9 @@ export default {
this.summaryInfo.push({ ...summaryInfo, summaryName: '汇总' });
});
},
//导出列表
exportList() {
const queryString = { ...this.filterValues(), excelConf: 'shopServiceList' };
const queryString = { ...this.currentSearchParams, excelConf: 'shopServiceList' };
const params = qs.stringify(queryString, true);
const href = `${baseExportApi}${params}`;
window.open(href, '_blank');
... ...
... ... @@ -10,6 +10,8 @@ const withdrawStatus = {
export default function() {
return {
//当前的搜索条件
currentSearchParams: {},
filters: {
createTime: {
label: '创建时间',
... ... @@ -87,8 +89,6 @@ export default function() {
},
],
},
pageNo: 1,
pageSize: 10,
},
tableCols: [
{
... ...
... ... @@ -10,6 +10,8 @@ const withdrawStatus = {
export default function() {
return {
//当前的搜索条件
currentSearchParams: {},
filters: {
createTime: {
label: '创建时间',
... ... @@ -95,8 +97,6 @@ export default function() {
label: '提现账户',
model: '',
},
pageNo: 1,
pageSize: 10,
},
tableCols: [
{
... ...