zrg
2026-01-27 2f179987eee898e1ca4c1565e303bdc0d9b1206c
pages/EmployeeRecords/EmployeeRecordsBill.vue
@@ -1,541 +1,520 @@
<template>
   <view class="form">
      <view class="form-base-info">
   <view>
      <view class="form">
         <view class="form-item">
            <view class="title">条码</view>
            <view class="right">
               <input type="text" :focus="HBarCodeFocus" v-model="HBarCode"
                  @confirm="GetMeesageByBarCode(HBarCode)" />
            <view class="right" style="width: 350rpx;">
               <input type="text" :focus="HBarCodeFocus" v-model="hform.HBarCode" placeholder="请扫描(或输入)条码"
                  @confirm="getHBarCodeData(hform.HBarCode)" />
            </view>
            <view class="right-icon">
               <uni-icons type="scan"
                  style="background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;" size="20"
                  @click="toScanCode2"></uni-icons>
            </view>
            <uni-icons type="scan"
               style="margin-left: 10rpx;background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;"
               size="20" @click="toScanCode"></uni-icons>
         </view>
         <view class="form-item">
            <view class="title">角色</view>
            <view class="right">
               <!-- 多选下拉框 -->
               <uni-data-select v-model="hform.HRoles" :multiple="true" :localdata="roleOptions"
                  placeholder="请选择角色" :clear="false" @change="onRoleChange">
               </uni-data-select>
            </view>
         <view class="tabs">
            <view :class="tabs == 0 ? 'on':''" @tap="() => { tabs = 0; reFocusBarCode(); }">单据信息</view>
            <view :class="tabs == 1 ? 'on':''" @tap="() => { tabs = 1; reFocusBarCode(); }">工单信息</view>
            <view :class="tabs == 2 ? 'on':''" @tap="() => { tabs = 2; reFocusBarCode(); }">制单信息</view>
         </view>
         <view class="form-item">
            <view class="title">生产车间:</view>
            <view class="right">
               <uni-combox :candidates="arrayHDeptName" placeholder="请选择车间" v-model="hform.HDeptName"
                  @input="HDeptNameChange"></uni-combox>
            </view>
         </view>
         <view class="form-item">
            <view class="title">签到人员:</view>
            <view class="right">
               <uni-combox :candidates="arrayHEmpName" placeholder="请选择签到人员" v-model="hform.HEmpName"
                  @input="HEmpNameChange"></uni-combox>
            </view>
         </view>
         <view class="form-item">
            <view class="title">班组:</view>
            <view class="right">
               <uni-combox :candidates="arrayHGroupName" placeholder="请选择班组" v-model="hform.HGroupName"
                  @input="HGroupNameChange"></uni-combox>
            </view>
         </view>
         <view class="form-item">
            <view class="title">班次:</view>
            <view class="right">
               <uni-combox :candidates="arrayHShiftsName" placeholder="请选择班次" v-model="hform.HShiftsName"
                  @input="HShiftsNameChange"></uni-combox>
            </view>
         </view>
         <view class="form-item">
            <view class="title">生产资源:</view>
            <view class="right">
               <uni-combox :candidates="arrayHSourceName" placeholder="请选择生产资源" v-model="hform.HSourceName"
                  @input="HSourceNameChange"></uni-combox>
            </view>
         </view>
         <view class="form-item">
            <view class="title">工序:</view>
            <view class="right">
               <uni-combox :candidates="arrayHProcName" placeholder="请选择工序" v-model="hform.HProcName"
                  @input="HProcNameChange"></uni-combox>
            </view>
         </view>
         <view class="form-item">
            <view class="title">日期</view>
            <view class="right disabled">
               <input type="text" disabled :value="hform.HDate" />
            </view>
         </view>
         <view class="form-item">
            <view class="title">单据号</view>
            <view class="right disabled">
               <input type="text" disabled :value="hform.HBillNo" />
            </view>
         </view>
      </view>
      <view class="tabs">
         <view :class="tabs == 0 ? 'on':''" @tap="tabs = 0">机台信息</view>
         <view :class="tabs == 1 ? 'on':''" @tap="tabs = 1">工单信息</view>
         <view :class="tabs == 2 ? 'on':''" @tap="tabs = 2">制单信息</view>
      </view>
      <!-- 装箱信息 -->
      <view v-if="tabs == 1" class="work-order-cards">
               <view v-for="(item, index) in listData" :key="item.index" class="work-order-card">
                  <view class="card-header">
                     <text class="card-title">工单信息 {{ index + 1 }}</text>
                     <checkbox :checked="item.checked" style="transform:scale(0.8)" color="#3A78FF"
                        @change="onCardCheckChange(item, index)" />
                  </view>
                  <view class="card-content">
                     <view class="card-row">
                        <text class="card-label">流转卡号:</text>
                        <text class="card-value">{{ item['流转卡号'] || '-' }}</text>
                     </view>
                     <view class="card-row">
                        <text class="card-label">物料代码:</text>
                        <text class="card-value">{{ item['物料代码'] || '-' }}</text>
                     </view>
                     <view class="card-row">
                        <text class="card-label">物料名称:</text>
                        <text class="card-value">{{ item['物料名称'] || '-' }}</text>
                     </view>
                     <view class="card-row">
                        <text class="card-label">规格型号:</text>
                        <text class="card-value">{{ item['规格型号'] || '-' }}</text>
                     </view>
                     <view class="card-row">
                        <text class="card-label">数量:</text>
                        <text class="card-value">{{ item['数量'] || '0' }}</text>
                     </view>
                     <view class="card-row">
                        <text class="card-label">生产资源:</text>
                        <text class="card-value">{{ item['生产资源'] || '-' }}</text>
                     </view>
                  </view>
               </view>
               <view v-if="listData.length === 0" class="empty-card">
                  <uni-icons type="info" size="30" color="#999"></uni-icons>
                  <text class="empty-text">暂无工单信息</text>
                  <text class="empty-tip">请先扫描条码获取工单信息</text>
               </view>
            </view>
      <view v-if="tabs == 0" class="machine-info-container">
         <view class="form-item" v-if="false">
            <view class="title">设备ID:</view>
            <view class="righton">
               <input name="HEquipID" disabled v-model="hform.HEquipID" />
            </view>
         </view>
         <view class="form-item">
            <view class="title">设备名称:</view>
            <view class="righton">
               <input name="HEquipName" disabled v-model="hform.HEquipName" />
            </view>
         </view>
         <view class="form-item">
            <view class="title">模具编码:</view>
            <view class="righton">
               <input name="HMouldNo" disabled v-model="hform.HMouldNo" />
            </view>
         </view>
         <view class="form-item">
            <view class="title">模具名称:</view>
            <view class="righton">
               <input name="HMouldName" disabled v-model="hform.HMouldName" />
            </view>
         </view>
         <view class="form-item">
            <view class="title">模具状态:</view>
            <view class="righton">
               <input name="HMouldState" disabled v-model="hform.HMouldState" />
            </view>
         </view>
         <!--                <label class="checkbox" style="float: right;">
                    <checkbox :checked="hform.chkHBarflag" style="transform:scale(0.8)" disabled color="#4f81fc" />条码核对
                </label> -->
      </view>
      <!-- 制单信息 -->
      <view v-if="tabs == 2">
         <view class="bill-info">
         <!-- 单据信息 -->
         <view v-if="tabs == 0">
            <view class="form-item">
               <view class="title">创建日期</view>
               <view class="title">角色</view>
               <view class="right">
                  <uni-datetime-picker type="date" v-model="hform.HDate">
                     <input type="text" v-model="hform.HDate" disabled />
                  </uni-datetime-picker>
                  <!-- 多选下拉框 -->
                  <uni-data-select v-model="hform.HRoles" :multiple="true" :localdata="roleOptions"
                     placeholder="请选择角色" :clear="false" @change="onRoleChange">
                  </uni-data-select>
               </view>
            </view>
         </view>
         <view class="bill-info">
            <view class="form-item">
               <view class="title">创建人</view>
               <view class="right disabled">
                  <input type="text" disabled :value="hform.HMaker" />
               </view>
            </view>
         </view>
         <view class="bill-info">
            <view class="form-item">
               <view class="title">修改日期</view>
               <view class="title"><text>*</text>生产车间:</view>
               <view class="right">
                  <uni-datetime-picker type="date" v-model="hform.HUpDateDate">
                     <input type="text" v-model="hform.HDate" disabled />
                  </uni-datetime-picker>
                  <uni-combox :candidates="arrayHDeptName" placeholder="请选择部门" v-model="hform.HDeptName"
                     @input="HDeptNameChange"></uni-combox>
               </view>
            </view>
         </view>
         <view class="bill-info">
            <view class="form-item">
               <view class="title">修改人</view>
               <view class="right disabled">
                  <input type="text" disabled :value="hform.HUpDater" />
               </view>
            </view>
         </view>
         <view class="bill-info">
            <view class="form-item">
               <view class="title">修改日期</view>
               <view class="title"><text>*</text>签到人员:</view>
               <view class="right">
                  <uni-datetime-picker type="date" v-model="hform.HCheckDate">
                     <input type="text" v-model="hform.HDate" disabled />
                  </uni-datetime-picker>
                  <uni-combox :candidates="arrayHEmpName" placeholder="请选择操作员" v-model="hform.HEmpName"
                     @input="HEmpNameChange"></uni-combox>
               </view>
            </view>
         </view>
         <view class="bill-info">
            <view class="form-item">
               <view class="title">修改人</view>
               <view class="right disabled">
                  <input type="text" disabled :value="hform.HChecker" />
               <view class="title"><text>*</text>生产资源:</view>
               <view class="right">
                  <uni-combox :candidates="arrayHSourceName" placeholder="请选择生产资源" v-model="hform.HSourceName"
                     @input="HSourceNameChange"></uni-combox>
               </view>
            </view>
         </view>
         <view class="bill-info">
            <view class="form-item">
               <view class="title">单据号</view>
               <view class="right disabled">
                  <input type="text" disabled :value="hform.HBillNo" />
               <view class="title"><text>*</text>生产班组:</view>
               <view class="right">
                  <uni-combox :candidates="arrayHGroupName" placeholder="请选择班组" v-model="hform.HGroupName"
                     @input="HGroupNameChange"></uni-combox>
               </view>
            </view>
         </view>
         <view class="bill-info">
            <view class="form-item">
               <view class="title">组织</view>
               <view class="right disabled">
                  <input type="text" disabled :value="hform.HStockOrgName" />
               <view class="title"><text>*</text>生产班次:</view>
               <view class="right">
                  <uni-combox :candidates="arrayHShiftsName" placeholder="请选择班次" v-model="hform.HShiftsName"
                     @input="HShiftsNameChange"></uni-combox>
               </view>
            </view>
            <view class="form-item">
               <view class="title"><text>*</text>模具实际出数:</view>
               <view class="right">
                  <input name="HMouldRelQty" v-model="hform.HMouldRelQty" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">工序:</view>
               <view class="right">
                  <uni-combox :candidates="arrayHProcName" placeholder="请选择工序" v-model="hform.HProcName"
                     @input="HProcNameChange"></uni-combox>
               </view>
            </view>
            <view class="form-item">
               <view class="title">设备编号:</view>
               <view class="righton">
                  <input name="HEquipNumber" disabled v-model="hform.HEquipNumber" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">设备名称:</view>
               <view class="righton">
                  <input name="HEquipName" disabled v-model="hform.HEquipName" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">模具编码:</view>
               <view class="righton">
                  <input name="HMouldNo" disabled v-model="hform.HMouldNo" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">模具名称:</view>
               <view class="righton">
                  <input name="HMouldName" disabled v-model="hform.HMouldName" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">模具状态:</view>
               <view class="righton">
                  <input name="HMouldState" disabled v-model="hform.HMouldState" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">单据号:</view>
               <view class="righton">
                  <input name="HBillNo" disabled v-model="hform.HBillNo" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">单据日期:</view>
               <view class="righton">
                  <picker mode="date" v-model="hform.HDate" @change="HDateChange">
                     <input disabled v-model="hform.HDate" placeholder="请选择日期" />
                  </picker>
               </view>
            </view>
            <view class="form-item">
               <view class="title">备注:</view>
               <view class="right">
                  <textarea name="HRemark" v-model="hform.HRemark" auto-height placeholder="请输入备注"></textarea>
               </view>
            </view>
         </view>
         <!-- 模具信息 -->
         <view v-if="tabs == 1">
            <view class="card-list" :style="{height: `${listTableHeight}px`, overflow: 'auto'}">
               <!-- 卡片列表 -->
               <view v-for="(item, index) in listData" :key="index" class="card-item">
                  <uni-card style="margin: 10rpx 0;">
                     <view class="card-content">
                        <view class="card-row">
                           <text class="card-label">流转卡号:</text>
                           <text class="card-value">{{ item['流转卡号'] || '-' }}</text>
                        </view>
                        <view class="card-row">
                           <text class="card-label">物料代码:</text>
                           <text class="card-value">{{ item['物料代码'] || '-' }}</text>
                        </view>
                        <view class="card-row">
                           <text class="card-label">物料名称:</text>
                           <text class="card-value">{{ item['物料名称'] || '-' }}</text>
                        </view>
                        <view class="card-row">
                           <text class="card-label">规格型号:</text>
                           <text class="card-value">{{ item['规格型号'] || '-' }}</text>
                        </view>
                        <view class="card-row">
                           <text class="card-label">数量:</text>
                           <text class="card-value">{{ item['数量'] || '0' }}</text>
                        </view>
                        <view class="card-row">
                           <text class="card-label">生产资源:</text>
                           <text class="card-value">{{ item['生产资源'] || '-' }}</text>
                        </view>
                     </view>
                  </uni-card>
               </view>
      </view>
      <view class="bottom-btn" id="bottom-btn">
         <button :class="EnableSubmit?'btn-a':'btn-c'" :disabled="!EnableSubmit" size="mini"
            @tap="cmdSubmit">提交</button>
         <view style="flex: 1;"></view>
         <!-- <button class="btn-d" size="mini" @tap="cmdDelete">删除</button> -->
         <button class="btn-c" size="mini" @tap="cmdExit">退出</button>
      </view>
      <!-- 打印模块 -->
      <labelPrinterComponentVue ref="labelPrinter" :printInfo="printInfo" :printMode="'cpcl'">
      </labelPrinterComponentVue>
      <!-- 打印机选择列表 -->
      <view v-if="maskShow" class="uni-mask" @tap="maskShow = false">
         <scroll-view class="uni-scroll_box" scroll-y>
            <view class="uni-list-box" v-for="(device, index) in discoveredDevices" :key="index"
               @tap="connectBT(device)">
               <view class="uni-list_name">名称:{{ device.name }}</view>
               <view class="uni-list_item">{{ connectedDeviceId === device.address?'已连接':'未连接' }}</view>
            </view>
         </scroll-view>
      </view>
      <view v-if="showResultTable" class="result-modal">
         <view class="modal-mask" @tap="closeResultTable"></view>
         <view class="modal-content">
            <view class="modal-header">
               <text class="modal-title">签到结果</text>
               <uni-icons type="close" size="20" @tap="closeResultTable"></uni-icons>
            </view>
            <view class="modal-body">
               <zb-table :fit="true" :style="{height: '400px'}" :columns="resultTableColumns"
                  :data="resultTableData" :show-header="true" :border="true" :row-key="row => row.index" />
            </view>
            <view class="modal-footer">
               <button class="btn-a" size="mini" @tap="toAddNew">新增</button>
               <button class="btn-a" size="mini" @tap="search">打印</button>
               <view style="flex: 1;"></view>
               <button class="btn-c" size="mini" @tap="closeResultTable">关闭</button>
               <view class="over" v-if="listData.length == 0">暂无工单信息</view>
            </view>
         </view>
         <view v-if="tabs == 2">
            <view class="form-item">
               <view class="title">制单人:</view>
               <view class="righton">
                  <input v-model="hform.HMaker" disabled />
               </view>
            </view>
            <view class="form-item">
               <view class="title">制单日期:</view>
               <view class="righton">
                  <input v-if="hform.HMakeDate" v-model="hform.HMakeDate.substr(0,10)" disabled />
                  <input v-else v-model="hform.HMakeDate" disabled />
               </view>
            </view>
            <view class="form-item">
               <view class="title">修改人:</view>
               <view class="righton">
                  <input v-model="hform.HUpDater" disabled />
               </view>
            </view>
            <view class="form-item">
               <view class="title">修改日期:</view>
               <view class="righton">
                  <input v-if="hform.HUpDateDate" v-model="hform.HUpDateDate.substr(0,10)" disabled />
                  <input v-else v-model="hform.HUpDateDate" disabled />
               </view>
            </view>
            <view class="form-item">
               <view class="title">审核人:</view>
               <view class="righton">
                  <input v-model="hform.HChecker" disabled />
               </view>
            </view>
            <view class="form-item">
               <view class="title">审核日期:</view>
               <view class="righton">
                  <input v-if="hform.HCheckDate" v-model="hform.HCheckDate.substr(0,10)" disabled />
                  <input v-else v-model="hform.HCheckDate" disabled />
               </view>
            </view>
         </view>
         <view class="bottom-btn">
            <button v-if="btnType == 1 && !isEdit" class="btn-a" size="mini" @tap="submit">提交</button>
            <button v-if="btnType != 1 && !isEdit" class="btn-a" size="mini" @tap="ifEdit">修改</button>
            <button v-if="btnType != 1 && isEdit" class="btn-a" size="mini" @tap="submit">提交</button>
            <button class="btn-c" size="mini" @tap="goBack">退出</button>
         </view>
      </view>
   </view>
</template>
<script>
   import dayjs from 'dayjs'
   import getDateTime from '@/utils/getdateTime.js';
   import {
      getUserInfo
   } from "../../utils/auth";
   } from "@/utils/auth.js";
   import dayjs from 'dayjs'
   import {
      CommonUtils
   } from "@/utils/common.js"
   import {
      MpaasScan
   } from "@/utils/mpaasScan.js"
   import labelPrinterComponentVue from "@/components/labelPrinterComponent/labelPrinterComponent.vue"
   import getdateTime from '../../utils/getdateTime';
   export default {
      components: {
         labelPrinterComponentVue
      },
      data() {
         return {
            serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
            // 计算列表高度
            bottomBtnTop: 0,
            listTableTop: 0,
            // 公共变量
            tabs: 0,
            userInfo: getUserInfo(),
            serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
            linterid: '',
            HBillNo: '',
            btnType: 1, //1新增,3修改
            showmore: false,
            HBarCodeFocus: false,
            arrayHDeptName: [], //部门
            HDeptNameList: [],
            arrayHEmpName: [], //员工
            arrayHEmpName: [], //发现人/负责人
            HEmpNameList: [],
            arrayHSourceName: [], //生产资源
            HSourceNameList: [],
            arrayHGroupName: [], //班组
            HGroupNameList: [],
            arrayHShiftsName: [], //班次
            HShiftsNameList: [],
            arrayHSourceName: [], //生产资源
            HSourceNameList: [],
            arrayHProcName: [], //工序
            HProcNameList: [],
            maskShow:false,
            printInfo:false,
            EnableScanBarCodePack: true,
            EnableSubmit: true,
            HBarCodePackFocus: false,
            HBarCodeFocus: false,
            HBarCode: '', // 包条码
            tabs: 0,
            HBillType: '4616',
            HBillSubType: '1', //子类型(1装箱、2组托)
            OperationType: 1, //操作类型(1新增、2从缓存列表中返回)
            HMaterNumber_Pack: "", //托条码对应物料代码
            listOption: [],
            listData: [],
            columns: [{
                  type: 'selection',
                  fixed: true,
                  width: 50
               },
               {
                  name: 'index',
                  label: '序号',
                  width: 60,
                  hidden: true
               },
               {
                  name: '流转卡号',
                  label: '流转卡号',
                  width: 100,
               },
               {
                  name: '数量',
                  label: '数量',
                  width: 100,
               },
               {
                  name: '物料代码',
                  label: '物料代码',
                  width: 100,
               },
               {
                  name: '物料名称',
                  label: '物料名称',
                  width: 100,
               },
               {
                  name: '规格型号',
                  label: '规格型号',
                  width: 100,
               },
               {
                  name: '数量',
                  label: '数量',
                  width: 100,
               },
               {
                  name: '生产资源',
                  label: '生产资源',
                  width: 100,
               }
            ],
            selectedRows: [], // 存储选中的数据
            titleData: [], //不需要显示的字段
            OperationType: 1, //从缓存列表中返回数据类型(1新增、2从缓存列表中返
            //展示表单
            showResultTable: false, // 控制结果表格显示
            resultTableData: [], // 结果表格数据
            resultTableColumns: [{
                  name: '设备编码',
                  label: '设备编码',
                  width: 120,
               },
               {
                  name: '设备名称',
                  label: '设备名称',
                  width: 120,
               },
               {
                  name: '签到角色',
                  label: '签到角色',
                  width: 100,
               },
               {
                  name: '生产资源名称',
                  label: '生产资源名称',
                  width: 100,
               }
            ],
            //
            // 表单提交值
            isEdit: false,
            listOption: [], // 列表选项
            listData: [], // 表格数据
            selectedRows: [], // 表格选中的数据
            roleOptions: [], // 下拉框选项
            roleList: [], // 完整角色列表(包含ID)
            // 添加用户已绑定角色数据
            userBoundRoles: [], // 用户已绑定的角色ID列表
            HBillType: 4616,
            hform: {
               HDate: dayjs(new Date()).format('YYYY-MM-DD'),
               HMaker: getUserInfo()['Czymc'],
               HInterID: '',
               HStockOrgName: uni.getStorageSync("Organization"),
               HStockOrgID: uni.getStorageSync("OrganizationID"),
               HQualityApproval: false,
               HMainID: '',
               HSubID: '',
               HSourceBillSEQ: '',
               HBillNo: '',
               HEmpID: getUserInfo()['HEmpID'] || '',
               HEmpName: getUserInfo()['Czymc'] || '',
               HEmpNumber: getUserInfo()['Czybm'] || uni.getStorageSync("HEmpNumber"),
               HCheckEmpName: '',
               HRemark: '',
               HProduceDate: dayjs(new Date()).format('YYYY-MM-DD'),
               //自定义
               HDate: getDateTime.dateTimeStr('y-m-d'),
               HBarCode: '',
               HDeptName: uni.getStorageSync('HDeptName'),
               HDeptID: uni.getStorageSync('HDeptID'),
               HEmpName: uni.getStorageSync('HEmpName'),
               HEmpID: uni.getStorageSync('HEmpID'),
               HSourceID: uni.getStorageSync('HSourceID'),
               HSourceName: uni.getStorageSync('HSourceName'),
               HProcID: uni.getStorageSync('HProcID'),
               HProcName: uni.getStorageSync('HProcName'),
               HGroupID: uni.getStorageSync('HGroupID'),
               HGroupName: uni.getStorageSync('HGroupName'),
               HShiftsID: 0,
               HShiftsName: '',
               HMouldID: 0,
               HMouldName: '',
               HMouldNumber: '',
               HMouldNo: '',
               HMouldState: '',
               HEquipID: 0,
               HEquipNumber: '',
               HEquipName: '',
               HSourceID: uni.getStorageSync('HSourceID'),
               HSourceName: uni.getStorageSync('HSourceName'),
               HProcID: uni.getStorageSync('HProcID'),
               HProcName:uni.getStorageSync('HProcName'),
               HGroupID:uni.getStorageSync('HGroupID'),
               HGroupName: uni.getStorageSync('HGroupName'),
               HShiftsID: 0,
               HShiftsName: '',
               HDeptName: uni.getStorageSync('HDeptName'),
               HDeptID: uni.getStorageSync('HDeptID'),
               //HEmpID:0,
               //HEmpName:'',
               HSignInReason: '',
               HSignRemark: '',
               HMouldRelQty: 0,
               HOrgID: uni.getStorageSync('OrganizationID'),
               HMaterID: 0,
               HMaterNumber: '',
               HMaterName: '',
               HMaterModel: '',
               HMaker: '',
               HMakeDate: '',
               HUpDater: '',
               HUpDateDate: '',
               HChecker: '',
               HCheckDate: '',
               HCloseMan: '',
               HCloseDate: '',
               HDeleteMan: '',
               HDeleteDate: '',
               HRoles: [],
            },
            roleOptions: [],
            // 分页模块元数据
            paginationMeta: {
               eventType: 'Add'
            }
         }
      },
      onLoad(e) {
         this.HBarCodeFocus = true
         this.getHDeptList()
         this.getHEmpList()
         this.getHSourceList()
         this.getHGroupList()
         this.getHShiftsList()
         this.getHProcList()
         //先获取角色列表,然后获取用户绑定的角色
         this.getRoleList().then(() => {
            this.getUserBoundRoles();
         });
         this.hform.HMaker = uni.getStorageSync('HUserName')
         console.log(e, this.userInfo)
         if (e.linterid) {
            this.btnType = 3
            this.linterid = e.linterid
            this.HBillNo = e.HBillNo
         } else {
            this.getNewData()
         }
         this.tabs = 0
      },
      // ==================== 计算属性 ====================
      computed: {
         // 计算表格高度
         listTableHeight: {
            get() {
               return this.bottomBtnTop - this.listTableTop - 10
            }
         }
      },
      methods: {
         onCardCheckChange(item, index) {
                     item.checked = !item.checked;
                     if (item.checked) {
                        this.selectedRows.push(item);
                     } else {
                        const idx = this.selectedRows.findIndex(row => row.index === item.index);
                        if (idx > -1) {
                           this.selectedRows.splice(idx, 1);
                        }
                     }
                     console.log('当前选中的行:', this.selectedRows);
                  },
         onTableRowClickHandler(row, index) {
            console.log('row: ', row);
            if (!this.listData[index].checked) {
               this.$set(this.listData[index], 'checked', true)
            } else {
               this.listData[index].checked = !this.listData[index].checked
            }
         //扫码
         toScanCode() {
            var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
            mpaasScanModule.mpaasScan({
               'hideAlbum': true,
               'timeoutInterval': '10', //超时时间
               'timeoutText': '未识别到二维码' //超时提醒
            }, (ret) => {
               console.log(ret.resp_result)
               this.hform.HBarCode = ret.resp_result
               this.getHBarCodeData(ret.resp_result)
            })
         },
         async HBarCodeFocusRefresh() {
            this.HBarCode = ''
         //光标
         async refreshBarCodeState() {
            this.HBarCodeFocus = false
            await this.$nextTick()
            this.HBarCodeFocus = true
            await this.$nextTick(() => {
               this.HBarCodeFocus = true
               this.hform.HBarCode = ""
            })
         },
         async HBarCodePackFocusRefresh() {
            this.HBarCode_Pack = ''
            this.HBarCodePackFocus = false
            await this.$nextTick()
            this.HBarCodePackFocus = true
         // 添加一个重新聚焦的方法
         reFocusBarCode() {
            this.HBarCodeFocus = false;
            this.$nextTick(() => {
               this.HBarCodeFocus = true;
            });
         },
         //#region 下拉框
         //获取使用部门数据
         async getHDeptList() {
            try{
               let res = await CommonUtils.doRequest2Async({
                  url: '/PublicPageMethod/DeptList',
                  data: {
                     sWhere: "where HStopFlag=0 and HEndFlag=1 and HUSEORGID = " + uni.getStorageSync(
                        'OrganizationID') + ""
                  },
               })
               console.log('res: ', res);
               if (res.data.count == 1) {
                  console.log('res.data.data: ', res.data.data);
                  this.HDeptNameList = res.data.data
                  // for (var i = 0; i < res.data.data.length; i++) {
                  //    this.arrayHDeptName[i] = res.data.data[i].HName
                  // }
                  this.arrayHDeptName = res.data.data.map(item => item.HName)
                  this.$forceUpdate();
               } else {
         //日期
         HDateChange(e) {
            console.log(e.detail.value)
            this.hform.HDate = e.detail.value
         },
         getHBarCodeData(HBarCode) {
            uni.request({
               url: this.serverUrl + '/Sc_EmployeeSignInNoteBillController/txtHBarCode_KeyDown',
               data: {
                  HBarCode: this.hform.HBarCode
               },
               success: (res) => {
                  if (res.data.code == 1) {
                     var data = res.data.data[0];
                     this.hform.HEquipID = data.HInterID
                     this.hform.HEquipNumber = data.设备代码
                     this.hform.HEquipName = data.设备名称
                     this.hform.HSourceID = data.HSourceID
                     this.hform.HSourceName = data.生产资源名称
                     this.getHMouldList()
                     this.getHIcmoList()
                     uni.showToast({
                        title: res.data.Message,
                        icon: 'none'
                     })
                  } else {
                     uni.showToast({
                        title: res.data.Message,
                        icon: 'none'
                     })
                  }
               },
               fail: (res) => {
                  console.log(res);
                  uni.showToast({
                     title: res.data.Message,
                     title: '接口请求失败',
                     icon: 'none'
                  })
               }
            }catch(err) {
               uni.showToast({
                  title: err,
                  icon: 'none'
               })
            }
               },
            });
         },
         //获取模具信息
         getHMouldList() {
            uni.request({
               url: this.serverUrl + '/Sc_EmployeeSignInNoteBillController/Get_HMouldList',
               data: {
                  HInterID: this.hform.HEquipID,
                  UserNmae: uni.getStorageSync('Czybm'),
               },
               success: (res) => {
                  if (res.data.code == 1) {
                     var data = res.data.data[0];
                     this.hform.HMouldID = data.模具id
                     this.hform.HMouldNo = data.模具编码
                     this.hform.HMouldName = data.模具名称
                     this.hform.HMouldState = data.模具状态
                  } else {
                     uni.showToast({
                        title: res.data.Message,
                        icon: 'none'
                     })
                  }
               },
               fail: (res) => {
                  console.log(res);
                  uni.showToast({
                     title: '接口请求失败',
                     icon: 'none'
                  })
               },
            });
         },
         //获取生产工单
         getHIcmoList() {
            uni.request({
               url: this.serverUrl + '/Sc_EmployeeSignInNoteBillController/Get_HIcmoList',
               data: {
                  HInterID: this.hform.HSourceID,
                  UserNmae: uni.getStorageSync('Czybm'),
               },
               success: (res) => {
                  if (res.data.code == 1) {
                     var data = res.data.data;
                     console.log(data)
                     for (let i = 0; i < data.length; i++) {
                        this.listData.push(Object.assign(data[i], {
                           index: i
                        }))
                     }
                  } else {
                     uni.showToast({
                        title: res.data.Message,
                        icon: 'none'
                     })
                  }
               },
               fail: (res) => {
                  console.log(res);
                  uni.showToast({
                     title: '接口请求失败',
                     icon: 'none'
                  })
               },
            });
         },
         //获取使用部门数据
         getHDeptList() {
            uni.request({
               url: this.serverUrl + '/PublicPageMethod/DeptList',
               data: {
                  sWhere: "where HStopFlag=0 and HEndFlag=1 and HUSEORGID = " + uni.getStorageSync(
                     'OrganizationID') + ""
               },
               success: (res) => {
                  if (res.data.count == 1) {
                     this.HDeptNameList = res.data.data
                     for (var i = 0; i < res.data.data.length; i++) {
                        this.arrayHDeptName[i] = res.data.data[i].HName
                     }
                     this.$forceUpdate();
                  } else {
                     uni.showToast({
                        title: res.data.Message,
                        icon: 'none'
                     })
                  }
               },
               fail: (res) => {
                  console.log(res);
                  uni.showToast({
                     title: '接口请求失败',
                     icon: 'none'
                  })
               },
            });
         },
         //选择使用部门
         HDeptNameChange(e) {
@@ -546,38 +525,35 @@
            }
         },
         //操作员、负责人
         async getHEmpList() {
            try{
               let res = await CommonUtils.doRequest2Async({
                  url: '/Web/GetEmployeeList_Json',
                  data: {
                     Employee: '',
                     HGroupID: 0
                  },
               })
               console.log('res: ', res);
               if (res.data.count == 1) {
                  console.log('res.data.data: ', res.data.data);
                  this.HEmpNameList = res.data.data
                  // for (var i = 0; i < res.data.data.length; i++) {
                  //    this.arrayHDeptName[i] = res.data.data[i].HName
                  // }
                  this.arrayHEmpName = res.data.data.map(item => item.HName)
                  this.$forceUpdate();
               } else {
         getHEmpList() {
            uni.request({
               url: this.serverUrl + '/Web/GetEmployeeList_Json',
               data: {
                  Employee: '',
                  HGroupID: 0
               },
               success: (res) => {
                  if (res.data.count == 1) {
                     this.HEmpNameList = res.data.data
                     for (var i = 0; i < res.data.data.length; i++) {
                        this.arrayHEmpName[i] = res.data.data[i].HName
                     }
                     this.$forceUpdate();
                  } else {
                     uni.showToast({
                        title: res.data.Message,
                        icon: 'none'
                     })
                  }
               },
               fail: (res) => {
                  console.log(res);
                  uni.showToast({
                     title: res.data.Message,
                     title: '接口请求失败',
                     icon: 'none'
                  })
               }
            }catch(err) {
               uni.showToast({
                  title: err,
                  icon: 'none'
               })
            }
               },
            });
         },
         //选择操作员
         HEmpNameChange(e) {
@@ -587,10 +563,47 @@
               }
            }
         },
         //生产资源
         getHSourceList() {
            uni.request({
               url: this.serverUrl + '/api/newBill/getSourceList',
               data: {
                  sWhere: " and HUSEORGID = " + uni.getStorageSync('OrganizationID') + ""
               },
               success: (res) => {
                  if (res.data.code == 1) {
                     this.HSourceNameList = res.data.data.Gy_Source
                     for (var i = 0; i < res.data.data.Gy_Source.length; i++) {
                        this.arrayHSourceName[i] = res.data.data.Gy_Source[i].生产资源
                     }
                     this.$forceUpdate();
                  } else {
                     uni.showToast({
                        title: res.data.Message,
                        icon: 'none'
                     })
                  }
               },
               fail: (res) => {
                  console.log(res);
                  uni.showToast({
                     title: '接口请求失败',
                     icon: 'none'
                  })
               },
            });
         },
         //选择生产资源
         HSourceNameChange(e) {
            for (var i = 0; i < this.HSourceNameList.length; i++) {
               if (this.HSourceNameList[i].生产资源 == e) {
                  this.hform.HSourceID = this.HSourceNameList[i].HItemID
               }
            }
         },
         //班组
         async getHGroupList() {
            try{
            try {
               let res = await CommonUtils.doRequest2Async({
                  url: '/Gy_Group/list',
                  data: {
@@ -598,14 +611,11 @@
                     user: getUserInfo()['Czymc'] || '',
                  },
               })
               console.log('res: ', res);
               if (res.data.count > 0) {
                  console.log('res.data.data: ', res.data.data);
                  this.HGroupNameList = res.data.data
                  // for (var i = 0; i < res.data.data.length; i++) {
                  //    this.arrayHDeptName[i] = res.data.data[i].HName
                  // }
                  this.arrayHGroupName = res.data.data.map(item => item.班组名称)
                  this.$forceUpdate();
               } else {
@@ -614,13 +624,13 @@
                     icon: 'none'
                  })
               }
            }catch(err) {
            } catch (err) {
               uni.showToast({
                  title: err,
                  icon: 'none'
               })
            }
         },
         //选择班组
         HGroupNameChange(e) {
@@ -630,9 +640,9 @@
               }
            }
         },
         //班ci
         //班次
         async getHShiftsList() {
            try{
            try {
               let res = await CommonUtils.doRequest2Async({
                  url: '/Gy_ShiftsController/Get_Gy_WorkShiftList',
                  data: {
@@ -640,14 +650,11 @@
                     HMaker: getUserInfo()['Czymc'] || '',
                  },
               })
               console.log('res: ', res);
               if (res.data.count > 0) {
                  console.log('res.data.data: ', res.data.data);
                  this.HShiftsNameList = res.data.data
                  // for (var i = 0; i < res.data.data.length; i++) {
                  //    this.arrayHDeptName[i] = res.data.data[i].HName
                  // }
                  this.arrayHShiftsName = res.data.data.map(item => item.班次名称)
                  this.$forceUpdate();
               } else {
@@ -656,15 +663,15 @@
                     icon: 'none'
                  })
               }
            }catch(err) {
            } catch (err) {
               uni.showToast({
                  title: err,
                  icon: 'none'
               })
            }
         },
         //选择班ci
         //选择班次
         HShiftsNameChange(e) {
            for (var i = 0; i < this.HSourceNameList.length; i++) {
               if (this.HSourceNameList[i].班次名称 == e) {
@@ -672,52 +679,9 @@
               }
            }
         },
         //生产资源
         async getHSourceList() {
            try{
               let res = await CommonUtils.doRequest2Async({
                  url: '/Gy_Source/list',
                  data: {
                     sWhere: '',
                     user: getUserInfo()['Czymc'] || '',
                  },
               })
               console.log('生产资源res: ', res);
               if (res.data.count > 0) {
                  console.log('生产资源res.data.data: ', res.data.data);
                  this.HSourceNameList = res.data.data
                  // for (var i = 0; i < res.data.data.length; i++) {
                  //    this.arrayHDeptName[i] = res.data.data[i].HName
                  // }
                  this.arrayHSourceName = res.data.data.map(item => item.生产资源名称)
                  this.$forceUpdate();
               } else {
                  uni.showToast({
                     title: res.data.Message,
                     icon: 'none'
                  })
               }
            }catch(err) {
               uni.showToast({
                  title: err,
                  icon: 'none'
               })
            }
         },
         //选择shengcanziyuan
         HSourceNameChange(e) {
            for (var i = 0; i < this.HSourceNameList.length; i++) {
               if (this.HSourceNameList[i].生产资源名称 == e) {
                  this.hform.HSourceID = this.HSourceNameList[i].HItemID
                  console.log("HSourceID为",this.hform.HSourceID)
               }
            }
         },
         //工序
         async getHProcList() {
            try{
            try {
               let res = await CommonUtils.doRequest2Async({
                  url: '/Gy_Process/list',
                  data: {
@@ -725,14 +689,11 @@
                     user: getUserInfo()['Czymc'] || '',
                  },
               })
               console.log('工序res: ', res);
               if (res.data.count > 0) {
                  console.log('工序res.data.data: ', res.data.data);
                  this.HProcNameList = res.data.data
                  // for (var i = 0; i < res.data.data.length; i++) {
                  //    this.arrayHDeptName[i] = res.data.data[i].HName
                  // }
                  this.arrayHProcName = res.data.data.map(item => item.工序名称)
                  this.$forceUpdate();
               } else {
@@ -741,13 +702,13 @@
                     icon: 'none'
                  })
               }
            }catch(err) {
            } catch (err) {
               uni.showToast({
                  title: err,
                  icon: 'none'
               })
            }
         },
         //选择Proc
         HProcNameChange(e) {
@@ -756,687 +717,316 @@
                  this.hform.HProcID = this.HProcNameList[i].HItemID
               }
            }
         },
         // 获取角色列表
         async getRoleList() {
           try {
             let res = await CommonUtils.doRequest2Async({
               url: '/Xt_UserGroup/list',
               data: {
                 sWhere: '',
               },
             })
             console.log('角色列表res: ', res);
             if (res.data.count > 0) {
               console.log('角色列表res.data.data: ', res.data.data);
               // 将接口返回的数据转换为 uni-data-select 需要的格式
               this.roleOptions = res.data.data.map(item => {
                 return {
                   value: item.角色 ,
                   text: item.角色
                 };
               });
               this.$forceUpdate();
             } else {
               uni.showToast({
                 title: res.data.Message || '获取角色列表失败',
                 icon: 'none'
               });
               // 如果接口失败,可以设置默认选项
               this.roleOptions = [];
             }
           } catch(err) {
             uni.showToast({
               title: err.message || '获取角色列表异常',
               icon: 'none'
             });
             // 异常情况设置默认选项
             this.roleOptions = [];
           }
         },
         //#endregion
         toScanCode2() {
            MpaasScan.scanCode((scanCode) => {
               this.HBarCode = scanCode
               GetMeesageByBarCode(scanCode)
            })
         },
         GetMeesageByBarCode(HBarCode) {
            let sBarCode = this.HBarCode
            if (!sBarCode) {
               return uni.showToast({
                  icon: 'none',
                  title: '条码不能为空,请扫描条码!',
               })
            }
            CommonUtils.doRequest2({
               url: '/Sc_EmployeeSignInNoteBillController/Get_equipmentMes',
               data: {
                  "HInterID": this.hform.HInterID,
                  "HBarCode": sBarCode,
               },
               resFunction: (res) => {
                  let {
                     data,
                     count,
                     Message
                  } = res.data
                  if (count == 1) {
                     //let data=res.data
                     console.log(sBarCode)
                     console.log(res.data.data[0])
                     var moulddate=res.data.data[0]
                     this.hform.HMouldID = moulddate.模具id
                     this.hform.HMouldNo = moulddate.模具编码
                     this.hform.HMouldName = moulddate.模具名称
                     this.hform.HMouldState = moulddate.模具状态
                     this.GetEquipmentMsg(this.HBarCode)
                  } else {
                     this.GetEquipmentMsg(this.HBarCode)
                     CommonUtils.playSound(0)
                     this.listData = []
                     this.HBarCodeFocusRefresh()
                     uni.showToast({
                        icon: 'none',
                        title: "模具为空"
                     })
                  }
         // 获取用户已绑定的角色
         async getUserBoundRoles() {
            try {
               // 确保角色列表已加载
               if (!this.roleList || this.roleList.length === 0) {
                  console.log('角色列表未加载,先加载角色列表');
                  await this.getRoleList();
               }
            })
         },
         GetEquipmentMsg(HBarCode)
         {
            CommonUtils.doRequest2({
               url: '/Sc_EmployeeSignInNoteBillController/APP_Edit_json',
               data: {
                  "HInterID": this.hform.HInterID,
                  "HBarCode": HBarCode,
               },
               resFunction: (res) => {
                  let {
                     data,
                     count,
                     Message
                  } = res.data
                  if (count == 1) {
                     //let data=res.data
                     //console.log(sBarCode)
                     console.log(res.data.data[0])
                     var tabledata=res.data.data[0]
                     this.hform.HEquipID = tabledata[0].设备内码
                     this.hform.HEquipName = tabledata[0].设备名称
                     this.listData = []
               let res = await CommonUtils.doRequest2Async({
                  url: '/Xt_UserGroup/UserGroupInfoList',
                  data: {
                     sWhere: ' and userid = '+getUserInfo()['Czybm']+''
                  },
               });
                     if (data[1].length > 0) {
                        this.hform.HMaterID = data[1].HMaterID
                        for (let i = 0; i < data[1].length; i++) {
                           this.listData.push(Object.assign(data[1][i], {
                              index: i
                           }))
                        }
               if (res.data.count > 0) {
                  // 提取角色ID
                  const boundRoleIds = res.data.data.map(item => item.GroupId);
                  this.userBoundRoles = boundRoleIds;
                  // 将角色ID转换为角色名称
                  const boundRoleNames = [];
                  for (const roleId of boundRoleIds) {
                     // 在角色列表中查找对应的角色
                     const roleItem = this.roleList.find(r => r.HGroupID == roleId);
                     if (roleItem && roleItem.角色) {
                        boundRoleNames.push(roleItem.角色);
                     }
                  } else {
                     CommonUtils.playSound(0)
                     this.listData = []
                     this.HBarCodeFocusRefresh()
                     uni.showToast({
                        icon: 'none',
                        title: "工单信息和设备信息为空"
                     })
                  }
                  console.log('用户绑定角色名称: ', boundRoleNames);
                  // 如果是新增模式,设置默认选中的角色
                  if (this.btnType == 1) {
                     this.hform.HRoles = boundRoleNames;
                     console.log('已设置默认角色: ', this.hform.HRoles);
                  }
                  this.$forceUpdate();
               } else {
                  // 如果没有绑定角色,清空选择
                  if (this.btnType == 1) {
                     this.hform.HRoles = [];
                  }
                  console.log('用户未绑定任何角色');
               }
            })
         },
         onRoleChange(e) {
            console.log('选中的角色:', this.hform.HRoles);
            } catch (err) {
               console.error('获取用户绑定角色失败:', err);
               uni.showToast({
                  title: err.message || '获取用户角色失败',
                  icon: 'none'
               });
            }
         },
         // 获取角色信息
         async getRoleList() {
            try {
               let res = await CommonUtils.doRequest2Async({
                  url: '/Xt_UserGroup/list',
                  data: {
                     sWhere: '',
                  },
               });
               if (res.data.count > 0) {
                  console.log('角色列表res.data.data: ', res.data.data);
         handleSelect(selected, array) {
            this.selectedRows = array
                  // 保存原始角色列表,包含角色ID
                  this.roleList = res.data.data;
                  // 生成下拉框选项
                  this.roleOptions = res.data.data.map(item => {
                     return {
                        value: item.角色,
                        text: item.角色
                     };
                  });
                  // 更新视图
                  this.$forceUpdate();
                  // 返回Promise以便链式调用
                  return Promise.resolve();
               } else {
                  uni.showToast({
                     title: res.data.Message || '获取角色列表失败',
                     icon: 'none'
                  });
                  // 设置空数组
                  this.roleList = [];
                  this.roleOptions = [];
                  // 返回Promise以便链式调用
                  return Promise.reject('获取角色列表失败');
               }
            } catch (err) {
               uni.showToast({
                  title: err.message || '获取角色列表异常',
                  icon: 'none'
               });
               // 设置空数组
               this.roleList = [];
               this.roleOptions = [];
               // 返回Promise以便链式调用
               return Promise.reject(err);
            }
         },
         handleSelectAll(selected, array) {
            this.selectedRows = array
         },
         getMaxNo() {
            CommonUtils.doRequest2({
               url: "/WEBSController/GetMaxBillNoAndID_Json",
         //新增
         getNewData() {
            uni.request({
               url: this.serverUrl + '/Web/GetMAXNum',
               data: {
                  "HBillType": this.HBillType
                  HBillType: '4616'
               },
               resFunction: (d) => {
                  let {
                     count,
                     data,
                     Message
                  } = d.data
                  if (count == 1) {
                     this.hform.HInterID = data[0].HInterID;
                     this.hform.HBillNo = data[0].HBillNo
               success: (res) => {
                  console.log(res.data)
                  if (res.data.count == 1) {
                     this.hform.HInterID = 0
                     this.hform.HBillNo = res.data.data[0].HBillNo
                     this.hform.HMakeDate = getDateTime.dateTimeStr('y-m-d')
                     this.btnType = 1
                  } else {
                     uni.showModal({
                        title: "温馨提示",
                        showCancel: false,
                        content: Message
                     uni.showToast({
                        title: res.data.Message,
                        icon: 'none'
                     })
                  }
               }
            })
               },
               fail: (res) => {
                  console.log(res);
                  uni.showToast({
                     title: '接口请求失败',
                     icon: 'none'
                  })
               },
            });
         },
         submitPreCheck() {
            if (CommonUtils.isEmpty(this.hform.HInterID)) {
               uni.showToast({
                  icon: 'none',
                  title: '单据内码获取失败,错误的单据内码!'
               })
               return false
         submit() {
            this.hform.HInterID = 0
            for (let i = 0; i < this.hform.HRoles.length; i++) {
               this.hform.HSignRemark = this.hform.HSignRemark + this.hform.HRoles[i] + ","
            }
            if (CommonUtils.isEmpty(this.hform.HBillNo)) {
               uni.showToast({
                  icon: 'none',
                  title: '单据号获取失败,错误的单据号!'
               })
               return false
            }
            if (this.listData.length < 1) {
               uni.showToast({
                  icon: 'none',
                  title: '没有扫码信息,请先扫描条码,确认无误后再提交!'
               })
               return false
            }
            return true
         },
         cmdDelete() {
            console.log('this.selectedRows: ', this.selectedRows);
            if (this.selectedRows.length != 1) {
               return uni.showToast({
                  icon: 'none',
                  title: '请选择一行记录,进行删除!'
               })
            }
            uni.showModal({
               title: '删除确认',
               content: '确认要删除选中行所有扫码记录?删除后将不可恢复!',
               success: () => {
                  if (confirm) {
                     CommonUtils.doRequest2({
                        url: '/WEBSController/set_DelPackUnionBill_Temp_Pack_Json',
                        data: {
                           HInterID: this.hform.HInterID,
                           HBillType: this.HBillType,
                           HBarCode: this.selectedRows[0].HBarCode
                        },
                        resFunction: (res) => {
                           let {
                              data,
                              count,
                              Message
                           } = res.data
                           if (count == 1) {
                              CommonUtils.playSound(1)
                              uni.showToast({
                                 icon: 'none',
                                 title: Message
            let oMain = JSON.stringify(this.hform);
            console.log("提交的json", oMain)
            let sMainSub = oMain + ';' + getUserInfo()['OrganizationID'] + ';' + getUserInfo()['Czymc'];
            CommonUtils.doRequest2({
               url: "/Sc_EmployeeSignInNoteBillController/SaveBill_APP",
               data: {
                  "msg": sMainSub
               },
               method: "POST",
               resFunction: (res) => {
                  let {
                     data,
                     count,
                     Message
                  } = res.data
                  if (count == 1) {
                     uni.showModal({
                        title: '提示',
                        content: res.data.Message + ' 是否继续新增?',
                        success: (res) => {
                           if (res.confirm) {
                              console.log('用户点击确定');
                              uni.redirectTo({
                                 url: '/pages/EmployeeRecords/EmployeeRecordsBill'
                              })
                              //this.DisBillEntryList()
                           } else {
                              CommonUtils.playSound(0)
                              uni.showToast({
                                 icon: 'none',
                                 title: Message
                              })
                           } else if (res.cancel) {
                              console.log('用户点击取消');
                              setTimeout(() => {
                                 uni.navigateBack();
                              }, 50)
                           }
                        }
                     })
                  }
               }
            })
         },
         async cmdSubmit() {
            let checkRes = this.submitPreCheck()
            if (!checkRes) {
               return
            }
            this.EnableSubmit = false
            try {
               debugger
               this.hform.HInterID = 0
               for (let i = 0; i < this.hform.HRoles.length; i++) {
                  this.hform.HSignRemark = this.hform.HSignRemark + this.hform.HRoles[i] + ","
               }
               let oMain = JSON.stringify(this.hform);
               console.log("提交的json", oMain)
               // this.HBillSub[0].HRepairCheckID = this.hform.HRepairCheckMainID
               // this.HBillSub[0].HManagerID = this.hform.HManagerID
               // this.HBillSub[0].HRepairCheckContent = this.hform.HRepairCheckMainContent
               // let sSubStr = JSON.stringify(this.HBillSub);
               let sMainSub = oMain + ';' + getUserInfo()['OrganizationID'] + ';' + getUserInfo()['Czymc'];
               await CommonUtils.doRequest2({
                  url: "/Sc_EmployeeSignInNoteBillController/SaveBill_APP",
                  data: {
                     "msg": sMainSub
                  },
                  method: "POST",
                  resFunction: async (res) => {
                     let {
                        data,
                        count,
                        Message
                     } = res.data
                     if (count == 1) {
                        uni.showModal({
                            title: '提示',
                            content: res.data.Message + '。是否继续新增?',
                            success: (res) => {
                                if (res.confirm) {
                                    console.log('用户点击确定');
                                    uni.redirectTo({
                                        url: '/pages/EmployeeRecords/EmployeeRecordsBill'
                                    })
                                } else if (res.cancel) {
                                    console.log('用户点击取消');
                                    // setTimeout(() => {
                                    //    uni.navigateBack();
                                    // }, 50)
                                }
                            }
                        });
                        // 等待数据获取完成后再显示表格
                        //await this.getResultTableData();
                     } else {
                        uni.showToast({
                           icon: 'none',
                           title: Message
                        })
                        this.EnableSubmit = true;
                     }
                  }
               })
            } catch (error) {
               console.error('提交失败:', error);
               this.EnableSubmit = true;
            }
         },
         getResultTableData() {
            CommonUtils.doRequest2({
               url: '/Sc_EmployeeSignInNoteBillController/GetListPage',
               data: {
                  "sWhere": 'and HEquipID=' + this.hform.HEquipID,
                  "user": 'admin'
               },
               resFunction: (res) => {
                  console.log('结果接口返回:', res);
                  let {
                     data,
                     count,
                     Message
                  } = res.data
                  if (count == 1) {
                     console.log('获取到结果数据:', data);
                     this.resultTableData = data;
                     this.showResultTable = true; // 显示结果表格
                     console.log('showResultTable 设置为:', this.showResultTable);
                     });
                  } else {
                     uni.showToast({
                        icon: 'none',
                        title: Message || '获取数据失败'
                        title: Message
                     })
                     this.EnableSubmit = true;
                  }
               }
            })
         },
         // 新增方法
         toAddNew() {
            // 重置数据,准备新增
            this.showResultTable = false;
            this.EnableSubmit = true;
            this.resultTableData = [];
            this.HBarCode_Pack = '';
            this.HBarCode = '';
            this.listData = [];
            this.getMaxNo(); // 重新获取新的单据号
            this.HBarCodePackFocusRefresh(); // 重新聚焦
         },
         // 关闭结果表格
         closeResultTable() {
            this.showResultTable = false;
            uni.navigateBack();
         },
         cmdExit() {
            uni.navigateBack()
         },
         //打印模块函数
         /**
          * 打印函数
          */
         async search() {
            // #ifndef APP-PLUS
         goBack() {
            uni.showModal({
               content: "不支持蓝牙打印功能,请切换移动设备...",
            })
            return
            // #endif
            if (this.$printer.isConnected() === false) {
               this.$refs.labelPrinter.openPopup()
            } else {
               let printContent = []
               let printInfoBuffer = []
               let count = 0
               uni.showLoading()
               console.log('this.listData: ', this.printListData);
               for (let listOne of this.printListData) {
                  let Message = await this.getPrintTemplate(listOne.HInterID, listOne.HItemID)
                  printContent.push(Message)
                  count++;
                  if (count == 10) {
                     printInfoBuffer.push(printContent.join("\r\n"))
                     count = 0
                     printContent = []
               title: '提示',
               content: '确认要退出当前页面吗?',
               success: (res) => {
                  if (res.confirm) {
                     console.log('用户点击确定');
                     uni.navigateBack()
                  } else if (res.cancel) {
                     console.log('用户点击取消');
                  }
               }
               uni.hideLoading()
               printInfoBuffer.push(printContent.join("\r\n"))
               this.printInfo = JSON.stringify(printInfoBuffer)
               printInfoBuffer = []
               await this.$nextTick(() => {
                  this.$refs.labelPrinter.execPrint()
               })
            }
         },
         /** 获取打印模板
          * @param {Object} HInterID
          * @param {Object} HItemID
          */
         async getPrintTemplate(HInterID, HItemID) {
            console.log('data: ', {
               HOrginationName: uni.getStorageSync("Organization"),
               HBillSubType: this.HBillType,
               HInterID: HInterID,
               HItemID: HItemID,
            })
            return new Promise((resolve, reject) => {
               CommonUtils.doRequest2({
                  url: "/Sc_BarCode/Get_BarCodePrintCode_CPCL",
                  data: {
                     HOrginationName: uni.getStorageSync("Organization"),
                     HBillSubType: this.HBillType,
                     HInterID: HInterID,
                     HItemID: HItemID,
                  },
                  resFunction: (res) => {
                     let {
                        Message,
                        count
                     } = res.data
                     if (count == 1) {
                        console.log('Message: ', Message);
                        resolve(Message)
                     } else {
                        uni.showToast({
                           icon: 'none',
                           title: Message
                        })
                        reject();
                     }
                  },
                  errFunction: (err) => {
                     reject();
                  },
               })
            })
         },
         /**
          * 查找打印机
          */
         async searchLabelPrinter() {
            // 查找打印机
            var that = this
            // 使用openBluetoothAdapter 接口,免去主动申请权限的麻烦
            uni.openBluetoothAdapter({
               success: async (res) => {
                  await this.checkPermission();
                  console.log('start discovery devices');
                  this.discoveredDevices = [];
                  console.log(res)
                  bluetoothTool.discoveryNewDevice();
                  this.maskShow = true
               },
               fail: async (e) => {
                  console.error(e)
                  switch (e.code) {
                     case "10009":
                        this.showToast("此设备不支持设备搜索功能!");
                        break;
                     default:
                        console.error(e);
                  }
               }
            })
         },
         onDevice(device) {
            console.log("监听寻找到新设备的事件---------------")
            console.log(device)
            if (typeof device === 'undefined') return;
            if (typeof device.name === 'undefined') return;
            console.log(device.name);
            if (device.name === '') return;
            if (device.name === null) return;
            if (device.name.toUpperCase().endsWith('_BLE') ||
               device.name.toUpperCase().endsWith('-LE') ||
               device.name.toUpperCase().endsWith('-BLE')) return;
            const isDuplicate = this.discoveredDevices.find(item => item.address === device.address);
            if (isDuplicate) return;
            this.discoveredDevices.push(device);
         },
         connectBT(device) {
            const vm = this;
            uni.showLoading({
               title: '连接中'
            });
            bluetoothTool.connDevice(device.address, (result) => {
               console.log(result)
               uni.hideLoading()
               if (result) {
                  //    // console.log(result);
                  bluetoothTool.cancelDiscovery();
                  // console.log(vm.$printer)
                  vm.$printer.init(new FakeConnectedDevice());
                  vm.connectedDeviceId = device.address;
                  uni.showToast({
                     icon: 'none',
                     title: '连接成功'
                  })
                  this.maskShow = false
               } else {
                  uni.showToast({
                     icon: 'none',
                     title: '连接失败'
                  })
               }
            });
         },
         stopSearchBT() {
            console.log("停止搜寻附近的蓝牙外围设备---------------")
            bluetoothTool.cancelDiscovery();
         },
         closeBluetooth() {
            console.log("停止蓝牙连接")
            const vm = this;
            if (vm.connectedDeviceId != '') {
               bluetoothTool.closeBtSocket();
               vm.connectedDeviceId = "";
            }
         },
      },
      computed: {
         listTableHeight: {
            get() {
               return this.bottomBtnTop - this.listTableTop - 10
            }
         }
      },
      async onReady() {
         // #ifndef MP-WEIXIN
         let query = uni.createSelectorQuery().in(this)
         query.select("#bottom-btn")
            .boundingClientRect((data) => {
               if (data) {
                  this.bottomBtnTop = data.top
               } else {
                  console.log("未找到#bottom-btn节点");
               }
            })
            .exec();
         query.select("#list-table")
            .boundingClientRect((data) => {
               if (data) {
                  this.listTableTop = data.top
               } else {
                  console.log("未找到#list-table节点");
               }
            })
            .exec();
         // #endif
      },
      onLoad(e) {
         // 1为 装箱 2为 组托
         this.BarCodeType = e.BarCodeType || 1
         this.OperationType = e.OperationType || 1
         this.getHDeptList()
         this.getHEmpList()
         this.getHGroupList()
         this.getHShiftsList()
         this.getHSourceList()
         this.getHProcList()
         this.getRoleList()
         if (this.OperationType == 1) {
            this.getMaxNo()
         } else if (this.OperationType == 2) {
            // this.GetMeesageByBarCode_Pack(this.HBarCode_Pack)
            //this.DisBillEntryList()
            this.tabs = 0
         }
         // 光标默认聚焦在托条码上
         this.HBarCodePackFocusRefresh()
      }
   }
</script>
<style lang="scss">
   input {
      width: inherit;
      padding: 8rpx 20rpx;
      font-size: 30rpx;
<style lang="scss" scoped>
   .form {
      width: 668rpx;
      margin: 20rpx auto;
      padding-bottom: 240rpx;
   }
   .uni-mask {
      position: fixed;
      top: 0;
      left: 0;
      bottom: 0;
      z-index: 3;
   .tab_area {
      width: 100%;
      height: 50rpx;
   }
   .other {
      margin-top: 8rpx;
      text-align: center;
      font-size: 28rpx;
      padding: 4rpx 18rpx;
      color: #1890FF;
   }
   .form-item {
      display: flex;
      align-items: center;
      width: 100%;
      background: rgba(0, 0, 0, 0.6);
      padding: 0 30rpx;
      box-sizing: border-box;
      font-size: 30rpx;
      padding: 6rpx 0;
      .title {
         width: 208rpx;
         text {
            color: red;
            font-weight: bold;
         }
      }
      .right {
         width: 450rpx;
         border-radius: 22rpx;
         border: 1px solid #acacac;
      }
      .righton {
         width: 450rpx;
         border-radius: 22rpx;
         border: 1px solid #e4e4e4;
         background-color: #e4e4e4;
      }
      input {
         width: 100%;
         padding: 8rpx 20rpx;
         font-size: 30rpx;
      }
      textarea {
         width: 98%;
         padding: 8rpx 20rpx;
         font-size: 30rpx;
      }
   }
   .form {
      display: flex;
      flex-direction: column;
      gap: 20rpx;
   .bottom-btn {
      width: 100%;
      // height: 120rpx;
      position: fixed;
      bottom: 0;
      left: 0;
      background-color: #fff;
      box-shadow: 0 2rpx 10rpx 2rpx rgba(0, 0, 0, 0.4);
      padding: 30rpx 40rpx 40rpx 40rpx;
      .form-base-info {
         display: flex;
         flex-direction: column;
         gap: 10rpx;
         box-sizing: border-box;
         padding: 30rpx;
      button {
         border-radius: 50rpx;
         width: 180rpx;
         height: 66rpx;
         line-height: 66rpx;
         font-size: 28rpx;
      }
      .bill-info {
         display: flex;
         flex-direction: column;
         gap: 10rpx;
         box-sizing: border-box;
         padding: 16rpx 30rpx;
         background-color: #fff;
      .btn-a {
         background-color: #3A78FF;
         color: #fff;
      }
      .form-item {
         display: flex;
         align-items: center;
         font-size: 30rpx;
         padding: 6rpx 0;
      .btn-b {
         background-color: #41a863;
         color: #fff;
      }
         .title {
            width: 208rpx;
      .btn-c {
         background-color: #FFA500;
         color: #fff;
         position: absolute;
         right: 120rpx;
      }
            text {
               color: red;
               font-weight: bold;
            }
         }
         .right {
            flex: 1;
            border-radius: 22rpx;
            border: 1px solid #acacac;
         }
         .righton {
            width: 450rpx;
            border-radius: 22rpx;
            border: 1px solid #e4e4e4;
            background-color: #e4e4e4;
         }
         input {
            // width: 100%;
            padding: 8rpx 20rpx;
            font-size: 30rpx;
         }
         textarea {
            width: 98%;
            padding: 8rpx 20rpx;
            font-size: 30rpx;
         }
      .btn-d {
         background-color: #ff8901;
         color: #fff;
      }
   }
@@ -1460,224 +1050,4 @@
         border-bottom: 3px solid #3a78ff;
      }
   }
   .machine-info-container {
      padding-left: 40rpx;
      /* 向右移动40rpx */
      padding-right: 40rpx;
      padding-top: 20rpx;
      .form-item {
         display: flex;
         align-items: center;
         font-size: 30rpx;
         padding: 10rpx 0;
         .title {
            width: 220rpx;
            /* 稍微加宽标题宽度 */
            min-width: 220rpx;
            color: #333;
         }
         .righton {
            flex: 1;
            border-radius: 22rpx;
            border: 1px solid #e4e4e4;
            background-color: #f8f8f8;
            input {
               width: 100%;
               padding: 12rpx 20rpx;
               font-size: 30rpx;
               color: #666;
            }
         }
      }
   }
   .bottom-btn {
      width: 100%;
      box-sizing: border-box;
      // height: 120rpx;
      position: fixed;
      bottom: 0;
      left: 0;
      background-color: #fff;
      box-shadow: 0 2rpx 10rpx 2rpx rgba(0, 0, 0, 0.4);
      padding: 30rpx 40rpx 40rpx 40rpx;
      display: flex;
      flex-direction: row;
      gap: 10rpx;
      button {
         border-radius: 50rpx;
         width: 180rpx;
         height: 66rpx;
         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;
      }
   }
   .result-modal {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 2;
      .modal-mask {
         position: absolute;
         top: 0;
         left: 0;
         width: 100%;
         height: 100%;
         background: rgba(0, 0, 0, 0.5);
      }
      .modal-content {
         position: absolute;
         top: 50%;
         left: 50%;
         transform: translate(-50%, -50%);
         width: 90%;
         max-width: 700rpx;
         background: #fff;
         border-radius: 20rpx;
         overflow: hidden;
         .modal-header {
            padding: 30rpx;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
            .modal-title {
               font-size: 32rpx;
               font-weight: bold;
            }
         }
         .modal-body {
            padding: 30rpx;
            max-height: 60vh;
            overflow-y: auto;
         }
         .modal-footer {
            padding: 30rpx;
            border-top: 1px solid #eee;
            display: flex;
            align-items: center;
         }
      }
   }
   .work-order-cards {
         padding: 30rpx;
         display: flex;
         flex-direction: column;
         gap: 20rpx;
         .work-order-card {
            background: #fff;
            border-radius: 16rpx;
            padding: 24rpx;
            box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.08);
            border: 1px solid #e8e8e8;
            .card-header {
               display: flex;
               justify-content: space-between;
               align-items: center;
               padding-bottom: 20rpx;
               border-bottom: 1px solid #f0f0f0;
               margin-bottom: 20rpx;
               .card-title {
                  font-size: 32rpx;
                  font-weight: bold;
                  color: #333;
               }
            }
            .card-content {
               .card-row {
                  display: flex;
                  align-items: center;
                  padding: 12rpx 0;
                  border-bottom: 1px dashed #f5f5f5;
                  &:last-child {
                     border-bottom: none;
                  }
                  .card-label {
                     width: 160rpx;
                     font-size: 28rpx;
                     color: #666;
                     flex-shrink: 0;
                  }
                  .card-value {
                     flex: 1;
                     font-size: 28rpx;
                     color: #333;
                     word-break: break-all;
                  }
               }
            }
            &:hover {
               box-shadow: 0 4rpx 16rpx rgba(58, 120, 255, 0.15);
               border-color: #3a78ff;
            }
         }
         .empty-card {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 80rpx 30rpx;
            background: #f8f9fa;
            border-radius: 16rpx;
            border: 2rpx dashed #dcdfe6;
            .empty-text {
               font-size: 30rpx;
               color: #999;
               margin-top: 20rpx;
               margin-bottom: 10rpx;
            }
            .empty-tip {
               font-size: 26rpx;
               color: #ccc;
            }
         }
      }
</style>