1
lkk
2025-06-10 35412dc0ad60ae6cbf09035914356be9c4e4c3a4
1
1个文件已修改
68 ■■■■■ 已修改文件
src/components/jianqianwenzhen/index.vue 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/jianqianwenzhen/index.vue
@@ -843,8 +843,8 @@
        xiyanpinlv: "",
        xiyanyear: "",
        yinjiu: "",
        jcwhys:"",
        tjwhys:"",
        jcwhys: "",
        tjwhys: "",
        yinjiupinlv: "",
        yinjiuyear: "",
        qita: "",
@@ -1046,33 +1046,49 @@
      }
      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) {