feat: 按钮权限
This commit is contained in:
parent
3229899c40
commit
9f70a61c24
@ -1,3 +1,9 @@
|
||||
export interface ButtonWithPermission {
|
||||
code: string;
|
||||
value: null | string;
|
||||
show: boolean;
|
||||
}
|
||||
|
||||
export interface TaskInfo {
|
||||
id: string;
|
||||
categoryName: string;
|
||||
@ -28,6 +34,7 @@ export interface TaskInfo {
|
||||
createBy: string;
|
||||
createByName: string;
|
||||
targetNodeName?: string;
|
||||
buttonList: ButtonWithPermission[];
|
||||
}
|
||||
|
||||
export interface CompleteTaskReqData {
|
||||
|
@ -90,6 +90,8 @@ const [BasicForm, formApi] = useVbenForm({
|
||||
|
||||
interface ModalProps {
|
||||
taskId: string;
|
||||
// 是否具有抄送权限
|
||||
copyPermission: boolean;
|
||||
}
|
||||
|
||||
const [BasicModal, modalApi] = useVbenModal({
|
||||
@ -104,7 +106,18 @@ const [BasicModal, modalApi] = useVbenModal({
|
||||
}
|
||||
modalApi.modalLoading(true);
|
||||
|
||||
const { taskId } = modalApi.getData() as ModalProps;
|
||||
const { taskId, copyPermission } = modalApi.getData() as ModalProps;
|
||||
// 是否显示抄送选择
|
||||
formApi.updateSchema([
|
||||
{
|
||||
fieldName: 'flowCopyList',
|
||||
dependencies: {
|
||||
show: copyPermission,
|
||||
triggerFields: [''],
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
await formApi.setFieldValue('taskId', taskId);
|
||||
|
||||
modalApi.modalLoading(false);
|
||||
|
@ -25,7 +25,7 @@ import {
|
||||
TabPane,
|
||||
Tabs,
|
||||
} from 'ant-design-vue';
|
||||
import { isObject } from 'lodash-es';
|
||||
import { isEmpty, isObject } from 'lodash-es';
|
||||
|
||||
import {
|
||||
cancelProcessApply,
|
||||
@ -76,6 +76,33 @@ const showMultiActions = computed(() => {
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* 按钮权限
|
||||
*/
|
||||
const buttonPermissions = computed(() => {
|
||||
const record: Record<string, boolean> = {};
|
||||
if (!currentTask.value) {
|
||||
return record;
|
||||
}
|
||||
currentTask.value.buttonList.forEach((item) => {
|
||||
record[item.code] = item.show;
|
||||
});
|
||||
return record;
|
||||
});
|
||||
|
||||
// 是否显示 `其他` 按钮
|
||||
const showButtonOther = computed(() => {
|
||||
if (isEmpty(buttonPermissions.value)) {
|
||||
return false;
|
||||
}
|
||||
// 加签 减 委托 转办
|
||||
const moreCollections = new Set(['addSign', 'subSign', 'transfer', 'trust']);
|
||||
// 是否包含其中之一
|
||||
return Object.keys(buttonPermissions.value).some((key) => {
|
||||
return moreCollections.has(key) && buttonPermissions.value[key];
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* myself 我发起的
|
||||
* readonly 只读 只用于查看
|
||||
@ -227,7 +254,9 @@ const [ApprovalModal, approvalModalApi] = useVbenModal({
|
||||
connectedComponent: approvalModal,
|
||||
});
|
||||
function handleApproval() {
|
||||
approvalModalApi.setData({ taskId: props.task?.id });
|
||||
// 是否具有抄送权限
|
||||
const copyPermission = buttonPermissions.value?.copy ?? false;
|
||||
approvalModalApi.setData({ taskId: props.task?.id, copyPermission });
|
||||
approvalModalApi.open();
|
||||
}
|
||||
|
||||
@ -459,10 +488,20 @@ async function handleCopy(text: string) {
|
||||
</Space>
|
||||
<Space v-if="type === 'approve'">
|
||||
<a-button type="primary" @click="handleApproval">通过</a-button>
|
||||
<a-button danger type="primary" @click="handleTermination">
|
||||
<a-button
|
||||
v-if="buttonPermissions?.termination"
|
||||
danger
|
||||
type="primary"
|
||||
@click="handleTermination"
|
||||
>
|
||||
终止
|
||||
</a-button>
|
||||
<a-button danger type="primary" @click="handleRejection">
|
||||
<a-button
|
||||
v-if="buttonPermissions?.back"
|
||||
danger
|
||||
type="primary"
|
||||
@click="handleRejection"
|
||||
>
|
||||
驳回
|
||||
</a-button>
|
||||
<Dropdown
|
||||
@ -471,21 +510,29 @@ async function handleCopy(text: string) {
|
||||
>
|
||||
<template #overlay>
|
||||
<Menu>
|
||||
<MenuItem key="1" @click="() => delegationModalApi.open()">
|
||||
<MenuItem
|
||||
v-if="buttonPermissions?.trust"
|
||||
key="1"
|
||||
@click="() => delegationModalApi.open()"
|
||||
>
|
||||
委托
|
||||
</MenuItem>
|
||||
<MenuItem key="2" @click="() => transferModalApi.open()">
|
||||
<MenuItem
|
||||
v-if="buttonPermissions?.transfer"
|
||||
key="2"
|
||||
@click="() => transferModalApi.open()"
|
||||
>
|
||||
转办
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
v-if="showMultiActions"
|
||||
v-if="showMultiActions && buttonPermissions?.addSign"
|
||||
key="3"
|
||||
@click="() => addSignatureModalApi.open()"
|
||||
>
|
||||
加签
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
v-if="showMultiActions"
|
||||
v-if="showMultiActions && buttonPermissions?.subSign"
|
||||
key="4"
|
||||
@click="() => reductionSignatureModalApi.open()"
|
||||
>
|
||||
@ -493,7 +540,7 @@ async function handleCopy(text: string) {
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
</template>
|
||||
<a-button> 其他 </a-button>
|
||||
<a-button v-if="showButtonOther"> 其他 </a-button>
|
||||
</Dropdown>
|
||||
<ApprovalModal @complete="$emit('reload')" />
|
||||
<RejectionModal @complete="$emit('reload')" />
|
||||
|
Loading…
Reference in New Issue
Block a user