| | |
| | | xiyanpinlv: "", |
| | | xiyanyear: "", |
| | | yinjiu: "", |
| | | jcwhys:"", |
| | | tjwhys:"", |
| | | jcwhys: "", |
| | | tjwhys: "", |
| | | yinjiupinlv: "", |
| | | yinjiuyear: "", |
| | | qita: "", |
| | |
| | | } |
| | | 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(); |
| | | }, |
| | | |
| | | // 新增行 |
| | | addmembers() { |
| | | if (this.form.cusName) { |