Commit 8195ab32713331b87a96067205f874a9bd6a01e5

Authored by loveumiko
1 parent f66dd1ed

fix: 一些权管理的问题

... ... @@ -48,6 +48,7 @@
48 48 'update:value',
49 49 'change',
50 50 'check',
  51 + 'unSelectAll',
51 52 'update:searchValue',
52 53 ],
53 54 setup(props, { attrs, slots, emit, expose }) {
... ... @@ -188,6 +189,7 @@
188 189 }
189 190
190 191 function checkAll(checkAll: boolean) {
  192 + if (!checkAll) emit('unSelectAll');
191 193 state.checkedKeys = checkAll ? getEnabledKeys() : ([] as Keys);
192 194 }
193 195
... ...
... ... @@ -22,6 +22,16 @@ export enum ConfigurationPermission {
22 22 PREVIEW = 'api:yt:dataview:center:get_configuration_info:preview',
23 23 PUBLISH = 'api:yt:dataview:center:publish',
24 24 // CANCEL_PUBLISH = 'api:yt:dataview:center:cancel_publish',
  25 + PUBLISH_INTERFACE = 'api:yt:dataview:center:public_interface',
  26 +}
  27 +
  28 +export enum PublicInterface {
  29 + CREATE = 'api:yt:dataview:center:public_interface:post',
  30 + LIST = 'api:yt:dataview:center:public_interface:list',
  31 + UPDATE = 'api:yt:dataview:center:public_interface:update',
  32 + DELETE = 'api:yt:dataview:center:public_interface:delete',
  33 + PUBLISH = 'api:yt:dataview:center:public_interface:publish',
  34 + CANCEL_PUBLISH = 'api:yt:dataview:center:public_interface:cancel',
25 35 }
26 36
27 37 // 查询字段
... ...
... ... @@ -218,7 +218,10 @@
218 218 <Authority v-if="!isCustomerUser" :value="ConfigurationPermission.CREATE">
219 219 <Button type="primary" @click="handleCreateOrUpdate()"> 新增大屏 </Button>
220 220 </Authority>
221   - <Authority v-if="hasPublicInterfacePermission" :value="ConfigurationPermission.CREATE">
  221 + <Authority
  222 + v-if="hasPublicInterfacePermission"
  223 + :value="ConfigurationPermission.PUBLISH_INTERFACE"
  224 + >
222 225 <Button type="primary" @click="handleCreateOrUpdatePublicApi()">公共接口管理</Button>
223 226 </Authority>
224 227 <CardLayoutButton v-model:value="listColumn" @change="handleCardLayoutChange" />
... ...
... ... @@ -9,23 +9,30 @@
9 9 <a-button type="link" class="ml-2" @click="handleRecordContent(record)"> 查看 </a-button>
10 10 </template>
11 11 <template #toolbar>
12   - <a-button type="primary" @click="handleCreateOrEdit(null)"> 新增公共接口 </a-button>
13   - <Popconfirm
14   - title="您确定要批量删除数据"
15   - ok-text="确定"
16   - cancel-text="取消"
17   - @confirm="handleDeleteOrBatchDelete(null)"
18   - >
19   - <a-button color="error" :disabled="hasBatchDelete"> 批量删除 </a-button>
20   - </Popconfirm>
21   - <Popconfirm
22   - title="您确定要批量发布"
23   - ok-text="确定"
24   - cancel-text="取消"
25   - @confirm="handleBatchPublish('batchPublish')"
26   - >
27   - <a-button color="error" :disabled="hasBatchPublish"> 批量发布 </a-button>
28   - </Popconfirm>
  12 + <Authority :value="PublicInterface.CREATE">
  13 + <a-button type="primary" @click="handleCreateOrEdit(null)"> 新增公共接口 </a-button>
  14 + </Authority>
  15 +
  16 + <Authority :value="PublicInterface.DELETE">
  17 + <Popconfirm
  18 + title="您确定要批量删除数据"
  19 + ok-text="确定"
  20 + cancel-text="取消"
  21 + @confirm="handleDeleteOrBatchDelete(null)"
  22 + >
  23 + <a-button color="error" :disabled="hasBatchDelete"> 批量删除 </a-button>
  24 + </Popconfirm>
  25 + </Authority>
  26 + <Authority :value="PublicInterface.PUBLISH">
  27 + <Popconfirm
  28 + title="您确定要批量发布"
  29 + ok-text="确定"
  30 + cancel-text="取消"
  31 + @confirm="handleBatchPublish('batchPublish')"
  32 + >
  33 + <a-button color="error" :disabled="hasBatchPublish"> 批量发布 </a-button>
  34 + </Popconfirm>
  35 + </Authority>
29 36 <!-- <Popconfirm
30 37 title="您确定要批量取消发布"
31 38 ok-text="确定"
... ... @@ -41,6 +48,7 @@
41 48 {
42 49 label: '发布',
43 50 icon: 'ant-design:node-expand-outlined',
  51 + auth: PublicInterface.PUBLISH,
44 52 onClick: handlePublish.bind(null, 'publish', record),
45 53 ifShow: () => {
46 54 return record.state === 0 && record.creator === userId;
... ... @@ -49,6 +57,7 @@
49 57 {
50 58 label: '取消发布',
51 59 icon: 'ant-design:node-collapse-outlined',
  60 + auth: PublicInterface.CANCEL_PUBLISH,
52 61 onClick: handlePublish.bind(null, 'canelPublish', record),
53 62 ifShow: () => {
54 63 return record.state === 1 && record.creator === userId;
... ... @@ -57,6 +66,7 @@
57 66 {
58 67 label: '修改',
59 68 icon: 'clarity:note-edit-line',
  69 + auth: PublicInterface.UPDATE,
60 70 onClick: handleCreateOrEdit.bind(null, record),
61 71 ifShow: () => {
62 72 return record.state === 0 && record.creator === userId;
... ... @@ -65,6 +75,7 @@
65 75 {
66 76 label: '删除',
67 77 icon: 'ant-design:delete-outlined',
  78 + auth: PublicInterface.DELETE,
68 79 color: 'error',
69 80 ifShow: () => {
70 81 return record.state === 0 && record.creator === userId;
... ... @@ -99,6 +110,8 @@
99 110 import { useMessage } from '/@/hooks/web/useMessage';
100 111 import { USER_INFO_KEY } from '/@/enums/cacheEnum';
101 112 import { getAuthCache } from '/@/utils/auth';
  113 + import { PublicInterface } from '../config';
  114 + import { Authority } from '/@/components/Authority';
102 115
103 116 const userInfo = getAuthCache(USER_INFO_KEY) as any;
104 117
... ... @@ -119,7 +132,7 @@
119 132 },
120 133 useSearchForm: true,
121 134 actionColumn: {
122   - width: 150,
  135 + width: 180,
123 136 title: '操作',
124 137 dataIndex: 'action',
125 138 slots: { customRender: 'action' },
... ...
... ... @@ -16,6 +16,7 @@
16 16 :replaceFields="{ title: 'name', key: 'id' }"
17 17 :checkedKeys="roleMenus"
18 18 @check="handleCheckClick"
  19 + @unSelectAll="handleUnSelectAll"
19 20 checkable
20 21 toolbar
21 22 ref="treeRef"
... ... @@ -128,6 +129,11 @@
128 129 });
129 130 const getTitle = computed(() => (!unref(isUpdate) ? '新增角色' : '编辑角色'));
130 131
  132 + // 取消全部的时候清除回显时获取的
  133 + const handleUnSelectAll = () => {
  134 + checkedKeysWithHalfChecked.value = [];
  135 + };
  136 +
131 137 async function handleSubmit() {
132 138 setDrawerProps({ loading: true, confirmLoading: true });
133 139 const { createMessage } = useMessage();
... ... @@ -143,7 +149,9 @@
143 149 roleType: RoleEnum.TENANT_ADMIN,
144 150 menu,
145 151 };
146   - if (req.menu == undefined) return createMessage.error('请勾选权限菜单');
  152 + // return;
  153 + if (req.menu == undefined || !req.menu.length)
  154 + return createMessage.error('请勾选权限菜单');
147 155 const res = await saveOrUpdateRoleInfoWithMenu(req);
148 156 if (res) {
149 157 closeDrawer();
... ... @@ -247,6 +255,7 @@
247 255 roleMenus,
248 256 treeRef,
249 257 handleCheckClick,
  258 + handleUnSelectAll,
250 259 };
251 260 },
252 261 });
... ...
... ... @@ -9,6 +9,7 @@ export enum VisualBoardPermission {
9 9 UPDATE = 'api:yt:data_board:update:update',
10 10 DELETE = 'api:yt:data_board:delete',
11 11 CREATE = '',
  12 + SHARE = 'api:yt:data_board:share',
12 13 DETAIL = 'api:yt:data_component:list',
13 14 }
14 15
... ...
... ... @@ -99,19 +99,22 @@
99 99 const dropMenuList = computed<DropMenu[]>(() => {
100 100 const hasUpdatePermission = hasPermission(VisualBoardPermission.UPDATE);
101 101 const hasDeletePermission = hasPermission(VisualBoardPermission.DELETE);
102   - const basicMenu: DropMenu[] = [
103   - {
104   - text: '分享',
105   - event: MoreActionEvent.SHARE,
106   - icon: 'ant-design:share-alt-outlined',
107   - },
108   - ];
  102 + const hasSharePermission = hasPermission(VisualBoardPermission.SHARE);
  103 + let basicMenu: DropMenu[] = [];
109 104 if (hasUpdatePermission)
110 105 basicMenu.push({
111 106 text: '编辑',
112 107 event: MoreActionEvent.EDIT,
113 108 icon: 'ant-design:edit-outlined',
114 109 });
  110 + if (hasSharePermission) {
  111 + basicMenu.push({
  112 + text: '分享',
  113 + event: MoreActionEvent.SHARE,
  114 + icon: 'ant-design:share-alt-outlined',
  115 + });
  116 + }
  117 +
115 118 if (hasDeletePermission)
116 119 basicMenu.push({
117 120 text: '删除',
... ...
... ... @@ -99,6 +99,7 @@
99 99 componentKey: TextComponent1Config.key,
100 100 categoryKey: PackagesCategoryEnum.TEXT,
101 101 };
  102 + activeKey.value = TabKeyEnum.BASIC;
102 103 dataSource.value = [genNewDataSourceItem()];
103 104 }
104 105 }
... ...