zhengyiming
9 天以前 c6eb1d663f6d91cf5d5fd5c95cc15e5b4f33c064
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<template>
  <ProDialog
    title="上传投保人员清单"
    v-model="innerVisible"
    destroy-on-close
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    draggable
    bodyNoPaddingBottom
    @close="onDialogClose"
    width="600px"
  >
    <ProForm :model="innerForm" ref="dialogForm" label-width="100px">
      <ProFormItemV2
        label="投保产品:"
        prop="productIdNumber"
        :check-rules="[{ message: '请选择投保产品' }]"
      >
        <ProFormSelect
          placeholder="请选择投保产品"
          :value-enum="allInsureProductSettingList"
          clearable
          v-model="form.productIdNumber"
          enum-label-key="insuranceScheme"
          enum-value-key="productIdNumber"
        ></ProFormSelect>
      </ProFormItemV2>
      <ProFormItemV2 label="批次号:" prop="serialNum" :check-rules="[{ message: '请输入批次号' }]">
        <ProFormText
          placeholder="请输入批次号"
          v-model.trim="innerForm.serialNum"
          :maxlength="30"
        ></ProFormText>
      </ProFormItemV2>
      <ProFormItemV2
        label="上传文件:"
        prop="url"
        :check-rules="[{ message: '请上传文件', type: 'upload' }]"
      >
        <ProFormUpload
          v-model:file-url="innerForm.url"
          :limit="1"
          :limitFileSize="10"
          accept="xlsx,xls"
        >
          <template #tip>
            <div>
              <el-text type="danger">支持excel文件,请上传同批次的投保人员清单</el-text>
            </div>
          </template>
        </ProFormUpload>
      </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 { useInsureProductSettingAllList } from '@/hooks';
import {
  ProDialog,
  UploadUserFile,
  ProForm,
  ProFormItemV2,
  ProFormText,
  ProFormUpload,
  ProFormSelect,
} from '@bole-core/components';
import { FormInstance } from 'element-plus';
import _ from 'lodash';
 
defineOptions({
  name: 'UploadInsurePersonDialog',
});
 
type Props = {
  modelValue: boolean;
  form?: {
    serialNum: string;
    url: UploadUserFile[];
    productIdNumber: string;
  };
};
 
const props = withDefaults(defineProps<Props>(), {
  modelValue: false,
});
 
const emit = defineEmits<{
  (e: 'update:modelValue', value: boolean): void;
  (e: 'update:form', value: Props['form']): void;
  (e: 'onConfirm'): void;
  (e: 'onCancel'): void;
}>();
 
// TODO 保险产品要跟当前用户关联 这个获取方式后续要修改
const { allInsureProductSettingList } = useInsureProductSettingAllList();
 
const innerVisible = computed({
  get() {
    return props.modelValue;
  },
  set(val) {
    emit('update:modelValue', val);
  },
});
 
const innerForm = computed({
  get() {
    return props.form;
  },
  set(val) {
    emit('update:form', val);
  },
});
 
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>