<!-- 智能模型处置结果弹窗 --> <script lang="ts" setup name="DisposalResultsDialog"> import type { FormInstance, FormRules } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus' import { reactive, ref } from 'vue' import { addResumeErrorList, submit } from '@/api/equipment/resume/error' import { SCHEDULE } from '@/utils/scheduleDict' const emit = defineEmits(['onSuccess']) // 退回成功方法 const dialogVisible = ref(false) // 弹窗显示状态 const formData = ref({ // 默认表单 handleResult: '', // 智能模型处置结果 }) const btnLoading = ref(false) // 保存按钮加载状态 const hadClickSave = ref(false) // 是否点击了保存按钮 const getRowData = ref() as any const submitId = ref('') // ---------------------------------表单提交--------------------------------------------- const dataFormRef = ref<FormInstance>() // 表单对象 const rules = reactive<FormRules>({ // 校验规则 handleResult: [{ required: true, message: '智能模型处置结果必填', trigger: ['blur', 'change'] }], }) // 提交 function submitForm() { if (!hadClickSave.value) { ElMessage.warning('请先保存') return false } btnLoading.value = true submit({ id: submitId.value, formId: SCHEDULE.EXCEPTION_HANDLING_APPROVAL }).then((res) => { ElMessage.success('已提交') emit('onSuccess') btnLoading.value = false handleClose() }).catch(() => { btnLoading.value = false }) } // 保存 const saveForm = (formEl: FormInstance | undefined) => { if (!formEl) { return } formEl.validate((valid) => { const params = { ...getRowData.value, applyType: '2', applyId: getRowData.value.id, handleResult: formData.value.handleResult, // 智能模型处置结果 id: '', } if (valid) { addResumeErrorList(params).then((res) => { btnLoading.value = true submitId.value = res.data.id ElMessage.success('已保存') hadClickSave.value = true btnLoading.value = false }).catch(() => { btnLoading.value = false }) } }) } // ------------------------------------------弹窗操作------------------------------------ /** * 初始化审批弹窗 * @param id 委托书id */ function initDialog(row: any) { getRowData.value = row dialogVisible.value = true } // 关闭弹窗 function handleClose() { dataFormRef.value?.resetFields() hadClickSave.value = false dialogVisible.value = false } // ------------------------------------- 以下是暴露的方法内容 ------------------------------ defineExpose({ initDialog }) </script> <template> <el-dialog v-model="dialogVisible" title="智能模型处置结果" width="600" :before-close="handleClose" > <el-form ref="dataFormRef" v-loading="btnLoading" label-position="top" label-width="80px" :model="formData" :rules="rules" > <el-row :gutter="24"> <el-col :span="24"> <el-form-item label="智能模型处置结果" prop="handleResult"> <el-input v-model="formData.handleResult" :rows="4" show-word-limit type="textarea" /> </el-form-item> </el-col> </el-row> </el-form> <template #footer> <el-button type="primary" :loading="btnLoading" @click="submitForm"> 提交 </el-button> <el-button type="primary" :loading="btnLoading" @click="saveForm(dataFormRef)"> 保存 </el-button> <el-button type="info" :loading="btnLoading" @click="handleClose"> 取消 </el-button> </template> </el-dialog> </template> <style lang="scss" scoped> // 样式 </style>