fix(全局): bug 修复

This commit is contained in:
baiqi 2024-05-29 11:47:03 +08:00 committed by 刘瑞斌
parent 557b542ec9
commit 5be8bcd6df
16 changed files with 66 additions and 57 deletions

View File

@ -147,7 +147,7 @@
Message.success(t('personal.switchOrgSuccess')); Message.success(t('personal.switchOrgSuccess'));
personalMenusVisible.value = false; personalMenusVisible.value = false;
orgKeyword.value = ''; orgKeyword.value = '';
await userStore.checkIsLogin(); await userStore.checkIsLogin(true);
appStore.hideLoading(); appStore.hideLoading();
router.replace({ router.replace({
name: getFirstRouteNameByPermission(router.getRoutes()), name: getFirstRouteNameByPermission(router.getRoutes()),

View File

@ -345,7 +345,7 @@
(e: 'pageSizeChange', value: number): void; (e: 'pageSizeChange', value: number): void;
(e: 'rowNameChange', value: TableData, cb: (v: boolean) => void): void; (e: 'rowNameChange', value: TableData, cb: (v: boolean) => void): void;
(e: 'rowSelectChange', key: string): void; (e: 'rowSelectChange', key: string): void;
(e: 'selectAllChange', value: SelectAllEnum): void; (e: 'selectAllChange', value: SelectAllEnum, onlyCurrent: boolean): void;
(e: 'dragChange', value: DragSortParams): void; (e: 'dragChange', value: DragSortParams): void;
(e: 'sorterChange', value: { [key: string]: string }): void; (e: 'sorterChange', value: { [key: string]: string }): void;
(e: 'expand', record: TableData): void | Promise<any>; (e: 'expand', record: TableData): void | Promise<any>;
@ -485,8 +485,8 @@
} }
// change // change
const handleSelectAllChange = (v: SelectAllEnum) => { const handleSelectAllChange = (v: SelectAllEnum, onlyCurrent: boolean) => {
emit('selectAllChange', v); emit('selectAllChange', v, onlyCurrent);
}; };
// change // change
const rowSelectChange = (key: string) => { const rowSelectChange = (key: string) => {

View File

@ -36,7 +36,7 @@
const { t } = useI18n(); const { t } = useI18n();
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'change', value: SelectAllEnum): void; (e: 'change', value: SelectAllEnum, onlyCurrent: boolean): void;
}>(); }>();
const props = withDefaults( const props = withDefaults(
@ -81,20 +81,20 @@
); );
}); });
const handleSelect = (v: SelectAllEnum) => { const handleSelect = (v: SelectAllEnum, onlyCurrent = true) => {
if ( if (
(selectAllStatus.value === SelectAllEnum.ALL && (selectAllStatus.value === SelectAllEnum.ALL &&
v === SelectAllEnum.NONE && v === SelectAllEnum.NONE &&
props.excludeKeys.length < props.total) || props.excludeKeys.length < props.total) ||
(selectAllStatus.value === SelectAllEnum.ALL && v === SelectAllEnum.CURRENT) (selectAllStatus.value === SelectAllEnum.ALL && v === SelectAllEnum.CURRENT && !onlyCurrent)
) { ) {
// //
// // ()
selectAllStatus.value = SelectAllEnum.ALL; selectAllStatus.value = SelectAllEnum.ALL;
} else { } else {
selectAllStatus.value = v; selectAllStatus.value = v;
} }
emit('change', v); emit('change', v, onlyCurrent);
}; };
function hasUnselectedChildren( function hasUnselectedChildren(
@ -113,7 +113,7 @@
const handleCheckChange = () => { const handleCheckChange = () => {
if (hasUnselectedChildren(props.currentData, props.selectedKeys, props.rowKey)) { if (hasUnselectedChildren(props.currentData, props.selectedKeys, props.rowKey)) {
// //
handleSelect(SelectAllEnum.CURRENT); handleSelect(SelectAllEnum.CURRENT, false);
} else { } else {
// //
handleSelect(SelectAllEnum.NONE); handleSelect(SelectAllEnum.NONE);

View File

@ -419,7 +419,7 @@ export default function useTableProps<T>(
}, },
// 表格SelectAll change // 表格SelectAll change
selectAllChange: (v: SelectAllEnum) => { selectAllChange: (v: SelectAllEnum, onlyCurrent: boolean) => {
const { data, rowKey } = propsRes.value; const { data, rowKey } = propsRes.value;
if (v === SelectAllEnum.NONE) { if (v === SelectAllEnum.NONE) {
// 清空选中项 // 清空选中项
@ -437,10 +437,10 @@ export default function useTableProps<T>(
v === SelectAllEnum.NONE && v === SelectAllEnum.NONE &&
propsRes.value.msPagination && propsRes.value.msPagination &&
propsRes.value.excludeKeys.size < propsRes.value.msPagination.total) || propsRes.value.excludeKeys.size < propsRes.value.msPagination.total) ||
(propsRes.value.selectorStatus === SelectAllEnum.ALL && v === SelectAllEnum.CURRENT) (propsRes.value.selectorStatus === SelectAllEnum.ALL && v === SelectAllEnum.CURRENT && !onlyCurrent)
) { ) {
// 如果当前是全选所有页状态,且是取消选中当前页操作,且排除项小于总数,则保持跨页全选状态 // 如果当前是全选所有页状态,且是取消选中当前页操作,且排除项小于总数,则保持跨页全选状态
// 如果当前是全选所有页状态,且是选中当前页操作,则保持跨页全选状态 // 如果当前是全选所有页状态,且是选中当前页操作(是点击全选的多选框,非下拉菜单全选当前页),则保持跨页全选状态
propsRes.value.selectorStatus = SelectAllEnum.ALL; propsRes.value.selectorStatus = SelectAllEnum.ALL;
} else { } else {
propsRes.value.selectorStatus = v; propsRes.value.selectorStatus = v;

View File

@ -228,7 +228,7 @@
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(error); console.log(error);
} finally { } finally {
await userStore.checkIsLogin(); await userStore.checkIsLogin(true);
appStore.hideLoading(); appStore.hideLoading();
router.replace({ router.replace({
name: getFirstRouteNameByPermission(router.getRoutes()), name: getFirstRouteNameByPermission(router.getRoutes()),

View File

@ -209,11 +209,11 @@ const useUserStore = defineStore('user', {
console.log(error); console.log(error);
} }
}, },
async checkIsLogin() { async checkIsLogin(forceSet = false) {
const { isLoginPage } = useUser(); const { isLoginPage } = useUser();
const router = useRouter(); const router = useRouter();
const appStore = useAppStore(); const appStore = useAppStore();
const isLogin = await this.isLogin(true); const isLogin = await this.isLogin(forceSet);
if (isLogin && appStore.currentProjectId !== 'no_such_project') { if (isLogin && appStore.currentProjectId !== 'no_such_project') {
// 当前为登陆状态,且已经选择了项目,初始化当前项目配置 // 当前为登陆状态,且已经选择了项目,初始化当前项目配置
try { try {

View File

@ -42,7 +42,7 @@
<a-form-item :label="t('apiTestManagement.belongModule')"> <a-form-item :label="t('apiTestManagement.belongModule')">
<a-tree-select <a-tree-select
v-model:modelValue="importForm.moduleId" v-model:modelValue="importForm.moduleId"
:data="props.moduleTree" :data="innerModuleTree"
class="w-[436px]" class="w-[436px]"
:field-names="{ title: 'name', key: 'id', children: 'children' }" :field-names="{ title: 'name', key: 'id', children: 'children' }"
:draggable="false" :draggable="false"
@ -248,7 +248,7 @@
<a-form-item :label="t('apiTestManagement.belongModule')"> <a-form-item :label="t('apiTestManagement.belongModule')">
<a-tree-select <a-tree-select
v-model:modelValue="importForm.moduleId" v-model:modelValue="importForm.moduleId"
:data="props.moduleTree" :data="innerModuleTree"
class="w-[500px]" class="w-[500px]"
:field-names="{ title: 'name', key: 'id', children: 'children' }" :field-names="{ title: 'name', key: 'id', children: 'children' }"
allow-search allow-search
@ -361,6 +361,7 @@
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import useUserStore from '@/store/modules/user'; import useUserStore from '@/store/modules/user';
import { filterTree, TreeNode } from '@/utils';
import type { ImportApiDefinitionParams, ImportApiDefinitionRequest } from '@/models/apiTest/management'; import type { ImportApiDefinitionParams, ImportApiDefinitionRequest } from '@/models/apiTest/management';
import type { ModuleTreeNode } from '@/models/common'; import type { ModuleTreeNode } from '@/models/common';
@ -381,6 +382,7 @@
const userStore = useUserStore(); const userStore = useUserStore();
const visible = useVModel(props, 'visible', emit); const visible = useVModel(props, 'visible', emit);
const innerModuleTree = ref<TreeNode<ModuleTreeNode>[]>([]);
const importType = ref<'file' | 'time'>('file'); const importType = ref<'file' | 'time'>('file');
const platformList = [ const platformList = [
{ {
@ -415,6 +417,7 @@
(val) => { (val) => {
if (val) { if (val) {
importForm.value.moduleId = props.activeModule !== 'all' ? props.activeModule : ''; importForm.value.moduleId = props.activeModule !== 'all' ? props.activeModule : '';
innerModuleTree.value = filterTree(props.moduleTree, (node) => node.type === 'MODULE');
} }
}, },
{ {

View File

@ -394,6 +394,13 @@
filterSlotName: FilterSlotNameEnum.API_TEST_API_REQUEST_METHODS, filterSlotName: FilterSlotNameEnum.API_TEST_API_REQUEST_METHODS,
}, },
}, },
{
title: 'apiTestManagement.path',
dataIndex: 'path',
showTooltip: true,
width: 200,
showDrag: true,
},
{ {
title: 'apiTestManagement.apiStatus', title: 'apiTestManagement.apiStatus',
dataIndex: 'status', dataIndex: 'status',
@ -405,13 +412,6 @@
width: 130, width: 130,
showDrag: true, showDrag: true,
}, },
{
title: 'apiTestManagement.path',
dataIndex: 'path',
showTooltip: true,
width: 200,
showDrag: true,
},
{ {
title: 'apiTestManagement.belongModule', title: 'apiTestManagement.belongModule',
dataIndex: 'moduleName', dataIndex: 'moduleName',

View File

@ -225,7 +225,7 @@
import useModal from '@/hooks/useModal'; import useModal from '@/hooks/useModal';
import useTableStore from '@/hooks/useTableStore'; import useTableStore from '@/hooks/useTableStore';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import { operationWidth } from '@/utils'; import { characterLimit, operationWidth } from '@/utils';
import { hasAnyPermission } from '@/utils/permission'; import { hasAnyPermission } from '@/utils/permission';
import { ApiDefinitionMockDetail } from '@/models/apiTest/management'; import { ApiDefinitionMockDetail } from '@/models/apiTest/management';
@ -441,7 +441,7 @@
* 删除接口 * 删除接口
*/ */
function removeMock(record?: ApiDefinitionMockDetail, isBatch?: boolean, params?: BatchActionQueryParams) { function removeMock(record?: ApiDefinitionMockDetail, isBatch?: boolean, params?: BatchActionQueryParams) {
let title = t('apiTestManagement.confirmDelete', { name: record?.name }); let title = t('apiTestManagement.confirmDelete', { name: characterLimit(record?.name) });
let selectIds = [record?.id || '']; let selectIds = [record?.id || ''];
if (isBatch) { if (isBatch) {
title = t('mockManagement.batchDeleteMockTip', { title = t('mockManagement.batchDeleteMockTip', {

View File

@ -220,6 +220,13 @@
width: 140, width: 140,
showDrag: true, showDrag: true,
}, },
{
title: 'apiTestManagement.path',
dataIndex: 'path',
showTooltip: true,
width: 200,
showDrag: true,
},
{ {
title: 'apiTestManagement.apiStatus', title: 'apiTestManagement.apiStatus',
dataIndex: 'status', dataIndex: 'status',
@ -228,13 +235,6 @@
width: 130, width: 130,
showDrag: true, showDrag: true,
}, },
{
title: 'apiTestManagement.path',
dataIndex: 'path',
showTooltip: true,
width: 200,
showDrag: true,
},
{ {
title: 'common.tag', title: 'common.tag',
dataIndex: 'tags', dataIndex: 'tags',

View File

@ -235,6 +235,12 @@
titleSlotName: 'methodFilter', titleSlotName: 'methodFilter',
width: 140, width: 140,
}, },
{
title: 'apiTestManagement.path',
dataIndex: 'path',
showTooltip: true,
width: 200,
},
{ {
title: 'apiTestManagement.apiStatus', title: 'apiTestManagement.apiStatus',
dataIndex: 'status', dataIndex: 'status',
@ -242,12 +248,6 @@
titleSlotName: 'statusFilter', titleSlotName: 'statusFilter',
width: 130, width: 130,
}, },
{
title: 'apiTestManagement.path',
dataIndex: 'path',
showTooltip: true,
width: 200,
},
{ {
title: 'common.tag', title: 'common.tag',
dataIndex: 'tags', dataIndex: 'tags',

View File

@ -878,6 +878,7 @@
const realStep = findNodeByKey<ScenarioStepItem>(steps.value, step.uniqueId, 'uniqueId'); const realStep = findNodeByKey<ScenarioStepItem>(steps.value, step.uniqueId, 'uniqueId');
if (id && realStep) { if (id && realStep) {
realStep.csvIds = realStep.csvIds.filter((item: string) => item !== id); realStep.csvIds = realStep.csvIds.filter((item: string) => item !== id);
scenario.value.unSaved = true;
} }
} }

View File

@ -26,8 +26,10 @@
@stop-debug="handleStopExecute" @stop-debug="handleStopExecute"
/> />
<a-button <a-button
v-permission=" v-if="
activeScenarioTab.isNew ? ['PROJECT_API_SCENARIO:READ+ADD'] : ['PROJECT_API_SCENARIO:READ+UPDATE'] activeScenarioTab.isNew
? hasAnyPermission(['PROJECT_API_SCENARIO:READ+ADD'])
: hasAnyPermission(['PROJECT_API_SCENARIO:READ+UPDATE'])
" "
type="primary" type="primary"
:loading="saveLoading" :loading="saveLoading"
@ -132,6 +134,7 @@
import router from '@/router'; import router from '@/router';
import useAppStore from '@/store/modules/app'; import useAppStore from '@/store/modules/app';
import { filterTree, getGenerateId, mapTree } from '@/utils'; import { filterTree, getGenerateId, mapTree } from '@/utils';
import { hasAnyPermission } from '@/utils/permission';
import { RequestResult } from '@/models/apiTest/common'; import { RequestResult } from '@/models/apiTest/common';
import { import {

View File

@ -71,7 +71,7 @@
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(error); console.log(error);
} finally { } finally {
await userStore.checkIsLogin(); await userStore.checkIsLogin(true);
appStore.hideLoading(); appStore.hideLoading();
router.replace({ router.replace({
name: getFirstRouteNameByPermission(router.getRoutes()), name: getFirstRouteNameByPermission(router.getRoutes()),

View File

@ -18,13 +18,13 @@
> >
<div ref="robotListRef" class="robot-list"> <div ref="robotListRef" class="robot-list">
<div v-for="robot of botList" :key="robot.id" class="robot-card"> <div v-for="robot of botList" :key="robot.id" class="robot-card">
<div class="flex items-center"> <div class="flex">
<MsIcon <MsIcon
:type="IconMap[robot.platform]" :type="IconMap[robot.platform]"
class="mr-[8px] h-[40px] w-[40px] bg-[var(--color-text-n9)] p-[8px] text-[rgb(var(--primary-5))]" class="mr-[8px] h-[40px] w-[40px] bg-[var(--color-text-n9)] p-[8px] text-[rgb(var(--primary-5))]"
/> />
<div class="flex flex-col"> <div class="flex flex-1 flex-col">
<div class="font-medium text-[var(--color-text-1)]">{{ robot.name }}</div> <div class="break-all font-medium text-[var(--color-text-1)]">{{ robot.name }}</div>
<div <div
v-if="['IN_SITE', 'MAIL'].includes(robot.platform)" v-if="['IN_SITE', 'MAIL'].includes(robot.platform)"
class="text-[12px] leading-[16px] text-[var(--color-text-4)]" class="text-[12px] leading-[16px] text-[var(--color-text-4)]"
@ -38,22 +38,24 @@
mini mini
:content="robot.createUser" :content="robot.createUser"
> >
<span class="one-line-text" style="max-width: 200px">{{ robot.createUser }}</span></a-tooltip <span class="one-line-text" style="max-width: 200px">{{ robot.createUser }}</span>
> </a-tooltip>
<span v-else class="one-line-text" style="max-width: 200px">{{ robot.createUser }}</span> <span v-else class="one-line-text" style="max-width: 200px">{{ robot.createUser }}</span>
<span class="mr-[16px]">{{ <span class="mr-[16px]">
`${t('project.messageManagement.createAt')} ${dayjs(robot.createTime).format( {{
'YYYY-MM-DD HH:mm:ss' `${t('project.messageManagement.createAt')} ${dayjs(robot.createTime).format(
)}` 'YYYY-MM-DD HH:mm:ss'
}}</span> )}`
}}
</span>
<a-tooltip <a-tooltip
v-if="translateTextToPX(robot.updateUser) > 200" v-if="translateTextToPX(robot.updateUser) > 200"
position="tl" position="tl"
mini mini
:content="robot.updateUser" :content="robot.updateUser"
> >
<span class="one-line-text" style="max-width: 200px">{{ robot.updateUser }}</span></a-tooltip <span class="one-line-text" style="max-width: 200px">{{ robot.updateUser }}</span>
> </a-tooltip>
<span v-else class="one-line-text" style="max-width: 200px">{{ robot.updateUser }}</span> <span v-else class="one-line-text" style="max-width: 200px">{{ robot.updateUser }}</span>
{{ {{
` ${t('project.messageManagement.updateAt')} ${dayjs(robot.updateTime).format( ` ${t('project.messageManagement.updateAt')} ${dayjs(robot.updateTime).format(
@ -475,7 +477,7 @@
function delRobot(robot: RobotItem) { function delRobot(robot: RobotItem) {
openModal({ openModal({
type: 'error', type: 'error',
title: t('project.messageManagement.deleteTitle', { name: robot.name }), title: t('project.messageManagement.deleteTitle', { name: characterLimit(robot.name) }),
content: t('project.messageManagement.deleteContent'), content: t('project.messageManagement.deleteContent'),
okText: t('common.confirmDelete'), okText: t('common.confirmDelete'),
cancelText: t('common.cancel'), cancelText: t('common.cancel'),

View File

@ -36,7 +36,7 @@ export async function enterProject(projectId: string, organizationId?: string) {
projectId, projectId,
userId: userStore.id || '', userId: userStore.id || '',
}); });
await userStore.checkIsLogin(); await userStore.checkIsLogin(true);
// 跳转到项目页面 // 跳转到项目页面
router.replace({ router.replace({
name: getFirstRouteNameByPermission(router.getRoutes()), name: getFirstRouteNameByPermission(router.getRoutes()),