| | |
| | | } |
| | | this.form.tjAskHistorysList = response.data.tjAskHistorysList; |
| | | this.form.zhiyezzList = response.data.zhiyezzList; |
| | | console.log(response.data.tjAskHistorysList, 123456); |
| | | |
| | | // this.isdisabled= true |
| | | }); |
| | |
| | | }); |
| | | }, |
| | | |
| | | addzj() { |
| | | /* addzj() { |
| | | if (this.form.cusName) { |
| | | if (!this.form.zhiyezzList) { |
| | | this.form.zhiyezzList = []; |
| | |
| | | }); |
| | | } |
| | | } else { |
| | | Message.warning("请先填写客户名"); |
| | | this.$message.warning("请先填写客户名"); |
| | | } |
| | | this.$forceUpdate(); |
| | | }, */ |
| | | |
| | | addzj() { |
| | | if (!this.form.cusName) { |
| | | this.$message.warning("请先填写客户名"); |
| | | return; |
| | | } |
| | | |
| | | if (!this.form.zhiyezzList) { |
| | | this.form.zhiyezzList = []; |
| | | } |
| | | |
| | | this.form.zhiyezzList.push({ |
| | | id: Date.now(), // 用时间戳当本地唯一 id |
| | | diseaseId: null, // 关键!明确标识“还没存进数据库” |
| | | isLocal: true, // 可选,便于后续处理 |
| | | diseaseName: "", |
| | | diseaseData: "", |
| | | diseaseCompany: "", |
| | | isOk: "", |
| | | remark: "", |
| | | icdId: "", |
| | | type: "", |
| | | }); |
| | | |
| | | this.$forceUpdate(); // 强制刷新(如果需要) |
| | | }, |
| | | |
| | | delezz() { |
| | | if (this.selectedZhiyezz && this.selectedZhiyezz.length > 0) { |
| | | const historyId = this.selectedZhiyezz.map((item) => item.diseaseId); |
| | | console.log(historyId, "准备删除的 diseaseId"); |
| | | |
| | | // 发请求 |
| | | removeAskHistorys(historyId).then((res) => { |
| | | console.log(res, "删除接口响应"); |
| | | |
| | | this.$message.success("删除成功"); |
| | | |
| | | // 接口成功后再本地删除 |
| | | this.form.zhiyezzList = this.form.zhiyezzList.filter( |
| | | (item) => |
| | | !this.selectedZhiyezz.some( |
| | | (selected) => selected.diseaseId === item.diseaseId |
| | | ) |
| | | ); |
| | | |
| | | this.selectedZhiyezz = []; |
| | | this.$forceUpdate(); |
| | | }); |
| | | } else { |
| | | async delezz() { |
| | | if (!this.selectedZhiyezz?.length) { |
| | | this.$message.warning("请先选择要删除的项"); |
| | | return; |
| | | } |
| | | |
| | | // 拆分“本地数据”和“数据库数据” |
| | | const localItems = this.selectedZhiyezz.filter((item) => !item.diseaseId); |
| | | const dbItems = this.selectedZhiyezz.filter((item) => item.diseaseId); |
| | | |
| | | // 先备份一下当前列表,方便出错时恢复 |
| | | const backupList = [...this.form.zhiyezzList]; |
| | | |
| | | // 删除本地新增项(不需要调接口) |
| | | this.form.zhiyezzList = this.form.zhiyezzList.filter( |
| | | (item) => !localItems.includes(item) |
| | | ); |
| | | |
| | | try { |
| | | // 如果有数据库项,要调用接口删除 |
| | | if (dbItems.length) { |
| | | const deletedIds = dbItems.map((item) => item.diseaseId); |
| | | const res = await removeAskHistorys(deletedIds); |
| | | if (res?.code !== 200) throw new Error("删除失败"); |
| | | |
| | | // 接口成功,再从页面移除数据库数据 |
| | | this.form.zhiyezzList = this.form.zhiyezzList.filter( |
| | | (item) => !dbItems.includes(item) |
| | | ); |
| | | this.$message.success("删除成功"); |
| | | } |
| | | } catch (err) { |
| | | // 删除失败 |
| | | this.form.zhiyezzList = backupList; |
| | | this.$message.error("删除失败"); |
| | | console.error(err); |
| | | } |
| | | |
| | | // 清空选中 |
| | | this.selectedZhiyezz = []; |
| | | this.$forceUpdate(); |
| | | }, |
| | | |
| | | // 新增行 |
| | |
| | | }, |
| | | |
| | | submitForm() { |
| | | console.log("提交前 form:", JSON.parse(JSON.stringify(this.form))); |
| | | // console.log("提交前 form:", JSON.parse(JSON.stringify(this.form))); |
| | | this.$refs.form.validate((valid) => { |
| | | console.log("校验后 form:", JSON.parse(JSON.stringify(this.form))); |
| | | // console.log("校验后 form:", JSON.parse(JSON.stringify(this.form))); |
| | | if (valid) { |
| | | this.$emit("submitLoading", true); |
| | | |
| | |
| | | id: match ? match.id : "", |
| | | }; |
| | | }); |
| | | console.log(this.form, 1236); |
| | | // console.log(this.form, 1236); |
| | | |
| | | updateHistory(this.form) |
| | | .then((response) => { |