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 {
|
export interface TaskInfo {
|
||||||
id: string;
|
id: string;
|
||||||
categoryName: string;
|
categoryName: string;
|
||||||
@ -28,6 +34,7 @@ export interface TaskInfo {
|
|||||||
createBy: string;
|
createBy: string;
|
||||||
createByName: string;
|
createByName: string;
|
||||||
targetNodeName?: string;
|
targetNodeName?: string;
|
||||||
|
buttonList: ButtonWithPermission[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CompleteTaskReqData {
|
export interface CompleteTaskReqData {
|
||||||
|
@ -90,6 +90,8 @@ const [BasicForm, formApi] = useVbenForm({
|
|||||||
|
|
||||||
interface ModalProps {
|
interface ModalProps {
|
||||||
taskId: string;
|
taskId: string;
|
||||||
|
// 是否具有抄送权限
|
||||||
|
copyPermission: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [BasicModal, modalApi] = useVbenModal({
|
const [BasicModal, modalApi] = useVbenModal({
|
||||||
@ -104,7 +106,18 @@ const [BasicModal, modalApi] = useVbenModal({
|
|||||||
}
|
}
|
||||||
modalApi.modalLoading(true);
|
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);
|
await formApi.setFieldValue('taskId', taskId);
|
||||||
|
|
||||||
modalApi.modalLoading(false);
|
modalApi.modalLoading(false);
|
||||||
|
@ -25,7 +25,7 @@ import {
|
|||||||
TabPane,
|
TabPane,
|
||||||
Tabs,
|
Tabs,
|
||||||
} from 'ant-design-vue';
|
} from 'ant-design-vue';
|
||||||
import { isObject } from 'lodash-es';
|
import { isEmpty, isObject } from 'lodash-es';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
cancelProcessApply,
|
cancelProcessApply,
|
||||||
@ -76,6 +76,33 @@ const showMultiActions = computed(() => {
|
|||||||
return false;
|
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 我发起的
|
* myself 我发起的
|
||||||
* readonly 只读 只用于查看
|
* readonly 只读 只用于查看
|
||||||
@ -227,7 +254,9 @@ const [ApprovalModal, approvalModalApi] = useVbenModal({
|
|||||||
connectedComponent: approvalModal,
|
connectedComponent: approvalModal,
|
||||||
});
|
});
|
||||||
function handleApproval() {
|
function handleApproval() {
|
||||||
approvalModalApi.setData({ taskId: props.task?.id });
|
// 是否具有抄送权限
|
||||||
|
const copyPermission = buttonPermissions.value?.copy ?? false;
|
||||||
|
approvalModalApi.setData({ taskId: props.task?.id, copyPermission });
|
||||||
approvalModalApi.open();
|
approvalModalApi.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -459,10 +488,20 @@ async function handleCopy(text: string) {
|
|||||||
</Space>
|
</Space>
|
||||||
<Space v-if="type === 'approve'">
|
<Space v-if="type === 'approve'">
|
||||||
<a-button type="primary" @click="handleApproval">通过</a-button>
|
<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>
|
||||||
<a-button danger type="primary" @click="handleRejection">
|
<a-button
|
||||||
|
v-if="buttonPermissions?.back"
|
||||||
|
danger
|
||||||
|
type="primary"
|
||||||
|
@click="handleRejection"
|
||||||
|
>
|
||||||
驳回
|
驳回
|
||||||
</a-button>
|
</a-button>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
@ -471,21 +510,29 @@ async function handleCopy(text: string) {
|
|||||||
>
|
>
|
||||||
<template #overlay>
|
<template #overlay>
|
||||||
<Menu>
|
<Menu>
|
||||||
<MenuItem key="1" @click="() => delegationModalApi.open()">
|
<MenuItem
|
||||||
|
v-if="buttonPermissions?.trust"
|
||||||
|
key="1"
|
||||||
|
@click="() => delegationModalApi.open()"
|
||||||
|
>
|
||||||
委托
|
委托
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem key="2" @click="() => transferModalApi.open()">
|
<MenuItem
|
||||||
|
v-if="buttonPermissions?.transfer"
|
||||||
|
key="2"
|
||||||
|
@click="() => transferModalApi.open()"
|
||||||
|
>
|
||||||
转办
|
转办
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
v-if="showMultiActions"
|
v-if="showMultiActions && buttonPermissions?.addSign"
|
||||||
key="3"
|
key="3"
|
||||||
@click="() => addSignatureModalApi.open()"
|
@click="() => addSignatureModalApi.open()"
|
||||||
>
|
>
|
||||||
加签
|
加签
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
v-if="showMultiActions"
|
v-if="showMultiActions && buttonPermissions?.subSign"
|
||||||
key="4"
|
key="4"
|
||||||
@click="() => reductionSignatureModalApi.open()"
|
@click="() => reductionSignatureModalApi.open()"
|
||||||
>
|
>
|
||||||
@ -493,7 +540,7 @@ async function handleCopy(text: string) {
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
</template>
|
</template>
|
||||||
<a-button> 其他 </a-button>
|
<a-button v-if="showButtonOther"> 其他 </a-button>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
<ApprovalModal @complete="$emit('reload')" />
|
<ApprovalModal @complete="$emit('reload')" />
|
||||||
<RejectionModal @complete="$emit('reload')" />
|
<RejectionModal @complete="$emit('reload')" />
|
||||||
|
Loading…
Reference in New Issue
Block a user