| <template> | 
|   <ProDialog | 
|     title="上传结算单" | 
|     v-model="visible" | 
|     @close="onDialogClose" | 
|     destroy-on-close | 
|     draggable | 
|     :width="700" | 
|   > | 
|     <ProForm :model="form" ref="dialogForm" label-width="120px"> | 
|       <ProFormItemV2 label="任务名称:" prop="name" :check-rules="[{ message: '请选择任务单号' }]"> | 
|         <ProFormSelect | 
|           v-model="form.name" | 
|           :valueEnum="taskSelect" | 
|           placeholder="请选择任务名称" | 
|           enum-value-key="id" | 
|           enum-label-key="name" | 
|           filterable | 
|           clearable | 
|           @change="handleCodeChange" | 
|         > | 
|         </ProFormSelect> | 
|       </ProFormItemV2> | 
|       <ProFormItemV2 label="任务单号:" prop="code" :check-rules="[{ message: '请输入任务单号' }]"> | 
|         <ProFormText | 
|           style="width: 50%" | 
|           placeholder="请输入任务单号" | 
|           v-model.trim="form.code" | 
|           disabled | 
|         ></ProFormText> | 
|       </ProFormItemV2> | 
|       <ProFormItemV2 | 
|         label="上传结算单:" | 
|         prop="settlementUrl" | 
|         :check-rules="[{ message: '请上传结算单', type: 'upload' }]" | 
|       > | 
|         <ProFormUpload | 
|           v-model:file-url="form.settlementUrl" | 
|           :limit="1" | 
|           :limitFileSize="10" | 
|           accept="xlsx,xls" | 
|         ></ProFormUpload> | 
|       </ProFormItemV2> | 
|     </ProForm> | 
|     <template #footer> | 
|       <span class="dialog-footer"> | 
|         <el-button @click="emit('onCancel')">取消</el-button> | 
|         <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, | 
|   ProFormUpload, | 
|   ProFormSelect, | 
|   UploadUserFile, | 
| } from '@bole-core/components'; | 
| import { Message } from '@bole-core/core'; | 
|   | 
| defineOptions({ | 
|   name: 'UploadStatementDialog', | 
| }); | 
|   | 
| type Form = { | 
|   title?: string; | 
|   id: string; | 
|   code: string; | 
|   name: string; | 
|   settlementUrl: UploadUserFile[]; | 
| }; | 
|   | 
| const { taskSelect } = useTaskSelect(); | 
|   | 
| const visible = defineModel({ type: Boolean }); | 
|   | 
| const form = defineModel<Form>('form'); | 
|   | 
| const emit = defineEmits<{ | 
|   (e: 'onConfirm'): void; | 
|   (e: 'onCancel'): void; | 
| }>(); | 
|   | 
| const dialogForm = ref<FormInstance>(); | 
|   | 
| function handleCodeChange(value: string) { | 
|   if (value) { | 
|     form.value.code = taskSelect.value?.find((item) => item.id === value)?.code ?? ''; | 
|   } else { | 
|     Message.errorMessage('请选择任务名称'); | 
|   } | 
| } | 
|   | 
| 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> |