fix: 权限相关严重bug修改

This commit is contained in:
RubyLiu 2024-02-20 18:35:50 +08:00 committed by Craftsman
parent 7ab54e66ac
commit 15ff97a4cb
12 changed files with 69 additions and 107 deletions

View File

@ -7,14 +7,12 @@
</a-radio> </a-radio>
</a-radio-group> </a-radio-group>
</div> </div>
<paramsTable <div v-if="innerParams.type === 'jsonPath'">
v-model:params="innerParams.responseHeader" <MsJsonPathPicker data="" />
:selectable="false" </div>
:columns="columns" <div v-else-if="innerParams.type === 'xPath'">
:scroll="{ minWidth: '700px' }" <MsXPathPicker :xml-string="innerParams.response" />
:default-param-item="defaultParamItem" </div>
@change="handleParamTableChange"
/>
</div> </div>
</template> </template>
@ -22,6 +20,8 @@
import { defineModel } from 'vue'; import { defineModel } from 'vue';
import { statusCodeOptions } from '@/components/pure/ms-advance-filter/index'; import { statusCodeOptions } from '@/components/pure/ms-advance-filter/index';
import MsJsonPathPicker from '@/components/pure/ms-jsonpath-picker/index.vue';
import MsXPathPicker from '@/components/pure/ms-jsonpath-picker/xpath.vue';
import paramsTable, { type ParamTableColumn } from '@/views/api-test/components/paramTable.vue'; import paramsTable, { type ParamTableColumn } from '@/views/api-test/components/paramTable.vue';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
@ -37,28 +37,6 @@
}>(); }>();
const { t } = useI18n(); const { t } = useI18n();
const defaultParamItem = {
responseHeader: '',
matchCondition: '',
matchValue: '',
enable: true,
};
const responseHeaderOption = [
{ label: 'Accept', value: 'accept' },
{ label: 'Accept-Encoding', value: 'acceptEncoding' },
{ label: 'Accept-Language', value: 'acceptLanguage' },
{ label: 'Cache-Control', value: 'cacheControl' },
{ label: 'Content-Type', value: 'contentType' },
{ label: 'Content-Length', value: 'contentLength' },
{ label: 'User-Agent', value: 'userAgent' },
{ label: 'Referer', value: 'referer' },
{ label: 'Cookie', value: 'cookie' },
{ label: 'Authorization', value: 'authorization' },
{ label: 'If-None-Match', value: 'ifNoneMatch' },
{ label: 'If-Modified-Since', value: 'ifModifiedSince' },
];
const responseRadios = [ const responseRadios = [
{ label: 'ms.assertion.jsonPath', value: 'jsonPath' }, { label: 'ms.assertion.jsonPath', value: 'jsonPath' },
{ label: 'ms.assertion.xpath', value: 'xPath' }, { label: 'ms.assertion.xpath', value: 'xPath' },
@ -66,44 +44,4 @@
{ label: 'ms.assertion.regular', value: 'regular' }, { label: 'ms.assertion.regular', value: 'regular' },
{ label: 'ms.assertion.script', value: 'script' }, { label: 'ms.assertion.script', value: 'script' },
]; ];
const columns: ParamTableColumn[] = [
{
title: 'ms.assertion.responseHeader', //
dataIndex: 'responseHeader',
slotName: 'responseHeader',
showInTable: true,
showDrag: true,
options: responseHeaderOption,
},
{
title: 'ms.assertion.matchCondition', //
dataIndex: 'matchCondition',
slotName: 'matchCondition',
showInTable: true,
showDrag: true,
options: statusCodeOptions,
},
{
title: 'ms.assertion.matchValue', //
dataIndex: 'matchValue',
slotName: 'matchValue',
showInTable: true,
showDrag: true,
},
{
title: '',
columnTitle: 'common.operation',
slotName: 'operation',
width: 50,
showInTable: true,
showDrag: true,
},
];
function handleParamTableChange(resultArr: any[], isInit?: boolean) {
innerParams.value = [...resultArr];
if (!isInit) {
emit('change');
}
}
</script> </script>

View File

@ -76,7 +76,7 @@
class="hidden-item" class="hidden-item"
> >
<a-input <a-input
v-if="item.type === FilterType.INPUT" v-if="item.type === FilterType.INPUT && !isMutipleOperator(item.operator as string)"
v-model:model-value="item.value" v-model:model-value="item.value"
class="w-full" class="w-full"
allow-clear allow-clear
@ -84,7 +84,7 @@
:max-length="255" :max-length="255"
/> />
<MsTagsInput <MsTagsInput
v-else-if="item.type === FilterType.TAGS_INPUT" v-else-if="isMutipleOperator(item.operator as string)"
v-model:model-value="item.value" v-model:model-value="item.value"
:disabled="!item.dataIndex" :disabled="!item.dataIndex"
allow-clear allow-clear
@ -214,7 +214,7 @@
import { SelectValue } from '@/models/projectManagement/menuManagement'; import { SelectValue } from '@/models/projectManagement/menuManagement';
import { OPERATOR_MAP } from './index'; import { isMutipleOperator, OPERATOR_MAP } from './index';
import { AccordBelowType, BackEndEnum, CombineItem, FilterFormItem, FilterResult, FilterType } from './type'; import { AccordBelowType, BackEndEnum, CombineItem, FilterFormItem, FilterResult, FilterType } from './type';
const { t } = useI18n(); const { t } = useI18n();
@ -334,7 +334,7 @@
combine[item.dataIndex as string] = { combine[item.dataIndex as string] = {
operator: item.operator, operator: item.operator,
value: item.value, value: item.value,
backendType: item.backendType, backendType: Array.isArray(item.value) ? BackEndEnum.ARRAY : item.backendType,
}; };
}); });
tmpObj.accordBelow = accordBelow.value; tmpObj.accordBelow = accordBelow.value;
@ -366,7 +366,7 @@
}; };
const operationChange = (v: SelectValue, dataIndex: string, idx: number) => { const operationChange = (v: SelectValue, dataIndex: string, idx: number) => {
if (v === 'between') { if (isMutipleOperator(v as string)) {
formModel.list[idx].value = []; formModel.list[idx].value = [];
} else { } else {
formModel.list[idx].value = isMultipleSelect(dataIndex) ? [] : ''; formModel.list[idx].value = isMultipleSelect(dataIndex) ? [] : '';

View File

@ -132,3 +132,9 @@ export const CustomTypeMaps: Record<string, any> = {
type: 'TAGS_INPUT', type: 'TAGS_INPUT',
}, },
}; };
export const MULTIPLE_OPERATOR_LIST = ['in', 'not_in', 'between'];
export function isMutipleOperator(operator: string) {
return MULTIPLE_OPERATOR_LIST.includes(operator);
}

View File

@ -419,7 +419,7 @@
id: item.field as string, id: item.field as string,
name: item.title as string, name: item.title as string,
type: item.sourceType as string, type: item.sourceType as string,
value: item.value as string, value: Array.isArray(item.value) ? JSON.stringify(item.value) : (item.value as string),
}); });
}); });
} }

View File

@ -472,7 +472,7 @@
id: item.field as string, id: item.field as string,
name: item.title as string, name: item.title as string,
type: item.sourceType as string, type: item.sourceType as string,
value: item.value as string, value: Array.isArray(item.value) ? JSON.stringify(item.value) : (item.value as string),
}); });
}); });
} }

View File

@ -292,7 +292,7 @@
}, },
{ {
title: 'bugManagement.creator', title: 'bugManagement.creator',
dataIndex: 'createUser', dataIndex: 'createUserName',
width: 112, width: 112,
showTooltip: true, showTooltip: true,
showDrag: true, showDrag: true,

View File

@ -22,13 +22,17 @@
</div> </div>
</template> </template>
<template #memberCount="{ record }"> <template #memberCount="{ record }">
<span class="cursor-pointer text-[rgb(var(--primary-5))]" @click="showUserDrawer(record)">{{ <span
record.memberCount v-if="hasAnyPermission(['PROJECT_GROUP:READ+UPDATE'])"
}}</span> class="cursor-pointer text-[rgb(var(--primary-5))]"
@click="showUserDrawer(record)"
>{{ record.memberCount }}</span
>
<span v-else>{{ record.memberCount }}</span>
</template> </template>
<template #operation="{ record }"> <template #operation="{ record }">
<div class="flex flex-row flex-nowrap"> <div class="flex flex-row flex-nowrap">
<span v-permission="['PROJECT_GROUP:READ+UPDATE']" class="flex flex-row"> <span v-permission="['PROJECT_GROUP:READ']" class="flex flex-row">
<MsButton class="!mr-0" @click="showAuthDrawer(record)">{{ t('project.userGroup.viewAuth') }}</MsButton> <MsButton class="!mr-0" @click="showAuthDrawer(record)">{{ t('project.userGroup.viewAuth') }}</MsButton>
<a-divider v-if="!record.internal" direction="vertical" /> <a-divider v-if="!record.internal" direction="vertical" />
</span> </span>

View File

@ -10,7 +10,11 @@
> >
<div> <div>
<div class="flex flex-row justify-between"> <div class="flex flex-row justify-between">
<a-button type="primary" @click="handleAddMember"> <a-button
v-if="hasAnyPermission(['ORGANIZATION_PROJECT:READ+ADD+MEMBER'])"
type="primary"
@click="handleAddMember"
>
{{ t('system.organization.addMember') }} {{ t('system.organization.addMember') }}
</a-button> </a-button>
<a-input-search <a-input-search
@ -32,6 +36,7 @@
</template> </template>
<template #operation="{ record }"> <template #operation="{ record }">
<MsRemoveButton <MsRemoveButton
v-permission="['ORGANIZATION_PROJECT:READ+DELETE+MEMBER']"
:title="t('system.project.removeName', { name: record.name })" :title="t('system.project.removeName', { name: record.name })"
:sub-title-tip="t('system.project.removeTip')" :sub-title-tip="t('system.project.removeTip')"
@ok="handleRemove(record)" @ok="handleRemove(record)"
@ -62,6 +67,7 @@
import { deleteProjectMemberByOrg, postProjectMemberByProjectId } from '@/api/modules/setting/organizationAndProject'; import { deleteProjectMemberByOrg, postProjectMemberByProjectId } from '@/api/modules/setting/organizationAndProject';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import { formatPhoneNumber } from '@/utils'; import { formatPhoneNumber } from '@/utils';
import { hasAnyPermission } from '@/utils/permission';
export interface projectDrawerProps { export interface projectDrawerProps {
visible: boolean; visible: boolean;
@ -81,6 +87,8 @@
const keyword = ref(''); const keyword = ref('');
const hasOperationPermission = computed(() => hasAnyPermission(['ORGANIZATION_PROJECT:READ+DELETE+MEMBER']));
const projectColumn: MsTableColumn = [ const projectColumn: MsTableColumn = [
{ {
title: 'system.organization.userName', title: 'system.organization.userName',
@ -100,9 +108,9 @@
dataIndex: 'phone', dataIndex: 'phone',
}, },
{ {
title: 'system.organization.operation', title: hasOperationPermission.value ? 'system.organization.operation' : '',
slotName: 'operation', slotName: 'operation',
width: 60, width: hasOperationPermission.value ? 60 : 20,
}, },
]; ];

View File

@ -36,7 +36,7 @@
</template> </template>
<template #memberCount="{ record }"> <template #memberCount="{ record }">
<span <span
v-if="hasAnyPermission(['ORGANIZATION_PROJECT:READ+UPDATE'])" v-if="hasAnyPermission(['ORGANIZATION_PROJECT:READ+ADD+MEMBER'])"
class="cursor-pointer text-[rgb(var(--primary-5))]" class="cursor-pointer text-[rgb(var(--primary-5))]"
@click="showUserDrawer(record)" @click="showUserDrawer(record)"
>{{ record.memberCount }}</span >{{ record.memberCount }}</span
@ -61,7 +61,7 @@
<MsButton v-permission="['ORGANIZATION_PROJECT:READ+UPDATE']" @click="showAddProjectModal(record)">{{ <MsButton v-permission="['ORGANIZATION_PROJECT:READ+UPDATE']" @click="showAddProjectModal(record)">{{
t('common.edit') t('common.edit')
}}</MsButton> }}</MsButton>
<MsButton v-permission="['ORGANIZATION_PROJECT:READ+UPDATE']" @click="showAddUserModal(record)">{{ <MsButton v-permission="['ORGANIZATION_PROJECT:READ+ADD+MEMBER']" @click="showAddUserModal(record)">{{
t('system.organization.addMember') t('system.organization.addMember')
}}</MsButton> }}</MsButton>
<MsButton <MsButton

View File

@ -23,7 +23,7 @@
</template> </template>
<template #memberCount="{ record }"> <template #memberCount="{ record }">
<span <span
v-if="hasAnyPermission(['SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE'])" v-if="hasAnyPermission(['SYSTEM_ORGANIZATION_PROJECT:READ+ADD_MEMBER'])"
class="primary-color" class="primary-color"
@click="showUserDrawer(record)" @click="showUserDrawer(record)"
>{{ record.memberCount }}</span >{{ record.memberCount }}</span
@ -46,27 +46,29 @@
}}</MsButton> }}</MsButton>
</template> </template>
<template v-else-if="!record.enable"> <template v-else-if="!record.enable">
<MsButton v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+UPDATE']" @click="handleEnableOrDisableOrg(record)">{{ <MsButton
t('common.enable') v-permission="['SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE']"
}}</MsButton> @click="handleEnableOrDisableOrg(record)"
<MsButton v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+DELETE']" @click="handleDelete(record)">{{ >{{ t('common.enable') }}</MsButton
>
<MsButton v-permission="['SYSTEM_ORGANIZATION_PROJECT:READ+DELETE']" @click="handleDelete(record)">{{
t('common.delete') t('common.delete')
}}</MsButton> }}</MsButton>
</template> </template>
<template v-else> <template v-else>
<MsButton v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+UPDATE']" @click="showOrganizationModal(record)">{{ <MsButton v-permission="['SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE']" @click="showOrganizationModal(record)">{{
t('common.edit') t('common.edit')
}}</MsButton> }}</MsButton>
<MsButton v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+UPDATE']" @click="showAddUserModal(record)">{{ <MsButton v-permission="['SYSTEM_ORGANIZATION_PROJECT:READ+ADD_MEMBER']" @click="showAddUserModal(record)">{{
t('system.organization.addMember') t('system.organization.addMember')
}}</MsButton> }}</MsButton>
<MsButton <MsButton
v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+UPDATE']" v-permission="['SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE']"
@click="handleEnableOrDisableOrg(record, false)" @click="handleEnableOrDisableOrg(record, false)"
>{{ t('common.end') }}</MsButton >{{ t('common.end') }}</MsButton
> >
<MsTableMoreAction <MsTableMoreAction
v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+DELETE']" v-permission="['SYSTEM_ORGANIZATION_PROJECT:READ+DELETE']"
:list="tableActions" :list="tableActions"
@select="handleMoreAction($event, record)" @select="handleMoreAction($event, record)"
></MsTableMoreAction> ></MsTableMoreAction>
@ -154,7 +156,7 @@
dataIndex: 'name', dataIndex: 'name',
width: 300, width: 300,
revokeDeletedSlot: 'revokeDelete', revokeDeletedSlot: 'revokeDelete',
editType: hasAnyPermission(['SYSTEM_ORGANIZATIN_PROJECT:READ+UPDATE']) ? ColumnEditTypeEnum.INPUT : undefined, editType: hasAnyPermission(['SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE']) ? ColumnEditTypeEnum.INPUT : undefined,
showTooltip: true, showTooltip: true,
}, },
{ {

View File

@ -23,7 +23,7 @@
</template> </template>
<template #memberCount="{ record }"> <template #memberCount="{ record }">
<span <span
v-if="hasAnyPermission(['SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE'])" v-if="hasAnyPermission(['SYSTEM_ORGANIZATION_PROJECT:READ+ADD_MEMBER'])"
class="primary-color" class="primary-color"
@click="showUserDrawer(record)" @click="showUserDrawer(record)"
>{{ record.memberCount }}</span >{{ record.memberCount }}</span
@ -38,28 +38,28 @@
</template> </template>
<template v-else-if="!record.enable"> <template v-else-if="!record.enable">
<MsButton <MsButton
v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+UPDATE']" v-permission="['SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE']"
@click="handleEnableOrDisableProject(record)" @click="handleEnableOrDisableProject(record)"
>{{ t('common.enable') }}</MsButton >{{ t('common.enable') }}</MsButton
> >
<MsButton v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+DELETE']" @click="handleDelete(record)">{{ <MsButton v-permission="['SYSTEM_ORGANIZATION_PROJECT:READ+DELETE']" @click="handleDelete(record)">{{
t('common.delete') t('common.delete')
}}</MsButton> }}</MsButton>
</template> </template>
<template v-else> <template v-else>
<MsButton v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+UPDATE']" @click="showAddProjectModal(record)">{{ <MsButton v-permission="['SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE']" @click="showAddProjectModal(record)">{{
t('common.edit') t('common.edit')
}}</MsButton> }}</MsButton>
<MsButton v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ']" @click="showAddUserModal(record)">{{ <MsButton v-permission="['SYSTEM_ORGANIZATION_PROJECT:READ+ADD_MEMBER']" @click="showAddUserModal(record)">{{
t('system.organization.addMember') t('system.organization.addMember')
}}</MsButton> }}</MsButton>
<MsButton <MsButton
v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+UPDATE']" v-permission="['SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE']"
@click="handleEnableOrDisableProject(record, false)" @click="handleEnableOrDisableProject(record, false)"
>{{ t('common.end') }}</MsButton >{{ t('common.end') }}</MsButton
> >
<MsTableMoreAction <MsTableMoreAction
v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+DELETE']" v-permission="['SYSTEM_ORGANIZATION_PROJECT:READ+DELETE']"
:list="tableActions" :list="tableActions"
@select="handleMoreAction($event, record)" @select="handleMoreAction($event, record)"
></MsTableMoreAction> ></MsTableMoreAction>
@ -144,7 +144,7 @@
title: 'system.organization.name', title: 'system.organization.name',
dataIndex: 'name', dataIndex: 'name',
revokeDeletedSlot: 'revokeDelete', revokeDeletedSlot: 'revokeDelete',
editType: hasAnyPermission(['SYSTEM_ORGANIZATIN_PROJECT:READ+UPDATE']) ? ColumnEditTypeEnum.INPUT : undefined, editType: hasAnyPermission(['SYSTEM_ORGANIZATION_PROJECT:READ+UPDATE']) ? ColumnEditTypeEnum.INPUT : undefined,
showTooltip: true, showTooltip: true,
}, },
{ {

View File

@ -11,7 +11,11 @@
> >
<div> <div>
<div class="flex flex-row justify-between"> <div class="flex flex-row justify-between">
<a-button v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+UPDATE']" type="primary" @click="handleAddMember"> <a-button
v-permission="['SYSTEM_ORGANIZATION_PROJECT:READ+ADD_MEMBER']"
type="primary"
@click="handleAddMember"
>
{{ t('system.organization.addMember') }} {{ t('system.organization.addMember') }}
</a-button> </a-button>
<a-input-search <a-input-search
@ -33,7 +37,7 @@
</template> </template>
<template #operation="{ record }"> <template #operation="{ record }">
<MsRemoveButton <MsRemoveButton
v-permission="['SYSTEM_ORGANIZATIN_PROJECT:READ+DELETE']" v-permission="['SYSTEM_ORGANIZATION_PROJECT:READ+DELETE_MEMBER']"
:title="t('system.organization.removeName', { name: characterLimit(record.name) })" :title="t('system.organization.removeName', { name: characterLimit(record.name) })"
:sub-title-tip="props.organizationId ? t('system.organization.removeTip') : t('system.project.removeTip')" :sub-title-tip="props.organizationId ? t('system.organization.removeTip') : t('system.project.removeTip')"
@ok="handleRemove(record)" @ok="handleRemove(record)"