zrg
2026-01-21 e8d4cc42b3ce74a818705aab13c2131d81a5ed6b
pages/MJGL/SC_MouldRepairCheck/Sc_MouldRepairCheckBill.vue
@@ -1,635 +1,718 @@
<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 == 2 ? 'on':''" @tap="tabs = 2">其他信息</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>
                    <zxz-uni-data-select class="right" :localdata="[
                        {key: '手工录入', value: '-1'},
                        {key: '模具故障登记单', value: '3815'}
                        ]" dataKey="key" dataValue="value" v-model="hform.HMainSourceBillType">
            <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="right" v-show="showHMainSourceBillType">
                  <picker :range="arrayHMainSourceBillType" @change="HMainSourceBillTypeChange">
                    </zxz-uni-data-select>
                    <!-- <input disabled v-model="hform.HDeptName" placeholder="请选择部门" /> -->
                </view>
                <view class="form-item">
                    <view class="title">源单号:</view>
                    <view class="right">
                        <input v-model="hform.HMainSourceBillNo" />
                    </view>
                    <view class="icon-wrapper">
                        <uni-icons type="search" size="20" @click="toCheckFile"></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">
                     <input disabled name="HMainSourceBillType" v-model="HMainSourceBillType"
                        placeholder="请选择源单类型" />
                     <view class="picker-overlay"></view>
                  </picker>
               </view>
               <view class="righton" v-show="!showHMainSourceBillType">
                  <input name="HMainSourceBillType" disabled v-model="HMainSourceBillType"
                     placeholder="请选择源单类型" />
               </view>
            </view>
            <view class="form-item">
               <view class="title required">故障登记单</view>
               <view class="right" v-show="hform.HMainSourceBillType != 1">
                  <input type="text" name="HBarCode" v-model="hform.HMainSourceBillNo" />
               </view>
               <view class="icon-wrapper" v-show="hform.HMainSourceBillType != 1"
                  :disabled="hform.HMainSourceBillType == -1">
                  <uni-icons type="search" size="20" @click="showBillList"></uni-icons>
               </view>
               <view class="righton" v-show="hform.HMainSourceBillType == 1">
                  <input type="text" disabled name="HBarCode" v-model="hform.HMainSourceBillNo" />
               </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 required">维修记录:</view>
                    <view class="right">
                        <input type="text" value="" />
                    </view>
                    <view class="icon-wrapper">
                        <uni-icons type="search" size="20" @click="toCheckFile"></uni-icons>
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">模具名称:</view>
                    <view class="righton">
                        <input v-model="hform.HMouldName" disabled />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">模具规格:</view>
                    <view class="righton">
                        <input v-model="hform.HMouldSpec" disabled />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">模具型号:</view>
                    <view class="righton">
                        <input v-model="hform.HMouldModel" disabled />
                    </view>
                </view>
            </view>
        </template>
        <!-- 其他信息 -->
        <template v-if="tabs == 2">
            <view class="form" :style="{
               </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.HRepairCheckMainID">
               </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 required">维修记录:</view>
               <view class="right" v-show="hform.HMainSourceBillType != 1">
                  <input type="text" v-model="hform.HMouldRepairWorkName"
                     :disabled="hform.HMainSourceBillType == -1" placeholder="请选择维修记录" />
               </view>
               <view class="icon-wrapper" v-show="hform.HMainSourceBillType != 1"
                  :disabled="hform.HMainSourceBillType == -1">
                  <uni-icons type="search" size="20" @click="showRepairRecordList"></uni-icons>
               </view>
               <view class="righton" v-show="hform.HMainSourceBillType == 1">
                  <input type="text" disabled v-model="hform.HMouldRepairWorkName" />
               </view>
            </view>
            <view class="form-item">
               <view class="title">模具名称:</view>
               <view class="righton">
                  <input v-model="hform.HMouldName" disabled />
               </view>
            </view>
            <view class="form-item">
               <view class="title">模具规格:</view>
               <view class="righton">
                  <input v-model="hform.HMouldSpec" disabled />
               </view>
            </view>
            <view class="form-item">
               <view class="title">模具型号:</view>
               <view class="righton">
                  <input v-model="hform.HMouldModel" 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>
      <!-- 弹出模具故障登记单的选择列表 -->
      <BillListPopupMouldConkBookBillVue ref="billList" :HBillType="hform.HBillType"
         :HSourceBillType="hform.HMainSourceBillType" :HStockOrgID="hform.HStockOrgID">
      </BillListPopupMouldConkBookBillVue>
      <!-- 弹出模具维修记录单的选择列表 -->
      <RepairRecordPopup ref="repairRecordList" :HBillType="hform.HBillType" :HStockOrgID="hform.HStockOrgID">
      </RepairRecordPopup>
   </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: 'Sc_MouldRepairCheckBill',
        data() {
            return {
                tabs: 0,
                HMainSourceBillType: "",
                btnTop: 0,
                tabsBottom: 0,
                HModName: "Sc_MouldRepairCheckBill",
                HBillType: '3817',
                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 BillListPopupMouldConkBookBillVue from '../../../components/BillListPopup/BillListPopupMouldConkBookBill.vue';
   import RepairRecordPopup from '../../../components/BillListPopup/BillListPopuMouldRepairRecordPopup.vue';
                HDeptList: [],
                HRepairCheckList: [],
                HEmpList: [],
   export default {
      components: {
         BillListPopupMouldConkBookBillVue,
         RepairRecordPopup
      },
      name: 'Sc_MouldRepairCheckBill',
      data() {
         return {
            tabs: 0,
            btnTop: 0,
            tabsBottom: 0,
            HModName: "Sc_MouldRepairCheckBill",
            HBillType: '3817',
            operationType: 1,
            enableEdit: true,
                hform: {
                    "HBarCode": "",
                    "HBillNo": "",
                    "HInterID": 0,
                    "HDate": dayjs(new Date()).format("YYYY-MM-DD"),
                    "HInnerBillNo": "",
                    "HMouldName": "",
                    "HMouldSpec": "",
                    "HMouldModel": "",
                    "HMouldID": 0,
                    "HMainSourceBillType": "-1",
                    "HMainSourceInterID": 0,
                    "HMainSourceEntryID": 0,
                    "HCheckResult": "OK",
                    "HEmpName": getUserInfo().HEmpName,
                    "HEmpID": getUserInfo().HEmpID,
                    "HCheckBeginDate": dayjs(new Date()).format("YYYY-MM-DD"),
                    "HDeptName": getUserInfo().HDeptName,
                    "HDeptID": getUserInfo().HDeptID,
                    "HMainSourceBillNo": "",
                    "HManagerName": getUserInfo().HManagerName,
                    "HManagerID": getUserInfo().HManagerID,
                    "HMouldRepairWorkName": "",
                    "HMouldRepairWorkID": 0,
                    "HExplanation": "",
                    "HRemark": "",
                    "HOrgID": uni.getStorageSync("OrganizationID"),
                    "HMaker": getUserInfo()["Czymc"],
                    "HChecker": "",
                    "HCloseMan": "",
                    "HUpDater": "",
                    "HMakeDate": dayjs(new Date()).format("YYYY-MM-DD"),
                    "HCheckDate": "",
                    "HCloseDate": "",
                    "HUpDateDate": "",
                    "HDeleteMan": "",
                    "HDeleteDate": "",
                    "HRepairCheckMainID": 0,
                    "HRepairCheckMainContent": "",
                },
                HBillSub: [{ // 后端接口需要。否则数据不会显示在缓存中
                    "HRepairCheckID": 0,
                    "HRepairCheckCode": "",
                    "HRepairCheckName": "",
                    "HRepairCheckContent": "",
                    "HManagerID": 0,
                    "HManagerCode": "",
                    "HManagerName": "",
                    "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
                    }
                }
            // 控制源单类型是否可编辑
            showHMainSourceBillType: true,
            HMainSourceBillType: '模具故障登记单',
            arrayHMainSourceBillType: ['模具故障登记单'],
            arrayHMainSourceBillTypeID: ['3815'],
                return {
                    Message: "",
                    state: true
                }
            },
            addNew() {
                uni.redirectTo({
                    url: './Sc_MouldRepairCheckBill?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
                }
            },
            //获取使用部门数据
            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')
                        }
                    })
            HDeptList: [],
            HRepairCheckList: [],
            HEmpList: [],
                    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",
                        }
                    })
            hform: {
               "HBillType": 3817,
               "HBarCode": "",
               "HBillNo": "",
               "HInterID": 0,
               "HDate": dayjs(new Date()).format("YYYY-MM-DD"),
               "HInnerBillNo": "",
               "HMouldName": "",
               "HMouldSpec": "",
               "HMouldModel": "",
               "HMouldID": 0,
               "HMainSourceBillType": "3815",
               "HMainSourceInterID": 0,
               "HMainSourceEntryID": 0,
               "HCheckResult": "OK",
               "HEmpName": getUserInfo().HEmpName,
               "HEmpID": getUserInfo().HEmpID,
               "HCheckBeginDate": dayjs(new Date()).format("YYYY-MM-DD"),
               "HDeptName": getUserInfo().HDeptName,
               "HDeptID": getUserInfo().HDeptID,
               "HMainSourceBillNo": "",
               "HManagerName": getUserInfo().HManagerName,
               "HManagerID": getUserInfo().HManagerID,
               "HMouldRepairWorkName": "",
               "HMouldRepairWorkID": 0,
               "HExplanation": "",
               "HRemark": "",
               "HOrgID": uni.getStorageSync("OrganizationID"),
               "HStockOrgID": uni.getStorageSync("OrganizationID"),
               "HMaker": getUserInfo()["Czymc"],
               "HChecker": "",
               "HCloseMan": "",
               "HUpDater": "",
               "HMakeDate": dayjs(new Date()).format("YYYY-MM-DD"),
               "HCheckDate": "",
               "HCloseDate": "",
               "HUpDateDate": "",
               "HDeleteMan": "",
               "HDeleteDate": "",
               "HRepairCheckMainID": 0,
               "HRepairCheckMainContent": "",
            },
            HBillSub: [{ // 后端接口需要。否则数据不会显示在缓存中
               "HRepairCheckID": 0,
               "HRepairCheckCode": "",
               "HRepairCheckName": "",
               "HRepairCheckContent": "",
               "HManagerID": 0,
               "HManagerCode": "",
               "HManagerName": "",
               "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
               }
            }
                    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'),
                        }
                    })
            return {
               Message: "",
               state: true
            }
         },
         addNew() {
            uni.redirectTo({
               url: './Sc_MouldRepairCheckBill?operationType=1'
            })
         },
         goBack() {
            uni.navigateBack()
         },
         showBillList() {
            this.$refs.billList.showPopup()
         },
         showRepairRecordList() {
            if (this.hform.HMouldID === 0) {
               CommonUtils.showTips({
                  title: '提示',
                  message: '请先选择模具'
               });
               return;
            }
            this.$refs.repairRecordList.showPopup(this.hform.HMouldID);
         },
         //选择源单类型
         HMainSourceBillTypeChange(e) {
            if (e.detail.value == -1 || e.detail.value == NaN) {
               this.HMainSourceBillType = '手工录入'
               this.hform.HMainSourceBillType = -1
               return
            }
            console.log(e.detail.value)
            console.log(e)
            this.HMainSourceBillType = this.arrayHMainSourceBillType[e.detail.value]
            this.hform.HMainSourceBillType = this.arrayHMainSourceBillTypeID[e.detail.value]
            const pages = getCurrentPages()
            // 获取页面栈中的最后一个元素,也就是当前显示的页面
            const currentPage = pages[pages.length - 1]
            // 选择源单类型后 缓存当前页面选择
            uni.setStorageSync(`${currentPage.route.split("/").pop()}_HSourceBillTypeCache`, {
               HSourceBillTypeName: this.HMainSourceBillType,
               HSourceBillType: this.hform.HMainSourceBillType
            })
         },
         checkBoxChangeHandler(index, e) {
            let cr = e.detail.value
            if (cr.length == 0) {
               this.HCheckFileList[index]["HDotCheckResult"] = false
            } else {
               this.HCheckFileList[index]["HDotCheckResult"] = true
            }
         },
         //获取使用部门数据
         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 {
                        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: "/Sc_PDA_MouldRepairCheckBill/txtHBarCode_KeyDown_List",
                        data: {
                            HBarCode: HBarCode,
                        },
                    })
               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 {
                  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 {
                  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: "/Sc_PDA_MouldRepairCheckBill/txtHBarCode_KeyDown_List",
                  data: {
                     HBarCode: HBarCode,
                  },
               })
                    if (!res) {
                        return
                    }
               if (!res) {
                  return
               }
                    let {
                        data,
                        count,
                        Message
                    } = res.data
               let {
                  data,
                  count,
                  Message
               } = res.data
                    if (count == 1) {
                        console.log('data: ', data);
                        this.hform.HMouldID = data[0].hmainid
                        this.hform.HMouldName = data[0].模具名称
                        this.hform.HMouldSpec = data[0].模具品类
                        this.hform.HMouldModel = data[0].模具型号
                        this.hform.HQty = 1
               if (count == 1) {
                  console.log('data: ', data);
                  this.hform.HMouldID = data[0].hmainid
                  this.hform.HMouldName = data[0].模具名称
                  this.hform.HMouldSpec = data[0].模具品类
                  this.hform.HMouldModel = data[0].模具型号
                  this.hform.HQty = 1
                        this.enableEdit = false
                    } else {
                        CommonUtils.showTips({
                            title: "温馨提示",
                            message: Message
                        })
                    }
                  this.enableEdit = false
               } 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
                        }
                    })
            } 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
                }
               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
            }
                try {
                    let oMain = JSON.stringify(this.hform);
                    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 + ';' + sSubStr + ';' + getUserInfo()['Czymc'];
                    let res = await CommonUtils.doRequest2Sync({
                        url: "/Sc_MouldRepairCheckBill/SaveGetMouldRepairCheckBillList",
                        data: {
                            "msg": sMainSub
                        },
                        method: "POST"
                    })
            try {
               let oMain = JSON.stringify(this.hform);
               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 + ';' + sSubStr + ';' + getUserInfo()['Czymc'];
               let res = await CommonUtils.doRequest2Sync({
                  url: "/Sc_MouldRepairCheckBill/SaveGetMouldRepairCheckBillList",
                  data: {
                     "msg": sMainSub
                  },
                  method: "POST"
               })
                    if (!res) {
                        return
                    }
               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_EquipRepairCheck/Sb_EquipRepairCheckBill?operationType=1'
                                    })
                                } else if (res.cancel) {
                                    console.log('用户点击取消');
                                    setTimeout(() => {
                                        uni.navigateBack();
                                    }, 50)
                                }
                            }
                        });
                    } else {
                        CommonUtils.showTips({
                            title: "温馨提示",
                            message: "提交单据失败: " + Message
                        })
                    }
               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_EquipRepairCheck/Sb_EquipRepairCheckBill?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
            }
            } 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()
            } else if (this.operationType == 2) {
                // 复制
            } else if (this.operationType == 3) {
                // 编辑
         if (this.operationType == 1) {
            // 新增
            this.getMaxNum()
         } else if (this.operationType == 2) {
            // 复制
         } else if (this.operationType == 3) {
            // 编辑
            } else if (this.operationType == 4) {
                // 浏览
         } else if (this.operationType == 4) {
            // 浏览
            }
         }
            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)
                })
        }
    }
         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.HMouldID = e.HMouldID
            this.hform.HMouldName = e.HMouldName
            this.hform.HMouldSpec = e.HMouldSpec
            this.hform.HMouldModel = e.HMouldModel
            this.$refs.billList.exit()
         })
         // 监听维修记录选择完成事件
         uni.$on('RepairRecordSelectComplete', (e) => {
            console.log("接收到维修记录选择: ", e);
            if (e.HInterID) {
               this.hform.HMouldRepairWorkName = e.HBillNo;
               this.hform.HMouldRepairWorkID = e.HInterID;
               // 可以根据需要设置其他字段
            }
            this.$refs.repairRecordList.exit();
         });
      },
      onUnload() {
         uni.$off('BillSelectComplete');
         uni.$off('RepairRecordSelectComplete');
      },
      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>