feat(接口测试): 接口用例参数变更权限补充

This commit is contained in:
xinxin.wu 2024-08-09 15:47:49 +08:00 committed by 刘瑞斌
parent 4ac754fb5a
commit 545077d397
2 changed files with 50 additions and 34 deletions

View File

@ -12,42 +12,54 @@
<template #title> <template #title>
<div class="flex w-full items-center justify-between"> <div class="flex w-full items-center justify-between">
<div>{{ t('case.apiAndCaseDiff') }}</div> <div>{{ t('case.apiAndCaseDiff') }}</div>
<div class="flex items-center text-[14px]"> <div class="flex items-center text-[14px]">
<div v-if="showSyncConfig" class="-mt-[2px] mr-[8px]"> {{ t('case.syncItem') }}</div> <div v-if="hasAnyPermission(['PROJECT_API_DEFINITION_CASE:READ+UPDATE'])" class="flex items-center">
<a-checkbox-group v-if="showSyncConfig" v-model="checkType"> <div v-if="showSyncConfig" class="-mt-[2px] mr-[8px]"> {{ t('case.syncItem') }}</div>
<a-checkbox v-for="item of checkList" :key="item.value" :value="item.value"> <a-checkbox-group v-if="showSyncConfig" v-model="checkType">
<div class="flex items-center"> <a-checkbox v-for="item of checkList" :key="item.value" :value="item.value">
{{ item.label }} <div class="flex items-center">
<a-tooltip v-if="item.tooltip" :content="item.tooltip" position="top"> {{ item.label }}
<div class="flex items-center"> <a-tooltip v-if="item.tooltip" :content="item.tooltip" position="top">
<icon-question-circle <div class="flex items-center">
class="ml-[4px] text-[var(--color-text-4)] hover:text-[rgb(var(--primary-5))]" <icon-question-circle
size="16" class="ml-[4px] text-[var(--color-text-4)] hover:text-[rgb(var(--primary-5))]"
/> size="16"
</div> />
</a-tooltip> </div>
</div> </a-tooltip>
</a-checkbox> </div>
</a-checkbox-group> </a-checkbox>
<a-divider v-if="showSyncConfig" direction="vertical" :margin="0" class="!mr-[8px]" /> </a-checkbox-group>
<a-switch <a-divider v-if="showSyncConfig" direction="vertical" :margin="0" class="!mr-[8px]" />
v-model:model-value="form.ignoreApiChange" <a-switch
:before-change="(val) => changeIgnore(val)" v-model:model-value="form.ignoreApiChange"
size="small" :before-change="(val) => changeIgnore(val)"
/> size="small"
<div class="ml-[8px]">{{ t('case.ignoreAllChange') }}</div> />
<a-divider direction="vertical" :margin="8"></a-divider> <div class="ml-[8px]">{{ t('case.ignoreAllChange') }}</div>
<a-switch v-if="showSyncConfig" v-model:model-value="form.deleteRedundantParam" size="small" /> <a-divider direction="vertical" :margin="8"></a-divider>
<div v-if="showSyncConfig" class="ml-[8px] font-normal text-[var(--color-text-1)]">{{ <a-switch v-if="showSyncConfig" v-model:model-value="form.deleteRedundantParam" size="small" />
t('case.deleteNotCorrespondValue') <div v-if="showSyncConfig" class="ml-[8px] font-normal text-[var(--color-text-1)]">
}}</div> {{ t('case.deleteNotCorrespondValue') }}
<a-divider v-if="showSyncConfig" direction="vertical" :margin="0" class="!ml-[8px]" /> </div>
<a-divider v-if="showSyncConfig" direction="vertical" :margin="0" class="!ml-[8px]" />
</div>
<a-button class="mx-[12px]" type="secondary" @click="cancel">{{ t('common.cancel') }}</a-button> <a-button class="mx-[12px]" type="secondary" @click="cancel">{{ t('common.cancel') }}</a-button>
<a-button v-if="showSyncConfig" class="mr-[12px]" type="outline" @click="clearThisChangeHandler"> <a-button
v-if="showSyncConfig && hasAnyPermission(['PROJECT_API_DEFINITION_CASE:READ+UPDATE'])"
class="mr-[12px]"
type="outline"
@click="clearThisChangeHandler"
>
{{ t('case.ignoreThisChange') }} {{ t('case.ignoreThisChange') }}
</a-button> </a-button>
<a-button type="primary" :loading="syncLoading" :disabled="!checkType.length" @click="confirmSync"> <a-button type="primary" :loading="syncLoading" :disabled="!checkType.length" @click="confirmSync">
{{ showSyncConfig ? t('case.apiSyncChange') : t('common.confirm') }} {{
showSyncConfig && hasAnyPermission(['PROJECT_API_DEFINITION_CASE:READ+UPDATE'])
? t('case.apiSyncChange')
: t('common.confirm')
}}
</a-button> </a-button>
</div> </div>
</div> </div>
@ -113,6 +125,7 @@
ignoreEveryTimeChange, ignoreEveryTimeChange,
} from '@/api/modules/api-test/management'; } from '@/api/modules/api-test/management';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import { hasAnyPermission } from '@/utils/permission';
import { EnableKeyValueParam, ExecuteRequestCommonParam } from '@/models/apiTest/common'; import { EnableKeyValueParam, ExecuteRequestCommonParam } from '@/models/apiTest/common';
import type { diffSyncParams, syncItem } from '@/models/apiTest/management'; import type { diffSyncParams, syncItem } from '@/models/apiTest/management';
@ -326,7 +339,11 @@
// //
async function confirmSync() { async function confirmSync() {
if (!caseDetail.value.inconsistentWithApi || form.value.ignoreApiChange) { if (
!caseDetail.value.inconsistentWithApi ||
form.value.ignoreApiChange ||
!hasAnyPermission(['PROJECT_API_DEFINITION_CASE:READ+UPDATE'])
) {
cancel(); cancel();
return; return;
} }

View File

@ -148,10 +148,9 @@
if (hasOperationPermission.value) { if (hasOperationPermission.value) {
return 250; return 250;
} }
if (hasAnyPermission(['SYSTEM_ORGANIZATION_PROJECT:READ+RECOVER'])) { if (hasAnyPermission(['SYSTEM_ORGANIZATION_PROJECT:READ'])) {
return 100; return 100;
} }
return 50;
}); });
const organizationColumns: MsTableColumn = [ const organizationColumns: MsTableColumn = [