fix: 参数配置方法权限控制post,put,delete

This commit is contained in:
TsMask
2024-05-09 18:27:32 +08:00
parent 2db0220c98
commit ad93588796

View File

@@ -43,7 +43,7 @@ let treeState: TreeStateType = reactive({
selectNode: { selectNode: {
topDisplay: '' as string, topDisplay: '' as string,
topTag: '' as string, topTag: '' as string,
method: '' as string, method: [] as string[],
// //
title: '' as string, title: '' as string,
key: '' as string, key: '' as string,
@@ -57,7 +57,11 @@ function fnSelectConfigNode(_: any, info: any) {
const { title, key, method } = info.node; const { title, key, method } = info.node;
treeState.selectNode.topDisplay = title; treeState.selectNode.topDisplay = title;
treeState.selectNode.topTag = key; treeState.selectNode.topTag = key;
treeState.selectNode.method = method; if (method) {
treeState.selectNode.method = method.split(',');
} else {
treeState.selectNode.method = ['post', 'put', 'delete'];
}
treeState.selectNode.title = title; treeState.selectNode.title = title;
treeState.selectNode.key = key; treeState.selectNode.key = key;
fnActiveConfigNode(key); fnActiveConfigNode(key);
@@ -1349,7 +1353,9 @@ onMounted(() => {
<EditOutlined <EditOutlined
class="editable-cell__icon" class="editable-cell__icon"
@click="listEdit(record)" @click="listEdit(record)"
v-if="!['read-only', 'read', 'ro'].includes(record.access)" v-if="
!['read-only', 'read', 'ro'].includes(record.access)
"
/> />
</div> </div>
</div> </div>
@@ -1363,7 +1369,7 @@ onMounted(() => {
<a-table <a-table
class="table" class="table"
row-key="index" row-key="index"
:columns="treeState.selectNode.method === 'get' ? arrayState.columnsDnd.filter((s:any)=>s.key !== 'index') : arrayState.columnsDnd" :columns="treeState.selectNode.method.includes('get') ? arrayState.columnsDnd.filter((s:any)=>s.key !== 'index') : arrayState.columnsDnd"
:data-source="arrayState.columnsData" :data-source="arrayState.columnsData"
:size="arrayState.size" :size="arrayState.size"
:pagination="tablePagination" :pagination="tablePagination"
@@ -1380,7 +1386,7 @@ onMounted(() => {
type="primary" type="primary"
@click.prevent="arrayAdd()" @click.prevent="arrayAdd()"
size="small" size="small"
v-if="treeState.selectNode.method !== 'get'" v-if="treeState.selectNode.method.includes('post')"
> >
<template #icon> <PlusOutlined /> </template> <template #icon> <PlusOutlined /> </template>
{{ t('common.addText') }} {{ t('common.addText') }}
@@ -1388,7 +1394,7 @@ onMounted(() => {
<TableColumnsDnd <TableColumnsDnd
type="ghost" type="ghost"
:cache-id="treeState.selectNode.key" :cache-id="treeState.selectNode.key"
:columns="treeState.selectNode.method === 'get' ? [...arrayState.columns.filter((s:any)=>s.key !== 'index')] : arrayState.columns" :columns="treeState.selectNode.method.includes('get') ? [...arrayState.columns.filter((s:any)=>s.key !== 'index')] : arrayState.columns"
v-model:columns-dnd="arrayState.columnsDnd" v-model:columns-dnd="arrayState.columnsDnd"
></TableColumnsDnd> ></TableColumnsDnd>
</a-space> </a-space>
@@ -1398,13 +1404,17 @@ onMounted(() => {
<template #bodyCell="{ column, text, record }"> <template #bodyCell="{ column, text, record }">
<template v-if="column?.key === 'index'"> <template v-if="column?.key === 'index'">
<a-space :size="16" align="center"> <a-space :size="16" align="center">
<a-tooltip> <a-tooltip
v-if="treeState.selectNode.method.includes('put')"
>
<template #title>{{ t('common.editText') }}</template> <template #title>{{ t('common.editText') }}</template>
<a-button type="link" @click.prevent="arrayEdit(text)"> <a-button type="link" @click.prevent="arrayEdit(text)">
<template #icon><FormOutlined /></template> <template #icon><FormOutlined /></template>
</a-button> </a-button>
</a-tooltip> </a-tooltip>
<a-tooltip> <a-tooltip
v-if="treeState.selectNode.method.includes('delete')"
>
<template #title>{{ t('common.deleteText') }}</template> <template #title>{{ t('common.deleteText') }}</template>
<a-button type="link" @click.prevent="arrayDelete(text)"> <a-button type="link" @click.prevent="arrayDelete(text)">
<template #icon><DeleteOutlined /></template> <template #icon><DeleteOutlined /></template>
@@ -1509,9 +1519,9 @@ onMounted(() => {
</a-button> </a-button>
</a-tooltip> </a-tooltip>
<a-tooltip> <a-tooltip>
<template #title>{{ <template #title>
t('common.deleteText') {{ t('common.deleteText') }}
}}</template> </template>
<a-button <a-button
type="link" type="link"
@click.prevent="arrayChildDelete(text)" @click.prevent="arrayChildDelete(text)"