fcx
6 天以前 dbfb045ad92072e880104e13fddb4dc7574499a1
1.给SJ获取检验项目添加防抖

2.将保存完一致性维护跳转回上一页跳转功能取消
3.添加手动创建巡检单功能调用逻辑
已修改6个文件
258 ■■■■ 文件已修改
pages/QC/SJ/Add.vue 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/QC/SJ/detail.vue 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/QC/SJ/yzxFrom.vue 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/QC/XJ/Add.vue 100 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/QC/XJ/List.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/QC/XJ/detail.vue 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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>
@@ -175,6 +175,8 @@
      comments: "",
      commentsPopup: false,
      current: true,
      getTableTimer: null, // 防抖定时器
    };
  },
@@ -308,6 +310,11 @@
        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秒后跳转到列表页面
@@ -327,6 +334,10 @@
    init() {
      if (this.formData.id) {
        // 从本地存储读取一致性核对状态
        const storageKey = `yzxChecked_${this.formData.id}`;
        const storedYzxChecked = uni.getStorageSync(storageKey);
        this.$post({
          url: "/SJ/GetPage",
          data: {
@@ -337,11 +348,11 @@
        }).then(res => {
          let tbBillListElement = res.data.tbBillList[0];
          if (tbBillListElement) {
            // 保存当前的yzxChecked状态
            const currentYzxChecked = this.formData.yzxChecked;
            this.formData = tbBillListElement;
            // 恢复yzxChecked状态,避免被服务器数据覆盖
            this.formData.yzxChecked = currentYzxChecked;
            // 恢复本地存储的一致性核对状态
            if (storedYzxChecked) {
              this.formData.yzxChecked = true;
            }
            this.$post({
              url: "/SJ/getQSItems",
              data: {
@@ -464,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: {
@@ -571,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",
@@ -623,8 +648,7 @@
  },
  onShow() {
    // 每次进入页面都会执行的方法
    // 注释掉init()调用,避免覆盖一致性核对状态
    // this.init();
    this.init();
  }
};
</script>
pages/QC/SJ/detail.vue
@@ -232,23 +232,23 @@
          const allCompleted = allItems.every(item => item.result !== '未完成');
          
          if (allCompleted) {
            // 所有项目已完成,跳转到Add页面并刷新
            const pages = getCurrentPages();
            if (pages.length >= 2) {
              const prevPage = pages[pages.length - 2];
              const route = '/' + prevPage.route;
              const options = prevPage.options;
              let query = '';
              for (let key in options) {
                query += `${key}=${options[key]}&`;
              }
              query = query.slice(0, -1);
              setTimeout(() => {
                uni.redirectTo({
                  url: query ? `${route}?${query}` : route
                });
              }, 1000);
            }
            // 所有项目已完成,不自动跳转,用户手动返回
            // const pages = getCurrentPages();
            // if (pages.length >= 2) {
            //   const prevPage = pages[pages.length - 2];
            //   const route = '/' + prevPage.route;
            //   const options = prevPage.options;
            //   let query = '';
            //   for (let key in options) {
            //     query += `${key}=${options[key]}&`;
            //   }
            //   query = query.slice(0, -1);
            //   setTimeout(() => {
            //     uni.redirectTo({
            //       url: query ? `${route}?${query}` : route
            //     });
            //   }, 1000);
            // }
          }
        }
      });
@@ -282,11 +282,13 @@
            }
          });
          
          // 排序后自动跳转到第一个标签
          this.currentTab = 0;
          if (this.tabs.length > 0) {
            this.id = this.tabs[0].id;
            this.refreshResult();
          // 根据当前id查找对应的标签索引(参考LLJ实现)
          const foundIndex = this.tabs.findIndex(tab => tab.id == this.id); // 使用==而非===,避免类型不匹配
          if (foundIndex !== -1) {
            this.currentTab = foundIndex;
          } else {
            // 如果没找到,默认跳转到第一个标签
            this.currentTab = 0;
          }
        } else {
          // 没有项目时至少添加当前项目到标签
@@ -365,9 +367,35 @@
      }).then(res => {
        this.formData.fcheckResu = null;
        this.$showMessage("保存成功");
        this.refreshResult();
        // 重新加载标签项以更新状态
        this.loadTabItems();
        // 等待tabs更新后,查找下一个未完成的项目
        this.$nextTick(() => {
          // 查找下一个未完成的项目
          const nextUnfinishedIndex = this.tabs.findIndex((tab, index) =>
            index > this.currentTab && tab.result === '未完成'
          );
          if (nextUnfinishedIndex !== -1) {
            // 找到了下一个未完成的项目,跳转过去
            this.currentTab = nextUnfinishedIndex;
            this.id = this.tabs[nextUnfinishedIndex].id;
            this.refreshResult();
          } else {
            // 没有下一个未完成的,从头查找第一个未完成的
            const firstUnfinishedIndex = this.tabs.findIndex(tab => tab.result === '未完成');
            if (firstUnfinishedIndex !== -1) {
              this.currentTab = firstUnfinishedIndex;
              this.id = this.tabs[firstUnfinishedIndex].id;
              this.refreshResult();
            } else {
              // 所有项目都已完成,刷新当前项目
              this.refreshResult();
            }
          }
        });
        
        // 检查是否所有检验项目都已完成
        this.checkAllItemsCompleted();
@@ -527,7 +555,8 @@
      this.remarks = this.formData.remarks;
    },
    editRemarks() {
      if (this.remarks) {
      // 允许保存空字符串或空格,只检查是否为null或undefined
      if (this.remarks !== null && this.remarks !== undefined) {
        //saveRemarksGid
        this.$post({
          url: "/SJ/saveRemarksPid",
pages/QC/SJ/yzxFrom.vue
@@ -159,6 +159,11 @@
                  icon: 'success',
                  duration: 2000
                })
                // 保存一致性核对状态到本地存储
                const storageKey = `yzxChecked_${this.formid}`;
                uni.setStorageSync(storageKey, true);
                // 保存成功后更新父页面状态
                const pages = getCurrentPages();
                if (pages.length > 1) {
@@ -168,10 +173,6 @@
                    prevPage.$vm.formData.yzxChecked = true;
                  }
                }
                // 自动返回上一页  增加的
                setTimeout(() => {
                  uni.navigateBack();
                }, 1500);
            }else{
                uni.showModal({
                    title: "提示",
pages/QC/XJ/Add.vue
@@ -3,14 +3,14 @@
    <!-- 头部信息 -->
    <view class="sheet-header">
      <h1>巡检单</h1>
      <view class="inspection-number">检验单号:{{ formData.billNo }}</view>
      <view class="inspection-number">巡检单号:{{ formData.releaseNo }}</view>
    </view>
    <!-- 基本信息区 -->
    <view class="basic-info">
      <view class="info-row">
        <span class="info-label">创建时间:</span>
        <span class="info-value">{{ formData.createTime }}</span>
        <span class="info-value">{{ formData.createDate }}</span>
        <span class="info-label">检验人:</span>
        <span class="info-value">{{ formData.statusUser }}</span>
      </view>
@@ -29,7 +29,7 @@
        <view class="info-label">物料编码:</view>
        <view v-if="!isUpdate" class="info-value">{{ formData.itemNo }}</view>
        <superwei-combox v-else v-model="formData.itemNo" :candidates="boardItems" :isJSON="true"
                         class="picker info-value-input" keyName="itemName" placeholder="请选择或输入"
                         class="picker info-value-input" keyName="itemNo" placeholder="请选择或输入"
                         @select="onItemChange"></superwei-combox>
      </view>
      <view class="info-block">
@@ -60,8 +60,8 @@
    <!-- 操作按钮区 -->
    <view class="action-buttons">
      <button v-if="current" class="secondary-btn" @click="getTable">获取检验项目</button>
      <button v-if="formData.billNo" class="secondary-btn" @click="closeInspection">关闭此次检验</button>
      <button v-if="current && !isUpdate" class="secondary-btn" @click="getTable">获取检验项目</button>
      <button v-if="formData.billNo && !isUpdate" class="secondary-btn" @click="closeInspection">关闭此次检验</button>
    <!-- <button v-if="isShowTable && isUpdate" class="primary-btn" @click="saveTable">生成检验项目</button> --> 
    </view>
@@ -101,7 +101,7 @@
    <!-- 操作按钮区 -->
    <view class="action-buttons">
      <button v-if="isUpdate && !isShowTable" class="secondary-btn" @click="getItem">创建检验单并生成部分默认值</button>
      <button v-if="isUpdate && !isShowTable" class="secondary-btn" @click="getItem1">创建检验单并生成部分默认值</button>
      <button v-if="!isUpdate && !isShowTable" class="secondary-btn" @click="uploadImages">查看所有图片</button>
      <button v-if="!isUpdate && !isShowTable" class="secondary-btn" @click="addDefectDescription">查看不良描述</button>
      <!--  <button v-if="!isUpdate && !formData.statusUser && !isShowTable" class="secondary-btn" @click="removeXJ">
@@ -133,9 +133,10 @@
  data() {
    return {
      formData: {
        createTime: "",
        createDate: "",
        id: "",
        billNo: "",
        releaseNo: "", // 添加巡检单号字段
        itemNo: "",
        itemName: "",
        workshopCode: "",
@@ -192,11 +193,12 @@
        this.isUpdate = false;
        // ⭐⭐⭐ 新增:必须保存到 this.id,后续接口才能使用
        this.id = params["id"];         // ←←← 必须加这一句!!!
        this.id = params["id"];
        // 原来你的逻辑保持不动
        this.formData.id = params["id"];
        this.formData.releaseNo = params["releaseNo"]; // 保存巡检单号
        this.formData.billNo = params["billNo"];
        // 初始化明细
@@ -209,7 +211,7 @@
            url: "/XJ/getMaxReleaseNo"
        }).then(res => {
            this.formData.billNo = res.data.tbBillList;
            this.formData.createTime = this.$getDate("yyyy-mm-dd");
            this.formData.createDate = this.$getDate("yyyy-mm-dd");
        });
        // 产品编码下拉框初始化
@@ -288,7 +290,8 @@
        url: "/XJ/XJQaSubmit",
        data: {
          userNo: this.$loginInfo.account,
          gid: this.formData.id
          gid: this.formData.id,
          releaseNo: this.formData.releaseNo
        }
      }).then(res => {
@@ -297,9 +300,16 @@
        console.log("Status Code的值:", res.statusCode);
        console.log("返回的数据:", res.data);
        
        // 检查多种成功条件
        // 检查tbBillList中的错误消息
        if (res.data && res.data.tbBillList) {
          const errorMsg = res.data.tbBillList.data || res.data.tbBillList.message;
          if (typeof errorMsg === 'string' && errorMsg) {
            this.$showMessage(errorMsg);
            return;
          }
        }
        if (res.statusCode === 200 || res.status === 0 || res.data === true || res.data.tbBillList === true) {
          this.$showMessage("成功提交检验");
          // 提交成功后跳转到列表页面
          setTimeout(() => {
@@ -395,9 +405,66 @@
      })
    },
    getItem1() {
      // 验证必填字段
      if (!this.formData.line) {
        this.$showMessage("请先选择生产线别");
        return;
      }
      if (!this.formData.itemNo) {
        this.$showMessage("请先选择物料编码");
        return;
      }
      if (!this.formData.daa001) {
        this.$showMessage("请先选择工单编号");
        return;
      }
      // 调用后端接口创建检验单
      this.$post({
        url: "/XJ/createInspection",
        data: {
          lineNo: this.formData.line,        // 生产线别
          itemNo: this.formData.itemNo,      // 物料编码
          daa001: this.formData.daa001,       // 工单编号
          account: this.$loginInfo.account  // 登录账号
        }
      }).then(res => {
        console.log("创建检验单完整响应:", res);
        console.log("返回的数据:", res.data);
        // 优先检查tbBillList中的message字段,存在则为失败
        if (res.data && res.data.tbBillList && res.data.tbBillList.message) {
          this.$showMessage(res.data.tbBillList.message);
          return;
        }
        // 检查res.data是否为字符串错误消息
        if (typeof res.data === 'string' && res.data) {
          this.$showMessage(res.data);
          return;
        }
        // 检查res.data是否有有效数据,存在Daa001等字段表示成功
        if (res.data && (res.data.Daa001 || res.data.ItemNo)) {
          this.$showMessage("创建检验单成功");
          // 根据后端返回的数据更新页面
          // 可以在这里处理返回的检验单信息
        } else {
          // 其他失败情况,尝试提取错误消息
          const errorMsg = res.data?.message || "创建失败";
          this.$showMessage(errorMsg);
        }
      }).catch(err => {
        console.log("创建检验单出错:", err);
        this.$showMessage("创建检验单失败,请重试");
      });
    },
    onItemChange(event) {
      this.formData.itemNo = event.itemNo;
      this.formData.itemName = event.itemName;
      this.formData.itemModel = event.itemModel;
      this.$post({
        url: "/XJ/getDaa001",
@@ -468,12 +535,14 @@
  const billNo = this.formData.billNo || '';
  const gid = this.formData.id || '';
  const itemIndex = index != null ? index : 0;
  const currentStatus = this.current ? 'A' : 'B'; // 添加current参数
  uni.navigateTo({
    url: 'detail?id=' + encodeURIComponent(itemId) + 
         '&billNo=' + encodeURIComponent(billNo) + 
         '&gid=' + encodeURIComponent(gid) + 
         '&index=' + encodeURIComponent(itemIndex)
         '&index=' + encodeURIComponent(itemIndex) +
         '&current=' + currentStatus // 传递current状态
  });
},
    getTable() {
@@ -494,7 +563,8 @@
      this.$post({
        url: "/XJ/setJYItem",
        data: {
          itemNo: this.formData.itemNo
          itemNo: this.formData.itemNo,
          releaseNo: this.formData.releaseNo  // 传递巡检单号
        }
      }).then(res => {
        if (res.data && res.data.tbBillList && res.data.tbBillList.length > 0) {
pages/QC/XJ/List.vue
@@ -199,7 +199,7 @@
    },
    handleFabClick() {
      uni.navigateTo({
        url: 'Add?id'
        url: 'Add?current=A'
      });
    },
    onClickItem(index) {
pages/QC/XJ/detail.vue
@@ -165,9 +165,9 @@
              <view v-if="isNumber && !isNaN(parseFloat(item.fcheckResu))" class="simple-number-result">
                <view class="result-value">{{ item.fcheckResu }}</view>
                <view v-if="formData.unitName" class="result-unit">{{ formData.unitName }}</view>
                <view :class="{'pass': isInRange(item.fcheckResu), 'fail': !isInRange(item.fcheckResu)}"
                <view :class="{'pass': item.fstand === '√' || item.isPass === 1, 'fail': item.fstand === '×' || item.isPass === 0}"
                      class="result-status">
                  {{ isInRange(item.fcheckResu) ? '合格' : '不合格' }}
                  {{ (item.fstand === '√' || item.isPass === 1) ? '合格' : '不合格' }}
                </view>
              </view>
@@ -179,12 +179,13 @@
              </view>
            </view>
            <view class="simple-data-cell simple-action">
              <button v-if="!isNumber" class="simple-btn" @click="numberEdit(item)">
              <button v-if="!isNumber && current" class="simple-btn" @click="numberEdit(item)">
                {{ editResult(item.fcheckResu) }}
              </button>
              <button v-if="isNumber" class="simple-btn" @click="toDetail(item)">
              <button v-if="isNumber && current" class="simple-btn" @click="toDetail(item)">
                修改
              </button>
              <view v-if="!current" class="simple-disabled">已提交</view>
            </view>
          </view>
        </view>
@@ -245,7 +246,8 @@
      remarks: "",
      remarksPopup: false,
      currentTab: 0,
      tabs: []
      tabs: [],
      current: true, // 添加current状态,A=true(未提交),B=false(已提交)
    }
  },
  methods: {
@@ -301,7 +303,7 @@
      let fstand = "√";
      //有最大值和最小值就根据是否符合标准值更新判定结果,没有最大值和最小值就根据是否通过检验判定结果
      if (this.formData.maxValue && this.formData.minValue) {
      if (this.formData.maxValue != null && this.formData.minValue != null) {
        if (!this.formData.fcheckResu) {
          this.$showMessage("请输入检验值");
@@ -377,7 +379,7 @@
          this.base64Image = 'data:image/jpeg;base64,' + this.formData.imageData;
        }
        if (this.formData.maxValue && this.formData.minValue && this.formData.standardValue) {
        if (this.formData.maxValue != null && this.formData.minValue != null && this.formData.standardValue != null) {
          this.isNumber = true;
        }
      })
@@ -399,7 +401,7 @@
      let fstand = "√";
      if (this.formData.maxValue && this.formData.minValue) {
      if (this.formData.maxValue != null && this.formData.minValue != null) {
        if (!this.editData.fcheckResu) {
          this.$showMessage("请输入检验值");
@@ -490,7 +492,8 @@
      this.remarks = this.formData.remarks;
    },
    editRemarks() {
      if (this.remarks) {
      // 允许保存空字符串或空格,只检查是否为null或undefined
      if (this.remarks !== null && this.remarks !== undefined) {
        //saveRemarksGid
        this.$post({
          url: "/XJ/saveRemarksPid",
@@ -532,6 +535,13 @@
    this.billNo = params["billNo"];
    this.gid = params["gid"];
    this.currentTab = parseInt(params["index"] || 0);
    // 读取current参数,判断是否已提交
    if (params["current"] === 'A') {
      this.current = true;  // 未提交,可以修改
    } else if (params["current"] === 'B') {
      this.current = false; // 已提交,禁止修改
    }
    this.refreshResult();
    this.loadTabItems();