wangyi
2026-03-03 fbe87c8d043cb038d384df7721bc071676a0c24c
pages/ZLGL/QcenvironmentTestDotCheckBill/QcenvironmentTestDotCheckBill.vue
@@ -65,8 +65,15 @@
               </view>
               <view class="form-item">
                   <view class="left">检测方案</view>
                   <view class="right disabled">
                       <input type="text" disabled :value="hform.HQCSchemeName" />
                   <view class="right" :class="{ 'disabled': hasSourceBill }">
                       <input
                           type="text"
                           v-model="hform.HQCSchemeName"
                           :disabled="hasSourceBill"
                           @confirm="searchSchemeByInput"
                           @blur="searchSchemeByInput"
                           placeholder="请输入单据号"
                       />
                   </view>
                   <view class="icon-wrapper-big">
                       <uni-icons type="search" size="20" @click="showSelectorModule(hform, 7)"></uni-icons>
@@ -251,13 +258,13 @@
         <button class="btn-a" size="mini" @tap="addNew">新增</button>
         <button class="btn-c" size="mini" @tap="goBack">退出</button>
      </view>
      <CheckEnvironmentTestItemPopupVue v-if="enablePopupModule == PopupModuleNameList[2]" ref="listPopup"
         @update="CheckItemComplete" :bindKey="currentChechItemIDCache">
      <CheckEnvironmentTestItemPopupVue v-if="enablePopupModule == PopupModuleNameList[2]" ref="checkItemPopup"
          @update="CheckItemComplete" :bindKey="currentChechItemIDCache">
      </CheckEnvironmentTestItemPopupVue>
      <ProcessPopupVue v-if="enablePopupModule == PopupModuleNameList[8]" ref="listPopup" @update="HProcComplete"
         :bindKey="0"></ProcessPopupVue>
      <CheckSchemePopupVue v-if="enablePopupModule == PopupModuleNameList[7]" ref="listPopup"
         @update="HQCSchemeComplete" :bindKey="0"></CheckSchemePopupVue>
      <ProcessPopupVue v-if="enablePopupModule == PopupModuleNameList[8]" ref="processPopup" @update="HProcComplete"
          :bindKey="0"></ProcessPopupVue>
      <CheckSchemePopupVue v-if="enablePopupModule == PopupModuleNameList[7]" ref="checkSchemePopup"
          @update="HQCSchemeComplete" :bindKey="0"></CheckSchemePopupVue>
   </view>
</template>
@@ -357,15 +364,66 @@
               HQCSchemeID: "0",
            },
            checkItems: {},
            searchTimer: null, // 添加搜索防抖定时器
         };
      },
      methods: {
         async showSelectorModule(item, index) {
             this.currentChechItemIDCache = item.num || 0;
             this.enablePopupModule = this.PopupModuleNameList[index];
             await this.$nextTick();
             this.$refs.listPopup.showPopup();
         },
               async showSelectorModule(item, index) {
                   console.log('showSelectorModule called with index:', index);
                   // 根据不同的模块类型设置不同的缓存值
                   if (index === 7) { // 检测方案
                       this.currentChechItemIDCache = 0;
                   } else if (index === 2) { // 检测项目
                       this.currentChechItemIDCache = item.num || 0;
                   } else if (index === 8) { // 工序
                       this.currentChechItemIDCache = 0;
                   } else {
                       this.currentChechItemIDCache = 0;
                   }
                   this.enablePopupModule = this.PopupModuleNameList[index];
                   console.log('enablePopupModule set to:', this.enablePopupModule);
                   await this.$nextTick();
                   // 根据不同的模块类型调用不同的 ref
                   let popupRef = null;
                   if (index === 2) {
                       popupRef = this.$refs.checkItemPopup;
                       console.log('checkItemPopup ref:', popupRef);
                   } else if (index === 7) {
                       popupRef = this.$refs.checkSchemePopup;
                       console.log('checkSchemePopup ref:', popupRef);
                   } else if (index === 8) {
                       popupRef = this.$refs.processPopup;
                       console.log('processPopup ref:', popupRef);
                   }
                   if (popupRef) {
                       console.log('Calling showPopup on ref');
                       popupRef.showPopup();
                   } else {
                       console.error('Popup ref not found for index:', index);
                       // 尝试重新设置 enablePopupModule
                       setTimeout(() => {
                           this.enablePopupModule = this.PopupModuleNameList[index];
                           this.$nextTick(() => {
                               const retryRef = index === 2 ? this.$refs.checkItemPopup :
                                                index === 7 ? this.$refs.checkSchemePopup :
                                                index === 8 ? this.$refs.processPopup : null;
                               if (retryRef) {
                                   retryRef.showPopup();
                               } else {
                                   uni.showToast({
                                       title: '弹出框加载失败',
                                       icon: 'none'
                                   });
                               }
                           });
                       }, 100);
                   }
               },
         async InitDept() {
             try {
                 let res = await CommonUtils.doRequest2Async({
@@ -427,13 +485,31 @@
                 })
             }
         },
         // 手动输入搜索检测方案
         searchSchemeByInput() {
             if (!this.hform.HQCSchemeName || this.hform.HQCSchemeName.trim() === '') {
                 return;
             }
             // 清除之前的定时器
             if (this.searchTimer) {
                 clearTimeout(this.searchTimer);
             }
             // 设置防抖,避免频繁请求
             this.searchTimer = setTimeout(() => {
                 this.getSchemeByNo(this.hform.HQCSchemeName.trim());
             }, 500);
         },
         // 扫描检测方案
         scanScheme() {
             // 调用扫描功能
             uni.scanCode({
                 success: (res) => {
                     if (res.result) {
                         this.getSchemeByScan(res.result);
                         this.getSchemeByNo(res.result);
                     }
                 },
                 fail: (err) => {
@@ -446,8 +522,10 @@
             });
         },
         
         // 根据扫描结果获取检测方案
         async getSchemeByScan(schemeNo) {
         // 根据单据号获取检测方案
         async getSchemeByNo(schemeNo) {
             if (!schemeNo) return;
             uni.showLoading({
                 title: '加载中...',
                 mask: true
@@ -473,6 +551,8 @@
                         icon: 'success'
                     });
                 } else {
                     // 未找到时清空相关字段
                     this.clearSchemeData();
                     uni.showToast({
                         title: '未找到检测方案',
                         icon: 'none'
@@ -487,6 +567,16 @@
             } finally {
                 uni.hideLoading();
             }
         },
         // 清空检测方案相关数据
         clearSchemeData() {
             this.hform.HQCSchemeName = '';
             this.hform.HEnvironmentTestSchemeID = '0';
             this.hform.HProcName = '';
             this.hform.HProcID = '0';
             this.checkItems = {};
             this.$forceUpdate();
         },
         
         // 处理检测方案数据
@@ -674,17 +764,20 @@
            return Object.keys(obj).length;
         },
         async CheckItemComplete(e) {
            for (var key in e["retVal"]) {
               let data = e["retVal"][key];
               Object.assign(this.checkItems[key], {
                  HEnvironmentItemID: data["HItemID"],
                  HQCCheckItemName: data["环境检测项目名称"],
               });
               await this.$nextTick();
               this.$refs.listPopup.exit();
               await this.$nextTick();
               this.enablePopupModule = this.PopupModuleNameList[0];
            }
             for (var key in e["retVal"]) {
                 let data = e["retVal"][key];
                 Object.assign(this.checkItems[key], {
                     HEnvironmentItemID: data["HItemID"],
                     HQCCheckItemName: data["环境检测项目名称"],
                 });
                 await this.$nextTick();
                 // 修改这里:使用 checkItemPopup 而不是 listPopup
                 if (this.$refs.checkItemPopup) {
                     this.$refs.checkItemPopup.exit();
                 }
                 await this.$nextTick();
                 this.enablePopupModule = this.PopupModuleNameList[0];
             }
         },
         async HQCSchemeComplete(e) {
             let allItems = Object.values(e.retVal);
@@ -763,17 +856,20 @@
             this.$forceUpdate();
         },
         async HProcComplete(e) {
            for (var key in e["retVal"]) {
               let data = e["retVal"][key];
               Object.assign(this.hform, {
                  HProcName: data["工序名称"],
                  HProcID: data["HItemID"],
               });
               await this.$nextTick();
               this.$refs.listPopup.exit();
               await this.$nextTick();
               this.enablePopupModule = this.PopupModuleNameList[0];
            }
             for (var key in e["retVal"]) {
                 let data = e["retVal"][key];
                 Object.assign(this.hform, {
                     HProcName: data["工序名称"],
                     HProcID: data["HItemID"],
                 });
                 await this.$nextTick();
                 // 修改这里:使用 processPopup 而不是 listPopup
                 if (this.$refs.processPopup) {
                     this.$refs.processPopup.exit();
                 }
                 await this.$nextTick();
                 this.enablePopupModule = this.PopupModuleNameList[0];
             }
         },
         async getMaxBillNo() {
            try {
@@ -905,6 +1001,12 @@
         await this.InitDept();
         await this.WorkCenter1();
      },
      // 组件销毁时清除定时器
      beforeDestroy() {
          if (this.searchTimer) {
              clearTimeout(this.searchTimer);
          }
      }
   };
</script>
@@ -963,6 +1065,13 @@
            .uni-combox { padding: 0; height: auto; }
            .uni-combox::v-deep input { height: inherit; font-size: 26rpx; }
            input {
                width: 100%;
                border: none;
                outline: none;
                background: transparent;
            }
         }
         .disabled { border: 1px solid #e4e4e4; background-color: #e4e4e4; }
         .none-border { border: none; }