liu
3 天以前 fe2d6627b8f1002af7a31b08f6f43bec034d04ee
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
<script lang="ts" setup>
import type { VehicleApplicationApi } from '#/api/vehicle/application';
 
import { computed, ref } from 'vue';
 
import { useVbenModal } from '@vben/common-ui';
 
import { message, Select } from 'ant-design-vue';
 
import { submitVehicleApplication } from '#/api/vehicle/application';
 
defineOptions({ name: 'VehicleApplicationProcessSelect' });
 
const emit = defineEmits(['success']);
 
const applicationId = ref<number>();
const processList = ref<VehicleApplicationApi.ProcessDefinition[]>([]);
const selectedProcessKey = ref('');
 
const processOptions = computed(() =>
  processList.value.map((item) => ({ label: item.name, value: item.key })),
);
 
const [Modal, modalApi] = useVbenModal({
  async onConfirm() {
    if (!selectedProcessKey.value) {
      message.warning('请选择审批流程');
      return;
    }
    modalApi.lock();
    try {
      await submitVehicleApplication(
        applicationId.value!,
        selectedProcessKey.value,
      );
      await modalApi.close();
      emit('success');
      message.success('提交成功,等待逐级审批');
    } finally {
      modalApi.unlock();
    }
  },
  async onOpenChange(isOpen: boolean) {
    if (!isOpen) {
      applicationId.value = undefined;
      selectedProcessKey.value = '';
      processList.value = [];
      return;
    }
    const data = modalApi.getData<{
      id: number;
      processList: VehicleApplicationApi.ProcessDefinition[];
    }>();
    applicationId.value = data.id;
    processList.value = data.processList || [];
    if (processList.value.length > 0) {
      selectedProcessKey.value = processList.value[0]!.key;
    }
  },
});
</script>
 
<template>
  <Modal title="选择用车审批流程" class="w-1/3">
    <div class="mb-4">
      <span class="mr-2">审批流程:</span>
      <Select
        v-model:value="selectedProcessKey"
        :options="processOptions"
        style="width: 240px"
        placeholder="请选择审批流程"
      />
    </div>
    <p class="text-sm text-gray-500">
      提交后按 BPM 中配置的用车审核/逐级审批节点流转,审批结果会回写到本申请并反馈给申请人。
    </p>
  </Modal>
</template>