gaoluyang
昨天 b64a0deae5b5d33f9e20671a68936b27f0b9b00b
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
<script lang="ts" setup>
import type { ProcessDefinition } from '#/api/erp/purchase/order';
 
import { ref, computed } from 'vue';
 
import { useVbenModal } from '@vben/common-ui';
 
import { Select } from 'ant-design-vue';
 
const emit = defineEmits(['success']);
 
const processList = ref<ProcessDefinition[]>([]);
const selectedProcessId = ref<string>('');
 
const processOptions = computed(() => {
  return processList.value.map((p) => ({
    label: `${p.name} (V${p.version})`,
    value: p.id,
  }));
});
 
const [Modal, modalApi] = useVbenModal({
  async onConfirm() {
    if (!selectedProcessId.value) {
      return;
    }
    await modalApi.close();
    emit('success', selectedProcessId.value);
  },
  async onOpenChange(isOpen: boolean) {
    if (!isOpen) {
      selectedProcessId.value = '';
      processList.value = [];
      return;
    }
    const data = modalApi.getData<ProcessDefinition[]>();
    if (data && data.length > 0) {
      processList.value = data;
    }
  },
});
</script>
 
<template>
  <Modal title="选择审批流程" class="w-1/3">
    <Select
      v-model:value="selectedProcessId"
      :options="processOptions"
      style="width: 100%"
      placeholder="请选择审批流程"
    />
  </Modal>
</template>