| | |
| | | <ProForm :model="form" ref="dialogForm" label-width="100px"> |
| | | <ProFormItemV2 |
| | | label="选择文件:" |
| | | prop="userList" |
| | | :check-rules="[{ message: '请上传人员名单', type: 'array' }]" |
| | | prop="url" |
| | | :check-rules="[{ message: '请上传人员名单', type: 'upload' }]" |
| | | > |
| | | <div style="display: flex"> |
| | | <ProFormUpload |
| | |
| | | :limit="1" |
| | | :limitFileSize="10" |
| | | accept="xlsx,xls" |
| | | :needUploadOss="false" |
| | | :on-success="handleImport" |
| | | ></ProFormUpload> |
| | | <el-button |
| | | type="primary" |
| | |
| | | |
| | | type Form = { |
| | | title?: string; |
| | | customerId: string; |
| | | contractTemplateId: string; |
| | | templateDataId: string; |
| | | url: UploadUserFile[]; |
| | | userList: any[]; |
| | | }; |
| | | |
| | | const visible = defineModel({ type: Boolean }); |
| | |
| | | (e: 'onConfirm'): void; |
| | | (e: 'onCancel'): void; |
| | | }>(); |
| | | |
| | | const { user } = useUser(); |
| | | |
| | | const dialogForm = ref<FormInstance>(); |
| | | |
| | |
| | | } else { |
| | | return; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | const XLSXHeaderMap = { |
| | | name: '姓名', |
| | | phone: '手机号', |
| | | }; |
| | | |
| | | function handleImport(response: UploadUserFile) { |
| | | XLSXUtils.resloveXLSXFromUploadInput<typeof XLSXHeaderMap>({ |
| | | //@ts-ignore |
| | | file: response.file, |
| | | resloveKeyList: Object.keys(XLSXHeaderMap), |
| | | onSuccess: async (worksheetList) => { |
| | | const userXLSXList = worksheetList[0]; |
| | | form.value.userList = userXLSXList; |
| | | dialogForm.value?.validateField?.('userList'); |
| | | }, |
| | | }); |
| | | } |
| | | </script> |