<script lang="ts" setup>
|
import type { DmsAccessExclusion } 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 { revokeAccessExclusions } from '#/api/x/dms/permission';
|
|
const emit = defineEmits<{
|
reload: [];
|
}>();
|
|
const exclusion = ref<DmsAccessExclusion>();
|
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: { exclusion: DmsAccessExclusion }) {
|
exclusion.value = data.exclusion;
|
await resetFields();
|
await setFieldsValue({ reason: '' });
|
}
|
|
async function handleSubmit() {
|
if (!exclusion.value) return;
|
const values = await validate();
|
if (!values) return;
|
changeOkLoading(true);
|
try {
|
const response = await revokeAccessExclusions({ exclusionIds: [exclusion.value.id], reason: String(values.reason).trim() });
|
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>
|