lkk
2024-10-24 b06a903d08d6f5432105d12686ccaf074b45323a
src/views/doctor/checkAll/index.vue
@@ -493,9 +493,7 @@
              </div>
              <div v-else>
                <table style="width: 100%" v-if="tjproject != '1'">
                  <tr
                    style="border: 1px solid #dfe6ec; "
                  >
                  <tr style="border: 1px solid #dfe6ec">
                    <td
                      style="
                        border: 1px solid #dfe6ec;
@@ -506,7 +504,10 @@
                    >
                      检查所见:
                    </td>
                    <td style="border: 1px solid #dfe6ec; height: 52px;" colspan="2">
                    <td
                      style="border: 1px solid #dfe6ec; height: 52px"
                      colspan="2"
                    >
                      <textarea
                        placeholder="请输入内容"
                        :autosize="{ minRows: 3, maxRows: 4 }"
@@ -1151,6 +1152,9 @@
  name: "checkAll",
  data() {
    return {
      // 更新总检建议
      initialTotalCheckAdvice: "",
      initialState: "",
      preObj: {},
      baogao: [],
      flags: false,
@@ -1698,6 +1702,21 @@
      }
    },
    /*  changRed(row) {
      if (row.label === "↑") {
        return {
          color: "green", // 设置上箭头为绿色
        };
      } else if (row.label === "↓") {
        return {
          color: "red", // 设置下箭头为红色
        };
      }
      // 默认颜色
      return {
        color: "black",
      };
    }, */
    handleCurrentChange(val) {
      if (val != null) {
        this.handleClick(val);
@@ -1709,15 +1728,7 @@
      this.$refs.Pre.open = false;
      this.tableAll = row;
      this.tjproject = "0";
      // if (this.tableAll.cusSex === 0) {
      //   this.tableAll.cusSex = "男";
      // }
      // if (this.tableAll.cusSex === 1) {
      //   this.tableAll.cusSex = "女";
      // }
      // if (this.tableAll.cusSex === 2) {
      //   this.tableAll.cusSex = "未知";
      // }
      this.tjNumber = this.tableAll.tjNumber;
      getState(this.tjNumber).then((res) => {
        this.status = res.data;
@@ -1737,8 +1748,17 @@
                  this.changedate = response.data;
                  if (this.changedate) {
                    this.changedate.forEach((item) => {
                      this.textarea1 = item.checkAdvice;
                      this.textarea1 = item.checkAdvice || "";
                    });
                    // 这里设置初始值
                    this.initialTotalCheckAdvice = this.textarea1; // 保存总检建议
                    // 保存初始状态
                    this.initialState = JSON.parse(
                      JSON.stringify(this.changedate)
                    );
                    for (let i = 0; i < this.changedate.length; i++) {
                      this.remark = this.changedate[i].remark;
                    }
@@ -1791,8 +1811,12 @@
                        for (let i = 0; i < this.changedate.length; i++) {
                          this.remark = this.changedate[i].remark;
                        }
                        this.initialState = JSON.parse(
                          JSON.stringify(this.changedate)
                        );
                        this.changedate.forEach((item) => {
                          this.textarea1 = item.checkAdvice;
                          this.textarea1 = item.checkAdvice || "";
                          // this.remark = item.remark;
                          // item.sons.forEach((item3) => {
@@ -1805,6 +1829,11 @@
                          // });
                          // item.remark = "";
                        });
                        // 保存总检建议
                        this.totalCheckAdvice = this.changedate.map(
                          (item) => item.totalCheckAdvice
                        );
                      } else {
                        this.$message({
                          type: "warning ",
@@ -1855,29 +1884,44 @@
      if (this.loading) {
        return;
      }
      this.$confirm("确定要提交吗?")
        .then((_) => {
          this.loading = true;
          this.timer = setTimeout(() => {
            done();
            this.determine();
            // 动画关闭需要一定的时间
            setTimeout(() => {
              this.loading = false;
            }, 400);
          }, 2000);
        })
        .catch((_) => {
          this.drawer = false;
          let data = {
            userId: this.userId,
            tjNumber: this.tjNumber,
            state: 1,
            id: this.MsgId,
          };
          getfiedState(data).then((res) => {});
          this.submitForm();
        });
      // 检查是否有修改
      let isModified =
        JSON.stringify(this.changedate) !== JSON.stringify(this.initialState) ||
        (this.textarea1 !== this.initialTotalCheckAdvice &&
          this.textarea1 !== null);
      console.log("Initial Total Check Advice:", this.initialTotalCheckAdvice);
      console.log("Current textarea1:", this.textarea1);
      if (isModified) {
        // 如果有修改,弹出确认框
        this.$confirm("检测内容有修改,确定要提交吗?")
          .then(() => {
            this.loading = true;
            this.timer = setTimeout(() => {
              done();
              this.determine();
              setTimeout(() => {
                this.loading = false;
              }, 400);
            }, 2000);
          })
          .catch(() => {
            // 用户取消操作
            this.drawer = false;
            let data = {
              userId: this.userId,
              tjNumber: this.tjNumber,
              state: 1,
              id: this.MsgId,
            };
            getfiedState(data).then((res) => {});
            this.submitForm();
          });
      } else {
        // 如果没有修改,直接关闭
        done();
      }
    },
    handleClose1() {
      this.jianqians = false;
@@ -1904,7 +1948,7 @@
    //   }
    // },
    change(vale) {},
    determine() {
   /*  determine() {
      let tjNumber = this.tableAll.tjNumber;
      let advice = this.textarea1;
      let data = {
@@ -1912,6 +1956,7 @@
        advice,
        checkStatus: 1,
      };
      this.loading = true;
      getTjdetailList(data).then((response) => {
        if (response.code === 200) {
          this.$modal.msgSuccess("提交成功");
@@ -1930,7 +1975,7 @@
              this.$modal.msgError(
                "打印报告失败,请前往报告打印页面补打报告!"
              );
            });
            })
          getfiedState(data).then((res) => {
            this.drawer = false;
          });
@@ -1938,7 +1983,6 @@
          this.queryParams.pageSize = 10;
          this.submitForm();
          this.$forceUpdate();
        }
      });
      for (let i = 0; i < this.changedate.length; i++) {
@@ -1958,6 +2002,89 @@
      //   this.proIds = item.parentId;
      //   // this.remark = item.remark;
      // });
    }, */
    determine() {
      let tjNumber = this.tableAll.tjNumber;
      let advice = this.textarea1;
      let data = {
        tjNumber,
        advice,
        checkStatus: 1,
      };
      // 开始加载
      this.loading = true;
      // 提交数据
      getTjdetailList(data)
        .then((response) => {
          if (response.code === 200) {
            this.$modal.msgSuccess("提交成功");
            // 准备生成报告的请求数据
            let reportData = {
              userId: this.userId,
              tjNumber: tjNumber,
              state: 1,
              id: this.MsgId,
            };
            // 生成报告并保持 loading 打开
            const reportPromise = gettoPdf(tjNumber)
              .then((res) => {
                this.$modal.msgSuccess("已生成报告!请前往报告核收页面确认!");
              })
              .catch((error) => {
                this.$modal.msgError(
                  "打印报告失败,请前往报告打印页面补打报告!"
                );
              });
            // 更新状态并提交修改请求
            const statePromise = getfiedState(reportData).then((res) => {
              this.drawer = false;
            });
            // 处理其他修改操作
            const updatePromises = this.changedate.map((item) => {
              this.proIds = item.parentId;
              let remarks = item.remark;
              let updateOrderRemarkVos = [
                {
                  tjNumber,
                  proId: this.proIds.toString(),
                  remarks,
                },
              ];
              return getModified(updateOrderRemarkVos); // 返回 Promise
            });
            // 等待所有请求完成
            Promise.all([reportPromise, statePromise, ...updatePromises])
              .then(() => {
                // 所有请求完成,关闭 loading
                this.loading = false;
                // 更新分页信息
                this.queryParams.page = 1;
                this.queryParams.pageSize = 10;
                this.submitForm();
                this.$forceUpdate();
              })
              .catch((error) => {
                // 处理错误情况
                this.loading = false;
                console.error("发生错误:", error);
              });
          } else {
            // 提交失败,关闭 loading
            this.loading = false;
          }
        })
        .catch((error) => {
          // 提交请求失败,关闭 loading
          this.loading = false;
          console.error("提交请求失败:", error);
        });
    },
  },
};