fcx
5 天以前 dbfb045ad92072e880104e13fddb4dc7574499a1
pages/QC/SJ/Add.vue
@@ -52,7 +52,7 @@
        <view class="info-label">工单数量:</view>
        <view class="info-value highlight">{{ formData.daa008 }}</view>
      </view>
      <view v-if="formData.remarks && current" class="info-block">
      <view v-if="formData.remarks" class="info-block">
        <view class="info-label">备注:</view>
        <view class="info-value">{{ formData.remarks }}</view>
      </view>
@@ -87,10 +87,10 @@
          <td>
            <button v-if="item.isCheck < item.levelNum" class="record-btn record-btn-fill"
                    @click="toDetail(item, index)">
              填写 ({{ item.isCheck }}/{{ item.levelNum }})
              填写 <!--({{ item.isCheck }}/{{ item.levelNum }})-->
            </button>
            <button v-else class="record-btn record-btn-view" @click="toDetail(item, index)">
              查看 ({{ item.isCheck }}/{{ item.levelNum }})
              查看<!--({{ item.isCheck }}/{{ item.levelNum }})-->
            </button>
          </td>
        </tr>
@@ -146,6 +146,7 @@
        statusUser: "",
        itemId: "",
        fSubmit: 0,
        yzxChecked: false, // 添加一致性核对状态字段
      },
      DAA020List: [],
@@ -174,6 +175,8 @@
      comments: "",
      commentsPopup: false,
      current: true,
      getTableTimer: null, // 防抖定时器
    };
  },
@@ -252,6 +255,44 @@
    },
    submit() {
      // 检查是否需要一致性核对
      if (this.current && !this.formData.yzxChecked) {
        // 先检查该物料是否维护了一致性核对项目
        this.$post({
          url: "/SJ/getYzxItem",
          data: {
            id: this.formData.id
          }
        }).then(res => {
          // 如果维护了一致性核对项目(components.length > 0),则要求完成核对
          if (res.data && res.data.length > 0) {
            uni.showModal({
              title: "提示",
              content: "请先完成一致性核对后再提交检验",
              confirmText: "去核对",
              cancelText: "取消",
              success: (modalRes) => {
                if (modalRes.confirm) {
                  this.toYzxSubmitFrom(this.formData.billNo);
                }
              }
            });
          } else {
            // 未维护一致性核对项目,允许直接提交
            this.submitInspection();
          }
        }).catch(() => {
          // 接口异常,允许提交
          this.submitInspection();
        });
        return;
      }
      // 已完成一致性核对或不需要核对,直接提交
      this.submitInspection();
    },
    submitInspection() {
      this.$post({
        url: "/SJ/SJQaSubmit",
        data: {
@@ -269,23 +310,34 @@
        if (res.statusCode === 200 || res.status === 0 || res.data === true || res.data.tbBillList === true) {
          this.$showMessage("成功提交检验");
          // 提交成功后跳转到列表页面
          // 清除本地存储的一致性核对状态
          const storageKey = `yzxChecked_${this.formData.id}`;
          uni.removeStorageSync(storageKey);
          // 提交成功后刷新页面数据
          this.init();
          // 1.5秒后跳转到列表页面
          setTimeout(() => {
            uni.navigateTo({
              url: '/pages/QC/SJ/List'
            });
          }, 1500); // 1.5秒后跳转,让用户看到成功提示
          }, 1500);
        } else {
          this.$showMessage(res.data.message || res.message || "提交失败");
        }
      }).catch(err => {
        console.log("提交出错:", err);
        this.$showMessage("提交失败,请重试");
        this.$showMessage("提交失败,请重试");
      })
    },
    init() {
      if (this.formData.id) {
        // 从本地存储读取一致性核对状态
        const storageKey = `yzxChecked_${this.formData.id}`;
        const storedYzxChecked = uni.getStorageSync(storageKey);
        this.$post({
          url: "/SJ/GetPage",
          data: {
@@ -297,6 +349,10 @@
          let tbBillListElement = res.data.tbBillList[0];
          if (tbBillListElement) {
            this.formData = tbBillListElement;
            // 恢复本地存储的一致性核对状态
            if (storedYzxChecked) {
              this.formData.yzxChecked = true;
            }
            this.$post({
              url: "/SJ/getQSItems",
              data: {
@@ -419,13 +475,26 @@
          duration: 2000,
        });
      } else {
        const currentStatus = this.current ? 'A' : 'B'; // 添加current参数
        uni.navigateTo({
          url: 'detail?id=' + item.id + '&billNo=' + this.formData.billNo + '&gid=' + this.formData
              .id + '&index=' + index
              .id + '&index=' + index + '&current=' + currentStatus
        });
      }
    },
    getTable() {
      // 清除上一次的定时器
      if (this.getTableTimer) {
        clearTimeout(this.getTableTimer);
      }
      // 设置1秒防抖
      this.getTableTimer = setTimeout(() => {
        this.executeGetTable();
      }, 1000);
    },
    executeGetTable() {
      this.$post({
        url: "/SJ/SetQSItems",
        data: {
@@ -526,7 +595,8 @@
      this.comments = this.formData.comments;
    },
    editRemarks() {
      if (this.remarks) {
      // 允许保存空字符串或空格,只检查是否为null或undefined
      if (this.remarks !== null && this.remarks !== undefined) {
        //saveRemarksGid
        this.$post({
          url: "/SJ/saveRemarksGid",
@@ -577,7 +647,7 @@
    }
  },
  onShow() {
    //每次进入页面都会执行的方法
    // 每次进入页面都会执行的方法
    this.init();
  }
};