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

View File

@ -2,7 +2,7 @@
<div> <div>
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div v-if="showType === 'link'" class="flex"> <div v-if="showType === 'link'" class="flex">
<a-tooltip> <a-tooltip :disabled="linkPropsRes.data.length ? true : false">
<template #content> <template #content>
{{ t('caseManagement.featureCase.noAssociatedDefect') }} {{ t('caseManagement.featureCase.noAssociatedDefect') }}
<span v-permission="['PROJECT_BUG:READ+ADD']" class="text-[rgb(var(--primary-4))]" @click="createDefect">{{ <span v-permission="['PROJECT_BUG:READ+ADD']" class="text-[rgb(var(--primary-4))]" @click="createDefect">{{
@ -10,7 +10,8 @@
}}</span> }}</span>
</template> </template>
<a-button <a-button
v-permission="hasAnyPermission(['FUNCTIONAL_CASE:READ+UPDATE'])" v-permission="['FUNCTIONAL_CASE:READ+UPDATE']"
:disabled="linkPropsRes.data.length ? false : true"
class="mr-3" class="mr-3"
type="primary" type="primary"
@click="linkDefect" @click="linkDefect"
@ -110,13 +111,20 @@
<template v-if="(keyword || '').trim() === ''" #empty> <template v-if="(keyword || '').trim() === ''" #empty>
<div class="flex w-full items-center justify-center"> <div class="flex w-full items-center justify-center">
{{ t('caseManagement.featureCase.tableNoDataWidthComma') }} {{ t('caseManagement.featureCase.tableNoDataWidthComma') }}
<span v-permission="['FUNCTIONAL_CASE:READ+UPDATE', 'PROJECT_BUG:READ+ADD']">{{ <span
t('caseManagement.featureCase.please') v-if="
}}</span> !linkPropsRes.data.length && hasAnyPermission(['FUNCTIONAL_CASE:READ+UPDATE', 'PROJECT_BUG:READ+ADD'])
<MsButton v-permission="['FUNCTIONAL_CASE:READ+UPDATE']" class="ml-[8px]" @click="linkDefect"> "
>{{ 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') }} {{ t('caseManagement.featureCase.linkDefect') }}
</MsButton> </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') t('caseManagement.featureCase.or')
}}</span> }}</span>
<MsButton v-permission="['PROJECT_BUG:READ+ADD']" class="ml-[8px]" @click="createDefect"> <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; currentDefaultValue = item.defaultValue;
// 处理多选情况 // 处理多选情况
} else if (multipleType.includes(item.type)) { } else if (multipleType.includes(item.type)) {
const tempValue = JSON.parse(item.defaultValue);
if (item.type !== 'MULTIPLE_INPUT' && !item.type.includes('MEMBER')) { if (item.type !== 'MULTIPLE_INPUT' && !item.type.includes('MEMBER')) {
const tempValue = JSON.parse(item.defaultValue);
const optionsIds = item.options?.map((e: any) => e.value); const optionsIds = item.options?.map((e: any) => e.value);
currentDefaultValue = optionsIds.filter((e: any) => tempValue.includes(e)); currentDefaultValue = optionsIds.filter((e: any) => tempValue.includes(e));
// 多选成员 // 多选成员
@ -199,7 +199,16 @@ export function initFormCreate(customFields: CustomAttributes[], permission: str
value: userStore.id || '', 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 { } else {
currentDefaultValue = JSON.parse(item.defaultValue); currentDefaultValue = JSON.parse(item.defaultValue);
} }