<script lang="ts" setup>
|
import type { DmsPermissionGrant, DmsPermissionRevoke } from '#/api/x/dms/permission';
|
|
import { ref } from 'vue';
|
|
import { useMessage } from '@jnpf/hooks';
|
import { BasicForm, useForm } from '@jnpf/ui/form';
|
import { BasicModal, useModalInner } from '@jnpf/ui/modal';
|
|
import { revokePermissionGrants } from '#/api/x/dms/permission';
|
import { onlineUtils } from '#/utils/jnpf';
|
|
const emit = defineEmits<{
|
reload: [];
|
}>();
|
|
const grant = ref<DmsPermissionGrant>();
|
const { createMessage } = useMessage();
|
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({
|
baseColProps: { span: 24 },
|
layout: 'vertical',
|
schemas: [
|
{
|
field: 'reason',
|
label: '撤销原因',
|
component: 'Textarea',
|
componentProps: { maxlength: 1000, rows: 4, showCount: true },
|
rules: [{ required: true, whitespace: true, message: '请输入撤销原因', trigger: 'blur' }],
|
},
|
],
|
showActionButtonGroup: false,
|
});
|
const [registerModal, { changeOkLoading, closeModal }] = useModalInner(init);
|
|
async function init(data: { grant: DmsPermissionGrant }) {
|
grant.value = data.grant;
|
await resetFields();
|
await setFieldsValue({ reason: '' });
|
}
|
|
async function handleSubmit() {
|
if (!grant.value) return;
|
const values = await validate();
|
if (!values) return;
|
const currentGrant = grant.value;
|
const data: DmsPermissionRevoke = { permissionIds: [currentGrant.id], reason: String(values.reason).trim() };
|
onlineUtils.sign({
|
title: '电子签名',
|
isFaceToFace: false,
|
metaData: {
|
biz_button: '撤销授权',
|
biz_data: [data],
|
biz_module: '文件夹权限管理',
|
biz_title: currentGrant.principalName || currentGrant.principalId,
|
is_biz_form: false,
|
is_review_button: false,
|
},
|
onCancel: () => {},
|
onSubmit: (signData) => submitRevoke(data, signData?.biz_sign),
|
});
|
}
|
|
async function submitRevoke(data: DmsPermissionRevoke, bizSign?: string) {
|
changeOkLoading(true);
|
try {
|
const response = await revokePermissionGrants(data, bizSign);
|
createMessage.success(response.msg || '权限已撤销');
|
closeModal();
|
emit('reload');
|
} finally {
|
changeOkLoading(false);
|
}
|
}
|
</script>
|
|
<template>
|
<BasicModal v-bind="$attrs" @register="registerModal" title="撤销文件权限" :width="520" destroy-on-close @ok="handleSubmit">
|
<a-alert class="mb-[18px]" type="warning" show-icon message="撤销立即生效,既有授权记录仍保留用于审计。" />
|
<BasicForm @register="registerForm" />
|
</BasicModal>
|
</template>
|