wupengfei
2025-03-24 ee36747f2db9ac3a641e1cbaeb01f726ce9faa98
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
82
83
84
85
86
87
88
89
90
<template>
  <ProDialog
    title="选择保单"
    v-model="visible"
    @close="onDialogClose"
    draggable
    destroy-on-close
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    :show-close="false"
  >
    <ProForm :model="form" ref="dialogForm" label-width="90px">
      <ProFormItemV2
        label="保单:"
        prop="insuranceOrderId"
        :check-rules="[{ message: '请选择保单' }]"
      >
        <ProFormSelect v-model="form.insuranceOrderId" :value-enum="insuranceOrderList" />
      </ProFormItemV2>
    </ProForm>
    <template #footer>
      <span class="dialog-footer">
        <el-button type="primary" @click="handleConfirm">确 定</el-button>
      </span>
    </template>
  </ProDialog>
</template>
 
<script setup lang="ts">
import { FormInstance } from 'element-plus';
import {
  ProDialog,
  ProForm,
  ProFormItemV2,
  ProFormText,
  ProFormRadio,
  ProFormSelect,
} from '@bole-core/components';
import { format } from '@/utils';
 
defineOptions({
  name: 'SelectOrderDialog',
});
 
// type Props = {};
 
// const props = withDefaults(defineProps<Props>(), {});
 
const visible = defineModel({ type: Boolean });
 
type Form = {
  title?: string;
  insuranceOrderId: string;
  insuranceOrderList: API.InsuranceOrderListOutput[];
};
 
const form = defineModel<Form>('form');
 
const insuranceOrderList = computed(() =>
  form.value.insuranceOrderList.map((x) => ({
    label: `${x.channel}-${x.name}-${x.idNumber}-${format(x.insuranceBeginTime)}-${format(
      x.insuranceEndTime
    )}-${x.insuredInstitution}-${x.insuranceScheme}-${x.onJobFlag}`,
    value: x.id,
  }))
);
 
const emit = defineEmits<{
  (e: 'onConfirm'): void;
  (e: 'onCancel'): void;
}>();
 
const dialogForm = ref<FormInstance>();
 
function onDialogClose() {
  if (!dialogForm.value) return;
  dialogForm.value.resetFields();
}
 
function handleConfirm() {
  if (!dialogForm.value) return;
  dialogForm.value.validate((valid) => {
    if (valid) {
      emit('onConfirm');
    } else {
      return;
    }
  });
}
</script>