diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index 9b9a5f2ab0..f312f8e886 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -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(); } } diff --git a/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseList.vue b/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseList.vue index a32b5abbc7..e4f0cfe1c2 100644 --- a/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/TestPlanTestCaseList.vue @@ -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(); } } diff --git a/frontend/src/common/js/utils.js b/frontend/src/common/js/utils.js index f70fbc971b..8c54a3d2b9 100644 --- a/frontend/src/common/js/utils.js +++ b/frontend/src/common/js/utils.js @@ -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}); + } +}