feat: 替换任务中心所有的表头筛选&公共脚本筛选

This commit is contained in:
xinxin.wu 2024-05-15 18:59:16 +08:00 committed by 刘瑞斌
parent b74eef8a6c
commit f1fe90aeb1
12 changed files with 304 additions and 390 deletions

View File

@ -106,7 +106,7 @@
:options="item.filterConfig.options" :options="item.filterConfig.options"
:data-index="item.dataIndex" :data-index="item.dataIndex"
v-bind="item.filterConfig" v-bind="item.filterConfig"
:filter="filter" :filter="filterData"
@handle-confirm="(v) => handleFilterConfirm(v, item.dataIndex as string, item.isCustomParam || false)" @handle-confirm="(v) => handleFilterConfirm(v, item.dataIndex as string, item.isCustomParam || false)"
> >
<template #item="{ filterItem }"> <template #item="{ filterItem }">
@ -356,8 +356,10 @@
value: string[] | (string | number)[] | undefined, value: string[] | (string | number)[] | undefined,
isCustomParam: boolean isCustomParam: boolean
): void; ): void;
(e: 'resetFilter', filterValue: Record<string, any>): void;
(e: 'moduleChange'): void; (e: 'moduleChange'): void;
(e: 'initEnd'): void; (e: 'initEnd'): void;
(e: 'reset'): void;
}>(); }>();
const attrs = useAttrs(); const attrs = useAttrs();
@ -637,13 +639,11 @@
columnSelectorVisible.value = true; columnSelectorVisible.value = true;
}; };
const filter = ref<Record<string, any>>({});
const handleFilterConfirm = ( const handleFilterConfirm = (
value: string[] | (string | number)[] | undefined, value: string[] | (string | number)[] | undefined,
dataIndex: string, dataIndex: string,
isCustomParam: boolean isCustomParam: boolean
) => { ) => {
filter.value[dataIndex] = value;
emit('filterChange', dataIndex, value, isCustomParam); emit('filterChange', dataIndex, value, isCustomParam);
}; };
@ -652,9 +652,13 @@
batchLeft.value = getBatchLeft(); batchLeft.value = getBatchLeft();
}); });
const filterData = computed(() => {
return (attrs.filter || {}) as Record<string, any>;
});
function hasSelectedFilter(item: MsTableColumnData) { function hasSelectedFilter(item: MsTableColumnData) {
if (item.filterConfig && item.dataIndex) { if (item.filterConfig && item.dataIndex) {
return (filter.value[item.dataIndex] || []).length > 0; return (filterData.value[item.dataIndex] || []).length > 0;
} }
return false; return false;
} }

View File

@ -124,9 +124,6 @@
const loading = ref(true); const loading = ref(true);
const optionLabelRender = (option: SelectOptionData) => { const optionLabelRender = (option: SelectOptionData) => {
if (option.email !== '') {
return `<span class='text-[var(--color-text-1)]'>${option.name}</span><span class='text-[var(--color-text-4)] ml-[4px]'>(${option.email})</span>`;
}
return `<span class='text-[var(--color-text-1)]'>${option.name}</span>`; return `<span class='text-[var(--color-text-1)]'>${option.name}</span>`;
}; };
@ -159,6 +156,25 @@
} }
return false; return false;
}); });
const isNoFilter = computed(() => {
if (props.filter && JSON.stringify(props.filter) !== '{}') {
return !Object.keys(props.filter).some((key: any) => {
return props.filter[key].length > 0;
});
}
return true;
});
//
watch(
() => isNoFilter.value,
(val) => {
if (val) {
checkedList.value = [];
}
}
);
</script> </script>
<style scoped lang="less"> <style scoped lang="less">

View File

@ -1,4 +1,6 @@
import { getProjectMemberOptions } from '@/api/modules/project-management/projectMember'; import { getProjectMemberOptions } from '@/api/modules/project-management/projectMember';
import { getProjectList } from '@/api/modules/setting/member';
import { getOrgOptions, getSystemProjectList } from '@/api/modules/system';
import { FilterRemoteMethodsEnum } from '@/enums/tableFilterEnum'; import { FilterRemoteMethodsEnum } from '@/enums/tableFilterEnum';
@ -6,6 +8,12 @@ export function initRemoteOptionsFunc(remoteMethod: string, params: Record<strin
switch (remoteMethod) { switch (remoteMethod) {
case FilterRemoteMethodsEnum.PROJECT_PERMISSION_MEMBER: case FilterRemoteMethodsEnum.PROJECT_PERMISSION_MEMBER:
return getProjectMemberOptions(params.projectId, params.keyword); return getProjectMemberOptions(params.projectId, params.keyword);
case FilterRemoteMethodsEnum.SYSTEM_ORGANIZATION_LIST:
return getOrgOptions();
case FilterRemoteMethodsEnum.SYSTEM_PROJECT_LIST:
return getSystemProjectList(params.keyword);
case FilterRemoteMethodsEnum.SYSTEM_ORGANIZATION_PROJECT:
return getProjectList(params.organizationId, params.keyword);
default: default:
break; break;
} }

View File

@ -345,6 +345,11 @@ export default function useTableProps<T>(
const getTableQueryParams = () => { const getTableQueryParams = () => {
return tableQueryParams.value; return tableQueryParams.value;
}; };
// 重置表头筛选
const resetFilterParams = () => {
filterItem.value = {};
propsRes.value.filter = cloneDeep(filterItem.value);
};
// 事件触发组 // 事件触发组
const propsEvent = ref({ const propsEvent = ref({
@ -472,5 +477,6 @@ export default function useTableProps<T>(
resetSelector, resetSelector,
getTableQueryParams, getTableQueryParams,
setTableSelected, setTableSelected,
resetFilterParams,
}; };
} }

View File

@ -8,10 +8,16 @@ export enum FilterSlotNameEnum {
API_TEST_API_REQUEST_METHODS = 'API_TEST_API_REQUEST_METHODS', // 接口测试请求方式 API_TEST_API_REQUEST_METHODS = 'API_TEST_API_REQUEST_METHODS', // 接口测试请求方式
API_TEST_API_REQUEST_API_STATUS = 'API_TEST_API_REQUEST_API_STATUS', // 接口测试接口状态 API_TEST_API_REQUEST_API_STATUS = 'API_TEST_API_REQUEST_API_STATUS', // 接口测试接口状态
TEST_PLAN_REPORT_EXEC_STATUS = 'TEST_PLAN_REPORT_EXEC_STATUS', TEST_PLAN_REPORT_EXEC_STATUS = 'TEST_PLAN_REPORT_EXEC_STATUS',
PROJECT_MANAGEMENT_COMMON_SCRIPT = 'PROJECT_MANAGEMENT_COMMON_SCRIPT', // 项目管理公共脚本脚本状态
GLOBAL_TASK_CENTER_API_CASE_STATUS = 'GLOBAL_TASK_CENTER_API_CASE_STATUS', // 任务中心执行状态
GLOBAL_TASK_CENTER_API_CASE_TRIGGED_MODE = 'GLOBAL_TASK_CENTER_API_CASE_TRIGGED_MODE', // 任务中心触发方式
} }
export enum FilterRemoteMethodsEnum { export enum FilterRemoteMethodsEnum {
PROJECT_PERMISSION_MEMBER = 'PROJECT_PERMISSION_MEMBER', // 项目下成员 PROJECT_PERMISSION_MEMBER = 'PROJECT_PERMISSION_MEMBER', // 项目下成员
SYSTEM_ORGANIZATION_LIST = 'SYSTEM_ORGANIZATION_LIST', // 组织列表
SYSTEM_PROJECT_LIST = 'SYSTEM_PROJECT_LIST', // 系统下项目
SYSTEM_ORGANIZATION_PROJECT = 'SYSTEM_ORGANIZATION_PROJECT', // 组织下项目
} }
export default {}; export default {};

View File

@ -8,6 +8,12 @@ export enum TaskCenterEnum {
TEST_RESOURCE = 'TEST_RESOURCE', // 测试资源 TEST_RESOURCE = 'TEST_RESOURCE', // 测试资源
API_IMPORT = 'API_IMPORT', // API导入 API_IMPORT = 'API_IMPORT', // API导入
} }
export type ResourceTypeMapKey =
| TaskCenterEnum.API_CASE
| TaskCenterEnum.API_SCENARIO
| TaskCenterEnum.UI_TEST
| TaskCenterEnum.LOAD_TEST
| TaskCenterEnum.TEST_PLAN;
// 执行方式 // 执行方式
export enum ExecutionMethods { export enum ExecutionMethods {

View File

@ -50,47 +50,19 @@
@change="() => handleStatusChange(record)" @change="() => handleStatusChange(record)"
> >
<template #label> <template #label>
<commonScriptStatus :status="record.status" /> <CommonScriptStatus :status="record.status" />
</template> </template>
<a-option :key="CommonScriptStatusEnum.PASSED" :value="CommonScriptStatusEnum.PASSED"> <a-option :key="CommonScriptStatusEnum.PASSED" :value="CommonScriptStatusEnum.PASSED">
<commonScriptStatus :status="CommonScriptStatusEnum.PASSED" /> <CommonScriptStatus :status="CommonScriptStatusEnum.PASSED" />
</a-option> </a-option>
<a-option :key="CommonScriptStatusEnum.DRAFT" :value="CommonScriptStatusEnum.DRAFT"> <a-option :key="CommonScriptStatusEnum.DRAFT" :value="CommonScriptStatusEnum.DRAFT">
<commonScriptStatus :status="CommonScriptStatusEnum.DRAFT" /> <CommonScriptStatus :status="CommonScriptStatusEnum.DRAFT" />
</a-option> </a-option>
</a-select> </a-select>
<commonScriptStatus v-else :status="record.status" /> <CommonScriptStatus v-else :status="record.status" />
</template> </template>
<template #statusFilter="{ columnConfig }"> <template #[FilterSlotNameEnum.PROJECT_MANAGEMENT_COMMON_SCRIPT]="{ filterContent }">
<a-trigger <CommonScriptStatus :status="filterContent.value" />
v-model:popup-visible="statusFilterVisible"
trigger="click"
@popup-visible-change="handleFilterHidden"
>
<MsButton type="text" class="arco-btn-text--secondary ml-[10px]" @click="statusFilterVisible = true">
{{ t(columnConfig.title as string) }}
<icon-down :class="statusFilterVisible ? 'text-[rgb(var(--primary-5))]' : ''" />
</MsButton>
<template #content>
<div class="arco-table-filters-content">
<div class="ml-[6px] flex items-center justify-start px-[6px] py-[2px]">
<a-checkbox-group v-model:model-value="statusFilters" direction="vertical" size="small">
<a-checkbox v-for="val of Object.values(CommonScriptStatusEnum)" :key="val" :value="val">
<commonScriptStatus :status="val" />
</a-checkbox>
</a-checkbox-group>
</div>
<div class="filter-button">
<a-button size="mini" class="mr-[8px]" @click="resetStatusFilter">
{{ t('common.reset') }}
</a-button>
<a-button type="primary" size="mini" @click="handleFilterHidden(false)">
{{ t('system.orgTemplate.confirm') }}
</a-button>
</div>
</div>
</template>
</a-trigger>
</template> </template>
<template #operation="{ record }"> <template #operation="{ record }">
<MsButton v-permission="['PROJECT_CUSTOM_FUNCTION:READ+UPDATE']" status="primary" @click="editHandler(record)"> <MsButton v-permission="['PROJECT_CUSTOM_FUNCTION:READ+UPDATE']" status="primary" @click="editHandler(record)">
@ -141,7 +113,7 @@
import MsTableMoreAction from '@/components/pure/ms-table-more-action/index.vue'; import MsTableMoreAction from '@/components/pure/ms-table-more-action/index.vue';
import { ActionsItem } from '@/components/pure/ms-table-more-action/types'; import { ActionsItem } from '@/components/pure/ms-table-more-action/types';
import AddScriptDrawer from '@/components/business/ms-common-script/ms-addScriptDrawer.vue'; import AddScriptDrawer from '@/components/business/ms-common-script/ms-addScriptDrawer.vue';
import commonScriptStatus from './components/commonScriptStatus.vue'; import CommonScriptStatus from './components/commonScriptStatus.vue';
import ScriptDetailDrawer from './components/scriptDetailDrawer.vue'; import ScriptDetailDrawer from './components/scriptDetailDrawer.vue';
import { import {
@ -163,6 +135,7 @@
} from '@/models/projectManagement/commonScript'; } from '@/models/projectManagement/commonScript';
import { CommonScriptStatusEnum } from '@/enums/commonScriptStatusEnum'; import { CommonScriptStatusEnum } from '@/enums/commonScriptStatusEnum';
import { TableKeyEnum } from '@/enums/tableEnum'; import { TableKeyEnum } from '@/enums/tableEnum';
import { FilterSlotNameEnum } from '@/enums/tableFilterEnum';
const appStore = useAppStore(); const appStore = useAppStore();
const currentProjectId = computed(() => appStore.currentProjectId); const currentProjectId = computed(() => appStore.currentProjectId);
@ -172,14 +145,21 @@
const { openModal } = useModal(); const { openModal } = useModal();
const { t } = useI18n(); const { t } = useI18n();
const statusFilterVisible = ref(false);
const keyword = ref<string>(''); const keyword = ref<string>('');
const statusFilters = ref<string[]>([]);
const hasOperationPermission = computed(() => const hasOperationPermission = computed(() =>
hasAnyPermission(['PROJECT_CUSTOM_FUNCTION:READ+UPDATE', 'PROJECT_CUSTOM_FUNCTION:READ+DELETE']) hasAnyPermission(['PROJECT_CUSTOM_FUNCTION:READ+UPDATE', 'PROJECT_CUSTOM_FUNCTION:READ+DELETE'])
); );
const statusFilterOptions = computed(() => {
return Object.values(CommonScriptStatusEnum).map((key) => {
return {
value: key,
label: key,
};
});
});
const columns: MsTableColumn = [ const columns: MsTableColumn = [
{ {
title: 'project.commonScript.name', title: 'project.commonScript.name',
@ -204,11 +184,14 @@
showInTable: true, showInTable: true,
width: 150, width: 150,
showDrag: true, showDrag: true,
titleSlotName: 'statusFilter',
sortable: { sortable: {
sortDirections: ['ascend', 'descend'], sortDirections: ['ascend', 'descend'],
sorter: true, sorter: true,
}, },
filterConfig: {
options: statusFilterOptions.value,
filterSlotName: FilterSlotNameEnum.PROJECT_MANAGEMENT_COMMON_SCRIPT,
},
}, },
{ {
title: 'project.commonScript.tags', title: 'project.commonScript.tags',
@ -290,26 +273,10 @@
setLoadListParams({ setLoadListParams({
projectId: currentProjectId.value, projectId: currentProjectId.value,
keyword: keyword.value, keyword: keyword.value,
filter: {
status: statusFilters.value,
},
}); });
loadList(); loadList();
} }
function handleFilterHidden(val: boolean) {
if (!val) {
statusFilterVisible.value = false;
initData();
}
}
function resetStatusFilter() {
statusFilters.value = [];
statusFilterVisible.value = false;
initData();
}
function deleteScript(record: CommonScriptItem) { function deleteScript(record: CommonScriptItem) {
openModal({ openModal({
type: 'error', type: 'error',
@ -370,6 +337,7 @@
}; };
await addOrUpdateCommonScriptReq(paramsObj); await addOrUpdateCommonScriptReq(paramsObj);
showScriptDrawer.value = false; showScriptDrawer.value = false;
resetSelector();
initData(); initData();
Message.success(form.id ? t('common.updateSuccess') : t('common.createSuccess')); Message.success(form.id ? t('common.updateSuccess') : t('common.createSuccess'));
if (showDetailDrawer.value) { if (showDetailDrawer.value) {

View File

@ -14,7 +14,6 @@
></a-input-search> ></a-input-search>
</div> </div>
</div> </div>
<ms-base-table <ms-base-table
v-bind="propsRes" v-bind="propsRes"
ref="tableRef" ref="tableRef"
@ -42,42 +41,8 @@
>{{ record.resourceName }} >{{ record.resourceName }}
</div> </div>
</template> </template>
<template #statusFilter="{ columnConfig }"> <template #[FilterSlotNameEnum.GLOBAL_TASK_CENTER_API_CASE_STATUS]="{ filterContent }">
<a-trigger <ExecutionStatus :module-type="props.moduleType" :status="filterContent.value" />
v-model:popup-visible="statusFilterVisible"
trigger="click"
@popup-visible-change="handleFilterHidden"
>
<a-button type="text" class="arco-btn-text--secondary p-[8px_4px]" @click.stop="statusFilterVisible = true">
<div class="font-medium">
{{ t(columnConfig.title as string) }}
</div>
<icon-down :class="statusFilterVisible ? 'text-[rgb(var(--primary-5))]' : ''" />
</a-button>
<template #content>
<div class="arco-table-filters-content">
<div class="flex items-center justify-center px-[6px] py-[2px]">
<a-checkbox-group
v-model:model-value="statusFiltersMap[props.moduleType]"
direction="vertical"
size="small"
>
<a-checkbox v-for="key of statusFilters" :key="key" :value="key">
<ExecutionStatus :module-type="props.moduleType" :status="key" />
</a-checkbox>
</a-checkbox-group>
</div>
<div class="arco-table-filters-bottom">
<a-button size="mini" type="secondary" @click="handleFilterReset">
{{ t('common.reset') }}
</a-button>
<a-button size="mini" type="primary" @click="handleFilterSubmit()">
{{ t('common.confirm') }}
</a-button>
</div>
</div>
</template>
</a-trigger>
</template> </template>
<template #status="{ record }"> <template #status="{ record }">
<ExecutionStatus <ExecutionStatus
@ -86,63 +51,19 @@
:script-identifier="record.scriptIdentifier" :script-identifier="record.scriptIdentifier"
/> />
</template> </template>
<template #projectName="{ record }">
<a-tooltip :content="`${record.projectName}`" position="tl">
<div class="one-line-text">{{ characterLimit(record.projectName) }}</div>
</a-tooltip>
</template>
<template #organizationName="{ record }">
<a-tooltip :content="`${record.organizationName}`" position="tl">
<div class="one-line-text">{{ characterLimit(record.organizationName) }}</div>
</a-tooltip>
</template>
<template #triggerMode="{ record }"> <template #triggerMode="{ record }">
<span>{{ t(ExecutionMethodsLabel[record.triggerMode as keyof typeof ExecutionMethodsLabel]) }}</span> <span>{{ t(ExecutionMethodsLabel[record.triggerMode as keyof typeof ExecutionMethodsLabel]) }}</span>
</template> </template>
<template #triggerModeFilter="{ columnConfig }">
<TableFilter
v-model:visible="triggerModeVisible"
v-model:status-filters="triggerModeFiltersMap[props.moduleType]"
:title="(columnConfig.title as string)"
:list="triggerModeList"
label-key="label"
@search="initData()"
>
<template #item="{ item }">
{{ item.label }}
</template>
</TableFilter>
</template>
<template v-if="appStore.packageType === 'enterprise' && xPack" #orgFilterName="{ columnConfig }">
<TableFilter
v-model:visible="orgFilterVisible"
v-model:status-filters="orgFiltersMap[props.moduleType]"
:title="(columnConfig.title as string)"
mode="remote"
value-key="id"
label-key="name"
:type="UserRequestTypeEnum.SYSTEM_ORGANIZATION_PROJECT"
:placeholder-text="t('project.taskCenter.filterOrgPlaceholderText')"
@search="initData()"
>
</TableFilter>
</template>
<template
v-if="
hasAnyPermission(
groupColumnsMap[props.group].key === TableKeyEnum.TASK_API_CASE_SYSTEM
? ['SYSTEM_ORGANIZATION_PROJECT:READ']
: ['ORGANIZATION_PROJECT:READ']
)
"
#projectFilterName="{ columnConfig }"
>
<TableFilter
v-model:visible="projectFilterVisible"
v-model:status-filters="projectFiltersMap[props.moduleType]"
:title="(columnConfig.title as string)"
mode="remote"
:load-option-params="{ organizationId: appStore.currentOrgId }"
:placeholder-text="t('project.taskCenter.filterProPlaceholderText')"
:type="
groupColumnsMap[props.group].key === TableKeyEnum.TASK_API_CASE_SYSTEM
? UserRequestTypeEnum.SYSTEM_PROJECT_LIST
: UserRequestTypeEnum.SYSTEM_ORGANIZATION_PROJECT
"
@search="initData()"
>
</TableFilter>
</template>
<template #operationTime="{ record }"> <template #operationTime="{ record }">
<span>{{ dayjs(record.operationTime).format('YYYY-MM-DD HH:mm:ss') }}</span> <span>{{ dayjs(record.operationTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
</template> </template>
@ -201,11 +122,9 @@
import MsBaseTable from '@/components/pure/ms-table/base-table.vue'; import MsBaseTable from '@/components/pure/ms-table/base-table.vue';
import type { BatchActionParams, BatchActionQueryParams, MsTableColumn } from '@/components/pure/ms-table/type'; import type { BatchActionParams, BatchActionQueryParams, MsTableColumn } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable'; import useTable from '@/components/pure/ms-table/useTable';
import { UserRequestTypeEnum } from '@/components/business/ms-user-selector/utils';
import ExecutionStatus from './executionStatus.vue'; import ExecutionStatus from './executionStatus.vue';
import caseAndScenarioReportDrawer from '@/views/api-test/components/caseAndScenarioReportDrawer.vue'; import caseAndScenarioReportDrawer from '@/views/api-test/components/caseAndScenarioReportDrawer.vue';
import ReportDetailDrawer from '@/views/api-test/report/component/reportDetailDrawer.vue'; import ReportDetailDrawer from '@/views/api-test/report/component/reportDetailDrawer.vue';
import TableFilter from '@/views/case-management/caseManagementFeature/components/tableFilter.vue';
import { import {
batchStopRealOrdApi, batchStopRealOrdApi,
@ -221,32 +140,30 @@
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useModal from '@/hooks/useModal'; import useModal from '@/hooks/useModal';
import useOpenNewPage from '@/hooks/useOpenNewPage'; import useOpenNewPage from '@/hooks/useOpenNewPage';
import { useAppStore, useTableStore } from '@/store'; import { useTableStore } from '@/store';
import useLicenseStore from '@/store/modules/setting/license';
import { characterLimit } from '@/utils'; import { characterLimit } from '@/utils';
import { hasAnyPermission } from '@/utils/permission'; import { hasAnyPermission } from '@/utils/permission';
import { BatchApiParams } from '@/models/common'; import { BatchApiParams } from '@/models/common';
import { RouteEnum } from '@/enums/routeEnum'; import { RouteEnum } from '@/enums/routeEnum';
import { TableKeyEnum } from '@/enums/tableEnum'; import { TableKeyEnum } from '@/enums/tableEnum';
import { FilterSlotNameEnum } from '@/enums/tableFilterEnum';
import { ExecutionMethodsLabel } from '@/enums/taskCenter'; import { ExecutionMethodsLabel } from '@/enums/taskCenter';
import type { ResourceTypeMapKey } from './utils'; import type { ExtractedKeys } from './utils';
import { Group, ordAndProjectColumn, TaskStatus } from './utils'; import { getOrgColumns, getProjectColumns, Group, TaskStatus } from './utils';
const { openNewPage } = useOpenNewPage(); const { openNewPage } = useOpenNewPage();
const tableStore = useTableStore(); const tableStore = useTableStore();
const appStore = useAppStore();
const { openModal } = useModal(); const { openModal } = useModal();
const { t } = useI18n(); const { t } = useI18n();
const props = defineProps<{ const props = defineProps<{
group: Group; group: Group;
moduleType: ResourceTypeMapKey; moduleType: ExtractedKeys;
name: string; name: string;
}>(); }>();
const keyword = ref<string>(''); const keyword = ref<string>('');
const statusFilterVisible = ref(false);
const permissionsMap: Record<Group, any> = { const permissionsMap: Record<Group, any> = {
organization: { organization: {
@ -307,7 +224,35 @@
const hasJumpPermission = computed(() => hasAnyPermission(permissionsMap[props.group][props.moduleType].jump)); const hasJumpPermission = computed(() => hasAnyPermission(permissionsMap[props.group][props.moduleType].jump));
const hasOperationPermission = computed(() => hasAnyPermission(permissionsMap[props.group][props.moduleType].stop)); const hasOperationPermission = computed(() => hasAnyPermission(permissionsMap[props.group][props.moduleType].stop));
const columns: MsTableColumn = [ const statusFilters = computed(() => {
return Object.keys(TaskStatus[props.moduleType]).map((key: any) => {
return {
value: key,
...TaskStatus[props.moduleType][key],
};
});
});
const triggerModeList = [
{
value: 'SCHEDULE',
label: t('project.taskCenter.scheduledTask'),
},
{
value: 'MANUAL',
label: t('project.taskCenter.manualExecution'),
},
{
value: 'API',
label: t('project.taskCenter.interfaceCall'),
},
{
value: 'BATCH',
label: t('project.taskCenter.batchExecution'),
},
];
const staticColumns: MsTableColumn = [
{ {
title: 'project.taskCenter.resourceID', title: 'project.taskCenter.resourceID',
dataIndex: 'resourceNum', dataIndex: 'resourceNum',
@ -334,11 +279,14 @@
title: 'project.taskCenter.executionResult', title: 'project.taskCenter.executionResult',
dataIndex: 'status', dataIndex: 'status',
slotName: 'status', slotName: 'status',
titleSlotName: 'statusFilter',
sortable: { sortable: {
sortDirections: ['ascend', 'descend'], sortDirections: ['ascend', 'descend'],
sorter: true, sorter: true,
}, },
filterConfig: {
options: statusFilters.value,
filterSlotName: FilterSlotNameEnum.GLOBAL_TASK_CENTER_API_CASE_STATUS,
},
showInTable: true, showInTable: true,
width: 200, width: 200,
showDrag: true, showDrag: true,
@ -347,11 +295,13 @@
title: 'project.taskCenter.executionMode', title: 'project.taskCenter.executionMode',
dataIndex: 'triggerMode', dataIndex: 'triggerMode',
slotName: 'triggerMode', slotName: 'triggerMode',
titleSlotName: 'triggerModeFilter',
sortable: { sortable: {
sortDirections: ['ascend', 'descend'], sortDirections: ['ascend', 'descend'],
sorter: true, sorter: true,
}, },
filterConfig: {
options: triggerModeList,
},
showInTable: true, showInTable: true,
width: 150, width: 150,
showDrag: true, showDrag: true,
@ -390,25 +340,22 @@
}, },
]; ];
const groupColumnsMap = { const tableKeysMap: Record<string, any> = {
system: { system: TableKeyEnum.TASK_API_CASE_SYSTEM,
key: TableKeyEnum.TASK_API_CASE_SYSTEM, organization: TableKeyEnum.TASK_API_CASE_ORGANIZATION,
columns: [...ordAndProjectColumn, ...columns], project: TableKeyEnum.TASK_API_CASE_PROJECT,
},
organization: {
key: TableKeyEnum.TASK_API_CASE_ORGANIZATION,
columns: [...ordAndProjectColumn.slice(-1), ...columns],
},
project: {
key: TableKeyEnum.TASK_API_CASE_PROJECT,
columns,
},
}; };
const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector } = useTable( const groupColumnsMap: Record<string, any> = {
system: [getOrgColumns(), getProjectColumns(tableKeysMap[props.group]), ...staticColumns],
organization: [getProjectColumns(tableKeysMap[props.group]), ...staticColumns],
project: staticColumns,
};
const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector, resetFilterParams } = useTable(
loadRealMap.value[props.group].list, loadRealMap.value[props.group].list,
{ {
tableKey: groupColumnsMap[props.group].key, tableKey: tableKeysMap[props.group],
scroll: { scroll: {
x: 1400, x: 1400,
}, },
@ -419,25 +366,6 @@
showSelectAll: true, showSelectAll: true,
} }
); );
const triggerModeList = ref([
{
value: 'SCHEDULE',
label: t('project.taskCenter.scheduledTask'),
},
{
value: 'MANUAL',
label: t('project.taskCenter.manualExecution'),
},
{
value: 'API',
label: t('project.taskCenter.interfaceCall'),
},
{
value: 'BATCH',
label: t('project.taskCenter.batchExecution'),
},
]);
const triggerModeVisible = ref<boolean>(false);
const triggerModeApiCase = ref([]); const triggerModeApiCase = ref([]);
const triggerModeApiScenario = ref([]); const triggerModeApiScenario = ref([]);
@ -454,8 +382,6 @@
API_SCENARIO: statusFilterApiScenario.value, API_SCENARIO: statusFilterApiScenario.value,
}); });
const orgFilterVisible = ref<boolean>(false);
const projectFilterVisible = ref<boolean>(false);
const orgApiCaseFilter = ref([]); const orgApiCaseFilter = ref([]);
const orgApiScenarioFilter = ref([]); const orgApiScenarioFilter = ref([]);
@ -470,32 +396,14 @@
API_CASE: projectApiCaseFilter.value, API_CASE: projectApiCaseFilter.value,
API_SCENARIO: projectApiScenarioFilter.value, API_SCENARIO: projectApiScenarioFilter.value,
}); });
const licenseStore = useLicenseStore();
const xPack = computed(() => licenseStore.hasLicense());
function initData() { function initData() {
setLoadListParams({ setLoadListParams({
keyword: keyword.value, keyword: keyword.value,
moduleType: props.moduleType, moduleType: props.moduleType,
filter: {
status: statusFiltersMap.value[props.moduleType],
triggerMode: triggerModeFiltersMap.value[props.moduleType],
organizationIds: orgFiltersMap.value[props.moduleType],
projectIds: projectFiltersMap.value[props.moduleType],
},
}); });
loadList(); loadList();
} }
function handleFilterReset() {
statusFiltersMap.value[props.moduleType] = [];
statusFilterVisible.value = false;
initData();
}
function handleFilterSubmit() {
statusFilterVisible.value = false;
initData();
}
const tableBatchActions = { const tableBatchActions = {
baseAction: [ baseAction: [
@ -600,16 +508,6 @@
initData(); initData();
}); });
const statusFilters = computed(() => {
return Object.keys(TaskStatus[props.moduleType]);
});
function handleFilterHidden(val: boolean) {
if (!val) {
initData();
}
}
/** /**
* 报告详情 showReportDetail * 报告详情 showReportDetail
*/ */
@ -633,6 +531,7 @@
(val) => { (val) => {
if (val) { if (val) {
resetSelector(); resetSelector();
resetFilterParams();
initData(); initData();
} }
} }
@ -665,7 +564,7 @@
} }
}); });
await tableStore.initColumn(groupColumnsMap[props.group].key, groupColumnsMap[props.group].columns, 'drawer', true); await tableStore.initColumn(tableKeysMap[props.group], groupColumnsMap[props.group], 'drawer', true);
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -22,10 +22,9 @@
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import type { ResourceTypeMapKey } from '@/enums/taskCenter';
import { TaskCenterEnum } from '@/enums/taskCenter'; import { TaskCenterEnum } from '@/enums/taskCenter';
import type { ResourceTypeMapKey } from './utils';
const { t } = useI18n(); const { t } = useI18n();
const props = defineProps<{ const props = defineProps<{
status: string; status: string;

View File

@ -54,6 +54,16 @@
{{ t(resourceTypeMap[record.resourceType as ResourceTypeMapKey].label) }} {{ t(resourceTypeMap[record.resourceType as ResourceTypeMapKey].label) }}
</div> </div>
</template> </template>
<template #projectName="{ record }">
<a-tooltip :content="`${record.projectName}`" position="tl">
<div class="one-line-text">{{ characterLimit(record.projectName) }}</div>
</a-tooltip>
</template>
<template #organizationName="{ record }">
<a-tooltip :content="`${record.organizationName}`" position="tl">
<div class="one-line-text">{{ characterLimit(record.organizationName) }}</div>
</a-tooltip>
</template>
<template #value="{ record }"> <template #value="{ record }">
<a-select <a-select
v-model:model-value="record.value" v-model:model-value="record.value"
@ -70,48 +80,6 @@
</a-option> </a-option>
</a-select> </a-select>
</template> </template>
<template v-if="appStore.packageType === 'enterprise' && xPack" #orgFilterName="{ columnConfig }">
<TableFilter
v-model:visible="orgFilterVisible"
v-model:status-filters="orgFiltersMap[props.moduleType]"
:title="(columnConfig.title as string)"
mode="remote"
value-key="id"
label-key="name"
:type="UserRequestTypeEnum.SYSTEM_ORGANIZATION_LIST"
:placeholder-text="t('project.taskCenter.filterOrgPlaceholderText')"
@search="initData()"
>
</TableFilter>
</template>
<template
v-if="
hasAnyPermission(
groupColumnsMap[props.group].key === TableKeyEnum.TASK_SCHEDULE_TASK_API_IMPORT_SYSTEM ||
groupColumnsMap[props.group].key === TableKeyEnum.TASK_SCHEDULE_TASK_API_SCENARIO_SYSTEM
? ['SYSTEM_ORGANIZATION_PROJECT:READ']
: ['ORGANIZATION_PROJECT:READ']
)
"
#projectFilterName="{ columnConfig }"
>
<TableFilter
v-model:visible="projectFilterVisible"
v-model:status-filters="projectFiltersMap[props.moduleType]"
:title="(columnConfig.title as string)"
mode="remote"
:load-option-params="{ organizationId: appStore.currentOrgId }"
:placeholder-text="t('project.taskCenter.filterProPlaceholderText')"
:type="
groupColumnsMap[props.group].key === TableKeyEnum.TASK_SCHEDULE_TASK_API_IMPORT_SYSTEM ||
groupColumnsMap[props.group].key === TableKeyEnum.TASK_SCHEDULE_TASK_API_SCENARIO_SYSTEM
? UserRequestTypeEnum.SYSTEM_PROJECT_LIST
: UserRequestTypeEnum.SYSTEM_ORGANIZATION_PROJECT
"
@search="initData()"
>
</TableFilter>
</template>
<template #operation="{ record }"> <template #operation="{ record }">
<a-switch <a-switch
v-model="record.enable" v-model="record.enable"
@ -147,8 +115,6 @@
import type { BatchActionParams, BatchActionQueryParams, MsTableColumn } from '@/components/pure/ms-table/type'; import type { BatchActionParams, BatchActionQueryParams, MsTableColumn } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable'; import useTable from '@/components/pure/ms-table/useTable';
import type { ActionsItem } from '@/components/pure/ms-table-more-action/types'; import type { ActionsItem } from '@/components/pure/ms-table-more-action/types';
import { UserRequestTypeEnum } from '@/components/business/ms-user-selector/utils';
import TableFilter from '@/views/case-management/caseManagementFeature/components/tableFilter.vue';
import { import {
batchDisableScheduleOrgTask, batchDisableScheduleOrgTask,
@ -173,19 +139,18 @@
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useModal from '@/hooks/useModal'; import useModal from '@/hooks/useModal';
import useOpenNewPage from '@/hooks/useOpenNewPage'; import useOpenNewPage from '@/hooks/useOpenNewPage';
import { useAppStore, useTableStore } from '@/store'; import { useTableStore } from '@/store';
import useLicenseStore from '@/store/modules/setting/license'; import { characterLimit } from '@/utils';
import { hasAnyPermission } from '@/utils/permission'; import { hasAnyPermission } from '@/utils/permission';
import { BatchApiParams } from '@/models/common'; import { BatchApiParams } from '@/models/common';
import { TimingTaskCenterApiCaseItem } from '@/models/projectManagement/taskCenter'; import { TimingTaskCenterApiCaseItem } from '@/models/projectManagement/taskCenter';
import { RouteEnum } from '@/enums/routeEnum'; import { RouteEnum } from '@/enums/routeEnum';
import { TableKeyEnum } from '@/enums/tableEnum'; import { TableKeyEnum } from '@/enums/tableEnum';
import type { ResourceTypeMapKey } from '@/enums/taskCenter';
import { TaskCenterEnum } from '@/enums/taskCenter'; import { TaskCenterEnum } from '@/enums/taskCenter';
import { Group, ordAndProjectColumn, resourceTypeMap, ResourceTypeMapKey } from './utils'; import { getOrgColumns, getProjectColumns, Group, resourceTypeMap } from './utils';
const appStore = useAppStore();
const { openNewPage } = useOpenNewPage(); const { openNewPage } = useOpenNewPage();
@ -268,7 +233,7 @@
hasAnyPermission([...(permissionsMap[props.group][props.moduleType]?.edit || '')]) hasAnyPermission([...(permissionsMap[props.group][props.moduleType]?.edit || '')])
); );
const columns: MsTableColumn = [ const resourceColumns: MsTableColumn = [
{ {
title: 'project.taskCenter.resourceID', title: 'project.taskCenter.resourceID',
dataIndex: 'resourceNum', dataIndex: 'resourceNum',
@ -291,6 +256,9 @@
columnSelectorDisabled: true, columnSelectorDisabled: true,
showInTable: true, showInTable: true,
}, },
];
const staticColumns: MsTableColumn = [
{ {
title: 'project.taskCenter.operationRule', title: 'project.taskCenter.operationRule',
dataIndex: 'value', dataIndex: 'value',
@ -352,50 +320,56 @@
}, },
]; ];
const groupColumnsMap: Record<string, any> = { const tableKeyMap: Record<string, any> = {
system: { system: {
API_IMPORT: { API_IMPORT: TableKeyEnum.TASK_SCHEDULE_TASK_API_IMPORT_SYSTEM,
key: TableKeyEnum.TASK_SCHEDULE_TASK_API_IMPORT_SYSTEM, API_SCENARIO: TableKeyEnum.TASK_SCHEDULE_TASK_API_SCENARIO_SYSTEM,
columns: [
...ordAndProjectColumn,
...columns.slice(0, 2),
...swaggerUrlColumn,
...columns.slice(2, columns.length),
],
},
API_SCENARIO: {
key: TableKeyEnum.TASK_SCHEDULE_TASK_API_SCENARIO_SYSTEM,
columns: [...ordAndProjectColumn, ...columns],
},
}, },
organization: { organization: {
API_IMPORT: { API_IMPORT: TableKeyEnum.TASK_SCHEDULE_TASK_API_IMPORT_ORGANIZATION,
key: TableKeyEnum.TASK_SCHEDULE_TASK_API_IMPORT_ORGANIZATION, API_SCENARIO: TableKeyEnum.TASK_SCHEDULE_TASK_API_SCENARIO_ORGANIZATION,
columns: [
...ordAndProjectColumn.slice(-1),
...columns.slice(0, 2),
...swaggerUrlColumn,
...columns.slice(2, columns.length),
],
},
API_SCENARIO: {
key: TableKeyEnum.TASK_SCHEDULE_TASK_API_SCENARIO_ORGANIZATION,
columns: [...ordAndProjectColumn.slice(-1), ...columns],
},
}, },
project: { project: {
API_IMPORT: { API_IMPORT: TableKeyEnum.TASK_SCHEDULE_TASK_API_IMPORT_PROJECT,
key: TableKeyEnum.TASK_SCHEDULE_TASK_API_IMPORT_PROJECT, API_SCENARIO: TableKeyEnum.TASK_SCHEDULE_TASK_API_SCENARIO_PROJECT,
columns: [...columns.slice(0, 2), ...swaggerUrlColumn, ...columns.slice(2, columns.length)], },
}, };
API_SCENARIO: {
key: TableKeyEnum.TASK_SCHEDULE_TASK_API_SCENARIO_PROJECT, const groupColumnsMap: Record<string, any> = {
columns, system: {
}, API_IMPORT: [
getOrgColumns(),
getProjectColumns(tableKeyMap[props.group][props.moduleType]),
...resourceColumns,
...swaggerUrlColumn,
...staticColumns,
],
API_SCENARIO: [
getOrgColumns(),
getProjectColumns(tableKeyMap[props.group][props.moduleType]),
...resourceColumns,
...staticColumns,
],
},
organization: {
API_IMPORT: [
getProjectColumns(tableKeyMap[props.group][props.moduleType]),
...resourceColumns,
...swaggerUrlColumn,
...staticColumns,
],
API_SCENARIO: [
getProjectColumns(tableKeyMap[props.group][props.moduleType]),
...resourceColumns,
...staticColumns,
],
},
project: {
API_IMPORT: [...resourceColumns, ...swaggerUrlColumn, ...staticColumns],
API_SCENARIO: [...resourceColumns, ...staticColumns],
}, },
}; };
const orgFilterVisible = ref<boolean>(false);
const projectFilterVisible = ref<boolean>(false);
const orgApiCaseFilter = ref([]); const orgApiCaseFilter = ref([]);
const orgApiScenarioFilter = ref([]); const orgApiScenarioFilter = ref([]);
@ -413,13 +387,10 @@
const hasJumpPermission = computed(() => hasAnyPermission(permissionsMap[props.group][props.moduleType].jump)); const hasJumpPermission = computed(() => hasAnyPermission(permissionsMap[props.group][props.moduleType].jump));
const licenseStore = useLicenseStore(); const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector, resetFilterParams } = useTable(
const xPack = computed(() => licenseStore.hasLicense());
const { propsRes, propsEvent, loadList, setLoadListParams, resetSelector } = useTable(
loadRealMap.value[props.group].list, loadRealMap.value[props.group].list,
{ {
tableKey: groupColumnsMap[props.group][props.moduleType].key, tableKey: tableKeyMap[props.group][props.moduleType],
scroll: { scroll: {
x: 1200, x: 1200,
}, },
@ -440,10 +411,6 @@
setLoadListParams({ setLoadListParams({
keyword: keyword.value, keyword: keyword.value,
scheduleTagType: props.moduleType, scheduleTagType: props.moduleType,
filter: {
organizationIds: orgFiltersMap.value[props.moduleType],
projectIds: projectFiltersMap.value[props.moduleType],
},
}); });
loadList(); loadList();
} }
@ -570,10 +537,7 @@
excludeIds, excludeIds,
condition: { condition: {
keyword: keyword.value, keyword: keyword.value,
filter: { filter: propsRes.value.filter,
organizationIds: orgFiltersMap.value[props.moduleType],
projectIds: projectFiltersMap.value[props.moduleType],
},
}, },
}); });
resetSelector(); resetSelector();
@ -649,8 +613,8 @@
); );
await tableStore.initColumn( await tableStore.initColumn(
groupColumnsMap[props.group][props.moduleType].key, tableKeyMap[props.group][props.moduleType],
groupColumnsMap[props.group][props.moduleType].columns, groupColumnsMap[props.group][props.moduleType],
'drawer', 'drawer',
true true
); );
@ -660,7 +624,8 @@
() => props.moduleType, () => props.moduleType,
(val) => { (val) => {
if (val) { if (val) {
tableRef.value.initColumn(groupColumnsMap[props.group][props.moduleType].columns); resetFilterParams();
tableRef.value.initColumn(groupColumnsMap[props.group][props.moduleType]);
} }
} }
); );

View File

@ -28,9 +28,10 @@
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import type { ResourceTypeMapKey } from '@/enums/taskCenter';
import { TaskCenterEnum } from '@/enums/taskCenter'; import { TaskCenterEnum } from '@/enums/taskCenter';
import type { ResourceTypeMapKey } from './utils'; import type { ExtractedKeys } from './utils';
const { t } = useI18n(); const { t } = useI18n();
@ -77,7 +78,7 @@
]); ]);
const activeTask = ref(route.query.tab || 'real'); const activeTask = ref(route.query.tab || 'real');
const activeTab = ref<ResourceTypeMapKey>((route.query.type as ResourceTypeMapKey) || TaskCenterEnum.API_CASE); const activeTab = ref<ExtractedKeys>((route.query.type as ExtractedKeys) || TaskCenterEnum.API_CASE);
const rightTabList = computed(() => { const rightTabList = computed(() => {
return activeTask.value === 'real' ? realTabList.value : timingTabList.value; return activeTask.value === 'real' ? realTabList.value : timingTabList.value;

View File

@ -1,148 +1,159 @@
import type { MsTableColumn } from '@/components/pure/ms-table/type'; import type { MsTableColumnData } from '@/components/pure/ms-table/type';
import { useI18n } from '@/hooks/useI18n';
import { useAppStore } from '@/store';
import useLicenseStore from '@/store/modules/setting/license';
import { hasAnyPermission } from '@/utils/permission';
import { TableKeyEnum } from '@/enums/tableEnum';
import { FilterRemoteMethodsEnum } from '@/enums/tableFilterEnum';
import type { ResourceTypeMapKey } from '@/enums/taskCenter';
import { TaskCenterEnum } from '@/enums/taskCenter'; import { TaskCenterEnum } from '@/enums/taskCenter';
export const TaskStatus = { const appStore = useAppStore();
const licenseStore = useLicenseStore();
const { t } = useI18n();
export const TaskStatus: Record<ResourceTypeMapKey, Record<string, { icon: string; label: string; color?: string }>> = {
[TaskCenterEnum.API_CASE]: { [TaskCenterEnum.API_CASE]: {
SUCCESS: { SUCCESS: {
icon: 'icon-icon_succeed_colorful', icon: 'icon-icon_succeed_colorful',
label: 'project.taskCenter.successful', label: t('project.taskCenter.successful'),
}, },
ERROR: { ERROR: {
icon: 'icon-icon_close_colorful', icon: 'icon-icon_close_colorful',
label: 'project.taskCenter.failure', label: t('project.taskCenter.failure'),
}, },
FAKE_ERROR: { FAKE_ERROR: {
icon: 'icon-icon_warning_colorful', icon: 'icon-icon_warning_colorful',
label: 'project.taskCenter.falseAlarm', label: t('project.taskCenter.falseAlarm'),
}, },
STOPPED: { STOPPED: {
icon: 'icon-icon_block_filled', icon: 'icon-icon_block_filled',
label: 'project.taskCenter.stop', label: t('project.taskCenter.stop'),
color: '!var(--color-text-input-border)', color: '!var(--color-text-input-border)',
}, },
RUNNING: { RUNNING: {
icon: 'icon-icon_testing', icon: 'icon-icon_testing',
label: 'project.taskCenter.inExecution', label: t('project.taskCenter.inExecution'),
color: '!text-[rgb(var(--link-6))]', color: '!text-[rgb(var(--link-6))]',
}, },
// RERUNNING: { // RERUNNING: {
// icon: 'icon-icon_testing', // icon: 'icon-icon_testing',
// label: 'project.taskCenter.rerun', // label: t('project.taskCenter.rerun',
// color: '!text-[rgb(var(--link-6))]', // color: '!text-[rgb(var(--link-6))]',
// }, // },
PENDING: { PENDING: {
icon: 'icon-icon_wait', icon: 'icon-icon_wait',
label: 'project.taskCenter.queuing', label: t('project.taskCenter.queuing'),
color: '!text-[rgb(var(--link-6))]', color: '!text-[rgb(var(--link-6))]',
}, },
}, },
[TaskCenterEnum.API_SCENARIO]: { [TaskCenterEnum.API_SCENARIO]: {
SUCCESS: { SUCCESS: {
icon: 'icon-icon_succeed_colorful', icon: 'icon-icon_succeed_colorful',
label: 'project.taskCenter.successful', label: t('project.taskCenter.successful'),
}, },
ERROR: { ERROR: {
icon: 'icon-icon_close_colorful', icon: 'icon-icon_close_colorful',
label: 'project.taskCenter.failure', label: t('project.taskCenter.failure'),
}, },
FAKE_ERROR: { FAKE_ERROR: {
icon: 'icon-icon_warning_colorful', icon: 'icon-icon_warning_colorful',
label: 'project.taskCenter.falseAlarm', label: t('project.taskCenter.falseAlarm'),
}, },
STOPPED: { STOPPED: {
icon: 'icon-icon_block_filled', icon: 'icon-icon_block_filled',
label: 'project.taskCenter.stop', label: t('project.taskCenter.stop'),
color: 'var(--color-text-input-border)', color: 'var(--color-text-input-border)',
}, },
RUNNING: { RUNNING: {
icon: 'icon-icon_testing', icon: 'icon-icon_testing',
label: 'project.taskCenter.inExecution', label: t('project.taskCenter.inExecution'),
color: '!text-[rgb(var(--link-6))]', color: '!text-[rgb(var(--link-6))]',
}, },
// RERUNNING: { // RERUNNING: {
// icon: 'icon-icon_testing', // icon: 'icon-icon_testing',
// label: 'project.taskCenter.rerun', // label: t('project.taskCenter.rerun',
// color: '!text-[rgb(var(--link-6))]', // color: '!text-[rgb(var(--link-6))]',
// }, // },
PENDING: { PENDING: {
icon: 'icon-icon_wait', icon: 'icon-icon_wait',
label: 'project.taskCenter.queuing', label: t('project.taskCenter.queuing'),
color: '!text-[rgb(var(--link-6))]', color: '!text-[rgb(var(--link-6))]',
}, },
}, },
[TaskCenterEnum.LOAD_TEST]: { [TaskCenterEnum.LOAD_TEST]: {
STARTING: { STARTING: {
icon: 'icon-icon_restarting', icon: 'icon-icon_restarting',
label: 'project.taskCenter.starting', label: t('project.taskCenter.starting'),
color: '!text-[rgb(var(--link-6))]', color: '!text-[rgb(var(--link-6))]',
}, },
RUNNING: { RUNNING: {
icon: 'icon-icon_testing', icon: 'icon-icon_testing',
label: 'project.taskCenter.inExecution', label: t('project.taskCenter.inExecution'),
color: '!text-[rgb(var(--link-6))]', color: '!text-[rgb(var(--link-6))]',
}, },
ERROR: { ERROR: {
icon: 'icon-icon_close_colorful', icon: 'icon-icon_close_colorful',
label: 'project.taskCenter.failure', label: t('project.taskCenter.failure'),
}, },
SUCCESS: { SUCCESS: {
icon: 'icon-icon_succeed_colorful', icon: 'icon-icon_succeed_colorful',
label: 'project.taskCenter.successful', label: t('project.taskCenter.successful'),
}, },
COMPLETED: { COMPLETED: {
icon: 'icon-icon_succeed_colorful', icon: 'icon-icon_succeed_colorful',
label: 'project.taskCenter.complete', label: t('project.taskCenter.complete'),
}, },
STOPPED: { STOPPED: {
icon: 'icon-icon_block_filled', icon: 'icon-icon_block_filled',
label: 'project.taskCenter.stop', label: t('project.taskCenter.stop'),
color: 'var(--color-text-input-border)', color: 'var(--color-text-input-border)',
}, },
}, },
[TaskCenterEnum.UI_TEST]: { [TaskCenterEnum.UI_TEST]: {
PENDING: { PENDING: {
icon: 'icon-icon_wait', icon: 'icon-icon_wait',
label: 'project.taskCenter.queuing', label: t('project.taskCenter.queuing'),
color: '!text-[rgb(var(--link-6))]', color: '!text-[rgb(var(--link-6))]',
}, },
RUNNING: { RUNNING: {
icon: 'icon-icon_testing', icon: 'icon-icon_testing',
label: 'project.taskCenter.inExecution', label: t('project.taskCenter.inExecution'),
color: '!text-[rgb(var(--link-6))]', color: '!text-[rgb(var(--link-6))]',
}, },
// RERUNNING: { // RERUNNING: {
// icon: 'icon-icon_testing', // icon: 'icon-icon_testing',
// label: 'project.taskCenter.rerun', // label: t('project.taskCenter.rerun',
// color: '!text-[rgb(var(--link-6))]', // color: '!text-[rgb(var(--link-6))]',
// }, // },
ERROR: { ERROR: {
icon: 'icon-icon_close_colorful', icon: 'icon-icon_close_colorful',
label: 'project.taskCenter.failure', label: t('project.taskCenter.failure'),
}, },
SUCCESS: { SUCCESS: {
icon: 'icon-icon_succeed_colorful', icon: 'icon-icon_succeed_colorful',
label: 'project.taskCenter.successful', label: t('project.taskCenter.successful'),
}, },
STOPPED: { STOPPED: {
icon: 'icon-icon_block_filled', icon: 'icon-icon_block_filled',
label: 'project.taskCenter.stop', label: t('project.taskCenter.stop'),
color: 'var(--color-text-input-border)', color: 'var(--color-text-input-border)',
}, },
}, },
[TaskCenterEnum.TEST_PLAN]: { [TaskCenterEnum.TEST_PLAN]: {
RUNNING: { RUNNING: {
icon: 'icon-icon_testing', icon: 'icon-icon_testing',
label: 'project.taskCenter.queuing', label: t('project.taskCenter.queuing'),
color: '!text-[rgb(var(--link-6))]', color: '!text-[rgb(var(--link-6))]',
}, },
SUCCESS: { SUCCESS: {
icon: 'icon-icon_succeed_colorful', icon: 'icon-icon_succeed_colorful',
label: 'project.taskCenter.successful', label: t('project.taskCenter.successful'),
}, },
STARTING: { STARTING: {
icon: 'icon-icon_restarting', icon: 'icon-icon_restarting',
label: 'project.taskCenter.starting', label: t('project.taskCenter.starting'),
color: '!text-[rgb(var(--link-6))]', color: '!text-[rgb(var(--link-6))]',
}, },
}, },
@ -150,57 +161,82 @@ export const TaskStatus = {
export type Group = 'system' | 'organization' | 'project'; export type Group = 'system' | 'organization' | 'project';
export type ResourceTypeMapKey = export type ExtractedKeys = Extract<ResourceTypeMapKey, TaskCenterEnum.API_CASE | TaskCenterEnum.API_SCENARIO>;
| TaskCenterEnum.API_CASE
| TaskCenterEnum.API_SCENARIO
| TaskCenterEnum.UI_TEST
| TaskCenterEnum.LOAD_TEST
| TaskCenterEnum.TEST_PLAN;
export const resourceTypeMap: Record<ResourceTypeMapKey, Record<string, any>> = { export const resourceTypeMap: Record<ResourceTypeMapKey, Record<string, any>> = {
[TaskCenterEnum.API_CASE]: { [TaskCenterEnum.API_CASE]: {
value: TaskCenterEnum.API_CASE, value: TaskCenterEnum.API_CASE,
label: 'project.taskCenter.interfaceCase', label: t('project.taskCenter.interfaceCase'),
}, },
[TaskCenterEnum.API_SCENARIO]: { [TaskCenterEnum.API_SCENARIO]: {
value: TaskCenterEnum.API_SCENARIO, value: TaskCenterEnum.API_SCENARIO,
label: 'project.taskCenter.apiScenario', label: t('project.taskCenter.apiScenario'),
}, },
[TaskCenterEnum.UI_TEST]: { [TaskCenterEnum.UI_TEST]: {
value: TaskCenterEnum.UI_TEST, value: TaskCenterEnum.UI_TEST,
label: 'project.taskCenter.uiDefaultFile', label: t('project.taskCenter.uiDefaultFile'),
}, },
[TaskCenterEnum.LOAD_TEST]: { [TaskCenterEnum.LOAD_TEST]: {
value: TaskCenterEnum.LOAD_TEST, value: TaskCenterEnum.LOAD_TEST,
label: 'project.taskCenter.performanceTest', label: t('project.taskCenter.performanceTest'),
}, },
[TaskCenterEnum.TEST_PLAN]: { [TaskCenterEnum.TEST_PLAN]: {
value: TaskCenterEnum.TEST_PLAN, value: TaskCenterEnum.TEST_PLAN,
label: 'project.taskCenter.testPlan', label: t('project.taskCenter.testPlan'),
}, },
}; };
export const ordAndProjectColumn: MsTableColumn = [ export function getOrgColumns(): MsTableColumnData {
{ const config: MsTableColumnData = {
title: 'project.belongOrganization', title: 'project.belongOrganization',
dataIndex: 'organizationName', dataIndex: 'organizationIds',
slotName: 'organizationName', slotName: 'organizationName',
titleSlotName: 'orgFilterName',
showTooltip: true,
showDrag: true, showDrag: true,
width: 200, width: 200,
showInTable: true, showInTable: true,
}, };
{ if (licenseStore.hasLicense()) {
config.filterConfig = {
mode: 'remote',
remoteMethod: FilterRemoteMethodsEnum.SYSTEM_ORGANIZATION_LIST,
placeholderText: t('project.taskCenter.filterOrgPlaceholderText'),
};
}
return config;
}
export function getProjectColumns(key: TableKeyEnum): MsTableColumnData {
const systemKey = [
TableKeyEnum.TASK_API_CASE_SYSTEM,
TableKeyEnum.TASK_SCHEDULE_TASK_API_IMPORT_SYSTEM,
TableKeyEnum.TASK_SCHEDULE_TASK_API_SCENARIO_SYSTEM,
];
const filterKeyPermission = systemKey.includes(key)
? hasAnyPermission(['SYSTEM_ORGANIZATION_PROJECT:READ'])
: hasAnyPermission(['ORGANIZATION_PROJECT:READ']);
const remoteMethod = systemKey.includes(key)
? FilterRemoteMethodsEnum.SYSTEM_PROJECT_LIST
: FilterRemoteMethodsEnum.SYSTEM_ORGANIZATION_PROJECT;
const config: MsTableColumnData = {
title: 'project.belongProject', title: 'project.belongProject',
dataIndex: 'projectName', dataIndex: 'projectIds',
slotName: 'projectName', slotName: 'projectName',
titleSlotName: 'projectFilterName',
showTooltip: true,
showDrag: true, showDrag: true,
width: 200, width: 200,
showInTable: true, showInTable: true,
}, };
]; if (filterKeyPermission && remoteMethod) {
config.filterConfig = {
mode: 'remote',
loadOptionParams: {
organizationId: appStore.currentOrgId,
},
remoteMethod,
placeholderText: t('project.taskCenter.filterProPlaceholderText'),
};
}
return config;
}
export default {}; export default {};