| | |
| | | if (this.submitLoading) { |
| | | return; |
| | | } |
| | | // 第二步:开启加载状态,禁用按钮 |
| | | |
| | | // 开启加载状态 |
| | | this.submitLoading = true; |
| | | console.log(this.submitLoading); |
| | | |
| | | try { |
| | | if (this.time4 && this.form.sendType == 3) |
| | | // 时间处理 |
| | | if (this.time4 && this.form.sendType == 3) { |
| | | this.form.showTimeMorn = this.time4; |
| | | } |
| | | this.form.sendTimeslot = [ |
| | | { |
| | | begantime: this.time4, |
| | |
| | | xh: 1, |
| | | }, |
| | | ]; |
| | | console.log(1); |
| | | |
| | | // 根据应用类型清理字段 |
| | | if (this.form.appltype == 1) { |
| | | this.leavehospitaldistrictcodes = []; |
| | | this.form.oplevelcode = null; |
| | |
| | | this.illnesscodes = []; |
| | | this.leavehospitaldistrictcodes = []; |
| | | } |
| | | |
| | | // 校验:服务类型 |
| | | if (this.checkList) { |
| | | this.form.preachform = this.checkList.join(","); |
| | | this.form.preachformList = this.selectedOrder; |
| | | } else { |
| | | this.$modal.msgError("请选择服务类型"); |
| | | this.submitLoading = false; |
| | | |
| | | return; |
| | | } |
| | | console.log(2); |
| | | |
| | | if ( |
| | | // 校验:疾病关联科室或病区 |
| | | if (this.form.appltype == 3) { |
| | | const hasDept = this.diseaseDept?.deptCode; |
| | | const hasWard = this.diseaseWard?.districtCode; |
| | | |
| | | if (!hasDept && !hasWard) { |
| | | this.$modal.msgError("当前疾病需关联科室或病区"); |
| | | this.submitLoading = false; |
| | | return; |
| | | } |
| | | } |
| | | |
| | | // 校验:任务关联条件 |
| | | const hasCondition = |
| | | this.deptcodesWards[0] || |
| | | this.leavehospitaldistrictcodes[0] || |
| | | this.diagglist[0] || |
| | | this.form.oplevelcode || |
| | | this.form.longTask == 2 || |
| | | this.serviceType == 3 |
| | | ) { |
| | | } else { |
| | | this.serviceType == 3; |
| | | |
| | | if (!hasCondition) { |
| | | this.$modal.msgError("请选择任务关联条件"); |
| | | this.submitLoading = false; |
| | | return; |
| | | } |
| | | //暂停任务患者限制 |
| | | // if (!this.form.patTaskRelevances[0] && !this.form.longTask) { |
| | | // this.$modal.msgError("请选择病人"); |
| | | // return; |
| | | // } |
| | | console.log(3); |
| | | |
| | | // 校验:模板 |
| | | if (!this.form.templatename && !this.templateor) { |
| | | this.$modal.msgError("未选择模板"); |
| | | this.submitLoading = false; |
| | | |
| | | return; |
| | | } |
| | | |
| | | if ( |
| | | // 校验:时间信息 |
| | | const isValidTime = |
| | | (this.form.sendType == 1 && this.time1) || |
| | | this.form.sendType == 2 |
| | | ) { |
| | | } else if ( |
| | | this.form.sendType == 2 || |
| | | (this.form.sendType == 3 && this.time4) || |
| | | this.form.longTask |
| | | ) { |
| | | } else { |
| | | this.form.longTask; |
| | | |
| | | if (!isValidTime) { |
| | | this.submitLoading = false; |
| | | return this.$modal.msgError("时间信息缺失"); |
| | | this.$modal.msgError("时间信息缺失"); |
| | | return; |
| | | } |
| | | |
| | | // 处理文本参数 |
| | | const filteredArray = this.variableList.filter( |
| | | (item) => |
| | | item.name !== "姓名" && item.name !== "电话" && item.name !== "地址" |
| | | ); |
| | | this.form.textParam = this.convertFormat2ToFormat1(filteredArray); |
| | | |
| | | // 设置操作类型 |
| | | if (this.form.taskid) { |
| | | this.form.isoperation = 2; |
| | | } else { |
| | | this.form.isoperation = 1; |
| | | } |
| | | |
| | | // 设置类型 |
| | | if (!this.form.type) { |
| | | this.form.type = this.$route.query.type; |
| | | } |
| | | console.log(4); |
| | | |
| | | // 组装提交数据 |
| | | this.form.serviceType = this.serviceType; |
| | | this.form.deptcode = this.deptcodesWards.join(","); |
| | | this.form.leavehospitaldistrictcode = |
| | | this.leavehospitaldistrictcodes.join(","); |
| | | // this.form.opcode = this.operationcodes.join(","); |
| | | |
| | | // 疾病关联的科室/病区 |
| | | if (this.form.appltype == 3) { |
| | | if (this.diseaseDept) { |
| | | this.form.deptcode = this.diseaseDept.deptCode; |
| | |
| | | } |
| | | } |
| | | |
| | | // 诊断信息 |
| | | this.form.icd10code = this.diagglist |
| | | .map((item) => item.icdcode) |
| | | .join(","); |
| | | this.form.icd10name = this.diagglist |
| | | .map((item) => item.icdname) |
| | | .join(","); |
| | | Editsingletask(this.form).then((res) => { |
| | | if (res.code == 200) { |
| | | if (this.form.taskid) { |
| | | this.$modal.msgSuccess("修改成功"); |
| | | |
| | | // 提交接口 |
| | | Editsingletask(this.form) |
| | | .then((res) => { |
| | | if (res.code == 200) { |
| | | if (this.form.taskid) { |
| | | this.$modal.msgSuccess("修改成功"); |
| | | } else { |
| | | this.$modal.msgSuccess("新增成功"); |
| | | } |
| | | this.$router.push({ |
| | | path: "/followvisit/tasklist", |
| | | query: { tasktopic: this.form.serviceType }, |
| | | }); |
| | | } else { |
| | | this.$modal.msgSuccess("新增成功"); |
| | | // ✅ 接口返回错误码时的处理 |
| | | this.$modal.msgError(res.msg || "操作失败"); |
| | | } |
| | | this.$router.push({ |
| | | path: "/followvisit/tasklist", |
| | | query: { tasktopic: this.form.serviceType }, |
| | | }); |
| | | }) |
| | | .catch((error) => { |
| | | // ✅ 捕获接口请求异常 |
| | | console.error("提交失败:", error); |
| | | this.$modal.msgError(error.message || "网络异常,请稍后重试"); |
| | | }) |
| | | .finally(() => { |
| | | // ✅ 无论成功或失败,最终都关闭加载状态 |
| | | this.submitLoading = false; |
| | | } |
| | | }); |
| | | }); |
| | | } catch (error) { |
| | | // ✅ 捕获同步代码异常 |
| | | console.error("表单提交异常:", error); |
| | | this.$modal.msgError(error.message || "表单提交异常"); |
| | | this.submitLoading = false; |
| | | } finally { |
| | | // 第四步:无论成功或失败,最终都关闭加载状态 |
| | | } |
| | | }, |
| | | handleDiseaseDeptChange(dept) { |
| | |
| | | this.form.patTaskRelevances = this.form.patTaskRelevances |
| | | ? this.form.patTaskRelevances |
| | | : []; |
| | | this.diseaseDept = { |
| | | deptCode: this.form.deptcode, |
| | | deptName: this.form.deptname, |
| | | }; |
| | | this.diseaseWard = { |
| | | districtCode: this.form.leavehospitaldistrictcode, |
| | | districtName: this.form.leavehospitaldistrictname, |
| | | }; |
| | | this.overallCase = this.form.patTaskRelevances.concat(); |
| | | this.checkList = this.form.preachform.split(","); |
| | | this.selectedOrder = this.form.preachformList; |