| | |
| | | <template> |
| | | <div> |
| | | <el-dialog |
| | | :title="title" |
| | | :visible.sync="localVisible" |
| | | :visible.sync="dialogVisible" |
| | | width="1200px" |
| | | :close-on-click-modal="false" |
| | | @close="handleClose" |
| | |
| | | v-model="formData.idcardtype" |
| | | placeholder="请选择证件类型" |
| | | > |
| | | <el-option label="身份证" value="1" /> |
| | | <el-option label="军人证" value="2" /> |
| | | <el-option label="护照" value="3" /> |
| | | <el-option label="身份证" :value="1" /> |
| | | <el-option label="军人证" :value="2" /> |
| | | <el-option label="护照" :value="3" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | <el-row :gutter="20"> |
| | | <el-col :span="6"> |
| | | <el-form-item label="联系电话" prop="phone"> |
| | | <el-input v-model="formData.phone" placeholder="请输入联系电话" /> |
| | | <el-input |
| | | v-model="formData.phone" |
| | | placeholder="请输入联系电话" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="学历" prop="education"> |
| | | <el-select v-model="formData.education" placeholder="请选择学历"> |
| | | <el-select |
| | | v-model="formData.education" |
| | | placeholder="请选择学历" |
| | | > |
| | | <el-option |
| | | v-for="dict in dictOptions.sys_education" |
| | | :key="dict.value" |
| | |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="职业" prop="occupation"> |
| | | <el-select v-model="formData.occupation" placeholder="请选择职业"> |
| | | <el-select |
| | | v-model="formData.occupation" |
| | | placeholder="请选择职业" |
| | | > |
| | | <el-option |
| | | v-for="dict in dictOptions.sys_occupation" |
| | | :key="dict.value" |
| | |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="Rh(D)" prop="rhyin"> |
| | | <el-radio-group v-model="form.rhyin"> |
| | | <el-radio-group v-model="formData.rhyin"> |
| | | <el-radio |
| | | v-for="dict in dict.type.sys_bloodtype_rhd || []" |
| | | :key="dict.value" |
| | | :label="dict.value" |
| | | >{{ dict.label }}</el-radio |
| | | > |
| | | >{{ dict.label }}</el-radio> |
| | | </el-radio-group> |
| | | </el-form-item> |
| | | </el-col> |
| | |
| | | |
| | | <el-row :gutter="20"> |
| | | <el-col :span="12"> |
| | | <el-form-item label="当前医疗机构" prop="currentMedicalInstitution"> |
| | | <el-form-item |
| | | label="当前医疗机构" |
| | | prop="currentMedicalInstitution" |
| | | > |
| | | <el-input |
| | | v-model="formData.currentMedicalInstitution" |
| | | placeholder="请输入当前医疗机构" |
| | |
| | | </el-col> |
| | | <el-col :span="12"> |
| | | <el-form-item label="部门ID" prop="deptid"> |
| | | <el-input v-model="formData.deptid" placeholder="请输入部门ID" /> |
| | | <el-input |
| | | v-model="formData.deptid" |
| | | placeholder="请输入部门ID" |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button @click="handleClose">取消</el-button> |
| | | <el-button type="primary" @click="handleSubmit" :loading="submitLoading"> |
| | | <el-button |
| | | type="primary" |
| | | @click="handleSubmit" |
| | | :loading="submitLoading" |
| | | > |
| | | {{ isEdit ? "更新" : "保存" }} |
| | | </el-button> |
| | | </div> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | |
| | | }, |
| | | data() { |
| | | return { |
| | | localVisible: this.visible, |
| | | isEdit: false, |
| | | submitLoading: false, |
| | | residenceAddress: {}, |
| | |
| | | computed: { |
| | | title() { |
| | | return this.isEdit ? "编辑案例信息" : "新增捐献案例"; |
| | | }, |
| | | dialogVisible: { |
| | | get() { |
| | | return this.visible; |
| | | }, |
| | | set(value) { |
| | | this.$emit('update:visible', value); |
| | | if (!value) { |
| | | this.handleClose(); |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | watch: { |
| | | visible(newVal) { |
| | | this.localVisible = newVal; |
| | | console.log("visible变化:", newVal); |
| | | if (newVal) { |
| | | this.$nextTick(() => { |
| | | this.initForm(); |
| | | }); |
| | | } else { |
| | | this.handleClose(); |
| | | } |
| | | }, |
| | | localVisible(newVal) { |
| | | this.$emit("update:visible", newVal); |
| | | }, |
| | | editData: { |
| | | immediate: true, |
| | | deep: true, |
| | | handler(newVal) { |
| | | if (newVal && newVal.id) { |
| | | this.isEdit = true; |
| | | this.$nextTick(() => { |
| | | // 确保 DOM 已经更新后再进行表单操作 |
| | | this.initForm(newVal); |
| | | }); |
| | | console.log("editData变化:", newVal); |
| | | this.isEdit = !!(newVal && newVal.id); |
| | | } |
| | | } |
| | | }, |
| | | deep: true, |
| | | immediate: true |
| | | } |
| | | created() { |
| | | console.log('EditCaseModal created'); |
| | | console.log('visible:', this.visible); |
| | | console.log('editData:', this.editData); |
| | | }, |
| | | mounted() { |
| | | console.log('EditCaseModal mounted'); |
| | | console.log('visible:', this.visible); |
| | | console.log('editData:', this.editData); |
| | | console.log('isEdit:', this.isEdit); |
| | | }, |
| | | methods: { |
| | | getDefaultFormData() { |
| | |
| | | }, |
| | | |
| | | async initForm() { |
| | | console.log(this.isEdit); |
| | | |
| | | if (this.isEdit) { |
| | | console.log('初始化表单,isEdit:', this.isEdit); |
| | | try { |
| | | if (this.isEdit && this.editData && this.editData.id) { |
| | | console.log('加载编辑数据,id:', this.editData.id); |
| | | await this.loadEditData(); |
| | | } else { |
| | | console.log('新增模式,初始化表单'); |
| | | this.formData = this.getDefaultFormData(); |
| | | // 设置默认值 |
| | | this.formData.nationality = "中国"; |
| | | this.formData.bloodtype = "0"; |
| | | this.formData.rhyin = "0"; |
| | |
| | | this.formData.acquisitiontissueno = "ZJOPO"; |
| | | this.formData.acquisitiontissuename = "浙江省人体器官获取组织"; |
| | | } |
| | | } catch (error) { |
| | | console.error("初始化表单失败:", error); |
| | | this.$message.error("初始化表单失败"); |
| | | } finally { |
| | | this.$nextTick(() => { |
| | | this.$refs.formRef?.clearValidate(); |
| | | if (this.$refs.formRef) { |
| | | this.$refs.formRef.clearValidate(); |
| | | } |
| | | }); |
| | | } |
| | | }, |
| | | |
| | | async loadEditData() { |
| | | try { |
| | | const response = await getDonatebaseinfo(this.editData.id); |
| | | const data = response.data; |
| | | console.log('加载到的数据:', data); |
| | | |
| | | // 处理数组字段 |
| | | const arrayFields = [ |
| | |
| | | }); |
| | | |
| | | this.formData = { ...this.getDefaultFormData(), ...data }; |
| | | console.log('合并后的formData:', this.formData); |
| | | |
| | | // 设置地址信息 |
| | | if (data.residenceprovince) { |
| | |
| | | |
| | | this.calculateAge(data.birthday); |
| | | } catch (error) { |
| | | console.error("获取案例数据失败:", error); |
| | | this.$message.error("获取案例数据失败"); |
| | | this.handleClose(); |
| | | } |
| | | }, |
| | | |
| | | handleIdCardBlur() { |
| | | // 身份证自动填充逻辑 |
| | | this.updateMessage(); |
| | | }, |
| | | |
| | |
| | | }, |
| | | |
| | | handleClose() { |
| | | this.localVisible = false; |
| | | console.log('关闭弹框'); |
| | | this.isEdit = false; |
| | | this.submitLoading = false; |
| | | this.formData = this.getDefaultFormData(); |
| | |
| | | this.submitLoading = true; |
| | | try { |
| | | const submitData = this.processSubmitData(); |
| | | console.log('提交数据:', submitData); |
| | | |
| | | const result = await updateDonatebaseinfo(submitData); |
| | | if (result.code === 200) { |
| | |
| | | this.$message.error(result.msg || "操作失败"); |
| | | } |
| | | } catch (error) { |
| | | console.error("操作失败:", error); |
| | | this.$message.error("操作失败"); |
| | | } finally { |
| | | this.submitLoading = false; |