wtt
2026-01-23 920675a9f1ccf311d32e6466ebde737dff765645
pages/MJGL/Sb_EquipRepairCheckBill/Sb_EquipRepairCheckBill.vue
@@ -1,736 +1,834 @@
<template>
    <view>
        <view class="tabs" id="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 :class="tabs == 3 ? 'on':''" @tap="tabs = 3">附件信息</view> -->
        </view>
        <!-- 基本信息 -->
        <template v-if="tabs == 0">
            <view class="form" :style="{
   <view>
      <view class="tabs" id="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 :class="tabs == 3 ? 'on':''" @tap="tabs = 3">附件信息</view> -->
      </view>
      <!-- 基本信息 -->
      <template v-if="tabs == 0">
         <view class="form" :style="{
                height: containerHeight + 'px',
                overflow: 'auto'
            }">
                <view class="form-item">
                    <view class="title">设备条码:</view>
                    <view :class="enableEdit?'right':'righton'">
                        <input v-model="hform.HBarCode" :disabled="!enableEdit"
                            @confirm="GetMessageByBarCode(hform.HBarCode)" placeholder="请输入(或扫描)设备条码" />
                    </view>
                    <view class="icon-wrapper">
                        <uni-icons type="scan" size="20" @click="toScanCode"></uni-icons>
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">最终结论:</view>
                    <view class="right none-border">
                        <radio-group @change="radioChange" class="radio_Container">
                            <label>
                                <view>
                                    <radio value="OK" :checked="hform.HCheckResult == 'OK'" />
                                    <text>OK</text>
                                </view>
                            </label>
                            </label>
                            <view>
                                <radio value="NG" :checked="hform.HCheckResult == 'NG'" />
                                <text>NG</text>
                            </view>
                            </label>
                        </radio-group>
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">验证内容:</view>
                    <view class="right">
                        <textarea v-model="hform.HRepairCheckMainContent" placeholder="请输入验证内容" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">单据号:</view>
                    <view class="righton">
                        <input disabled v-model="hform.HBillNo" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">单据日期:</view>
                    <view class="righton">
                        <input disabled v-model="hform.HDate" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title required">部门:</view>
                    <zxz-uni-data-select required class="right" :localdata="HDeptList" dataKey="部门名称"
                        dataValue="HItemID" v-model="hform.HDeptID">
                    </zxz-uni-data-select>
                    <!-- <input disabled v-model="hform.HDeptName" placeholder="请选择部门" /> -->
                </view>
                <view class="form-item">
                    <view class="title required">验收人:</view>
                    <zxz-uni-data-select required class="right" :localdata="HEmpList" dataKey="HName"
                        dataValue="HItemID" v-model="hform.HEmpID">
                    </zxz-uni-data-select>
                    <!-- <input disabled v-model="hform.HDeptName" placeholder="请选择部门" /> -->
                </view>
                <view class="form-item">
                    <view class="title required">验证项目:</view>
                    <zxz-uni-data-select required class="right" :localdata="HRepairCheckList" dataKey="维修验收项目"
                        dataValue="hitemid" v-model="hform.HRepairCheckMainID">
                    </zxz-uni-data-select>
                    <!-- <input disabled v-model="hform.HDeptName" placeholder="请选择部门" /> -->
                </view>
                <view class="form-item">
                    <view class="title required">负责人:</view>
                    <zxz-uni-data-select required class="right" :localdata="HEmpList" dataKey="HName"
                        dataValue="HItemID" v-model="hform.HManagerID">
                    </zxz-uni-data-select>
                    <!-- <input disabled v-model="hform.HDeptName" placeholder="请选择部门" /> -->
                </view>
                <view class="form-item">
                    <view class="title">设备名称:</view>
                    <view class="righton">
                        <input v-model="hform.HBarName" disabled />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">设备规格:</view>
                    <view class="righton">
                        <input v-model="hform.HBarSpec" disabled />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">设备型号:</view>
                    <view class="righton">
                        <input v-model="hform.HBarModel" disabled />
                    </view>
                </view>
            </view>
        </template>
        <!-- 其他信息 -->
        <template v-if="tabs == 2">
            <view class="form" :style="{
            <view class="form-item">
               <view class="title">设备条码:</view>
               <view :class="enableEdit?'right':'righton'">
                  <input v-model="hform.HBarCode" :disabled="!enableEdit"
                     @confirm="GetMessageByBarCode(hform.HBarCode)" placeholder="请输入(或扫描)设备条码" />
               </view>
               <view class="icon-wrapper">
                  <uni-icons type="scan" size="20" @click="toScanCode"></uni-icons>
               </view>
            </view>
            <view class="form-item">
               <view class="title">最终结论:</view>
               <view class="right none-border">
                  <radio-group @change="radioChange" class="radio_Container">
                     <label>
                        <view>
                           <radio value="OK" :checked="hform.HCheckResult == 'OK'" />
                           <text>OK</text>
                        </view>
                     </label>
                     </label>
                     <view>
                        <radio value="NG" :checked="hform.HCheckResult == 'NG'" />
                        <text>NG</text>
                     </view>
                     </label>
                  </radio-group>
               </view>
            </view>
            <view class="form-item">
               <view class="title">验收内容:</view>
               <view class="right">
                  <textarea v-model="HDetailList[0].HRepairCheckContent" placeholder="请输入验收内容" />
               </view>
            </view>
            <!-- 维修记录(源单) -->
            <view class="form-item">
               <view class="title required">维修记录:</view>
               <view :class="enableSourceBillEdit?'right':'righton'">
                  <input v-model="hform.HMainSourceBillNo" :disabled="!enableSourceBillEdit"
                     @confirm="GetMessageByHMainSourceBillNo(hform.HMainSourceBillNo)"
                     placeholder="请输入(或扫描)维修记录单号" />
               </view>
               <!-- 放大镜图标 -->
               <view class="icon-wrapper">
                  <uni-icons type="search" size="20" @click="showBillList"></uni-icons>
               </view>
               <!-- 扫描图标 -->
               <view class="icon-wrapper">
                  <uni-icons type="scan" size="20" @click="toScanHMainSourceBillNo"></uni-icons>
               </view>
            </view>
            <view class="form-item">
               <view class="title">单据号:</view>
               <view class="righton">
                  <input disabled v-model="hform.HBillNo" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">单据日期:</view>
               <view class="righton">
                  <input disabled v-model="hform.HDate" />
               </view>
            </view>
            <view class="form-item">
               <view class="title required">部门:</view>
               <zxz-uni-data-select required class="right" :localdata="HDeptList" dataKey="部门名称"
                  dataValue="HItemID" v-model="hform.HDeptID">
               </zxz-uni-data-select>
            </view>
            <view class="form-item">
               <view class="title required">验收人:</view>
               <zxz-uni-data-select required class="right" :localdata="HEmpList" dataKey="HName"
                  dataValue="HItemID" v-model="hform.HEmpID">
               </zxz-uni-data-select>
            </view>
            <view class="form-item">
               <view class="title required">验收项目:</view>
               <zxz-uni-data-select required class="right" :localdata="HRepairCheckList" dataKey="维修验收项目"
                  dataValue="hitemid" v-model="hform.HRepairCheckID">
               </zxz-uni-data-select>
            </view>
            <view class="form-item">
               <view class="title required">负责人:</view>
               <zxz-uni-data-select required class="right" :localdata="HEmpList" dataKey="HName"
                  dataValue="HItemID" v-model="hform.HManagerID">
               </zxz-uni-data-select>
            </view>
            <view class="form-item">
               <view class="title">设备名称:</view>
               <view class="righton">
                  <input v-model="hform.HBarName" disabled />
               </view>
            </view>
            <view class="form-item">
               <view class="title">设备规格:</view>
               <view class="righton">
                  <input v-model="hform.HBarSpec" disabled />
               </view>
            </view>
            <view class="form-item">
               <view class="title">设备型号:</view>
               <view class="righton">
                  <input v-model="hform.HBarModel" disabled />
               </view>
            </view>
         </view>
      </template>
      <!-- 其他信息 -->
      <template v-if="tabs == 2">
         <view class="form" :style="{
                height: containerHeight + 'px',
                overflow: 'auto'
            }">
                <view class="form-item">
                    <view class="title">创建人:</view>
                    <view class="righton">
                        <input v-model="hform.HMaker" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">创建日期:</view>
                    <view class="righton">
                        <input v-model="hform.HMakeDate" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">修改人:</view>
                    <view class="righton">
                        <input v-model="hform.HUpDater" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">修改日期:</view>
                    <view class="righton">
                        <input v-model="hform.HUpDateDate" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">审核人:</view>
                    <view class="righton">
                        <input v-model="hform.HChecker" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">审核时间:</view>
                    <view class="righton">
                        <input v-model="hform.HCheckDate" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">作废人:</view>
                    <view class="righton">
                        <input v-model="hform.HDeleteMan" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">作废日期:</view>
                    <view class="righton">
                        <input v-model="hform.HDeleteDate" />
                    </view>
                </view>
            </view>
            <view class="form-item">
               <view class="title">创建人:</view>
               <view class="righton">
                  <input v-model="hform.HMaker" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">创建日期:</view>
               <view class="righton">
                  <input v-model="hform.HMakeDate" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">修改人:</view>
               <view class="righton">
                  <input v-model="hform.HUpDater" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">修改日期:</view>
               <view class="righton">
                  <input v-model="hform.HUpDateDate" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">审核人:</view>
               <view class="righton">
                  <input v-model="hform.HChecker" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">审核时间:</view>
               <view class="righton">
                  <input v-model="hform.HCheckDate" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">作废人:</view>
               <view class="righton">
                  <input v-model="hform.HDeleteMan" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">作废日期:</view>
               <view class="righton">
                  <input v-model="hform.HDeleteDate" />
               </view>
            </view>
         </view>
        </template>
        <!-- 操作按钮 -->
        <view class="buttons" id="buttons">
            <button class="btn-a" size="mini" @tap="submit">提交</button>
            <view style="flex: 1;"></view>
            <button class="btn-a" size="mini" @tap="addNew">新增</button>
            <button class="btn-c" size="mini" @tap="goBack">退出</button>
        </view>
        <xe-upload ref="XeUpload" :options="uploadOptions" @callback="handleUploadCallback"></xe-upload>
    </view>
      </template>
      <!-- 操作按钮 -->
      <view class="buttons" id="buttons">
         <button class="btn-a" size="mini" @tap="submit">提交</button>
         <view style="flex: 1;"></view>
         <button class="btn-a" size="mini" @tap="addNew">新增</button>
         <button class="btn-c" size="mini" @tap="goBack">退出</button>
      </view>
      <xe-upload ref="XeUpload" :options="uploadOptions" @callback="handleUploadCallback"></xe-upload>
      <!-- 源单单据列表弹窗 -->
      <BillListPopupEquipConkBookBillVue ref="billList" :HBillType="hform.HBillType" :HSourceBillType="'设备维修记录单'"
         :HStockOrgID="hform.HStockOrgID">
      </BillListPopupEquipConkBookBillVue>
   </view>
</template>
<script>
    import dayjs from "dayjs";
    import {
        CommonUtils
    } from "@/utils/common";
    import {
        MpaasScan
    } from "@/utils/mpaasScan.js"
    import {
        getUserInfo
    } from "../../../utils/auth";
    export default {
        name: 'sb_EquipRepairCheckBill',
        data() {
            return {
                tabs: 0,
                HMainSourceBillType: "",
                btnTop: 0,
                tabsBottom: 0,
                HModName: "sb_EquipRepairCheckBill",
                HBillType: '3911',
                operationType: 1,
                uploadOptions: {},
                enableEdit: true,
   import dayjs from "dayjs";
   import {
      CommonUtils
   } from "@/utils/common";
   import {
      MpaasScan
   } from "@/utils/mpaasScan.js"
   import {
      getUserInfo
   } from "../../../utils/auth";
   // 引入源单单据列表弹窗组件
   import BillListPopupEquipConkBookBillVue from '../../../components/BillListPopup/BillListPopupEquipConkBookBill.vue';
                HDeptList: [],
                HRepairCheckList: [],
                HEmpList: [],
   export default {
      name: 'sb_EquipRepairCheckBill',
      components: {
         BillListPopupEquipConkBookBillVue
      },
      data() {
         return {
            tabs: 0,
            btnTop: 0,
            tabsBottom: 0,
            HModName: "sb_EquipRepairCheckBill",
            HBillType: '3911',
            operationType: 1,
            uploadOptions: {},
            enableEdit: true,
            enableSourceBillEdit: true, // 新增:控制维修记录编辑状态
                hform: {
                    "HBarCode": "",
                    "HCheckBeginDate": dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss"),
                    "HCheckResult": "OK",
                    "HRepairCheckMainContent": "",
                    "HBillNo": "",
                    "HInterID": 0,
                    "HDate": dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss"),
                    "HDeptName": getUserInfo().HDeptName,
                    "HDeptID": getUserInfo().HDeptID,
                    "HEmpName": getUserInfo().HEmpName,
                    "HEmpID": getUserInfo().HEmpID,
                    "HManagerName": getUserInfo().HManagerName,
                    "HManagerID": getUserInfo().HManagerID,
                    "HRepairCheckMainName": "",
                    "HRepairCheckMainID": 0,
                    "HBarName": "",
                    "HEquipID": 0,
                    "HBarSpec": "",
                    "HBarModel": "",
                    "HMaker": getUserInfo()["Czymc"],
                    "HMakeDate": dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss"),
                    "HUpDater": "",
                    "HUpDateDate": "",
                    "HChecker": "",
                    "HCheckDate": "",
                    "HDeleteMan": "",
                    "HDeleteDate": "",
                    "lngBillKey": "",
                    "lngBillSubKey": ""
                },
                HBillSub: [{ // 后端接口需要。否则数据不会显示在缓存中
                    "HRepairID": 0,
                    "HRepairCode": "",
                    "HRepairName": "",
                    "HManagerID": 0,
                    "HManagerCode": "",
                    "HManagerName": "",
                    "HRepairExplanation": "",
                    "HRemark": "",
                    "LAY_TABLE_INDEX": 0
                }]
            };
        },
        computed: {
            containerHeight: {
                get() {
                    return this.btnTop - this.tabsBottom - 5
                }
            },
        },
        methods: {
            // 提交数据有效性校验
            ValidCheck() {
                if (this.hform.HEquipID == 0) {
                    return {
                        Message: "未录入设备信息,请先录入设备信息!",
                        state: false
                    }
                }
                if (this.hform.HDeptID == 0) {
                    return {
                        Message: "部门不得为空!",
                        state: false
                    }
                }
                if (this.hform.HEmpID == 0) {
                    return {
                        Message: "验收人不得为空!",
                        state: false
                    }
                }
                if (this.hform.HRepairCheckMainID == 0) {
                    return {
                        Message: "验证项目不得为空!",
                        state: false
                    }
                }
                if (this.hform.HManagerID == 0) {
                    return {
                        Message: "负责人不得为空!",
                        state: false
                    }
                }
            HDeptList: [],
            HRepairCheckList: [],
            HEmpList: [],
                return {
                    Message: "",
                    state: true
                }
            },
            addNew() {
                uni.redirectTo({
                    url: './Sb_EquipRepairCheckBill?operationType=1'
                })
            },
            goBack() {
                uni.navigateBack()
            },
            checkBoxChangeHandler(index, e) {
                let cr = e.detail.value
                if (cr.length == 0) {
                    this.HCheckFileList[index]["HDotCheckResult"] = false
                } else {
                    this.HCheckFileList[index]["HDotCheckResult"] = true
                }
            },
            uploadFile(index) {
                console.log('filePath: ', this.attachmentInfo[index].filePath);
                // 通过临时路径读取文件
                uni.uploadFile({
                    url: CommonUtils.getServerUrl() + "/Sb_EquipDotCheckBill/UploadFile",
                    filePath: this.attachmentInfo[index].filePath,
                    name: 'file',
                    formData: {
                        HBillNo: this.hform.HBillNo,
                        HRemark: "",
                        HUserName: getUserInfo()["Czymc"]
                    },
                    success: (uploadRes) => {
                        CommonUtils.showTips({
                            message: "上传成功"
                        })
                        this.attachmentInfo[index].status = "上传成功"
                    },
                    fail: (err) => {
                        CommonUtils.showTips({
                            title: '温馨提示',
                            message: `上传失败: ${err}`
                        })
                    }
                })
            },
            delFile(index) {
                console.log('attachmentInfo: ', this.attachmentInfo[index]);
                uni.showModal({
                    title: '提示',
                    content: '确认要删除 " ' + this.attachmentInfo[index].fileName + ' " 删除后将不可恢复!',
                    success: (res) => {
                        if (res.confirm) {
                            this.attachmentInfo.splice(index, 1)
                        }
                    },
                })
            hform: {
               "HBillType": '3911',
               "HBarCode": "",
               "HCheckBeginDate": dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss"),
               "HCheckResult": "OK",
               "HRepairCheckContent": "",
               "HBillNo": "",
               "HInterID": 0,
               "HDate": dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss"),
               "HDeptName": getUserInfo().HDeptName,
               "HDeptID": getUserInfo().HDeptID,
               "HEmpName": getUserInfo().HEmpName,
               "HEmpID": getUserInfo().HEmpID,
               "HManagerName": getUserInfo().HManagerName,
               "HManagerID": getUserInfo().HManagerID,
               "HRepairCheckMainName": "",
               "HRepairCheckID": 0,
               "HBarName": "",
               "HEquipID": 0,
               "HBarSpec": "",
               "HBarModel": "",
               "HMaker": getUserInfo()["Czymc"],
               "HMakeDate": dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss"),
               "HUpDater": "",
               "HUpDateDate": "",
               "HChecker": "",
               "HCheckDate": "",
               "HDeleteMan": "",
               "HDeleteDate": "",
               "lngBillKey": "",
               "lngBillSubKey": "",
               // 新增:维修记录(源单)相关字段
               "HMainSourceBillNo": "",
               "HMainSourceInterID": 0,
               "HMainSourceEntryID": 0,
               "HMouldRepairWorkName":"",
               "HMouldRepairWorkID":0,
               "HStockOrgID": uni.getStorageSync("OrganizationID"),
            },
            HDetailList: [{ // 后端接口提交需要 明细信息
              "HRepairCheckID": 0,
              "HRepairCode": "",
              "HRepairName": "",
              "HManagerID": 0,
              "HManagerCode": "",
              "HManagerName": "",
              "HRepairCheckContent": "",
              "HRemark": "",
              "LAY_TABLE_INDEX": 0
            }]
         };
      },
      computed: {
         containerHeight: {
            get() {
               return this.btnTop - this.tabsBottom - 5
            }
         },
      },
      methods: {
         // 显示源单单据列表弹窗
         showBillList() {
            this.$refs.billList.showPopup();
         },
            },
            handleUploadCallback(res) { // 文件上传回调
                console.log('file: ', res);
                let fileInfo = res.data[0]
                this.attachmentInfo.push({
                    fileName: fileInfo.name,
                    size: fileInfo.size,
                    status: '等待上传',
                    filePath: fileInfo.tempFilePath
                })
            },
            // 上传文件
            fileUpload() {
                this.$refs.XeUpload.upload('file', {});
            },
            //获取班次数据
            async getShiftList() {
                try {
                    let res = await CommonUtils.doRequest2Async({
                        url: '/Web/GetGy_ShiftsList_Json',
                        data: {
                            Shifts: "",
                        }
                    })
         // 扫描维修记录单号
         toScanHMainSourceBillNo() {
            MpaasScan.scanCode(cb => {
               this.hform.HMainSourceBillNo = cb;
               this.GetMessageByHMainSourceBillNo(cb);
            });
         },
                    let {
                        data,
                        count,
                        Message
                    } = res.data
                    if (count == 1) {
                        this.HShiftsList = data
                    } else {
                        CommonUtils.showTips({
                            title: '温馨提示',
                            message: Message
                        })
                    }
                } catch (err) {
                    CommonUtils.showTips({
                        title: '温馨提示',
                        message: err
                    })
                }
            },
            //获取使用部门数据
            async getHDeptList() {
                try {
                    let res = await CommonUtils.doRequest2Async({
                        url: '/Gy_Department/list',
                        data: {
                            sWhere: ` and HUSEORGID = ${uni.getStorageSync('OrganizationID')}`,
                            user: uni.getStorageSync('HUserName'),
                            Organization: uni.getStorageSync('Organization')
                        }
                    })
         // 根据维修记录单号获取信息
         async GetMessageByHMainSourceBillNo(HSouceBillNo) {
            try {
               let url = "/Sb_EqpRepairWorkBill/GetEqpRepairWorkBillListPage";
               let dataField = {
                  sWhere: ` and 单据号 = '${HSouceBillNo}'`,
                  user: getUserInfo()["Czymc"],
                  page: 1,
                  size: 1,
               };
                    let {
                        data,
                        count,
                        Message
                    } = res.data
                    if (count == 1) {
                        this.HDeptList = data
                    } else {
                        CommonUtils.showTips({
                            title: '温馨提示',
                            message: Message
                        })
                    }
                } catch (err) {
                    CommonUtils.showTips({
                        title: '温馨提示',
                        message: err
                    })
                }
            },
            // 获取职员数据
            async getEmpList() {
                try {
                    let res = await CommonUtils.doRequest2Async({
                        url: '/PublicPageMethod/UserList',
                        data: {
                            sWhere: " where 1=1",
                        }
                    })
               let res = await CommonUtils.doRequest2Async({
                  url: url,
                  data: dataField
               });
                    let {
                        data,
                        count,
                        Message
                    } = res.data
                    if (count == 1) {
                        this.HEmpList = data
                    } else {
                        CommonUtils.showTips({
                            title: '温馨提示',
                            message: Message
                        })
                    }
                } catch (err) {
                    CommonUtils.showTips({
                        title: '温馨提示',
                        message: err
                    })
                }
            },
            // 获取验证项目数据
            async getCheckProjList() {
                try {
                    let res = await CommonUtils.doRequest2Async({
                        url: '/Gy_RepairCheck/GetRepairCheckList',
                        data: {
                            sWhere: "",
                            user: uni.getStorageSync('HUserName'),
                        }
                    })
               let {
                  count,
                  Message,
                  data
               } = res.data;
               if (count == 1) {
                  this.hform.HMainSourceBillNo = data[0]["单据号"];
                  this.hform.HMainSourceInterID = data[0]["hmainid"];
                  this.hform.HMainSourceEntryID = data[0]["hsubid"];
                    let {
                        data,
                        count,
                        Message
                    } = res.data
                    if (count == 1) {
                        this.HRepairCheckList = data
                    } else {
                        CommonUtils.showTips({
                            title: '温馨提示',
                            message: Message
                        })
                    }
                } catch (err) {
                    CommonUtils.showTips({
                        title: '温馨提示',
                        message: err
                    })
                }
            },
            toScanCode() {
                MpaasScan.scanCode(cb => {
                    this.hfrom.HBarCode = cb
                    this.GetMessageByBarCode(cb)
                })
            },
            async GetMessageByBarCode(HBarCode) {
                try {
                    let res = await CommonUtils.doRequest2Sync({
                        url: "/Sb_PDA_EquipDotCheckBill/txtHBarCode_KeyDown_List",
                        data: {
                            HBarCode: HBarCode,
                        },
                    })
                  // 如果源单有设备信息,可以自动填充
                  if (data[0].HEquipID) {
                     this.hform.HEquipID = data[0].HEquipID;
                     this.getEquipFileMain(data[0].HEquipID);
                  }
               } else {
                  CommonUtils.showTips({
                     title: "温馨提示",
                     message: `获取维修记录单失败: ${Message}`
                  });
               }
            } catch (err) {
               CommonUtils.showTips({
                  title: "温馨提示",
                  message: `获取维修记录单失败: ${err}`
               });
            }
         },
                    if (!res) {
                        return
                    }
         // 根据设备ID获取设备信息
         async getEquipFileMain(HInterID) {
            try {
               let res = await CommonUtils.doRequest2Sync({
                  url: "/Sb_PDA_EquipDotCheckBill/txtHBarCode_KeyDown_ListByHEquipID",
                  data: {
                     HEquipID: HInterID,
                  },
               });
                    let {
                        data,
                        count,
                        Message
                    } = res.data
               if (!res) {
                  return;
               }
                    if (count == 1) {
                        console.log('data: ', data);
                        this.hform.HEquipID = data[0].hmainid
                        this.hform.HBarName = data[0].设备名称
                        this.hform.HBarSpec = data[0].设备规格
                        this.hform.HBarModel = data[0].设备型号
                        this.hform.HQty = 1
               let {
                  data,
                  count,
                  Message
               } = res.data;
                        this.enableEdit = false
                    } else {
                        CommonUtils.showTips({
                            title: "温馨提示",
                            message: Message
                        })
                    }
               if (count == 1) {
                  this.hform.HEquipID = data[0].hmainid;
                  this.hform.HBarName = data[0].设备名称;
                  this.hform.HBarSpec = data[0].设备规格;
                  this.hform.HBarModel = data[0].设备型号;
                  this.hform.HBarCode = data[0].设备条码 || "";
                  this.enableEdit = false;
               } else {
                  CommonUtils.showTips({
                     title: "温馨提示",
                     message: Message
                  });
               }
            } catch (err) {
               CommonUtils.showTips({
                  title: "温馨提示",
                  message: err
               });
            }
         },
                } catch (err) {
                    CommonUtils.showTips({
                        title: "温馨提示",
                        message: err
                    })
                }
            },
            async GetItemByEquipFile() {
                try {
                    let res = await CommonUtils.doRequest2Async({
                        url: "/Web/GetItemByEquipFile",
                        data: {
                            "EquipProjectID": this.hform.HEquipID,
                            "Type": "DJ",
                            "HDate": this.hform.HBeginDate
                        }
                    })
         // 提交数据有效性校验
         ValidCheck() {
            if (this.hform.HEquipID == 0) {
               return {
                  Message: "未录入设备信息,请先录入设备信息!",
                  state: false
               }
            }
            if (this.hform.HDeptID == 0) {
               return {
                  Message: "部门不得为空!",
                  state: false
               }
            }
            if (this.hform.HEmpID == 0) {
               return {
                  Message: "验收人不得为空!",
                  state: false
               }
            }
            if (this.hform.HRepairCheckID == 0) {
               return {
                  Message: "验证项目不得为空!",
                  state: false
               }
            }
            if (this.hform.HManagerID == 0) {
               return {
                  Message: "负责人不得为空!",
                  state: false
               }
            }
            // 新增:维修记录校验
            if (!this.hform.HMainSourceBillNo || this.hform.HMainSourceBillNo.trim() === '') {
               return {
                  Message: "维修记录不得为空!",
                  state: false
               }
            }
                    let {
                        data,
                        Message,
                        count
                    } = res.data
                    if (count == 1) {
                        this.hform.HEquipDotCheckRuleInterID = data[0].点检规程ID
                        this.hform.HEquipDotCheckRuleInterNo = data[0].点检规程单号
                        this.hform.HPlanNo = data[0].点检计划单
                        this.hform.HPlanInterID = (data[0].点检计划ID == null ? 0 : data[0].点检计划ID) == "" ? 0 : data[0]
                            .点检计划ID
                        this.hform.HPlanEntryID = (data[0].点检计划子ID == null ? 0 : data[0].点检计划子ID) == "" ? 0 : data[
                            0].点检计划子ID
            return {
               Message: "",
               state: true
            }
         },
         addNew() {
            uni.redirectTo({
               url: './Sb_EquipRepairCheckBill?operationType=1'
            })
         },
         goBack() {
            uni.navigateBack()
         },
         checkBoxChangeHandler(index, e) {
            let cr = e.detail.value
            if (cr.length == 0) {
               this.HCheckFileList[index]["HDotCheckResult"] = false
            } else {
               this.HCheckFileList[index]["HDotCheckResult"] = true
            }
         },
         uploadFile(index) {
            console.log('filePath: ', this.attachmentInfo[index].filePath);
            // 通过临时路径读取文件
            uni.uploadFile({
               url: CommonUtils.getServerUrl() + "/Sb_EquipDotCheckBill/UploadFile",
               filePath: this.attachmentInfo[index].filePath,
               name: 'file',
               formData: {
                  HBillNo: this.hform.HBillNo,
                  HRemark: "",
                  HUserName: getUserInfo()["Czymc"]
               },
               success: (uploadRes) => {
                  CommonUtils.showTips({
                     message: "上传成功"
                  })
                  this.attachmentInfo[index].status = "上传成功"
               },
               fail: (err) => {
                  CommonUtils.showTips({
                     title: '温馨提示',
                     message: `上传失败: ${err}`
                  })
               }
            })
         },
         delFile(index) {
            console.log('attachmentInfo: ', this.attachmentInfo[index]);
            uni.showModal({
               title: '提示',
               content: '确认要删除 " ' + this.attachmentInfo[index].fileName + ' " 删除后将不可恢复!',
               success: (res) => {
                  if (res.confirm) {
                     this.attachmentInfo.splice(index, 1)
                  }
               },
            })
                        this.HCheckFileList = Array.from(data).map(item => {
                            return {
                                "HDotCheckItemID": item.HDotCheckItemID,
                                "HDotCheckCode": item.点检项目代码,
                                "HDotCheckItem": item.点检项目,
                                "HDotCheckPart": item.点检部位,
                                "HClaim": item.具体要求,
                                "HManagerID": item.负责人ID,
                                "HManagerCode": item.负责人代码,
                                "HManagerName": item.负责人名称,
                                "HSourceInterID": item.点检计划ID == null ? 0 : item.点检计划ID,
                                "HSourceEntryID": item.点检计划子ID == null ? 0 : item.点检计划子ID,
                                "HSourceBillNo": item.点检计划单,
                                "HDotCheckItemClassID": 0,
                                "HDotCheckItemClassName": "",
                                "HDotCheckItemMethodID": 0,
                                "HDotCheckItemMethodName": "",
                                "HDotCheckResult": item.默认结论 == 1 ? true : false
                            }
                        })
         },
         handleUploadCallback(res) { // 文件上传回调
            console.log('file: ', res);
            let fileInfo = res.data[0]
            this.attachmentInfo.push({
               fileName: fileInfo.name,
               size: fileInfo.size,
               status: '等待上传',
               filePath: fileInfo.tempFilePath
            })
         },
         // 上传文件
         fileUpload() {
            this.$refs.XeUpload.upload('file', {});
         },
         //获取班次数据
         async getShiftList() {
            try {
               let res = await CommonUtils.doRequest2Async({
                  url: '/Web/GetGy_ShiftsList_Json',
                  data: {
                     Shifts: "",
                  }
               })
                    } else {
                        CommonUtils.showTips({
                            title: '温馨提示',
                            message: `获取点检规程错误: ${Message}`
                        })
                    }
                } catch (err) {
                    CommonUtils.showTips({
                        title: '温馨提示',
                        message: `获取点检规程错误: ${err}`
                    })
                }
            },
            radioChange({
                detail: {
                    value
                }
            }) {
                this.hform.HCheckResult = value
            },
            async getMaxNum() {
                try {
                    let res = await CommonUtils.doRequest2Async({
                        url: "/Web/GetMAXNum",
                        data: {
                            "HBillType": this.HBillType
                        }
                    })
               let {
                  data,
                  count,
                  Message
               } = res.data
               if (count == 1) {
                  this.HShiftsList = data
               } else {
                  CommonUtils.showTips({
                     title: '温馨提示',
                     message: Message
                  })
               }
            } catch (err) {
               CommonUtils.showTips({
                  title: '温馨提示',
                  message: err
               })
            }
         },
         //获取使用部门数据
         async getHDeptList() {
            try {
               let res = await CommonUtils.doRequest2Async({
                  url: '/Gy_Department/list',
                  data: {
                     sWhere: ` and HUSEORGID = ${uni.getStorageSync('OrganizationID')}`,
                     user: uni.getStorageSync('HUserName'),
                     Organization: uni.getStorageSync('Organization')
                  }
               })
                    let {
                        count,
                        data,
                        Message
                    } = res.data
                    console.log('data: ', data);
                    this.hform.HInterID = 0
                    this.hform.HBillNo = data[0]["HBillNo"]
                } catch (err) {
                    CommonUtils.showTips({
                        title: "温馨提示",
                        message: "获取单据信息异常: " + err
                    })
                }
            },
            async submit() {
                let valid = this.ValidCheck()
                if (!valid.state) {
                    CommonUtils.showTips({
                        message: valid.Message
                    })
                    return
                }
               let {
                  data,
                  count,
                  Message
               } = res.data
               if (count == 1) {
                  this.HDeptList = data
               } else {
                  CommonUtils.showTips({
                     title: '温馨提示',
                     message: Message
                  })
               }
            } catch (err) {
               CommonUtils.showTips({
                  title: '温馨提示',
                  message: err
               })
            }
         },
         // 获取职员数据
         async getEmpList() {
            try {
               let res = await CommonUtils.doRequest2Async({
                  url: '/PublicPageMethod/UserList',
                  data: {
                     sWhere: " where 1=1",
                  }
               })
                try {
                    let oMain = JSON.stringify(this.hform);
                    let sSubStr = JSON.stringify(this.HBillSub);
                    let sMainSub = oMain + ';' + sSubStr + ';' + getUserInfo()['Czymc'];
                    let res = await CommonUtils.doRequest2Sync({
                        url: "/Sb_EqpRepairWorkBill/SaveGetEqpRepairCheckBillList",
                        data: {
                            "msg": sMainSub
                        },
                        method: "POST"
                    })
               let {
                  data,
                  count,
                  Message
               } = res.data
               if (count == 1) {
                  this.HEmpList = data
               } else {
                  CommonUtils.showTips({
                     title: '温馨提示',
                     message: Message
                  })
               }
            } catch (err) {
               CommonUtils.showTips({
                  title: '温馨提示',
                  message: err
               })
            }
         },
         // 获取验证项目数据
         async getCheckProjList() {
            try {
               let res = await CommonUtils.doRequest2Async({
                  url: '/Gy_RepairCheck/GetRepairCheckList',
                  data: {
                     sWhere: "",
                     user: uni.getStorageSync('HUserName'),
                  }
               })
                    if (!res) {
                        return
                    }
               let {
                  data,
                  count,
                  Message
               } = res.data
               if (count == 1) {
                  this.HRepairCheckList = data
               } else {
                  CommonUtils.showTips({
                     title: '温馨提示',
                     message: Message
                  })
               }
            } catch (err) {
               CommonUtils.showTips({
                  title: '温馨提示',
                  message: err
               })
            }
         },
         toScanCode() {
            MpaasScan.scanCode(cb => {
               this.hform.HBarCode = cb; // 修复:原来是 hfrom 应该是 hform
               this.GetMessageByBarCode(cb)
            })
         },
         async GetMessageByBarCode(HBarCode) {
            try {
               let res = await CommonUtils.doRequest2Sync({
                  url: "/Sb_PDA_EquipDotCheckBill/txtHBarCode_KeyDown_List",
                  data: {
                     HBarCode: HBarCode,
                  },
               })
                    let {
                        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/MJGL/Sb_EquipDotCheckBill/Sb_EquipDotCheckBill?operationType=1'
                                    })
                                } else if (res.cancel) {
                                    console.log('用户点击取消');
                                    setTimeout(() => {
                                        uni.navigateBack();
                                    }, 50)
                                }
                            }
                        });
                    } else {
                        CommonUtils.showTips({
                            title: "温馨提示",
                            message: "提交单据失败: " + Message
                        })
                    }
               if (!res) {
                  return
               }
               let {
                  data,
                  count,
                  Message
               } = res.data
                } catch (err) {
                    CommonUtils.showTips({
                        title: "温馨提示",
                        message: "提交单据失败: " + err
                    })
                }
            }
        },
        onLoad(e) {
            console.log('e: ', e);
            if (!e.operationType) {
                this.operationType = 1
            } else {
                this.operationType = e.operationType
            }
               if (count == 1) {
                  console.log('data: ', data);
                  this.hform.HEquipID = data[0].hmainid
                  this.hform.HBarName = data[0].设备名称
                  this.hform.HBarSpec = data[0].设备规格
                  this.hform.HBarModel = data[0].设备型号
                  this.hform.HBarCode = HBarCode;
                  this.hform.HQty = 1
            if (this.operationType == 1) {
                // 新增
                this.getMaxNum()
            } else if (this.operationType == 2) {
                // 复制
            } else if (this.operationType == 3) {
                // 编辑
                  this.enableEdit = false
               } else {
                  CommonUtils.showTips({
                     title: "温馨提示",
                     message: Message
                  })
               }
            } else if (this.operationType == 4) {
                // 浏览
            } catch (err) {
               CommonUtils.showTips({
                  title: "温馨提示",
                  message: err
               })
            }
         },
         radioChange({
            detail: {
               value
            }
         }) {
            this.hform.HCheckResult = value
         },
         async getMaxNum() {
            try {
               let res = await CommonUtils.doRequest2Async({
                  url: "/Web/GetMAXNum",
                  data: {
                     "HBillType": this.HBillType
                  }
               })
            }
               let {
                  count,
                  data,
                  Message
               } = res.data
               console.log('data: ', data);
               this.hform.HInterID = 0
               this.hform.HBillNo = data[0]["HBillNo"]
            } catch (err) {
               CommonUtils.showTips({
                  title: "温馨提示",
                  message: "获取单据信息异常: " + err
               })
            }
         },
         async submit() {
            let valid = this.ValidCheck()
            if (!valid.state) {
               CommonUtils.showTips({
                  message: valid.Message
               })
               return
            }
            this.getHDeptList()
            this.getEmpList()
            this.getCheckProjList()
        },
        onReady() {
            const query = uni.createSelectorQuery().in(this)
            query.select("#buttons")
                .boundingClientRect()
                .select("#tabs")
                .boundingClientRect()
                .exec(res => {
                    this.btnTop = Math.floor(res[0].top)
                    this.tabsBottom = Math.ceil(res[1].bottom)
                })
        }
    }
            try {
               let oMain = JSON.stringify(this.hform);
               this.HDetailList[0].HManagerID = this.hform.HManagerID
               this.HDetailList[0].HRepairCheckID = this.hform.HRepairCheckID
               let sSubStr = JSON.stringify(this.HDetailList);
               let sMainSub = oMain + ';' + sSubStr + ';' + getUserInfo()['Czymc'];
               let res = await CommonUtils.doRequest2Sync({
                  url: "/Sb_EqpRepairWorkBill/SaveGetEqpRepairCheckBillList",
                  data: {
                     "msg": 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) {
                           console.log('用户点击确定');
                           uni.redirectTo({
                              url: '/pages/MJGL/Sb_EquipDotCheckBill/Sb_EquipDotCheckBill?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
               })
            }
         }
      },
      onLoad(e) {
         console.log('e: ', e);
         if (!e.operationType) {
            this.operationType = 1
         } else {
            this.operationType = e.operationType
         }
         if (this.operationType == 1) {
            // 新增
            this.getMaxNum()
            this.enableEdit = true;
            this.enableSourceBillEdit = true;
         } else if (this.operationType == 2) {
            // 复制
         } else if (this.operationType == 3) {
            // 编辑
         } else if (this.operationType == 4) {
            // 浏览
            this.enableEdit = false;
            this.enableSourceBillEdit = false;
         }
         this.getHDeptList()
         this.getEmpList()
         this.getCheckProjList()
         // 监听单据选择完成事件
         uni.$on('BillSelectComplete', (e) => {
            console.log("接收到的消息: ", e)
            this.hform.HMainSourceInterID = e.HInterID
            this.hform.HMainSourceBillNo = e.HBillNo
            this.hform.HMainSourceEntryID = e.HEntryID
            this.hform.HMouldRepairWorkID = e.HInterID
            this.hform.HMouldRepairWorkName = e.HBillNo
            this.hform.HEquipID = e.HEquipID
            this.hform.HBarName = e.HEquipName
            this.hform.HBarSpec = e.HEquipSpec
            this.hform.HBarModel = e.HEquipModel
            this.hform.HBarCode = e.HEquipBarCode || ""
            this.$refs.billList.exit()
         })
      },
      onUnload() {
         uni.$off('BillSelectComplete')
      },
      onReady() {
         const query = uni.createSelectorQuery().in(this)
         query.select("#buttons")
            .boundingClientRect()
            .select("#tabs")
            .boundingClientRect()
            .exec(res => {
               this.btnTop = Math.floor(res[0].top)
               this.tabsBottom = Math.ceil(res[1].bottom)
            })
      }
   }
</script>
<style lang="scss" scoped>
    @import "@/pages/MJGL/style/MJBillStyle.scss"
   @import "@/pages/MJGL/style/MJBillStyle.scss"
</style>