wangyi
2026-03-03 346314803cee2a7a0a1fbe6dfd9923887679016f
pages/ZLGL/QcenvironmentTestDotCheckBill/QcenvironmentTestDotCheckBill.vue
@@ -35,19 +35,17 @@
                   </view>
               </view>
               <view class="form-item">
                  <view class="left">工作中心</view>
                  <view class="right disabled">
                     <input type="text" :value="hform.HCenterWorkName" disabled />
                  </view>
                  <view class="icon-wrapper-big"><uni-icons type="search" size="20":class="!hasSourceBill?'enable-icon-button':'disable-icon-button'"
                     :disabled="HCenterWorkName"
                        @click="showSelectorModule(hform, 6)"></uni-icons></view>
                   <view class="left">工作中心</view>
                   <view class="right">
                       <uni-combox :candidates="WorkCenterList" placeholder="请选择工作中心" v-model="hform.HCenterWorkName"
                           @input="WorkCenterChange"></uni-combox>
                   </view>
               </view>
               <view class="form-item">
                   <view class="left">洁净度</view>
                   <view class="right select-border">  
                       <uni-data-select
                           v-model="hform.HCleanliness"
                           v-model="hform.HCleanType"
                           :localdata="cleanlinessList"
                           :clear="false"
                           placeholder="请选择洁净度"
@@ -61,17 +59,22 @@
                  <view class="left">记录人</view>
                  <view class="right">
                     <uni-combox :candidates="GyFirstCheckEmpNameList" placeholder="请选择记录人"
                        v-model="hform.HFirstCheckEmpName"
                        v-model="hform.HEmpName"
                        @update:modelValue="HFirstCheckEmpChange"></uni-combox>
                  </view>
               </view>
               <view class="form-item">
                  <view class="left">检测方案</view>
                  <view class="right disabled">
                     <input type="text" disabled :value="this.hform.HQCSchemeName" />
                  </view>
                  <view class="icon-wrapper-big"><uni-icons type="search" size="20"
                        @click="showSelectorModule(hform, 7)"></uni-icons></view>
                   <view class="left">检测方案</view>
                   <view class="right disabled">
                       <input type="text" disabled :value="hform.HQCSchemeName" />
                   </view>
                   <view class="icon-wrapper-big">
                       <uni-icons type="search" size="20" @click="showSelectorModule(hform, 7)"></uni-icons>
                   </view>
                   <!-- 添加扫描图标 -->
                   <view class="icon-wrapper-big" style="margin-left: 10rpx;">
                       <uni-icons type="scan" size="20" @click="scanScheme"></uni-icons>
                   </view>
               </view>
               <view class="form-item">
                  <view class="left">工序</view>
@@ -88,13 +91,13 @@
               <view class="form-item">
                  <view class="left">改善对策</view>
                  <view class="right">
                     <input type="text" v-model="hform.HErrTreatment" value="" />
                     <input type="text" v-model="hform.HNote" value="" />
                  </view>
               </view>
                    <view class="form-item">
                       <view class="left">异常原因</view>
                       <view class="right">
                          <input type="text" v-model="hform.HBatchNo" />
                          <input type="text" v-model="hform.HErrMsgBack" />
                       </view>
                    </view>
                    <view class="form-item">
@@ -103,6 +106,12 @@
                          <input type="text" v-model="hform.HRemark" value="" />
                       </view>
                    </view>
               <view class="form-item">
                  <view class="left">组织</view>
                  <view class="right disabled">
                      <input type="text" v-model="hform.Organization" value="" disabled />
                  </view>
               </view>
            </view>
            <!-- 制单信息 -->
            <view class="bill-main-content" v-if="mainTabSelected == 3">
@@ -176,37 +185,64 @@
            <view v-for="subTab in subTabs" :key="subTab.id" :class="subTab.id == subTabSelected ? 'selected' : ''"
               @tap="subTabSelected = subTab.id">{{ subTab.name }}</view>
         </view>
         <!-- 子表内容 -->
         <view class="bill-main-contents">
            <!-- 检验项目 呈现 -->
            <view v-if="subTabSelected == 1">
               <!-- 需通过显式调用忽略$event参数 -->
               <view class="buttons" @tap="addCheckItem()">
                  <uni-icons type="plus" style="margin-right: 10rpx" size="22"></uni-icons>新增
               </view>
               <view class="over" v-if="!checkItems || getObjLength(checkItems) == 0">暂无数据</view>
               <view class="list" v-else>
                  <uni-card v-for="checkItem in checkItems" :key="checkItem.num">
                     <view class="card-detail">
                        <view class="detail"> <text>序号:</text>{{ checkItem.num }} </view>
                        <view class="detail editable">
                           <view style="flex-shrink: 0"><text>检验项目:</text></view>
                           <input type="text" :value="checkItem.HQCCheckItemName" disabled="" />
                           <view class="icon-wrapper"><uni-icons type="search" size="16"
                                 @click="showSelectorModule(checkItem, 2)"></uni-icons></view>
                        </view>
                     </view>
                     <view style="height: 20rpx"></view>
                     <view class="more">
                        <view class="part" style="color: #da0000" @tap.stop="removeCheckItem(checkItem)">
                           <uni-icons type="trash" style="color: #da0000; margin-right: 10rpx"
                              size="18"></uni-icons>删除
      <!-- 子表内容 -->
      <view class="bill-main-contents">
          <!-- 检验项目 呈现 -->
          <view v-if="subTabSelected == 1">
              <view class="buttons" @tap="addCheckItem()">
                  <uni-icons type="plus" style="margin-right: 10rpx" size="22"></uni-icons>新增
              </view>
              <view class="over" v-if="!checkItems || getObjLength(checkItems) == 0">暂无数据</view>
              <view class="list" v-else>
                  <uni-card v-for="checkItem in checkItems" :key="checkItem.num">
                      <view class="card-detail">
                          <view class="detail-row">
                              <view class="detail"><text>序号:</text>{{ checkItem.num }}</view>
                              <view class="detail editable">
                                  <text>检测项目:</text>
                                  <input type="text" :value="checkItem.HQCCheckItemName" disabled class="editable-input" />
                                  <view class="icon-wrapper">
                                      <uni-icons type="search" size="16" @click="showSelectorModule(checkItem, 2)"></uni-icons>
                                  </view>
                              </view>
                        </view>
                     </view>
                  </uni-card>
               </view>
            </view>
         </view>
                          <view class="values-row">
                        <view class="detail actual-value">
                             <text>实际值:</text>
                             <input
                                 type="text"
                                 v-model="checkItem.HMeasure"
                                 placeholder="请输入"
                                 class="actual-input"
                             />
                         </view>
                              <view class="value-item">
                                  <text>目标值:</text>
                                  <text class="value">{{ checkItem.HTargetVal || '' }}</text>
                              </view>
                        </view>
                     <view class="values-row">
                              <view class="value-item">
                                  <text>上限值:</text>
                                  <text class="value">{{ checkItem.HUpLimit || '' }}</text>
                              </view>
                              <view class="value-item">
                                  <text>下限值:</text>
                                  <text class="value">{{ checkItem.HDownLimit || '' }}</text>
                              </view>
                          </view>
                      </view>
                      <!-- 删除按钮 -->
                      <view class="more">
                          <view class="part" style="color: #da0000" @tap.stop="removeCheckItem(checkItem)">
                              <uni-icons type="trash" style="color: #da0000; margin-right: 10rpx" size="18"></uni-icons>删除
                          </view>
                      </view>
                  </uni-card>
              </view>
          </view>
      </view>
      </view>
      <view style="height: 120rpx"></view>
      <view class="bottom-btn">
@@ -215,28 +251,13 @@
         <button class="btn-a" size="mini" @tap="addNew">新增</button>
         <button class="btn-c" size="mini" @tap="goBack">退出</button>
      </view>
      <SampleSchemePopupVue v-if="enablePopupModule == PopupModuleNameList[1]" ref="listPopup"
         @update="SampleSchemeComplete" :bindKey="currentChechItemIDCache">
      </SampleSchemePopupVue>
      <CheckItemPopupVue v-if="enablePopupModule == PopupModuleNameList[2]" ref="listPopup"
      <CheckEnvironmentTestItemPopupVue v-if="enablePopupModule == PopupModuleNameList[2]" ref="listPopup"
         @update="CheckItemComplete" :bindKey="currentChechItemIDCache">
      </CheckItemPopupVue>
      <InspectMentPopupVue v-if="enablePopupModule == PopupModuleNameList[3]" ref="listPopup"
         @update="InspectMentComplete" :bindKey="currentChechItemIDCache">
      </InspectMentPopupVue>
      <MaterialPopupVue v-if="enablePopupModule == PopupModuleNameList[4]" ref="listPopup" @update="MaterComplete"
         :bindKey="0">
      </MaterialPopupVue>
      <ICMOBillPopupVue v-if="enablePopupModule == PopupModuleNameList[5]" ref="listPopup" @update="ICMOBillComplete"
         :bindKey="0"></ICMOBillPopupVue>
      <ProcExchBillPopupVue v-if="enablePopupModule == PopupModuleNameList[6]" ref="listPopup"
         @update="ProcExchBillComplete" :bindKey="0"></ProcExchBillPopupVue>
      </CheckEnvironmentTestItemPopupVue>
      <ProcessPopupVue v-if="enablePopupModule == PopupModuleNameList[8]" ref="listPopup" @update="HProcComplete"
         :bindKey="0"></ProcessPopupVue>
      <CheckProjectPopupVue v-if="enablePopupModule == PopupModuleNameList[7]" ref="listPopup"
         @update="HQCSchemeComplete" :bindKey="0"></CheckProjectPopupVue>
      <BillListPopupVue ref="billList" :HBillType="hform.HBillType" :HSourceBillType="hform.HSourceBillType"
         :HStockOrgID="hform.HStockOrgID" @BillSelectComplete="HandleBillSelectComplete"></BillListPopupVue>
      <CheckSchemePopupVue v-if="enablePopupModule == PopupModuleNameList[7]" ref="listPopup"
         @update="HQCSchemeComplete" :bindKey="0"></CheckSchemePopupVue>
   </view>
</template>
@@ -245,367 +266,107 @@
   import {
      CommonUtils
   } from "../../../utils/common";
   import InspectValueTemplateVue from "@/components/ZLGL/InspectValueTemplate.vue";
   import SampleSchemePopupVue from "@/components/ZLGL/SampleSchemePopup.vue";
   import CheckItemPopupVue from "@/components/ZLGL/CheckItemPopup.vue";
   import InspectMentPopupVue from "../../../components/ZLGL/InspectMentPopup.vue";
   import MaterialPopupVue from "../../../components/ZLGL/MaterialPopup.vue";
   import ICMOBillPopupVue from "../../../components/ZLGL/ICMOBillPopup.vue";
   import ProcExchBillPopupVue from "../../../components/ZLGL/ProcExchBillPopup.vue";
   import CheckEnvironmentTestItemPopupVue from "../../../components/ZLGL/CheckEnvironmentTestItemPopup.vue";
   import ProcessPopupVue from "../../../components/ZLGL/ProcessPopup.vue";
   import CheckProjectPopupVue from "../../../components/ZLGL/CheckProjectPopup.vue";
   import BillListPopupVue from "../../../components/BillListPopup/BillListPopup.vue";
   import CheckSchemePopupVue from "../../../components/ZLGL/CheckSchemePopup.vue";
   import {
      getUserInfo
   } from "../../../utils/auth";
   import {
      MpaasScan
   } from "../../../utils/mpaasScan";
   export default {
      components: {
         InspectValueTemplateVue,
         SampleSchemePopupVue,
         CheckItemPopupVue,
         InspectMentPopupVue,
         MaterialPopupVue,
         ICMOBillPopupVue,
         ProcExchBillPopupVue,
         CheckEnvironmentTestItemPopupVue,
         ProcessPopupVue,
         CheckProjectPopupVue,
         BillListPopupVue,
      },
      computed: {
         judgeConclusion: {
            get() {
               return true;
            },
         },
         CheckSchemePopupVue,
      },
      data() {
         return {
            operationType: 1,
            mainTabSelected: 1,
            subTabSelected: 1,
            // 源单状态控制
            hasSourceBill: false,
            // 控制当前显示的弹窗模块
            enablePopupModule: "",
            PopupModuleNameList: [
               "",
               "SampleScheme",
               "",
               "CheckItem",
               "InspectMent",
               "Material",
               "ICMOBill",
               "ProcExchBill",
               "",
               "",
               "",
               "",
               "QCScheme",
               "Process",
            ],
            // 当前操作的检验单ID缓存
            currentChechItemIDCache: -1,
            // uni-combox 选择器使用
            // 检验员
            GyFirstCheckEmpList: [],
            GyFirstCheckEmpNameList: [],
            // 部门列表
            DeptNameList: [],
            DeptList: [],
            WorkCenter:[],
            WorkCenterList:[],
            cleanlinessList: [
                { value: 'A', text: 'A' },
                { value: 'B', text: 'B' },
                { value: 'C', text: 'C' }
                ],
                hform: {
                    HCleanliness: ''
                },
            ArrayAnalysisMethodValue: [1],
            // 子表 页签信息
            ],
            subTabs: {
               1: {
                  id: "1",
                  name: "检验项目",
               },
            },
            // 主表属性
            hform: {
               HSourceBillType: "3791",
               HBillType: '7524',
               HSourceBillNo: "",
               HSourceBillQty: 0,
               HBillNo: "",
               HBillSubType: '7524',
               HInterID: "0",
               HDate: dayjs(new Date()).format("YYYY-MM-DD"),
               HSourceName: "",
               HSourceID: "0",
               HShiftsName: "",
               HShiftsID: "0",
               HDeptID:"0",
               HDeptName:"",
               HICMOBillNo: "",
               HICMOInterID: "0",
               HICMOEntryID: "1",
               HICMOQty: "0",
               HProcExchBillNo: "",
               HProcExchInterID: "0",
               HProcExchEntryID: "0",
               HProcExchQty: "0",
               HMaterNumber: "",
               HMaterID: "0",
               HMaterName: "",
               HFirstCheckEmpName: getUserInfo().HEmpName,
               HFirstCheckEmp: getUserInfo().HEmpID,
               HQCSchemeName: "",
               HQCSchemeID: "0",
               HBatchNo: "",
               HCheckerResult: true, // 默认合格
               HProcName: "",
               HBillNo: "",
               HBillStatus: "1",
               HYear: String(dayjs(new Date()).year()),
               HPeriod: String(dayjs(new Date()).month() + 1),
               HDeptID: String(getUserInfo()["HDeptID"] || "0"),
               HDeptName: getUserInfo()["HDeptName"] || "",
               Organization: getUserInfo()["Organization"] || "",
               HCenterWorkID: "",
               HCenterWorkName: "",
               HProcID: "0",
               HTakeSampleCheckBillNo: "", // 取样单
               HTakeSampleCheckBillID: "0",
               HProcName: "",
               HCleanType: 'A',
               HEmpID: String(getUserInfo().HEmpID || "0"),
               HEmpName: getUserInfo().HEmpName || "",
               HEnvironmentTestSchemeID: "0",
               HEnvironmentTestSchemeName: "",
               HErrMsgBack: "",
               HNote: "",
               HRemark: "",
               HDeptName: getUserInfo()["HDeptName"],
               HDeptID: getUserInfo()["HDeptID"],
               HMaker: getUserInfo()["Czymc"] || "",
               HChecker: "",
               HCloseMan: "",
               HMakeDate: dayjs(new Date()).format("YYYY-MM-DDTHH:mm:ss"),
               HCheckDate: "",
               HCloseDate: "",
               HUpDater: "",
               HDeleteMan: "",
               HUpDateDate: "",
               HDeleteDate: "",
               HResult: 1,
               HAnalysisMethod: "",
               HCheckQty: 0,
               HResDec: "",
               HStatus: 1,
               HMainSourceBillType: "",
               HMainSourceInterID: "0",
               HMainSourceEntryID: "1",
               HMainSourceBillNo: "",
               HStockOrgID: uni.getStorageSync('OrganizationID'),
               HOrgID: uni.getStorageSync('OrganizationID') || "0",
               HMaker: getUserInfo()["Czymc"] || "",
               HMakeDate: dayjs(new Date()).format("YYYY-MM-DDTHH:mm:ss"),
               HChecker: "",
               HCheckDate: "",
               HCloseMan: "",
               HCloseDate: "",
               HUpDater: "",
               HUpDateDate: "",
               HDeleteMan: "",
               HDeleteDate: "",
               HQCSchemeName: "",
               HQCSchemeID: "0",
            },
            // 检项目
            checkItems: {},
            // 检测值模块
            InspectModules: {},
            // 检测值
            InspectValues: {},
         };
      },
      methods: {
         // 源单类型选择
         HSourceBillTypeNameChange(e) {
            this.HSourceBillType = this.HSourceBillTypeNameList[e.detail.value];
            this.hform.HSourceBillType = this.HSourceBillTypeValueList[e.detail.value];
            const pages = getCurrentPages()
            // 获取页面栈中的最后一个元素,也就是当前显示的页面
            const currentPage = pages[pages.length - 1]
            // 选择源单类型后 缓存当前页面选择
            uni.setStorageSync(`${currentPage.route.split("/").pop()}_HSourceBillTypeCache`, {
               HSourceBillTypeName: this.HSourceBillType,
               HSourceBillType: this.hform.HSourceBillType
            })
         async showSelectorModule(item, index) {
             this.currentChechItemIDCache = item.num || 0;
             this.enablePopupModule = this.PopupModuleNameList[index];
             await this.$nextTick();
             this.$refs.listPopup.showPopup();
         },
         // 读取缓存
         loadCache() {
            const pages = getCurrentPages()
            // 获取页面栈中的最后一个元素,也就是当前显示的页面
            const currentPage = pages[pages.length - 1]
            let HBillTypeCache = uni.getStorageSync(`${currentPage.route.split("/").pop()}_HSourceBillTypeCache`)
            if (HBillTypeCache) {
               this.HSourceBillType = HBillTypeCache.HSourceBillTypeName
               this.hform.HSourceBillType = HBillTypeCache.HSourceBillType
               this.hform.HMainSourceBillType = HBillTypeCache.HSourceBillType
            }
         },
         // 根据源单类型选择单据
         toBillSelector() {
            this.$refs['billList'].showPopup()
         },
         toScanCode() {
            MpaasScan.scanCode((res) => {
               if (res) {
                  this.getSourceBillInfo(HBarCode);
               }
            });
         },
         async HandleBillSelectComplete(e) {
             try {
                 let res = await CommonUtils.doRequest2Async({
                     url: "/WEBSController/get_CheckBillBarCode_Json_CheckItem",
                     data: {
                         HBillType: this.hform.HBillType,
                         HSourceBillType: this.hform.HSourceBillType,
                         HBarCode: "",
                         HInterID: e?.HInterID,
                         HEntryID: e?.HEntryID,
                         Mode: 2 ,//选单模式
                     user:getUserInfo()["Czymc"]
                     }
                 })
                 let {
                     data,
                     Message,
                     count
                 } = res.data
                 if (count == 1) {
                     console.log('获取源单:', data)
                     this.hform.HMaterID = data[0]['HMaterID']
                     this.hform.HMaterName = data[0]['产品名称']
                     this.hform.HMaterNumber = data[0]['产品代码']
                     this.hform.HMainSourceBillNo = data[0]['HBillNo']
                     this.hform.HSourceBillNo = data[0]['HBillNo']
                     this.hform.HMainSourceInterID = data[0].HInterID
                     this.hform.HMainSourceEntryID = data[0].HEntryID
                     this.hform.HQCSchemeName = data[0].检验方案名称
                     this.hform.HQCSchemeID = data[0].检验方案ID
                     this.hform.HSourceBillQty = data[0].HSourceBillQty
                     this.hform.HICMOBillNo= data[0].任务单号
                     this.hform.HICMOInterID= data[0].HICMOInterID
                     this.hform.HICMOEntryID= data[0].HICMOEntryID
                     this.hform.HICMOQty= data[0].生产数量
                     this.hform.HProcExchBillNo= data[0].单据号
                     this.hform.HProcExchInterID= data[0].HInterID
                     this.hform.HProcExchEntryID= data[0].HEntryID
                     this.hform.HProcExchQty= data[0].流转卡数量
                     this.hform.HSourceName= data[0].生产资源
                     this.hform.HSourceID= data[0].HSourceID
                     this.hform.HProcID= data[0].HProcID
                     this.hform.HProcName= data[0].当前工序
                     this.get_CheckItem();
                     this.hasSourceBill = true
                     this.$refs['billList'].exit()
                 } else {
                     CommonUtils.showTips({
                         title: '温馨提示',
                         message: Message
                     })
                 }
             } catch (err) {
                 CommonUtils.showTips({
                     title: '温馨提示',
                     message: "源单下推错误: " + err
                 })
             }
         },
         async GetCheckItemID() {
            if (!this.hform.HMaterName && !this.hform.HProcName) {
               try {
                  let res = await CommonUtils.doRequest2Async({
                     url: "/Web/GetCheckItemID",
                     data: {
                        HName: this.hform.HMaterName,
                        HProName: this.hform.HProcName,
                        HSourceID: this.hform.HSourceID,
                     },
                  });
                  let {
                     count,
                     Message,
                     data
                  } = res.data;
                  if (count != 1) {
                     CommonUtils.showTips({
                        title: "温馨提示",
                        message: `获取检验方案 错误: ${Message}`,
                     });
                     return;
                  }
                  this.hform.HQCSchemeName = data[0].检验方案名称;
                  this.hform.HQCSchemeID = data[0].hmainid;
                  this.get_CheckItem();
               } catch (err) {
                  CommonUtils.showTips({
                     title: "温馨提示",
                     message: `获取检验方案 错误: ${err}`,
                  });
               }
            }
         },
         async LoadingInformation_ProcExchange(HBarCode) {
            // 工序流转卡
            try {
               let res = await CommonUtils.doRequest2Async({
                  url: "/CheckBill/get_ProcessExchangeBill_ByBillNo",
                  data: {
                     HBillNo: HBarCode,
                     user: getUserInfo()["Czymc"],
                  },
               });
               let {
                  count,
                  Message,
                  data
               } = res.data;
               if (count != 1) {
                  CommonUtils.showTips({
                     title: "温馨提示",
                     message: `获取工序流转卡 错误: ${Message}`,
                  });
                  return;
               }
               this.hform.HProcExchBillNo = data[0].流转卡号;
               this.hform.HProcExchInterID = data[0].HProcExchInterID;
               this.hform.HProcExchEntryID = data[0].HProcExchEntryID || 0;
               this.hform.HProcExchQty = data[0].流转卡数量 || 0;
               this.hform.HICMOBillNo = data[0].任务单;
               this.hform.HICMOInterID = data[0].HICMOInterID;
               this.hform.HICMOQty = data[0].HICMOQty || 0;
               this.hform.HSourceName = data[0].生产资源;
               this.hform.HSourceID = data[0].HSourceID || 0;
               this.hform.HMaterID = data[0].HMaterID;
               this.hform.HMaterName = data[0].产品名称;
               this.hform.HMainSourceBillNo = data[0].单据号;
               this.hform.HMainSourceBillType = data[0].HBillType;
               this.hform.HMainSourceInterID = data[0].HInterID;
               this.hform.HICMOEntryID = data[0].HICMOEntryID || 1;
               this.hform.HQCSchemeName = data[0].检验方案名称;
               this.hform.HQCSchemeID = data[0].检验方案ID;
               this.hform.HProcName = data[0].当前工序;
               this.hform.HBatchNo = data[0].批号;
               this.hasSourceBill = true
               this.get_CheckItem();
            } catch (err) {
               CommonUtils.showTips({
                  title: "温馨提示",
                  message: `获取工序流转卡 错误: ${err}`,
               });
            }
         },
         // 部门
         async InitDept() { // 初始化部门
         async InitDept() {
             try {
                 let res = await CommonUtils.doRequest2Async({
                     url: '/PublicPageMethod/DeptList',
@@ -613,12 +374,7 @@
                         sWhere: 'where 1=1',
                     }
                 })
                 let {
                     count,
                     code,
                     Message,
                     data
                 } = res.data
                 let { count, code, Message, data } = res.data
                 if (count == 1) {
                     this.DeptList = data
                     this.DeptNameList = Array.from(data).map(elem => elem['HName'])
@@ -635,19 +391,187 @@
                 })
             }
         },
         DeptChange(elem) { // 部门改变 句柄
         DeptChange(elem) {
             let index = this.DeptNameList.findIndex(e => e == elem)
             if (index == -1) {
                 this.hform.HDeptName = ''
                 this.hform.HDeptID = 0
                 return
             }
             this.hform.HDeptName = this.DeptList[index]['HName']
             this.hform.HDeptID = this.DeptList[index]['HItemID']
         },
         // 记录人初始化
         async WorkCenter1() {
             try {
                 let res = await CommonUtils.doRequest2Async({
                     url: '/Gy_WorkCenter/list',
                     data: {
                       sWhere : "",
                       user: getUserInfo()["Czymc"],
                  }
                 })
                 let { count, code, Message, data } = res.data
                 if (count == 1) {
                     this.WorkCenter = data
                     this.WorkCenterList = Array.from(data).map(elem => elem['工作中心名称'])
                 } else {
                     CommonUtils.showTips({
                         title: '错误提示',
                         message: "初始化生产中心错误: " + Message,
                     })
                 }
             } catch (err) {
                 CommonUtils.showTips({
                     title: '错误提示',
                     message: "初始生产中心错误: " + err,
                 })
             }
         },
         // 扫描检测方案
         scanScheme() {
             // 调用扫描功能
             uni.scanCode({
                 success: (res) => {
                     if (res.result) {
                         this.getSchemeByScan(res.result);
                     }
                 },
                 fail: (err) => {
                     console.error('扫描失败:', err);
                     uni.showToast({
                         title: '扫描失败',
                         icon: 'none'
                     });
                 }
             });
         },
         // 根据扫描结果获取检测方案
         async getSchemeByScan(schemeNo) {
             uni.showLoading({
                 title: '加载中...',
                 mask: true
             });
             try {
                 let res = await CommonUtils.doRequest2Async({
                     url: "/Gy_BaseInformation/getGy_EnvironmentTestSchemeBillMainList",
                     data: {
                         sWhere: ` and 单据号 = '${schemeNo}'`,
                         user: getUserInfo()['Czymc']
                     }
                 });
                 let { data, count, Message } = res.data;
                 if (count == 1 && data && data.length > 0) {
                     // 处理检测方案数据
                     this.processSchemeData(data);
                     uni.showToast({
                         title: `已加载 ${data.length} 条数据`,
                         icon: 'success'
                     });
                 } else {
                     uni.showToast({
                         title: '未找到检测方案',
                         icon: 'none'
                     });
                 }
             } catch (err) {
                 console.error('加载检测方案失败:', err);
                 uni.showToast({
                     title: '加载失败',
                     icon: 'none'
                 });
             } finally {
                 uni.hideLoading();
             }
         },
         // 处理检测方案数据
         processSchemeData(data) {
             // 获取主表数据(第一条记录)
             let mainData = data[0];
             // 更新主表信息
             this.hform.HQCSchemeName = mainData.单据号 || "";
             this.hform.HEnvironmentTestSchemeID = mainData.HInterID || 0;
             // 如果有部门信息,自动填充
             if (mainData.生产部门) {
                 let deptIndex = this.DeptList.findIndex(dept => dept.HName == mainData.生产部门);
                 if (deptIndex != -1) {
                     this.hform.HDeptName = mainData.生产部门;
                     this.hform.HDeptID = this.DeptList[deptIndex].HItemID;
                 }
             }
             // 如果有工作中心信息,自动填充
             if (mainData.工作中心) {
                 let workCenterIndex = this.WorkCenter.findIndex(wc => wc.工作中心名称 == mainData.工作中心);
                 if (workCenterIndex != -1) {
                     this.hform.HCenterWorkName = mainData.工作中心;
                     this.hform.HCenterWorkID = this.WorkCenter[workCenterIndex].HItemID;
                 }
             }
             // 如果有工序信息,自动填充
             if (mainData.工序) {
                 this.hform.HProcName = mainData.工序;
                 if (mainData.HProcID) {
                     this.hform.HProcID = mainData.HProcID;
                 }
             }
             // 清空并重新加载检验项目
             this.checkItems = {};
             // 加载所有检验项目(子表数据)
             let mainInterID = mainData.HInterID;
             let details = data.filter(item => item.HInterID === mainInterID);
             if (details.length > 0) {
                 details.forEach((item, index) => {
                     let ordinal = index + 1;
                     let checkItem = {
                         num: ordinal,
                         HInterID: this.hform.HInterID,
                         HBillNo_bak: this.hform.HBillNo || "",
                         HEntryID: ordinal,
                         HCloseMan: "",
                         HEntryCloseDate: item.HEntryCloseDate === "0" ? "2000-01-01" : item.HEntryCloseDate,
                         HCloseType: 0,
                         HRemark: item.备注 || "",
                         HSourceInterID: 0,
                         HSourceEntryID: 0,
                         HSourceBillNo: "",
                         HSourceBillType: "",
                         HRelationQty: 0,
                         HRelationMoney: 0,
                         HQCCheckItemName: item.检测项目,
                         HEnvironmentItemID: item.HEnvironmentItemID || "",
                         HMeasure: item.实际值 || "",
                         HTargetVal: item.目标值 || "",
                         HUpLimit: item.上限值 || "",
                         HDownLimit: item.下限值 || "",
                         HEnvironmentItemName: item.检测项目 || "",
                     };
                     this.$set(this.checkItems, ordinal, checkItem);
                 });
             }
             this.$forceUpdate();
         },
         WorkCenterChange(elem) {
             let index = this.WorkCenterList.findIndex(e => e == elem)
             if (index == -1) {
                 this.hform.HCenterWorkName = ''
                 this.hform.HCenterWorkID = 0
                 return
             }
             this.hform.HCenterWorkID = this.WorkCenter[index]['HItemID']
         },
         async InitHEmp() {
            try {
               let res = await CommonUtils.doRequest2Async({
@@ -659,14 +583,9 @@
                  },
               });
               let {
                  data,
                  Message,
                  count
               } = res.data;
               let { data, Message, count } = res.data;
               if (count == 1) {
                  console.log("data: ", data);
                  this.GyFirstCheckEmpList = data;
                  this.GyFirstCheckEmpNameList = Array.from(data).map((e) => e["职员名称"]);
               } else {
@@ -683,191 +602,50 @@
            }
         },
         async HFirstCheckEmpChange(e) {
            console.log("选中检验员: ", e);
            let index = this.GyFirstCheckEmpList.findIndex((elem) => elem["职员名称"] == e);
            if (index == -1) {
               this.hform.HFirstCheckEmp = 0;
               this.hform.HFirstCheckEmpName = "";
               this.hform.HEmpID = 0;
               this.hform.HEmpName = "";
               return;
            }
            this.hform.HFirstCheckEmp = this.GyFirstCheckEmpList[index]["HItemID"];
            this.hform.HFirstCheckEmpName = this.GyFirstCheckEmpList[index]["职员名称"];
            this.hform.HEmpID = this.GyFirstCheckEmpList[index]["HItemID"];
            this.hform.HEmpName = this.GyFirstCheckEmpList[index]["职员名称"];
         },
         // 生产班次初始化
         async InitHWorkShift() {
            try {
               let res = await CommonUtils.doRequest2Async({
                  url: "/Gy_ShiftsController/Get_Gy_WorkShiftList",
                  data: {
                     sWhere: ` and 禁用标记 = '' and ISNULL(审核人,'')  != '' and 使用组织名称 = '${uni.getStorageSync("Organization")}'`,
                     HMaker: getUserInfo()["Czymc"],
                  },
               });
               let {
                  data,
                  Message,
                  count
               } = res.data;
               if (count == 1) {
                  console.log("data: ", data);
                  this.GyWorkShiftList = data;
                  this.GyWorkShiftNameList = Array.from(data).map((e) => e["班次名称"]);
               } else {
                  CommonUtils.showTips({
                     title: "温馨提示",
                     message: `初始化班次失败: ${Message}`,
                  });
               }
            } catch (err) {
               CommonUtils.showTips({
                  title: "温馨提示",
                  message: `初始化班次失败: ${err}`,
               });
            }
         cleanlinessChange(e) {
            this.hform.HCleanType = e;
         },
         async HWorkShiftChange(e) {
            console.log("选中班次: ", e);
            let index = this.GyWorkShiftList.findIndex((elem) => elem["班次名称"] == e);
            if (index == -1) {
               this.hform.HWorkShiftID = 0;
               this.hform.HWorkShiftName = "";
               return;
            }
            this.hform.HWorkShiftID = this.GySourceList[index]["HInterID"];
            this.hform.HWorkShiftName = this.GySourceList[index]["班次名称"];
         },
         // 生产资源更新
         // 生产资源初始化
         async InitHSource() {
            try {
               let res = await CommonUtils.doRequest2Async({
                  url: "/Gy_Source/list",
                  data: {
                     sWhere: `and 禁用标记 != 'Y' and ISNULL(审核人,'')  != '' and 组织 = '${uni.getStorageSync("Organization")}'`,
                     user: getUserInfo()["Czymc"],
                  },
               });
               let {
                  data,
                  Message,
                  count
               } = res.data;
               if (count == 1) {
                  this.GySourceList = data;
                  this.GySourceNameList = Array.from(data).map((e) => e["生产资源名称"]);
               } else {
                  CommonUtils.showTips({
                     title: "温馨提示",
                     message: `初始化生产资源失败: ${Message}`,
                  });
               }
            } catch (err) {
               CommonUtils.showTips({
                  title: "温馨提示",
                  message: `初始化生产资源失败: ${err}`,
               });
            }
         },
         // 生产资源更新
         async HSourceChange(e) {
            console.log("选中生产资源: ", e);
            let index = this.GySourceList.findIndex((elem) => elem["生产资源名称"] == e);
            if (index == -1) {
               this.hform.HSourceID = 0;
               this.hform.HSourceName = "";
               return;
            }
            this.hform.HSourceID = this.GySourceList[index]["HItemID"];
            this.hform.HSourceName = this.GySourceList[index]["生产资源名称"];
            this.get_ICMOBillStatusList();
            this.get_QC_TakeSampleCheckBillList();
            this.GetCheckItemID();
         },
         // 显示弹窗
         async showSelectorModule(item, index) {
            this.currentChechItemIDCache = item.num || 0; // 0 表示没有任何子表被选中
            this.enablePopupModule = this.PopupModuleNameList[index];
            console.log("this.$refs: ", this.$refs);
            await this.$nextTick();
            if (index == 7) {
               // 检验方案需要额外传递工序和物料名称两个参数
               this.$refs.listPopup.setRequiredInfo(item.HMaterName, item.HProcName);
            }
            this.$refs.listPopup.showPopup();
         },
         getAnalysisMethodDisplay(val) {
            console.log("AnalysisMethodVal: ", val);
            if (val) {
               return this.arrayAnalysisMethod.find((e) => e.value == val).name;
            }
            return "";
         },
         checkResultChange(event) {
            console.log("event: ", event);
         },
         // 检验项目新增行
         addCheckItem(resource) {
            let ordinal = this.getObjLength(this.checkItems) + 1;
            let checkItem = {
               num: ordinal,
               HInterID: this.hform.HInterID,
               HQCCheckItemID: "",
               HQCCheckItemNumber: "",
               HQCCheckItemName: "",
               HInspectInstruMentID: "0",
               HInspectInstruMentNumber: "",
               HInspectInstruMentName: "",
               HQCStd: "",
               HUnit: "",
               HQCNote: "",
               HAnalysisMethod: "",
               HResult: 1,
               HMax: "",
               HMin: "",
               HAvg: "",
               HBillNo_bak: this.hform.HBillNo || "",
               HEntryID: ordinal,
               HCloseMan: "",
               HEntryCloseDate: "",
               HCloseType: 0,
               HRemark: "",
               HKeyInspect: false,
               HStatus: 1,
               HSampleSchemeID: "",
               HUnitID: 0,
               HInspectVal: "",
               HSourceInterID: 0,
               HSourceEntryID: 0,
               HSourceBillNo: "",
               HSourceBillType: "",
               HRelationQty: 0,
               HRelationMoney: 0,
               HEnvironmentItemID: "",
               HMeasure: "",
               HTargetVal: "",
               HUpLimit: "",
               HDownLimit: "",
               HUpOffSet: "",
               HDownOffSet: "",
               HSampleDamageQty: 0,
               HSampleSchemeName: "",
               HSampleQty: 0,
               HAcceptQty: 0,
               HInspectionLevel: "",
               HRejectQty: 0,
               HStrictness: "",
               HSampleUnRightQty: 0,
               HAQL: "",
               HSamplingType: "",
               HInspectResultToSee: "",
               HEnvironmentItemName: "",
               HQCCheckItemName: "",
            };
            if (resource) {
               // 通过主表检验方案带出的检验项目
               Object.assign(checkItem, resource);
            }
            this.$set(this.checkItems, ordinal, checkItem);
            this.$nextTick(() => {
               // 检查是否可以新增检验值项
               this.setInspectValModule(this.checkItems[ordinal]);
            });
         },
         // 检验项目删除行
         removeCheckItem(item) {
            uni.showModal({
               title: "温馨提示",
@@ -875,7 +653,6 @@
               success: (res) => {
                  if (res.confirm) {
                     this.$delete(this.checkItems, item.num);
                     this.$delete(this.subTabs, `_${item.num}`);
                     this.$forceUpdate();
                     this.refreshCheckItemNum();
                  }
@@ -884,7 +661,6 @@
         },
         async refreshCheckItemNum() {
            await this.$nextTick();
            // 重排序号
            let num = 1;
            let checkItemsCache = {};
            for (let s in this.checkItems) {
@@ -897,129 +673,96 @@
         getObjLength(obj) {
            return Object.keys(obj).length;
         },
         // 结论修改
         HResultChange(id, e) {
            console.log("e: ", e);
            this.checkItems[id]["HResult"] = e.detail.value ? 1 : 2;
            this.HCheckLastResult();
         },
         // 每次检验项目的结论更新,都要判断最终结论
         HCheckLastResult() {
            let unPassNum = 0;
            for (var key in this.checkItems) {
               if (!(this.checkItems[key]["HResult"] == 1)) {
                  unPassNum++;
               }
            }
            if (unPassNum > 0) {
               this.hform.HCheckerResult = false;
               return;
            }
            this.hform.HCheckerResult = true;
         },
         // 检验值 计算是否合格
         calcHResult(item) {
             // 非抽检条件下判断结论
             console.log('item: ', item);
             if (!item.HSampleSchemeID) {
                 return
             }
             if (item.HInspectValQ >= item.HDownLimit && item.HInspectValQ <= item.HUpLimit) {
                 this.checkItems[item.num].HResult = 1
                 return
             }
             this.checkItems[item.num].HResult = 2
         },
         // 检验方案修改
         HAnalysisMethodChange(id, e) {
            console.log("e: ", e);
            this.checkItems[id]["HAnalysisMethod"] = this.arrayAnalysisMethod[e.detail.value][
               "value"
            ];
            // 检查是否可以新增检验值项
            this.setInspectValModule(this.checkItems[id]);
         },
         // 重点检查修改
         HKeyInspectChange(id, e) {
            console.log("e: ", e);
            this.checkItems[id]["HKeyInspect"] = e.detail.value;
         },
         // 检验项目返回
         async CheckItemComplete(e) {
            console.log("CheckItemRet: ", e);
            for (var key in e["retVal"]) {
               let data = e["retVal"][key];
               Object.assign(this.checkItems[key], {
                  HQCCheckItemID: data["HItemID"],
                  HQCCheckItemNumber: data["代码"],
                  HQCCheckItemName: data["名称"],
                  HEnvironmentItemID: data["HItemID"],
                  HQCCheckItemName: data["环境检测项目名称"],
               });
               await this.$nextTick();
               this.$refs.listPopup.exit();
               // 确保在弹窗结束后,再将页面上挂在的组件置空
               await this.$nextTick();
               this.enablePopupModule = this.PopupModuleNameList[0];
            }
         },
         // 检验方案返回
         async SampleSchemeComplete(e) {
            console.log("SampleSchemeRet: ", e);
            for (var key in e["retVal"]) {
               let data = e["retVal"][key];
               Object.assign(this.checkItems[key], {
                  HSampleSchemeID: data["hmainid"],
                  HSampleSchemeNumber: data["抽样方案代码"],
                  HSampleSchemeName: data["抽样方案名称"],
                  HSampleQty: data["样本量"] || 0,
                  HAcceptQty: data["允许数"] || 0,
                  HInspectionLevel: data["检验水平"],
                  HRejectQty: data["拒绝数"] || 0,
                  HStrictness: data["严格度"],
                  HSampleUnRightQty: data["样本不合格数"] || 0,
                  HAQL: data["AQL"],
                  HSamplingType: data["抽样类型"],
                  HInspectResultToSee: data["检验结果"],
                  HUpLimit: data["上限值"] || 0,
                  HDownLimit: data["下限值"] || 0,
                  HSampleDamageQty: data["样本破坏数"] || 0,
               });
               await this.$nextTick();
               this.$refs.listPopup.exit();
               this.setInspectValModule(this.checkItems[key]);
               await this.$nextTick();
               this.enablePopupModule = this.PopupModuleNameList[0];
            }
         },
         // 检验方案(主表)返回
         async HQCSchemeComplete(e) {
            console.log("HQCSchemeRet: ", e);
            for (var key in e["retVal"]) {
               let data = e["retVal"][key];
               Object.assign(this.hform, {
                  HQCSchemeID: data.hmainid,
                  HQCSchemeName: data.检验方案名称,
               });
               await this.get_CheckItem();
               await this.$nextTick();
               this.$refs.listPopup.exit();
               // 确保在弹窗结束后,再将页面上挂在的组件置空
               await this.$nextTick();
               this.enablePopupModule = this.PopupModuleNameList[0];
            }
             let allItems = Object.values(e.retVal);
             if (allItems.length === 0) return;
             let selectedMainData = e.selectedMainData || allItems[0];
             this.hform.HQCSchemeName = selectedMainData.单据号 || "";
             this.hform.HEnvironmentTestSchemeID = selectedMainData.HInterID || 0;
             if (selectedMainData.生产部门) {
                 let deptIndex = this.DeptList.findIndex(dept => dept.HName == selectedMainData.生产部门);
                 if (deptIndex != -1) {
                     this.hform.HDeptName = selectedMainData.生产部门;
                     this.hform.HDeptID = this.DeptList[deptIndex].HItemID;
                 }
             }
             if (selectedMainData.工作中心) {
                 let workCenterIndex = this.WorkCenter.findIndex(wc => wc.工作中心名称 == selectedMainData.工作中心);
                 if (workCenterIndex != -1) {
                     this.hform.HCenterWorkName = selectedMainData.工作中心;
                     this.hform.HCenterWorkID = this.WorkCenter[workCenterIndex].HItemID;
                 }
             }
             if (selectedMainData.工序) {
                 this.hform.HProcName = selectedMainData.工序;
                 if (selectedMainData.HProcID) {
                     this.hform.HProcID = selectedMainData.HProcID;
                 }
             }
             this.checkItems = {};
             this.enablePopupModule = this.PopupModuleNameList[0];
             await this.$nextTick();
             let mainInterID = selectedMainData.HInterID;
             let details = allItems.filter(item => item.HInterID === mainInterID);
             if (details.length > 0) {
                 details.forEach((item, index) => {
                     let ordinal = index + 1;
                     let checkItem = {
                         num: ordinal,
                         HInterID: this.hform.HInterID,
                         HBillNo_bak: this.hform.HBillNo || "",
                         HEntryID: ordinal,
                         HCloseMan: "",
                         HEntryCloseDate: item.HEntryCloseDate === "0" ? "2000-01-01" : item.HEntryCloseDate,
                         HCloseType: 0,
                         HRemark: item.备注 || "",
                         HSourceInterID: 0,
                         HSourceEntryID: 0,
                         HSourceBillNo: "",
                         HSourceBillType: "",
                         HRelationQty: 0,
                         HRelationMoney: 0,
                     HQCCheckItemName: item.检测项目,
                         HEnvironmentItemID: item.HEnvironmentItemID || "",
                         HMeasure: item.实际值 || "",
                         HTargetVal: item.目标值 || "",
                         HUpLimit: item.上限值 || "",
                         HDownLimit: item.下限值 || "",
                         HEnvironmentItemName: item.检测项目 || "",
                     };
                     this.$set(this.checkItems, ordinal, checkItem);
                 });
                 uni.showToast({
                     title: `已添加 ${details.length} 条检验项目`,
                     icon: 'success'
                 });
             }
             this.$forceUpdate();
         },
         // 工序返回
         async HProcComplete(e) {
            console.log(" HProcRet: ", e);
            for (var key in e["retVal"]) {
               let data = e["retVal"][key];
               Object.assign(this.hform, {
@@ -1028,16 +771,10 @@
               });
               await this.$nextTick();
               this.$refs.listPopup.exit();
               // 确保在弹窗结束后,再将页面上挂在的组件置空
               await this.$nextTick();
               this.enablePopupModule = this.PopupModuleNameList[0];
               await this.GetCheckItemID();
               await this.get_ICMOBillStatusList();
               await this.get_QC_TakeSampleCheckBillList();
            }
         },
         async getMaxBillNo() {
            try {
               let res = await CommonUtils.doRequest2Sync({
@@ -1047,15 +784,9 @@
                  },
               });
               if (!res) {
                  return;
               }
               if (!res) return;
               let {
                  data,
                  Message,
                  count
               } = res.data;
               let { data, count, Message } = res.data;
               if (count == 1) {
                  this.hform.HInterID = data[0].HInterID;
                  this.hform.HBillNo = data[0].HBillNo;
@@ -1069,355 +800,119 @@
               });
            }
         },
         checkSubmitValidate() {
            // if (this.hform.HICMOQty == "" || this.hform.HICMOQty <= 0) {
            //     CommonUtils.showTips({
            //         message: "任务单数量不能为空且不能小于等于0!",
            //     });
            //     return false;
            //
            if (this.hform.HFirstCheckEmp == 0) {
               CommonUtils.showTips({
                  message: "记录人未选择!",
               });
            if (this.hform.HEmpID == 0) {
               CommonUtils.showTips({ message: "记录人未选择!" });
               return false;
            }
            for (let key in this.checkItems) {
               if (!this.checkItems[key].HQCCheckItemID) {
               if (!this.checkItems[key].HEnvironmentItemID) {
                  CommonUtils.showTips({
                     message: `第${this.checkItems[key].num}行检验项目不能为空!`,
                  });
                  return false;
               }
               if (
                  this.checkItems[key].HSampleSchemeID == "" ||
                  this.checkItems[key].HSampleSchemeID == null
               ) {
                  this.checkItems[key].HSampleSchemeID = 0;
               }
               if (
                  this.checkItems[key].HSampleQty == "" ||
                  this.checkItems[key].HSampleQty == null
               ) {
                  this.checkItems[key].HSampleQty = 0;
               }
               if (
                  this.checkItems[key].HSampleDamageQty == "" ||
                  this.checkItems[key].HSampleDamageQty == null
               ) {
                  this.checkItems[key].HSampleDamageQty = 0;
               }
               if (
                  this.checkItems[key].HAcceptQty == "" ||
                  this.checkItems[key].HAcceptQty == null
               ) {
                  this.checkItems[key].HAcceptQty = 0;
               }
               if (
                  this.checkItems[key].HRejectQty == "" ||
                  this.checkItems[key].HRejectQty == null
               ) {
                  this.checkItems[key].HRejectQty = 0;
               }
               if (
                  this.checkItems[key].HSampleUnRightQty == "" ||
                  this.checkItems[key].HSampleUnRightQty == 0
               ) {
                  this.checkItems[key].HSampleUnRightQty = 0;
               }
               if (this.checkItems[key].HUnitID == "") {
                  this.checkItems[key].HUnitID = 0;
               }
            }
            return true;
         },
         async submit() {
            if (!this.checkSubmitValidate()) {
               return;
            }
            try {
               console.log('this.$refs: ', this.$refs);
               // 检查是否有未切换的检验值模块(是否包含set_SaveValue方法),如果有,则运行一次保存检验值的方法,根据检验值是否保存成功再执行下一步
               if (typeof this.$refs.InspectValueModules != "undefined" && this.$refs.InspectValueModules.length >
                  0) {
                  // 加载有检验值模块
                  await this.$refs.InspectValueModules[0].set_SaveValue();
                  this.InspectValues[0] = this.$refs.InspectValueModules[0].InSpectValues;
                  await this.InspectValueComplete(this.$refs.InspectValueModules[0].checkData)
               }
               let InspectValuesTrans = [];
               let HInterID = this.hform.HInterID;
               for (let key in this.InspectValues) {
                  let HEntryID = key;
                  InspectValuesTrans.push(
                     `${JSON.stringify(this.InspectValues[key])}`
                  );
               }
               let checkItemsArray = [];
               for (var key in this.checkItems) {
                  let checkItem = JSON.parse(JSON.stringify(this.checkItems[key]))
                  delete checkItem.data
                  checkItemsArray.push(checkItem);
               }
               console.log('checkItemsArray: ', checkItemsArray);
               let sMainSub = `${JSON.stringify(this.hform)};${JSON.stringify(
          checkItemsArray
        )};${this.operationType};${getUserInfo()["Czymc"]};${InspectValuesTrans[0]}`;
               console.log("this.checkItems: ", this.checkItems);
               let res = await CommonUtils.doRequest2Sync({
                  url: "/QC_ProcessCheckBill/set_SaveBill",
                  data: {
                     sMainSub: sMainSub,
                  },
                  method: "POST",
               });
               if (!res) {
                  return;
               }
               let {
                  count,
                  Message,
                  data
               } = res.data;
               if (count == 1) {
                  uni.showModal({
                     title: "提示",
                     content: res.data.Message + "。是否继续新增?",
                     success: (res) => {
                        if (res.confirm) {
                           console.log("用户点击确定");
                           uni.redirectTo({
                              url: "/pages/ZLGL/mojianjianyan/form?operationType=1",
                           });
                        } else if (res.cancel) {
                           console.log("用户点击取消");
                           // setTimeout(() => {
                           //     uni.navigateBack();
                           // }, 50)
                        }
                     },
                  });
               } else {
                  CommonUtils.showTips({
                     title: "温馨提示",
                     message: `末件检验单保存错误: ${Message}`,
                  });
               }
            } catch (err) {
               CommonUtils.showTips({
                  title: "温馨提示",
                  message: `末件检验单保存错误: ${err}`,
               });
            }
             if (!this.checkSubmitValidate()) return;
             try {
                 let checkItemsArray = [];
                 for (var key in this.checkItems) {
                     let checkItem = JSON.parse(JSON.stringify(this.checkItems[key]));
                     delete checkItem.num;
                     delete checkItem.HEnvironmentItemName;
                     delete checkItem.HQCCheckItemName;
                     checkItemsArray.push(checkItem);
                 }
                 let operation = this.operationType == 1 ? "Add" : "3";
                 let sMainSub = `${JSON.stringify(this.hform)};${JSON.stringify(
                     checkItemsArray
                 )};${operation};${getUserInfo()["Czymc"]};{}`;
                 let res = await CommonUtils.doRequest2Sync({
                     url: "/QC_EnvironmentTestDotCheckBill/SaveQC_EnvironmentTestDotCheckBillMain",
                     data: { sMainSub: sMainSub },
                     method: "POST",
                 });
                 if (!res) return;
                 let { count, Message } = res.data;
                 if (count == 1) {
                     uni.showModal({
                         title: "提示",
                         content: res.data.Message + "。是否继续新增?",
                         success: (res) => {
                             if (res.confirm) {
                                 uni.redirectTo({
                                      url: "/pages/ZLGL/QcenvironmentTestDotCheckBill/QcenvironmentTestDotCheckBill?operationType=1",
                                 });
                             }
                         },
                     });
                 } else {
                     CommonUtils.showTips({
                         title: "温馨提示",
                         message: `环境检测单保存错误: ${Message}`,
                     });
                 }
             } catch (err) {
                 CommonUtils.showTips({
                     title: "温馨提示",
                     message: `环境检测单保存错误: ${err}`,
                 });
             }
         },
         addNew() {
            uni.redirectTo({
               url: "/pages/ZLGL/mojianjianyan/lastPieceCheckBillList?operationType=1",
            });
             uni.showLoading({
                 title: '加载中...',
                 mask: true
             });
             // 延迟一点再跳转,让用户能看到加载提示
             setTimeout(() => {
                 uni.redirectTo({
                     url: "/pages/ZLGL/QcenvironmentTestDotCheckBill/QcenvironmentTestDotCheckBill?operationType=1",
                     complete: () => {
                         uni.hideLoading();
                     }
                 });
             }, 300);
         },
         goBack() {
            uni.navigateBack();
         },
         async RoadBillMain() {
            try {
               let res = await CommonUtils.doRequest2Async({
                  url: "/QC_ProcessCheckBill/QC_ProcessCheckBill_Edit",
                  data: {
                     sWhere: ` and hmainid=${this.hform.HInterID}`,
                     user: getUserInfo()["Czymc"],
                  },
               });
               let {
                  data,
                  count,
                  Message
               } = res.data;
               if (count == 1) {
                  console.log("RoadBillMain: : ", data);
                  Object.assign(this.hform, {
                     HInterID: data[0].hmainid,
                     HBillNo: data[0].单据号,
                     HDate: dayjs(data[0].日期).format("YYYY-MM-DD"),
                     HSourceID: data[0].HSourceID,
                     HSourceName: data[0].生产资源名称,
                     HICMOBillNo: data[0].任务单号,
                     HICMOQty: data[0].任务单数量,
                     HICMOInterID: data[0].HICMOInterID,
                     HICMOEntryID: data[0].HICMOEntryID || 1,
                     HMaterID: data[0].HMaterID,
                     HMaterName: data[0].物料名称,
                     HMaterNumber: data[0].物料代码,
                     HProcID: data[0].HProcID,
                     HProcName: data[0].HProcName,
                     HProcExchQty: data[0].HProcExchQty || 0,
                     HProcExchBillNo: data[0].HProcExchBillNo,
                     HProcExchInterID: data[0].HProcExchInterID,
                     HProcExchEntryID: data[0].HProcExchEntryID || 0,
                     HFirstCheckEmp: data[0].HFirstCheckEmp,
                     HFirstCheckEmpName: data[0].质检员名称,
                     HQCSchemeID: data[0].检验方案ID,
                     HQCSchemeName: data[0].检验方案名称,
                     HRemark: data[0].表头备注,
                     HMaker: data[0].制单人,
                     HMakeDate: data[0].制单日期,
                     HChecker: data[0].审核人,
                     HCheckDate: data[0].审核日期,
                     HCloseMan: data[0].关闭人,
                     HCloseDate: data[0].关闭日期,
                     HUpDateDate: data[0].修改日期,
                     HDeleteDate: data[0].作废日期,
                     HSampleSchemeID: data[0].HSampleSchemeID,
                     HSampleSchemeName: data[0].抽样方案名称,
                     HSampleQty: data[0].样本量,
                     HSampleQty2: data[0].样本量,
                     HSampleDamageQty: data[0].样本破坏数,
                     HSamplingType: data[0].抽样类型,
                     HAcceptQty: data[0].允许数,
                     HInspectionLevel: data[0].检验水平,
                     HRejectQty: data[0].拒绝数,
                     HStrictness: data[0].严格度,
                     HSampleUnRightQty: data[0].样本不合格数 || 0,
                     HSampleUnRightQty2: data[0].样本不合格数,
                     HAQL: data[0].AQL,
                     HUnitID: data[0].HUnitID,
                     HUnit: data[0].单位,
                     HInspectValB: data[0].检测值基础资料,
                     HInspectVal: data[0].检测值,
                     HTargetValB: data[0].目标值基础资料,
                     HTargetVal: data[0].目标值,
                     HUpLimit: data[0].上限值,
                     HDownLimit: data[0].下限值,
                     HUpOffSet: data[0].上偏差,
                     HDownOffSet: data[0].下偏差,
                     HEntryID: data[0].hsubid,
                     HQCCheckItemName: data[0].检验项目名称,
                     HQCCheckItemID: data[0].HQCCheckItemID,
                     HShiftsID: data[0].HShiftsID,
                     HShiftsName: data[0].班次名称,
                     HErrTreatment: data[0].异常临时处理方案,
                     HBatchNo: data[0].批号,
                     HCheckerResult: data[0].判定结论 == "合格" ? true : false,
                     HTakeSampleCheckBillID: data[0].HTakeSampleCheckBillID,
                     HTakeSampleCheckBillNo: data[0].HTakeSampleCheckBillNo,
                     HAnalysisMethod: function() {
                        if (data[0].HAnalysisMethod == 1) {
                           return '定性检验'
                        } else if (data[0].HAnalysisMethod == 2) {
                           return '定量检验'
                        } else {
                           return '其他检验'
                        }
                     }(),
                  });
                  for (let i = 0; i < data.length; i++) {
                     this.addCheckItem({
                        HQCCheckItemID: data[i].HQCCheckItemID,
                        HQCCheckItemNumber: data[i].检验项目代码,
                        HQCCheckItemName: data[i].检验项目名称,
                        HInspectInstruMentID: data[i].HInspectInstruMentID,
                        HInspectInstruMentNumber: data[i].检验仪器代码,
                        HInspectInstruMentName: data[i].检验仪器名称,
                        HQCStd: data[i].检验标准,
                        HUnit: data[i].单位名称,
                        HQCNote: data[i].检验记录,
                        HResult: data[i].结论 == "合格" ? 1 : 0,
                        HMax: data[i].最大值,
                        HMin: data[i].最小值,
                        HAvg: data[i].平均值,
                        HRemark: data[i].表体备注,
                        HAnalysisMethod: data[i].分析方法 == "定性分析" ?
                           1 : data[i].分析方法 == "定量分析" ?
                           2 : 3,
                        HKeyInspect: data[i].重点检查 == "否" ? false : true,
                        HSampleSchemeID: data[i].HSampleSchemeID,
                        HUnitID: data[i].HUnitID,
                        HInspectVal: data[i].检测值,
                        HTargetVal: data[i].目标值,
                        HUpLimit: data[i].上限值,
                        HDownLimit: data[i].下限值,
                        HUpOffSet: data[i].上偏差,
                        HDownOffSet: data[i].下偏差,
                        HSampleDamageQty: data[i].样本破坏数,
                        HSampleSchemeName: data[i].抽样方案名称,
                        HSampleQty: data[i].样本量,
                        HSampleDamageQty: data[i].样本破坏数,
                        HAcceptQty: data[i].允许数,
                        HInspectionLevel: 0,
                        HRejectQty: data[i].拒绝数,
                        HStrictness: 0,
                        HSampleUnRightQty: data[i].样本不合格数,
                        HAQL: data[i].AQL,
                        HSamplingType: 0,
                        HSamplingType: data[i].抽样类型,
                        HStrictness: data[i].严格度,
                        HInspectResultToSee: data[i].检验结果
                     });
                  }
                  this.hasSourceBill = true
               } else {
                  CommonUtils.showTips({
                     title: "温馨提示",
                     message: `加载单据失败: ${Message}`,
                  });
               }
            } catch (err) {
               CommonUtils.showTips({
                  title: "温馨提示",
                  message: `加载单据失败: ${err}`,
               });
            }
         },
      },
      async onLoad(e) {
         this.operationType = e.operationType || 1;
         this.hform.HInterID = e.linterid || 0;
         this.hform.HCleanType = 'A';
         const organization = uni.getStorageSync('Organization');
         this.hform.Organization = organization || '';
         if (this.operationType == 1) {
            await this.getMaxBillNo();
         } else if (this.operationType == 2) {
         } else if (this.operationType == 3) {
            await this.RoadBillMain();
         }
         await this.InitHSource();
         await this.InitHWorkShift();
         await this.InitHEmp();
         await this.loadCache();
         await this.InitDept();
         await this.WorkCenter1();
      },
   };
</script>
<style lang="scss" scoped>
   input {
      width: inherit;
      font-size: 26rpx;
   }
   .uni-input {
      padding: 0;
   }
   .bill-main-tabs,
   .bill-sub-tabs {
   input { width: inherit; font-size: 26rpx; }
   .uni-input { padding: 0; }
   .bill-main-tabs, .bill-sub-tabs {
      box-sizing: border-box;
      width: 730rpx;
      display: flex;
@@ -1445,8 +940,7 @@
      }
   }
   .bill-main-content,
   .bill-sub-content {
   .bill-main-content, .bill-sub-content {
      box-sizing: border-box;
      padding: 0 30rpx 0 30rpx;
      display: flex;
@@ -1459,47 +953,19 @@
         font-size: 26rpx;
         padding: 6rpx 0;
         .left {
            width: 208rpx;
            text {
               color: red;
               font-weight: bold;
            }
         }
         .left { width: 208rpx; }
         .right {
            // width: 450rpx;
            padding: 8rpx 20rpx;
            font-size: 26rpx;
            flex: 1;
            border-radius: 22rpx;
            border: 1px solid #acacac;
            .uni-combox {
               padding: 0;
               height: auto;
               .uni-input-placeholder,
               .uni-input-input {
                  font-size: 26rpx;
               }
            }
            .uni-combox::v-deep input {
               height: inherit;
               font-size: 26rpx;
            }
            .uni-combox { padding: 0; height: auto; }
            .uni-combox::v-deep input { height: inherit; font-size: 26rpx; }
         }
         .disabled {
            border: 1px solid #e4e4e4;
            background-color: #e4e4e4;
         }
         .none-border {
            border: none;
         }
         .disabled { border: 1px solid #e4e4e4; background-color: #e4e4e4; }
         .none-border { border: none; }
      }
   }
@@ -1511,7 +977,7 @@
      bottom: 0;
      left: 0;
      background-color: #fff;
      box-shadow: 0 2rpx 10rpx 2rpx rgba(0, 0, 0, 0.4);
      box-shadow: 0 2rpx 10rpx 2rpx rgba(0,0,0,0.4);
      padding: 30rpx 40rpx 40rpx 40rpx;
      display: flex;
      flex-direction: row;
@@ -1524,28 +990,8 @@
         line-height: 66rpx;
         font-size: 28rpx;
      }
      .btn-a {
         background-color: #3a78ff;
         color: #fff;
      }
      .btn-b {
         background-color: #41a863;
         color: #fff;
      }
      .btn-c {
         background-color: #acacac;
         color: #fff;
         // position: absolute;
         // right: 120rpx;
      }
      .btn-d {
         background-color: #ff8901;
         color: #fff;
      }
      .btn-a { background-color: #3a78ff; color: #fff; }
      .btn-c { background-color: #acacac; color: #fff; }
   }
   .buttons {
@@ -1554,46 +1000,20 @@
      display: flex;
      justify-content: center;
      padding: 10rpx 0;
      button {
         border-radius: 50rpx;
         width: 180rpx;
         height: 66rpx;
         line-height: 66rpx;
         font-size: 26rpx;
      }
      .btn-a {
         background-color: #acacac;
         color: #fff;
      }
      .btn-b {
         background-color: #41a863;
         color: #fff;
      }
      .btn-c {
         background-color: #3a78ff;
         color: #fff;
      }
   }
   /* 给 select 容器添加边框 */
   .select-border {
       border: 1px solid #acacac !important;
       border-radius: 22rpx !important;
       padding: 8rpx 20rpx !important;
   }
   
   /* 移除 uni-data-select 自带边框 */
   .no-border-select {
       ::v-deep .uni-select {
           border: none !important;
           border-radius: 0 !important;
       }
   }
   .list {
      width: 100%;
@@ -1607,21 +1027,15 @@
         line-height: 120%;
         gap: 10rpx 0;
         input {
            font-size: 26rpx;
         }
         input { font-size: 26rpx; }
         .detail {
            // width: 50%;
            box-sizing: border-box;
            font-size: 26rpx;
            color: #555;
            padding-right: 20rpx;
            text {
               color: #999;
               font-size: 26rpx;
            }
            text { color: #999; font-size: 26rpx; }
         }
         .editable {
@@ -1630,15 +1044,7 @@
            flex-direction: row;
            align-items: center;
            text {
               flex-shrink: 0;
            }
            .sampleDestory {
               border: 1px solid #acacac;
               border-radius: 10%;
               padding: 0 12rpx;
            }
            text { flex-shrink: 0; }
            .editable-input {
                border: 1px solid #acacac;
                border-radius: 5rpx;
@@ -1657,10 +1063,7 @@
      justify-content: center;
      align-items: center;
      flex-shrink: 0;
      .uni-icons {
         color: #fff !important;
      }
      .uni-icons { color: #fff !important; }
   }
   .icon-wrapper-big {
@@ -1673,10 +1076,7 @@
      align-items: center;
      flex-shrink: 0;
      margin-left: 20rpx;
      .uni-icons {
         color: #fff !important;
      }
      .uni-icons { color: #fff !important; }
   }
   .more {
@@ -1692,15 +1092,6 @@
      }
   }
   .pass-background {
      background-color: #cee3f2;
      border: none;
   }
   .unpass-background {
      background-color: #f0d6e3;
      border: none;
   }
   .enable-icon-button {
      background-color: #3a78ff;
      padding: 6rpx;
@@ -1716,6 +1107,50 @@
      pointer-events: none;
   }
   
   .card-detail {
       width: 100%;
       display: flex;
       flex-direction: column;
       gap: 16rpx;
   }
   
   .detail-row {
       width: 100%;
       display: flex;
       align-items: center;
       justify-content: space-between;
       gap: 20rpx;
   }
   
   .values-row {
       width: 100%;
       display: flex;
       justify-content: space-between;
       background-color: #f9f9f9;
       padding: 16rpx 20rpx;
       border-radius: 12rpx;
       margin-top: 8rpx;
   }
   .value-item {
       font-size: 26rpx;
       color: #555;
       display: flex;
       align-items: center;
       text { color: #999; margin-right: 8rpx; }
       .value { color: #3a78ff; font-weight: bold; }
   }
   .actual-input {
       border: 1px solid #acacac;
       border-radius: 10rpx;
       padding: 6rpx 12rpx;
       font-size: 26rpx;
       width: 140rpx;
       background-color: #fff;
       margin-left: 8rpx;
       z-index: 10;
       position: relative;
   }
</style>