From 93ae49263a802339ee73a602117cdb140f2769c0 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Tue, 12 May 2020 20:11:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=8F=96=E8=A1=A8=E6=A0=BC=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E6=8E=92=E5=BA=8F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../track/case/components/TestCaseList.vue | 40 +++---------------- .../view/comonents/TestPlanTestCaseList.vue | 34 ++-------------- frontend/src/common/js/utils.js | 38 ++++++++++++++++++ 3 files changed, 47 insertions(+), 65 deletions(-) diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index 9b9a5f2ab..f312f8e88 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 a32b5abbc..e4f0cfe1c 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 f70fbc971..8c54a3d2b 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}); + } +} -- GitLab