刘光辉
6 小时以前 cf11e63b659afcc9792ab3e395f1b45d844431a8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<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>