Skip to content

Commit c9c03be

Browse files
committed
perf: 模型列表 权限检查用computed 替代vue指令 减少检查次数
1 parent d710c9d commit c9c03be

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

src/views/bpm/model/CategoryDraggableModel.vue

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
link
159159
type="primary"
160160
@click="openModelForm('update', scope.row.id)"
161-
v-hasPermi="['bpm:model:update']"
161+
v-if="hasPermiUpdate"
162162
:disabled="!isManagerUser(scope.row)"
163163
>
164164
修改
@@ -167,7 +167,7 @@
167167
link
168168
type="primary"
169169
@click="openModelForm('copy', scope.row.id)"
170-
v-hasPermi="['bpm:model:update']"
170+
v-if="hasPermiUpdate"
171171
:disabled="!isManagerUser(scope.row)"
172172
>
173173
复制
@@ -177,36 +177,36 @@
177177
class="!ml-5px"
178178
type="primary"
179179
@click="handleDeploy(scope.row)"
180-
v-hasPermi="['bpm:model:deploy']"
180+
v-if="hasPermiDeploy"
181181
:disabled="!isManagerUser(scope.row)"
182182
>
183183
发布
184184
</el-button>
185185
<el-dropdown
186186
class="!align-middle ml-5px"
187187
@command="(command) => handleModelCommand(command, scope.row)"
188-
v-hasPermi="['bpm:process-definition:query', 'bpm:model:update', 'bpm:model:delete']"
188+
v-if="hasPermiMore"
189189
>
190190
<el-button type="primary" link>更多</el-button>
191191
<template #dropdown>
192192
<el-dropdown-menu>
193193
<el-dropdown-item
194194
command="handleDefinitionList"
195-
v-if="checkPermi(['bpm:process-definition:query'])"
195+
v-if="hasPermiPdQuery"
196196
>
197197
历史
198198
</el-dropdown-item>
199199
<el-dropdown-item
200200
command="handleChangeState"
201-
v-if="checkPermi(['bpm:model:update']) && scope.row.processDefinition"
201+
v-if="hasPermiUpdate && scope.row.processDefinition"
202202
:disabled="!isManagerUser(scope.row)"
203203
>
204204
{{ scope.row.processDefinition.suspensionState === 1 ? '停用' : '启用' }}
205205
</el-dropdown-item>
206206
<el-dropdown-item
207207
type="danger"
208208
command="handleDelete"
209-
v-if="checkPermi(['bpm:model:delete'])"
209+
v-if="hasPermiDelete"
210210
:disabled="!isManagerUser(scope.row)"
211211
>
212212
删除
@@ -274,6 +274,23 @@ const originalData: any = ref([]) // 原始数据
274274
const modelList: any = ref([]) // 模型列表
275275
const isExpand = ref(false) // 是否处于展开状态
276276
277+
const hasPermiUpdate = computed(() => {
278+
return checkPermi(['bpm:model:update'])
279+
})
280+
const hasPermiDelete = computed(() => {
281+
return checkPermi(['bpm:model:delete'])
282+
})
283+
const hasPermiDeploy = computed(() => {
284+
return checkPermi(['bpm:model:deploy'])
285+
})
286+
const hasPermiMore = computed(() => {
287+
return checkPermi(['bpm:process-definition:query', 'bpm:model:update', 'bpm:model:delete'])
288+
})
289+
const hasPermiPdQuery = computed(() => {
290+
return checkPermi(['bpm:process-definition:query'])
291+
})
292+
293+
277294
/** '更多'操作按钮 */
278295
const handleModelCommand = (command: string, row: any) => {
279296
switch (command) {

0 commit comments

Comments
 (0)