From 3db0e65c6bff11505bb8a10f6e1695331e45b53a Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Tue, 12 Dec 2023 16:40:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E8=A1=A8=E5=A4=B4=E9=BB=98=E8=AE=A4=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=89=80=E5=B1=9E=E6=A8=A1=E5=9D=97=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --story=1013902 --user=王旭 【接口测试】和【UI测试】场景列表的表头字段支持展示所属模块 https://www.tapd.cn/55049933/s/1442910 --- .../automation/scenario/ApiScenarioList.vue | 4 +-- .../src/utils/default-table-header.js | 4 +-- .../frontend/src/utils/tableUtils.js | 30 +++++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/api-test/frontend/src/business/automation/scenario/ApiScenarioList.vue b/api-test/frontend/src/business/automation/scenario/ApiScenarioList.vue index 49a62e775d..a1a93bdb17 100644 --- a/api-test/frontend/src/business/automation/scenario/ApiScenarioList.vue +++ b/api-test/frontend/src/business/automation/scenario/ApiScenarioList.vue @@ -442,7 +442,7 @@ import { API_SCENARIO_CONFIGS } from 'metersphere-frontend/src/components/search import { API_SCENARIO_LIST } from 'metersphere-frontend/src/utils/constants'; import { buildBatchParam, - getCustomTableHeader, + getCustomTableHeaderByDefault, getCustomTableWidth, getLastTableSortField, getSelectDataCounts, @@ -558,7 +558,7 @@ export default { result: false, tableHeaderKey: 'API_SCENARIO', type: API_SCENARIO_LIST, - fields: getCustomTableHeader('API_SCENARIO', undefined), + fields: getCustomTableHeaderByDefault('API_SCENARIO', undefined), fieldsWidth: getCustomTableWidth('API_SCENARIO'), screenHeight: 'calc(100vh - 200px)', //屏幕高度, condition: { diff --git a/framework/sdk-parent/frontend/src/utils/default-table-header.js b/framework/sdk-parent/frontend/src/utils/default-table-header.js index d577807c70..0551a2a4e0 100644 --- a/framework/sdk-parent/frontend/src/utils/default-table-header.js +++ b/framework/sdk-parent/frontend/src/utils/default-table-header.js @@ -77,7 +77,7 @@ export let CUSTOM_TABLE_HEADER = { API_SCENARIO: [ { id: "num", key: "1", label: "ID" }, { id: "name", key: "2", label: "api_report.scenario_name" }, - { id: 'nodePath', key: '9', label: 'api_test.automation.module'}, + { id: 'nodePath', key: '9', label: 'api_test.automation.module', defaultHide: true }, { id: "level", key: "3", label: "api_test.automation.case_level" }, { id: "status", key: "4", label: "test_track.plan.plan_status" }, { id: "tags", key: "5", label: "commons.tag" }, @@ -100,7 +100,7 @@ export let CUSTOM_TABLE_HEADER = { UI_SCENARIO: [ { id: "num", key: "1", label: "ID" }, { id: "name", key: "2", label: "api_report.scenario_name" }, - { id: 'nodePath', key: '9', label: 'api_test.automation.module'}, + { id: 'nodePath', key: '9', label: 'api_test.automation.module', defaultHide: true }, { id: "level", key: "3", label: "api_test.automation.case_level" }, { id: "status", key: "4", label: "test_track.plan.plan_status" }, { id: "tags", key: "5", label: "commons.tag" }, diff --git a/framework/sdk-parent/frontend/src/utils/tableUtils.js b/framework/sdk-parent/frontend/src/utils/tableUtils.js index 825975b368..4e908f718c 100644 --- a/framework/sdk-parent/frontend/src/utils/tableUtils.js +++ b/framework/sdk-parent/frontend/src/utils/tableUtils.js @@ -304,6 +304,36 @@ export function getCustomTableHeader(key, customFields) { return getCustomTableHeaderByFiledSetting(key, fieldSetting); } + +export function getCustomTableHeaderByDefault(key, customFields) { + let fieldSetting = getAllFieldWithCustomFieldsByDefault(key, customFields); + return getCustomTableHeaderByFiledSetting(key, fieldSetting); +} + +export function getAllFieldWithCustomFieldsByDefault(key, customFields) { + let fieldSetting = [...CUSTOM_TABLE_HEADER[key]]; + // 如果没有 license, 排除 xpack + if (!hasLicense()) { + fieldSetting = fieldSetting.filter((v) => !v.xpack); + } + fieldSetting = fieldSetting.filter((v) => !v.defaultHide); + fieldSetting = JSON.parse(JSON.stringify(fieldSetting)); + translateLabel(fieldSetting); + if (customFields) { + customFields.forEach((item) => { + let field = { + id: item.name, + key: item.key, + label: item.name, + isCustom: true, + }; + fieldSetting.push(field); + }); + } + return fieldSetting; +} + + /** * 获取 localStorage 的值,过滤 * @param key