fix: 修改排序接口联调bug (#53)
This commit is contained in:
parent
b6e9c05d1f
commit
4031266ce8
@ -114,14 +114,14 @@ export default class SurveyManage {
|
||||
let filter = {}, order = {};
|
||||
if (condition.filter) {
|
||||
try {
|
||||
filter = this.getFilter(JSON.parse(condition.filter));
|
||||
filter = this.getFilter(JSON.parse(decodeURIComponent(condition.filter)));
|
||||
} catch (error) {
|
||||
throw new CommonError('filter参数格式不正确');
|
||||
}
|
||||
}
|
||||
if (condition.order) {
|
||||
try {
|
||||
order = this.getOrder(JSON.parse(condition.order));
|
||||
order = this.getOrder(JSON.parse(decodeURIComponent(condition.order)));
|
||||
} catch (error) {
|
||||
throw new CommonError('order参数格式不正确');
|
||||
}
|
||||
@ -178,13 +178,13 @@ export default class SurveyManage {
|
||||
|
||||
private getOrder(order) {
|
||||
|
||||
const allowOrderField = ['createDate', 'updateDate'];
|
||||
const allowOrderFields = ['createDate', 'updateDate', 'curStatus.date'];
|
||||
|
||||
const orderList = JSON.parse(order).filter((orderItem) =>
|
||||
allowOrderField.includes(orderItem.field),
|
||||
const orderList = order.filter((orderItem) =>
|
||||
allowOrderFields.includes(orderItem.field),
|
||||
);
|
||||
return orderList.reduce((pre, cur) => {
|
||||
pre[cur.field] = cur.value;
|
||||
pre[cur.field] = cur.value === 1 ? 1 : -1;
|
||||
return pre;
|
||||
}, {});
|
||||
}
|
||||
|
@ -182,13 +182,9 @@ class SurveyService {
|
||||
},
|
||||
condition.filter,
|
||||
);
|
||||
const order = Object.assign(
|
||||
{},
|
||||
{
|
||||
const order = condition.order && Object.keys(condition.order).length > 0 ? condition.order as Sort : {
|
||||
createDate: -1,
|
||||
},
|
||||
condition.order,
|
||||
) as Sort;
|
||||
} as Sort;
|
||||
const data = await surveyMeta.find(query)
|
||||
.sort(order)
|
||||
.limit(condition.pageSize)
|
||||
|
Loading…
Reference in New Issue
Block a user