抽取表格过滤排序代码
This commit is contained in:
parent
dd7409681b
commit
93ae49263a
|
@ -115,7 +115,7 @@
|
||||||
import MsTableOperator from "../../../common/components/MsTableOperator";
|
import MsTableOperator from "../../../common/components/MsTableOperator";
|
||||||
import MsTableOperatorButton from "../../../common/components/MsTableOperatorButton";
|
import MsTableOperatorButton from "../../../common/components/MsTableOperatorButton";
|
||||||
import MsTableButton from "../../../common/components/MsTableButton";
|
import MsTableButton from "../../../common/components/MsTableButton";
|
||||||
import {humpToLine} from "../../../../../common/js/utils";
|
import {_filter, _sort, humpToLine} from "../../../../../common/js/utils";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "TestCaseList",
|
name: "TestCaseList",
|
||||||
|
@ -225,19 +225,6 @@
|
||||||
this.selectIds.clear();
|
this.selectIds.clear();
|
||||||
this.$emit('refresh');
|
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) {
|
showDetail(row, event, column) {
|
||||||
this.$emit('testCaseDetail', row);
|
this.$emit('testCaseDetail', row);
|
||||||
},
|
},
|
||||||
|
@ -263,27 +250,12 @@
|
||||||
moveToNode() {
|
moveToNode() {
|
||||||
this.$emit('moveToNode', this.selectIds);
|
this.$emit('moveToNode', this.selectIds);
|
||||||
},
|
},
|
||||||
|
filter(filters) {
|
||||||
|
_filter(filters, this.condition);
|
||||||
|
this.initTableData();
|
||||||
|
},
|
||||||
sort(column) {
|
sort(column) {
|
||||||
column.prop = humpToLine(column.prop);
|
_sort(column, this.condition);
|
||||||
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});
|
|
||||||
}
|
|
||||||
this.initTableData();
|
this.initTableData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,7 +127,7 @@
|
||||||
import NodeBreadcrumb from '../../../common/NodeBreadcrumb';
|
import NodeBreadcrumb from '../../../common/NodeBreadcrumb';
|
||||||
|
|
||||||
import {TokenKey} from '../../../../../../common/js/constants';
|
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 PriorityTableItem from "../../../common/tableItems/planview/PriorityTableItem";
|
||||||
import StatusTableItem from "../../../common/tableItems/planview/StatusTableItem";
|
import StatusTableItem from "../../../common/tableItems/planview/StatusTableItem";
|
||||||
import TypeTableItem from "../../../common/tableItems/planview/TypeTableItem";
|
import TypeTableItem from "../../../common/tableItems/planview/TypeTableItem";
|
||||||
|
@ -316,39 +316,11 @@
|
||||||
this.$refs.testCaseReportView.open(id);
|
this.$refs.testCaseReportView.open(id);
|
||||||
},
|
},
|
||||||
filter(filters) {
|
filter(filters) {
|
||||||
if (!this.condition.filters) {
|
_filter(filters, this.condition);
|
||||||
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();
|
this.initTableData();
|
||||||
},
|
},
|
||||||
sort(column) {
|
sort(column) {
|
||||||
column.prop = humpToLine(column.prop);
|
_sort(column, this.condition);
|
||||||
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});
|
|
||||||
}
|
|
||||||
this.initTableData();
|
this.initTableData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,3 +89,41 @@ export function mapToJson(strMap) {
|
||||||
export function humpToLine(name) {
|
export function humpToLine(name) {
|
||||||
return name.replace(/([A-Z])/g, "_$1").toLowerCase();
|
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