fix(用例管理): 修复成员多选多种情况不回显问题

This commit is contained in:
xinxin.wu 2024-03-14 13:31:26 +08:00 committed by Craftsman
parent 755eca4225
commit 84f84cde69
3 changed files with 27 additions and 10 deletions

View File

@ -212,7 +212,6 @@
import MsButton from '@/components/pure/ms-button/index.vue';
import MsCard from '@/components/pure/ms-card/index.vue';
import { MsExportDrawerMap, MsExportDrawerOption } from '@/components/pure/ms-export-drawer/types';
import MsBaseTable from '@/components/pure/ms-table/base-table.vue';
import { BatchActionParams, BatchActionQueryParams, MsTableColumn } from '@/components/pure/ms-table/type';
import useTable from '@/components/pure/ms-table/useTable';
import MsTableMoreAction from '@/components/pure/ms-table-more-action/index.vue';
@ -255,6 +254,7 @@
const { t } = useI18n();
const MsExportDrawer = defineAsyncComponent(() => import('@/components/pure/ms-export-drawer/index.vue'));
const DeleteModal = defineAsyncComponent(() => import('./components/deleteModal.vue'));
const MsBaseTable = defineAsyncComponent(() => import('@/components/pure/ms-table/base-table.vue'));
const tableStore = useTableStore();
const appStore = useAppStore();

View File

@ -2,7 +2,7 @@
<div>
<div class="flex items-center justify-between">
<div v-if="showType === 'link'" class="flex">
<a-tooltip>
<a-tooltip :disabled="linkPropsRes.data.length ? true : false">
<template #content>
{{ t('caseManagement.featureCase.noAssociatedDefect') }}
<span v-permission="['PROJECT_BUG:READ+ADD']" class="text-[rgb(var(--primary-4))]" @click="createDefect">{{
@ -10,7 +10,8 @@
}}</span>
</template>
<a-button
v-permission="hasAnyPermission(['FUNCTIONAL_CASE:READ+UPDATE'])"
v-permission="['FUNCTIONAL_CASE:READ+UPDATE']"
:disabled="linkPropsRes.data.length ? false : true"
class="mr-3"
type="primary"
@click="linkDefect"
@ -110,13 +111,20 @@
<template v-if="(keyword || '').trim() === ''" #empty>
<div class="flex w-full items-center justify-center">
{{ t('caseManagement.featureCase.tableNoDataWidthComma') }}
<span v-permission="['FUNCTIONAL_CASE:READ+UPDATE', 'PROJECT_BUG:READ+ADD']">{{
t('caseManagement.featureCase.please')
}}</span>
<MsButton v-permission="['FUNCTIONAL_CASE:READ+UPDATE']" class="ml-[8px]" @click="linkDefect">
<span
v-if="
!linkPropsRes.data.length && hasAnyPermission(['FUNCTIONAL_CASE:READ+UPDATE', 'PROJECT_BUG:READ+ADD'])
"
>{{ t('caseManagement.featureCase.please') }}</span
>
<MsButton
v-if="linkPropsRes.data.length && hasAnyPermission(['FUNCTIONAL_CASE:READ+UPDATE'])"
class="ml-[8px]"
@click="linkDefect"
>
{{ t('caseManagement.featureCase.linkDefect') }}
</MsButton>
<span v-permission="['FUNCTIONAL_CASE:READ+UPDATE', 'PROJECT_BUG:READ+ADD']">{{
<span v-if="linkPropsRes.data.length && hasAnyPermission(['PROJECT_BUG:READ+ADD'])">{{
t('caseManagement.featureCase.or')
}}</span>
<MsButton v-permission="['PROJECT_BUG:READ+ADD']" class="ml-[8px]" @click="createDefect">

View File

@ -185,8 +185,8 @@ export function initFormCreate(customFields: CustomAttributes[], permission: str
currentDefaultValue = item.defaultValue;
// 处理多选情况
} else if (multipleType.includes(item.type)) {
const tempValue = JSON.parse(item.defaultValue);
if (item.type !== 'MULTIPLE_INPUT' && !item.type.includes('MEMBER')) {
const tempValue = JSON.parse(item.defaultValue);
const optionsIds = item.options?.map((e: any) => e.value);
currentDefaultValue = optionsIds.filter((e: any) => tempValue.includes(e));
// 多选成员
@ -199,7 +199,16 @@ export function initFormCreate(customFields: CustomAttributes[], permission: str
value: userStore.id || '',
},
];
currentDefaultValue = tempValue;
// 多选成员没有选择CREATE_USER
if (Array.isArray(item.defaultValue) && !item.defaultValue.includes('CREATE_USER')) {
currentDefaultValue = [];
// 选择了创建人
} else if (item.defaultValue.includes('CREATE_USER')) {
currentDefaultValue = [userStore.id];
// 已选择成员
} else {
currentDefaultValue = JSON.parse(item.defaultValue);
}
} else {
currentDefaultValue = JSON.parse(item.defaultValue);
}