From a236d63a3c5bfe5015d50213d097043105e28cbd Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 6 Sep 2021 11:25:35 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=B5=8B=E8=AF=95=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E5=92=8C=E8=AF=84=E5=AE=A1=E7=94=A8=E4=BE=8B=E8=AE=B0?= =?UTF-8?q?=E4=BD=8F=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/common/components/table/MsTable.vue | 10 ++++++---- .../comonents/functional/FunctionalTestCaseList.vue | 11 ++++++++--- .../review/view/components/TestReviewTestCaseList.vue | 11 ++++++++--- frontend/src/common/js/utils.js | 6 ++++++ 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/frontend/src/business/components/common/components/table/MsTable.vue b/frontend/src/business/components/common/components/table/MsTable.vue index 47e6fcbbd7..8dab90da5f 100644 --- a/frontend/src/business/components/common/components/table/MsTable.vue +++ b/frontend/src/business/components/common/components/table/MsTable.vue @@ -90,6 +90,7 @@ import MsTableOperators from "@/business/components/common/components/MsTableOpe import HeaderLabelOperate from "@/business/components/common/head/HeaderLabelOperate"; import HeaderCustom from "@/business/components/common/head/HeaderCustom"; import MsCustomTableHeader from "@/business/components/common/components/table/MsCustomTableHeader"; +import {lineToHump} from "@/common/js/utils"; /** * 参考 ApiList @@ -248,13 +249,14 @@ export default { let orders = this.condition.orders; if (orders) { orders.forEach(item => { - this.defaultSort = {}; - this.defaultSort.prop = item.name; + this.defaultSort = { + prop: lineToHump(item.name), + order: 'descending' + }; if (item.type === 'asc') { this.defaultSort.order = 'ascending'; - } else { - this.defaultSort.order = 'descending'; } + return; }); } }, diff --git a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue index 278af4f340..bfe9cd5337 100644 --- a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue @@ -21,7 +21,7 @@ @@ -266,7 +267,7 @@ import {hub} from "@/business/components/track/plan/event-bus"; import MsTag from "@/business/components/common/components/MsTag"; import { buildBatchParam, checkTableRowIsSelected, - getCustomFieldValue, getCustomTableWidth, + getCustomFieldValue, getCustomTableWidth, getLastTableSortField, getTableHeaderWithCustomFields, initCondition, } from "@/common/js/tableUtils"; @@ -312,6 +313,7 @@ export default { testPlan: {}, isReadOnly: false, hasEditPermission: false, + tableHeaderKey: 'TEST_PLAN_FUNCTION_TEST_CASE', priorityFilters: [ {text: 'P0', value: 'P0'}, {text: 'P1', value: 'P1'}, @@ -405,6 +407,9 @@ export default { this.$emit('setCondition', this.condition); }, }, + created() { + this.condition.orders = getLastTableSortField(this.tableHeaderKey); + }, mounted() { this.$emit('setCondition', this.condition); hub.$on("openFailureTestCase", row => { @@ -431,7 +436,7 @@ export default { let template = data[1]; this.result.loading = true; this.testCaseTemplate = template; - this.fields = getTableHeaderWithCustomFields('TEST_PLAN_FUNCTION_TEST_CASE', this.testCaseTemplate.customFields); + this.fields = getTableHeaderWithCustomFields(this.tableHeaderKey, this.testCaseTemplate.customFields); this.result.loading = false; this.$refs.table.reloadTable(); }); diff --git a/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue b/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue index 6d49355ee9..f223aa79d0 100644 --- a/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue +++ b/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue @@ -18,7 +18,7 @@ @@ -168,7 +169,7 @@ import TestReviewTestCaseEdit from "./TestReviewTestCaseEdit"; import ReviewStatus from "@/business/components/track/case/components/ReviewStatus"; import { _handleSelectAll, - buildBatchParam, checkTableRowIsSelected, deepClone, getCustomTableWidth, + buildBatchParam, checkTableRowIsSelected, deepClone, getCustomTableWidth, getLastTableSortField, getSelectDataCounts, getTableHeaderWithCustomFields, initCondition, toggleAllSelection @@ -211,6 +212,7 @@ export default { isReadOnly: false, isTestManagerOrTestUser: false, selectDataCounts: 0, + tableHeaderKey: 'TEST_CASE_REVIEW_FUNCTION_TEST_CASE', priorityFilters: [ {text: 'P0', value: 'P0'}, {text: 'P1', value: 'P1'}, @@ -285,6 +287,9 @@ export default { return this.$store.state.testReviewSelectNodeIds; } }, + created() { + this.condition.orders = getLastTableSortField(this.tableHeaderKey); + }, mounted() { this.$emit('setCondition', this.condition); this.refreshTableAndReview(); @@ -294,7 +299,7 @@ export default { methods: { initTableHeader() { this.result.loading = true; - this.fields = getTableHeaderWithCustomFields('TEST_CASE_REVIEW_FUNCTION_TEST_CASE', []); + this.fields = getTableHeaderWithCustomFields(this.tableHeaderKey, []); this.result.loading = false; this.$refs.table.reloadTable(); }, diff --git a/frontend/src/common/js/utils.js b/frontend/src/common/js/utils.js index 312920f618..7612ca30f3 100644 --- a/frontend/src/common/js/utils.js +++ b/frontend/src/common/js/utils.js @@ -253,6 +253,12 @@ export function mapToJson(strMap) { export function humpToLine(name) { return name.replace(/([A-Z])/g, "_$1").toLowerCase(); } +// 下划线转换驼峰 +export function lineToHump(name) { + return name.replace(/\_(\w)/g, function(all, letter){ + return letter.toUpperCase(); + }); +} export function downloadFile(name, content) { const blob = new Blob([content]);