抽取表格过滤排序代码
This commit is contained in:
parent
dd7409681b
commit
93ae49263a
|
@ -115,7 +115,7 @@
|
|||
import MsTableOperator from "../../../common/components/MsTableOperator";
|
||||
import MsTableOperatorButton from "../../../common/components/MsTableOperatorButton";
|
||||
import MsTableButton from "../../../common/components/MsTableButton";
|
||||
import {humpToLine} from "../../../../../common/js/utils";
|
||||
import {_filter, _sort, humpToLine} from "../../../../../common/js/utils";
|
||||
|
||||
export default {
|
||||
name: "TestCaseList",
|
||||
|
@ -225,19 +225,6 @@
|
|||
this.selectIds.clear();
|
||||
this.$emit('refresh');
|
||||
},
|
||||
filter(filters) {
|
||||
if (!this.condition.filters) {
|
||||
this.condition.filters = {};
|
||||
}
|
||||
for(let filter in filters) {
|
||||
if (filters[filter] && filters[filter].length > 0) {
|
||||
this.condition.filters[filter] = filters[filter];
|
||||
} else {
|
||||
this.condition.filters[filter] = null;
|
||||
}
|
||||
}
|
||||
this.initTableData();
|
||||
},
|
||||
showDetail(row, event, column) {
|
||||
this.$emit('testCaseDetail', row);
|
||||
},
|
||||
|
@ -263,27 +250,12 @@
|
|||
moveToNode() {
|
||||
this.$emit('moveToNode', this.selectIds);
|
||||
},
|
||||
filter(filters) {
|
||||
_filter(filters, this.condition);
|
||||
this.initTableData();
|
||||
},
|
||||
sort(column) {
|
||||
column.prop = humpToLine(column.prop);
|
||||
if (column.order == 'descending') {
|
||||
column.order = 'desc';
|
||||
} else {
|
||||
column.order = 'asc';
|
||||
}
|
||||
if (!this.condition.orders) {
|
||||
this.condition.orders = [];
|
||||
}
|
||||
let hasProp = false;
|
||||
this.condition.orders.forEach(order => {
|
||||
if (order.name == column.prop) {
|
||||
order.type = column.order;
|
||||
hasProp = true;
|
||||
return;
|
||||
}
|
||||
});
|
||||
if (!hasProp) {
|
||||
this.condition.orders.push({name: column.prop, type: column.order});
|
||||
}
|
||||
_sort(column, this.condition);
|
||||
this.initTableData();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@
|
|||
import NodeBreadcrumb from '../../../common/NodeBreadcrumb';
|
||||
|
||||
import {TokenKey} from '../../../../../../common/js/constants';
|
||||
import {humpToLine, tableFilter} from '../../../../../../common/js/utils';
|
||||
import {_filter, _sort, humpToLine, tableFilter} from '../../../../../../common/js/utils';
|
||||
import PriorityTableItem from "../../../common/tableItems/planview/PriorityTableItem";
|
||||
import StatusTableItem from "../../../common/tableItems/planview/StatusTableItem";
|
||||
import TypeTableItem from "../../../common/tableItems/planview/TypeTableItem";
|
||||
|
@ -316,39 +316,11 @@
|
|||
this.$refs.testCaseReportView.open(id);
|
||||
},
|
||||
filter(filters) {
|
||||
if (!this.condition.filters) {
|
||||
this.condition.filters = {};
|
||||
}
|
||||
for(let filter in filters) {
|
||||
if (filters[filter] && filters[filter].length > 0) {
|
||||
this.condition.filters[filter] = filters[filter];
|
||||
} else {
|
||||
this.condition.filters[filter] = null;
|
||||
}
|
||||
}
|
||||
_filter(filters, this.condition);
|
||||
this.initTableData();
|
||||
},
|
||||
sort(column) {
|
||||
column.prop = humpToLine(column.prop);
|
||||
if (column.order == 'descending') {
|
||||
column.order = 'desc';
|
||||
} else {
|
||||
column.order = 'asc';
|
||||
}
|
||||
if (!this.condition.orders) {
|
||||
this.condition.orders = [];
|
||||
}
|
||||
let hasProp = false;
|
||||
this.condition.orders.forEach(order => {
|
||||
if (order.name == column.prop) {
|
||||
order.type = column.order;
|
||||
hasProp = true;
|
||||
return;
|
||||
}
|
||||
});
|
||||
if (!hasProp) {
|
||||
this.condition.orders.push({name: column.prop, type: column.order});
|
||||
}
|
||||
_sort(column, this.condition);
|
||||
this.initTableData();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,3 +89,41 @@ export function mapToJson(strMap) {
|
|||
export function humpToLine(name) {
|
||||
return name.replace(/([A-Z])/g, "_$1").toLowerCase();
|
||||
}
|
||||
|
||||
//表格数据过滤
|
||||
export function _filter(filters, condition) {
|
||||
if (!condition.filters) {
|
||||
condition.filters = {};
|
||||
}
|
||||
for(let filter in filters) {
|
||||
if (filters[filter] && filters[filter].length > 0) {
|
||||
condition.filters[filter] = filters[filter];
|
||||
} else {
|
||||
condition.filters[filter] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//表格数据排序
|
||||
export function _sort(column, condition) {
|
||||
column.prop = humpToLine(column.prop);
|
||||
if (column.order == 'descending') {
|
||||
column.order = 'desc';
|
||||
} else {
|
||||
column.order = 'asc';
|
||||
}
|
||||
if (!condition.orders) {
|
||||
condition.orders = [];
|
||||
}
|
||||
let hasProp = false;
|
||||
condition.orders.forEach(order => {
|
||||
if (order.name == column.prop) {
|
||||
order.type = column.order;
|
||||
hasProp = true;
|
||||
return;
|
||||
}
|
||||
});
|
||||
if (!hasProp) {
|
||||
condition.orders.push({name: column.prop, type: column.order});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue