1
wtt
2025-10-16 8806189489160840024346e10ff4cbc60be075cc
1
1个文件已添加
2089 ■■■■■ 已修改文件
components/StationOutBillPopup/StationOutBillPopup.vue 2089 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
components/StationOutBillPopup/StationOutBillPopup.vue
New file
@@ -0,0 +1,2089 @@
<template>
    <view>
        <uni-popup ref="popup" type="bottom" @change="popupChangeHandler">
            <view class="form">
                <view class="form-item" v-show="false">
                    <view class="title"><text>*</text>条形码:</view>
                    <view class="right" style="width: 380rpx;">
                        <input name="HBarCode" v-model="hform.HBarCode" placeholder="请扫描条码" @confirm="toInCode(e)" />
                    </view>
                    <uni-icons type="scan"
                        style="margin-left: 10rpx;background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;"
                        size="20" @click="toScanCode"></uni-icons>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title">序列号:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHSEQName" placeholder="请选择序列" v-model="hform.HSEQName"
                            @input="HSEQNameChange"></uni-combox>
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title"><text>*</text>流水号:</view>
                    <view class="right" style="width: 380rpx;">
                        <input v-model="hform.HProcNo" placeholder="请输入(或扫描)流水号"
                            @blur="getHProcNoData2(hform.HBarCode,hform.HProcNo,hform.HSEQNumber)" />
                    </view>
                    <uni-icons type="scan"
                        style="margin-left: 10rpx;background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;"
                        size="20" @click="toScanProcNo"></uni-icons>
                </view>
                <view class="form-item">
                    <view class="title">工序编码:</view>
                    <view class="righton">
                        <input disabled v-model="hform.HProcNumber" placeholder="请输入工序编码" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">未报工数量:</view>
                    <view class="righton">
                        <input disabled v-model="hform.HNotReportQty" placeholder="请输入未报工数量" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">合格数量:</view>
                    <view class="right">
                        <input v-model="hform.HQty" placeholder="请输入合格数量" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">不良数量:</view>
                    <view class="right">
                        <input v-model="hform.HBadCount"  placeholder="请输入不良数量" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">报废数量:</view>
                    <view class="right">
                        <input v-model="hform.HWasterQty" placeholder="请输入报废数量" />
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title">生产资源:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHSourceName" placeholder="请选择生产资源" v-model="hform.HSourceName"
                            @input="HSourceNameChange"></uni-combox>
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title"><text>*</text>工作中心:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHCenterName" placeholder="请选择工作中心" v-model="hform.HCenterName"
                            @input="HCenterNameChange"></uni-combox>
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title">生产班组:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHGroupName" placeholder="请选择生产班组" v-model="hform.HGroupName"
                            @input="HGroupNameChange"></uni-combox>
                    </view>
                </view>
                <view class="form-item">
                    <view class="title"><text>*</text>操作员:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHEmpName" placeholder="请选择操作员" v-model="hform.HEmpName"
                            @input="HEmpNameChange"></uni-combox>
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">备注:</view>
                    <view class="right">
                        <textarea name="HRemark" v-model="hform.HRemark" auto-height placeholder="请输入备注"></textarea>
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">单据日期:</view>
                    <view class="right">
                        <picker mode="date" v-model="hform.HDate" @change="HDateChange">
                            <input disabled v-model="hform.HDate" placeholder="请选择日期" />
                        </picker>
                    </view>
                </view>
                <view class="tick-wrapper">
                    <view class="form-item">
                        <view class="title">工时:</view>
                        <view class="right">
                            <input v-model="hform.HWorkTimes" placeholder="请输入工时" @blur="HWorkTimesChange" :disabled="hform.HIsTimeFlag!=1"/>
                        </view>
                    </view>
                    <view class="form-item">
                        <checkbox-group name="checkboxGroup" @change="onCGChangeHandler">
                            <label>
                                <checkbox :checked="hform.HIsTimeFlag == 1" value="1" />
                                是否计时
                            </label>
                        </checkbox-group>
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">开工时间:</view>
                    <view class="right">
                         <uni-datetime-picker v-model="hform.HRelBeginTime" @change="HRelBeginTimeChange" v-if="hform.HIsTimeFlag==1" :hide-second="true">
                             <input disabled v-model="hform.HRelBeginTime" placeholder="请选择开工时间"  style="pointer-events: none;"/>
                         </uni-datetime-picker>
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">完工时间:</view>
                    <view class="right">
                         <uni-datetime-picker v-model="hform.HRelEndTime" @change="HRelEndTimeChange" v-if="hform.HIsTimeFlag==1" :hide-second="true">
                             <input disabled v-model="hform.HRelEndTime" placeholder="请选择完工时间" />
                         </uni-datetime-picker>
                    </view>
                </view>
                <!--
                    <view class="title">是否计时</view>
                    <checkbox-group name="checkboxGroup" @change="onCGChangeHandler">
                        <label>
                            <checkbox :checked="hform.HIsTimeFlag == 1" value="1" />
                        </label>
                    </checkbox-group>
                </view> -->
                <view class="tab_area"></view>
                <view class="form-item" v-show="false">
                    <view class="title">单据号:</view>
                    <view class="righton">
                        <input name="HBillNo" disabled v-model="hform.HBillNo" />
                    </view>
                </view>
                <view class="form-item" v-show="false" >
                    <view class="title">生产订单:</view>
                    <view class="righton">
                        <input name="HICMOBillNo" disabled v-model="hform.HICMOBillNo" />
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title">流转卡:</view>
                    <view class="righton">
                        <input disabled v-model="hform.HProcExchBillNo" />
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title">物料代码:</view>
                    <view class="righton">
                        <input disabled v-model="hform.HMaterNumber" />
                        <!-- <uni-combox :candidates="arrayHMaterNumber" placeholder="请选择产品代码" v-model="hform.HMaterNumber" @input="HMaterNumberChange"></uni-combox> -->
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title">物料名称:</view>
                    <view class="righton">
                        <input v-model="hform.HMaterName" disabled />
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title">规格型号:</view>
                    <view class="righton">
                        <input v-model="hform.HMaterModel" disabled />
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title">款号:</view>
                    <view class="righton">
                        <input v-model="hform.HStyleNumber" disabled />
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title">计量单位:</view>
                    <view class="righton">
                        <input v-model="hform.单位" disabled />
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title">工序:</view>
                    <!--                 <view class="right">
                        <uni-combox :candidates="arrayHProcName" placeholder="请选择当前工序" v-model="hform.HProcName" @input="HProcNameChange"></uni-combox>
                    </view> -->
                    <view class="righton">
                        <input v-model="hform.HProcName" disabled />
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title">生产组织:</view>
                    <view class="righton">
                        <input v-model="hform.HPRDOrg" disabled />
                    </view>
                </view>
                <!--
                <view class="form-item">
                    <view class="title">订单数量:</view>
                    <view class="right">
                        <input name="HICMOQty" v-model="hform.HICMOQty" placeholder="请输入订单数量" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">订单跟踪号:</view>
                    <view class="right">
                        <input name="HOrderProcNO" v-model="hform.HOrderProcNO" placeholder="请输入订单跟踪号" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">产品代码:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHMaterNumber" placeholder="请选择产品代码" v-model="hform.HMaterNumber" @input="HMaterNumberChange"></uni-combox>
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">产品名称:</view>
                    <view class="right">
                        <input v-model="hform.HMaterName" placeholder="请输入产品名称" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">规格型号:</view>
                    <view class="right">
                        <input v-model="hform.HMaterModel" placeholder="请输入规格型号" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title"><text>*</text>流转卡号:</view>
                    <view class="right">
                        <input v-model="hform.HProcExchBillNo" placeholder="请输入流转卡号" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">流转卡数量:</view>
                    <view class="right">
                        <input v-model="hform.HPlanQty" placeholder="请输入流转卡数量" />
                    </view>
                </view>
                <view class="tab_area"></view>
                <view class="form-item">
                    <view class="title"><text>*</text>当前工序:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHProcName" placeholder="请选择当前工序" v-model="hform.HProcName" @input="HProcNameChange"></uni-combox>
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">检验员:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHEmpName" placeholder="请选择检验员" v-model="hform.HQCCheckName" @input="HQCCheckNameChange"></uni-combox>
                    </view>
                </view> -->
                <view class="tab_area"></view>
                <view class="form-item" v-show="false">
                    <view class="title">操作员2:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHEmpName" placeholder="请选择操作员" v-model="hform.HEmpName2"
                            @input="HEmpName2Change"></uni-combox>
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title">操作员3:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHEmpName" placeholder="请选择操作员" v-model="hform.HEmpName3"
                            @input="HEmpName3Change"></uni-combox>
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title">操作员4:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHEmpName" placeholder="请选择操作员" v-model="hform.HEmpName4"
                            @input="HEmpName4Change"></uni-combox>
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title">操作员5:</view>
                    <view class="right">
                        <uni-combox :candidates="arrayHEmpName" placeholder="请选择操作员" v-model="hform.HEmpName5"
                            @input="HEmpName5Change"></uni-combox>
                    </view>
                </view>
                <view class="form-item" v-show="false">
                    <view class="title"></view>
                    <!--                 <view style="padding-top: 10rpx;" @tap="hform.HLastSubProc = hform.HLastSubProc==true?false:true">
                        <radio value="true" :checked="hform.HLastSubProc == true" style="transform:scale(1);"/>转下道
                    </view> -->
                    <view style="padding-top: 10rpx;">
                        <radio value="true" :checked="hform.HLastSubProc == true" style="transform:scale(1);" />转下道
                    </view>
                </view>
                <view v-if="showmore" v-show="false">
                    <view class="form-item">
                        <view class="title">订单跟踪号:</view>
                        <view class="righton">
                            <input v-model="hform.HOrderProcNO" disabled />
                        </view>
                    </view>
                    <view class="form-item">
                        <view class="title">制单人:</view>
                        <view class="righton">
                            <input v-model="hform.HMaker" disabled />
                        </view>
                    </view>
                    <view class="form-item">
                        <view class="title">制单日期:</view>
                        <view class="righton">
                            <input v-if="hform.HMakeDate" v-model="hform.HMakeDate.substr(0,10)" disabled />
                            <input v-else v-model="hform.HMakeDate" disabled />
                        </view>
                    </view>
                    <view class="form-item">
                        <view class="title">修改人:</view>
                        <view class="righton">
                            <input v-model="hform.HUpDater" disabled />
                        </view>
                    </view>
                    <view class="form-item">
                        <view class="title">修改日期:</view>
                        <view class="righton">
                            <input v-if="hform.HUpDateDate" v-model="hform.HUpDateDate.substr(0,10)" disabled />
                            <input v-else v-model="hform.HUpDateDate" disabled />
                        </view>
                    </view>
                    <view class="form-item">
                        <view class="title">审核人:</view>
                        <view class="righton">
                            <input v-model="hform.HChecker" disabled />
                        </view>
                    </view>
                    <view class="form-item">
                        <view class="title">审核日期:</view>
                        <view class="righton">
                            <input v-if="hform.HCheckDate" v-model="hform.HCheckDate.substr(0,10)" disabled />
                            <input v-else v-model="hform.HCheckDate" disabled />
                        </view>
                    </view>
                    <view class="form-item">
                        <view class="title">作废人:</view>
                        <view class="righton">
                            <input v-model="hform.HDeleteMan" disabled />
                        </view>
                    </view>
                    <view class="form-item">
                        <view class="title">作废日期:</view>
                        <view class="righton">
                            <input v-if="hform.HDeleteDate" v-model="hform.HDeleteDate.substr(0,10)" disabled />
                            <input v-else v-model="hform.HDeleteDate" disabled />
                        </view>
                    </view>
                </view>
                <view class="other">
                    <view v-if="!showmore" @tap="showmore = true">
                        展开其他信息<uni-icons color="#1890FF" style="margin-left: 8rpx;" type="bottom"></uni-icons>
                    </view>
                    <view v-if="showmore" @tap="showmore = false">
                        折叠其他信息<uni-icons color="#1890FF" style="margin-left: 8rpx;" type="top"></uni-icons>
                    </view>
                </view>
                <!--             <view class="op">
                    <button class="op1" size="mini" plain @tap="huibao">汇报</button>
                    <button class="op2" size="mini" plain @tap="ruku">入库</button>
                    <button class="op3" size="mini" plain @tap="baofei">报废</button>
                </view> -->
                <view class="bottom-btn">
                    <button v-if="btnType == 0 && !isEdit" class="btn-a" size="mini" @tap="submit">提交</button>
                    <button v-if="btnType != 0 && !isEdit" class="btn-a" size="mini" @tap="ifEdit">修改</button>
                    <button v-if="btnType != 0 && isEdit" class="btn-a" size="mini" @tap="submit">提交</button>
                    <button v-if="btnType != 0 && btnType == 2" class="btn-b" style="margin-left: 20rpx;" size="mini"
                        @tap="check">审核</button>
                    <button v-if="btnType != 0 && btnType == 3" class="btn-d" style="margin-left: 20rpx;" size="mini"
                        @tap="abandonCheck">反审核</button>
                    <!-- <button class="btn-b" size="mini" @tap="addNew">新增</button>
                    <button class="btn-c" size="mini" @tap="goBack">退出</button> -->
                </view>
            </view>
        </uni-popup>
    </view>
</template>
<script>
    import getDateTime from '@/utils/getdateTime.js';
    import {
        getUserInfo
    } from "@/utils/auth.js";
import { CommonUtils } from '../../utils/common';
    export default {
        name: "BillListPopup_gongxuOut",
        data() {
            return {
                userInfo: getUserInfo(),
                serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
                linterid: '',
                HBillNo: '',
                btnType: 0, //0新增,1修改,2审核,3反审核
                FirstEndHProcNo: 0, //默认0  首道工序1 末道工序2
                OperationType: 1,
                showmore: false,
                arrayHMaterNumber: [], //产品
                HMaterNumberList: [],
                arrayHProcName: [], //工序
                HProcNameList: [],
                arrayHSupName: [], //供应商
                HSupNameList: [],
                arrayHSourceName: [], //生产资源
                HSourceNameList: [],
                arrayHGroupName: [], //生产班组
                HGroupNameList: [],
                arrayHEmpName: [], //接收人
                HEmpNameList: [],
                arrayHCenterName: [], //工作中心
                HCenterNameList: [],
                arrayHSEQName:[],//序列
                HSEQNameList:[],
                isEdit: false,
                hform: {
                    HInterID: '',
                    HBillNo: '',
                    HBarCode: '',
                    HProcNo: '',
                    HQty: '',
                    HBadCount:0,
                    HProcNumber: '',
                    HNotReportQty: 0,
                    HIsTimeFlag: 0,
                    HRelBeginTime:'',
                    HRelEndTime:'',
                    // HPieceQty:'',
                    HWasterQty: 0,
                    HSourceName: '',
                    HSourceID: 0,
                    HCenterName: '',
                    HCenterID: 0,
                    HGroupName: '',
                    HGroupID: 0,
                    HEmpName: '',
                    HEmpID: 0,
                    HSEQName:'',
                    HSEQNumber:0,
                    HRemark: '',
                    HDate: getDateTime.dateTimeStr('y-m-d'),
                    HICMOBillNo: '',
                    HProcExchBillNo: '',
                    HMaterNumber: '',
                    HMaterName: '',
                    HMaterID: 0,
                    HMaterModel: '',
                    单位: '',
                    HProcName: '',
                    HProcID: '',
                    HPRDOrg: '',
                    HOrderProcNO: '',
                    HWorkTimes: 0,
                    HEmpName2: '',
                    HEmpID2: 0,
                    HEmpName3: '',
                    HEmpID3: 0,
                    HEmpName4: '',
                    HEmpID4: 0,
                    HEmpName5: '',
                    HEmpID5: 0,
                    HLastSubProc: true,
                    // HICMOInterID:'',
                    // HICMOQty:'',
                    HProcExchHinteID: '',
                    lngBillKey: '',
                    // HPlanQty:'',
                    // HSupName:'',
                    // HSupID:'',
                    // HWWWorkOrderBillNo:'',
                    // HTaxRate:'',
                    // HPrice:'',
                    // HMoney:'',
                    HStationInTime: getDateTime.dateTimeStr('y-m-d h:i:s'),
                    // HStationOutTime:getDateTime.dateTimeStr('y-m-d h:i:s'),
                    // HSendBillNo:'',
                    // HInnerBillNo:'',
                    // HEmp:'',
                    // HEmpID:'',
                    // HQCCheckName:'',
                    // HQCCheckID:'',
                    // HSourceName2:'',
                    // HSourceID2:'',
                    // HSourceName3:'',
                    // HSourceID3:'',
                    // HSourceName4:'',
                    // HSourceID4:'',
                    // HSourceName5:'',
                    // HSourceID5:'',
                    // HDept:'',
                    // HDeptID:'',
                    // HMouldNum:'',
                    // HPayProcID:'',
                    // HSourceNameList:'',
                    HMaker: uni.getStorageSync('HUserName'),
                    HMakeDate: getDateTime.dateTimeStr('y-m-d h:i:s'),
                    HUpDater: '',
                    HUpDateDate: '',
                    HChecker: '',
                    HCheckDate: '',
                    // HCloseMan:'',
                    // HCloseDate:'',
                    HDeleteMan: '',
                    HDeleteDate: '',
                    HStyleNumber: '', // 款号
                    eventType: 'Add',
                }
            }
        },
        mounted(e) {
            // this.getEditData('1516','GXCZHB000000001290')
            console.log(e, this.userInfo)
            // this.hform.HEmpID = this.userInfo.Czybm
            // this.hform.HEmp = uni.getStorageSync('HUserName')
            this.hform.HMaker = uni.getStorageSync('HUserName')
            this.hform.HMakeDate = getDateTime.dateTimeStr('y-m-d h:i:s')
            // this.hform.HDate = getDateTime.dateTimeStr('y-m-d')
            // this.hform.HStationOutTime = getDateTime.dateTimeStr('y-m-d h:i:s')
    //         if (e.linterid) {
    //             this.btnType = 1
    //             this.OperationType = 4
    //             this.linterid = e.linterid
    //             this.HBillNo = e.HBillNo
    //             this.getEditData(e.linterid, e.HBillNo)
    //         } else {
    //             this.getNewData()
                // if(e.HBarCode){
                //     this.hform.HBarCode=e.HBarCode
                //     setTimeout(() => {
                //         this.toInCode(e);
                //     }, 1000)
                // }
    //         }
            this.getNewData()
            this.getHMaterList()
            this.getHProcList()
            this.getHSupList()
            this.getHSourceList()
            this.getHGroupList()
            this.getHEmpList()
            this.getHCenterList()
            this.getDefValByUser()
        },
        methods: {
            //打开时加载
            popupChangeHandler(e) {
                if (e.show === false) {
                    this.hform.HQty='';
                    this.hform.HBadCount=0;
                    this.hform.HWasterQty=0;
                    this.getNewData()
                }
            },
            //打开弹框
            showPopup(hBarCode) {
                this.hform.HBarCode=hBarCode;
                this.toInCode(hBarCode);
                this.$refs.popup.open();
            },
            //选中全部文本
            selectAllText(e) {
              console.log(e.target)
              console.log(e)
            },
            onCGChangeHandler({
                detail
            }) {
                console.log(detail.value[0])
                this.hform.HIsTimeFlag = detail.value[0] || 0
                if(detail.value[0]){
                    this.getNewHRelBeginDate()
                    this.hform.HRelEndTime = getDateTime.dateTimeStr('y-m-d h:i');
                }else{
                    this.hform.HWorkTimes = 0;
                }
            },
            //通过登录用户获取默认值
            getDefValByUser() {
                uni.request({
                    url: this.serverUrl + '/Cj_StationInBill/GetDefValByUser',
                    type: "GET",
                    async: false,
                    data: {
                        "Czybm": this.userInfo.Czybm,
                        "Czymc": this.userInfo.Czymc
                    },
                    success: (res) => {
                        // console.log(res.data)
                        if (res.data.count == 1) {
                            var data = res.data.data[0]
                            this.hform.HGroupID = data.HGroupID
                            this.hform.HGroupName = data.生产班组名称
                            this.hform.HEmpID = data.HEmpID
                            this.hform.HEmpName = data.操作员名称
                            this.hform.HEmpNumber = data.操作员代码
                            this.hform.HSourceID = data.HSourceID
                            this.hform.HSourceName = data.生产资源名称
                            this.hform.HCenterID = data.HWorkCenterID
                            this.hform.HCenterName = data.工作中心名称
                            this.hform.HEmpName_second = data.操作员名称
                        } else {
                            uni.showToast({
                                title: '获取生产班组信息失败',
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '获取生产班组信息失败',
                            icon: 'none'
                        })
                    },
                });
            },
            //扫码
            toScanCode() {
                var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
                mpaasScanModule.mpaasScan({
                    'hideAlbum': true,
                    'timeoutInterval': '10', //超时时间
                    'timeoutText': '未识别到二维码' //超时提醒
                }, (ret) => {
                    console.log(ret.resp_result)
                    var str = ret.resp_result
                    if (str.includes('@')) {
                        const parts = str.split('@');
                        //如果代码包含子序列
                        if(parts.length==3){
                            this.hform.HBarCode = parts[0]
                            this.hform.HProcNo = parts[1]
                            this.hform.HSEQNumber = parts[2]
                            this.getHBarCodeData(parts[0], 2)
                        }else{
                            this.hform.HBarCode = parts[0]
                            this.hform.HProcNo = parts[1]
                            this.getHBarCodeData(parts[0], 1)
                        }
                        // this.getHProcNoData(parts[0],parts[1])
                    } else {
                        this.hform.HBarCode = ret.resp_result
                        this.getHBarCodeData(ret.resp_result)
                    }
                })
                // const str = "GXLX250603001-01@10";
                // uni.scanCode({
                //     onlyFromCamera: true,
                //     // autoZoom:false,
                //     success: (res) => {
                //         console.log('条码内容:' + res.result);
                //         var str = res.result
                //         if(str.includes('@')) {
                //           const parts = str.split('@');
                //           this.hform.HBarCode = parts[0]
                //           this.hform.HProcNo = parts[1]
                //           this.getHBarCodeData(parts[0],1)
                //           // this.getHProcNoData(parts[0],parts[1])
                //         }else{
                //             this.hform.HBarCode = res.result
                //             this.getHBarCodeData(res.result)
                //         }
                //     }
                // });
            },
            toInCode(e) {
                var str = this.hform.HBarCode
                if (str.includes('@')) {
                    const parts = str.split('@');
                    //如果代码包含子序列
                    if(parts.length==3){
                        this.hform.HBarCode = parts[0]
                        this.hform.HProcNo = parts[1]
                        this.hform.HSEQNumber = parts[2]
                        this.getHBarCodeData(parts[0], 2)
                    }else{
                        this.hform.HBarCode = parts[0]
                        this.hform.HProcNo = parts[1]
                        this.getHBarCodeData(parts[0], 1)
                    }
                    // this.getHProcNoData(parts[0],parts[1])
                } else {
                    this.getHBarCodeData(this.hform.HBarCode)
                }
            },
            //扫流水号
            toScanProcNo() {
                var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
                mpaasScanModule.mpaasScan({
                    'hideAlbum': true,
                    'timeoutInterval': '10', //超时时间
                    'timeoutText': '未识别到二维码' //超时提醒
                }, (ret) => {
                    console.log(ret.resp_result)
                    this.hform.HProcNo = ret.resp_result
                    this.getHProcNoData2(this.hform.HBarCode, ret.resp_result,this.hform.HSEQNumber)
                })
            },
            //日期
            HDateChange(e) {
                console.log(e.detail.value)
                this.hform.HDate = e.detail.value
            },
            HRelBeginTimeChange(e) {
                console.log(e)
                this.hform.HRelBeginTime = e
                this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime);
            },
            HRelEndTimeChange(e) {
                console.log(e)
                this.hform.HRelEndTime = e
                this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime);
            },
            HWorkTimesChange(e){
                console.log(e);
                this.hform.HRelEndTime = getDateTime.addHoursToDate(this.hform.HRelBeginTime,e.detail.value);
            },
            //获取产品数据
            getHMaterList() {
                var Value = " Where HStopFlag=0  and HEndFlag=1 and HUSEORGID = " + uni.getStorageSync('OrganizationID')
                uni.request({
                    url: this.serverUrl + '/Web/GetMaterialList_Json',
                    data: {
                        sWhere: Value
                    },
                    success: (res) => {
                        if (res.data.count == 1) {
                            this.HMaterNumberList = res.data.data
                            for (var i = 0; i < res.data.data.length; i++) {
                                this.arrayHMaterNumber[i] = res.data.data[i].HNumber
                            }
                            this.$forceUpdate();
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            //选择产品数据
            HMaterNumberChange(e) {
                for (var i = 0; i < this.HMaterNumberList.length; i++) {
                    if (this.HMaterNumberList[i].HNumber == e) {
                        this.hform.HMaterName = this.HMaterNumberList[i].HName
                        this.hform.HMaterID = this.HMaterNumberList[i].HItemID
                    }
                }
            },
            //工序
            getHProcList() {
                uni.request({
                    url: this.serverUrl + '/Web/GetProcList_Json',
                    data: {
                        sWhere: ''
                    },
                    success: (res) => {
                        if (res.data.count == 1) {
                            this.HProcNameList = res.data.data
                            for (var i = 0; i < res.data.data.length; i++) {
                                this.arrayHProcName[i] = res.data.data[i].工序
                            }
                            this.$forceUpdate();
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            //选择工序
            HProcNameChange(e) {
                for (var i = 0; i < this.HProcNameList.length; i++) {
                    if (this.HProcNameList[i].工序 == e) {
                        this.hform.HProcID = this.HProcNameList[i].HItemID
                    }
                }
            },
            //获取供应商数据
            getHSupList() {
                if (!uni.getStorageSync('OrganizationID')) {
                    var HOtherOrgID = 0;
                } else {
                    var HOtherOrgID = uni.getStorageSync('OrganizationID')
                }
                uni.request({
                    url: this.serverUrl + '/Web/GetSupplierList_Json',
                    data: {
                        Supplier: '',
                        HOrgID: HOtherOrgID
                    },
                    success: (res) => {
                        if (res.data.count == 1) {
                            this.HSupNameList = res.data.data
                            for (var i = 0; i < res.data.data.length; i++) {
                                this.arrayHSupName[i] = res.data.data[i].HName
                            }
                            this.$forceUpdate();
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            //选择供应商
            HSupNameChange(e) {
                for (var i = 0; i < this.HSupNameList.length; i++) {
                    if (this.HSupNameList[i].HName == e) {
                        this.hform.HSupID = this.HSupNameList[i].HItemID
                    }
                }
            },
            //生产资源
            getHSourceList() {
                uni.request({
                    url: this.serverUrl + '/api/newBill/getSourceList',
                    data: {
                        sWhere: ''
                    },
                    success: (res) => {
                        if (res.data.code == 1) {
                            this.HSourceNameList = res.data.data.Gy_Source
                            for (var i = 0; i < res.data.data.Gy_Source.length; i++) {
                                this.arrayHSourceName[i] = res.data.data.Gy_Source[i].生产资源
                            }
                            this.$forceUpdate();
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            //选择生产资源
            HSourceNameChange(e) {
                for (var i = 0; i < this.HSourceNameList.length; i++) {
                    if (this.HSourceNameList[i].生产资源 == e) {
                        this.hform.HSourceID = this.HSourceNameList[i].HItemID
                    }
                }
            },
            HSourceName2Change(e) {
                for (var i = 0; i < this.HSourceNameList.length; i++) {
                    if (this.HSourceNameList[i].生产资源 == e) {
                        this.hform.HSourceID2 = this.HSourceNameList[i].HItemID
                    }
                }
            },
            HSourceName3Change(e) {
                for (var i = 0; i < this.HSourceNameList.length; i++) {
                    if (this.HSourceNameList[i].生产资源 == e) {
                        this.hform.HSourceID3 = this.HSourceNameList[i].HItemID
                    }
                }
            },
            HSourceName4Change(e) {
                for (var i = 0; i < this.HSourceNameList.length; i++) {
                    if (this.HSourceNameList[i].生产资源 == e) {
                        this.hform.HSourceID4 = this.HSourceNameList[i].HItemID
                    }
                }
            },
            HSourceName5Change(e) {
                for (var i = 0; i < this.HSourceNameList.length; i++) {
                    if (this.HSourceNameList[i].生产资源 == e) {
                        this.hform.HSourceID5 = this.HSourceNameList[i].HItemID
                    }
                }
            },
            //生产班组
            getHGroupList() {
                uni.request({
                    url: this.serverUrl + '/Web/GetProductionTeamList_Json',
                    data: {
                        sWhere: "and HUSEORGID = " + uni.getStorageSync('OrganizationID') + ""
                    },
                    success: (res) => {
                        if (res.data.count == 1) {
                            this.HGroupNameList = res.data.data
                            for (var i = 0; i < res.data.data.length; i++) {
                                this.arrayHGroupName[i] = res.data.data[i].班组
                            }
                            this.$forceUpdate();
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            //选择生产班组
            HGroupNameChange(e) {
                for (var i = 0; i < this.HGroupNameList.length; i++) {
                    if (this.HGroupNameList[i].班组 == e) {
                        this.hform.HGroupID = this.HGroupNameList[i].HItemID
                    }
                }
            },
            //操作员等
            getHEmpList() {
                uni.request({
                    url: this.serverUrl + '/Web/GetEmployeeList_Json',
                    data: {
                        Employee: '',
                        HGroupID: 0
                    },
                    success: (res) => {
                        if (res.data.count == 1) {
                            this.HEmpNameList = res.data.data
                            for (var i = 0; i < res.data.data.length; i++) {
                                this.arrayHEmpName[i] = res.data.data[i].HName
                            }
                            this.$forceUpdate();
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            //选择操作员
            HEmpNameChange(e) {
                for (var i = 0; i < this.HEmpNameList.length; i++) {
                    if (this.HEmpNameList[i].HName == e) {
                        this.hform.HEmpID = this.HEmpNameList[i].HItemID
                    }
                }
            },
            //选择检验员
            HQCCheckNameChange(e) {
                for (var i = 0; i < this.HEmpNameList.length; i++) {
                    if (this.HEmpNameList[i].HName == e) {
                        this.hform.HQCCheckID = this.HEmpNameList[i].HItemID
                    }
                }
            },
            //选操作员
            HEmpName2Change(e) {
                for (var i = 0; i < this.HEmpNameList.length; i++) {
                    if (this.HEmpNameList[i].HName == e) {
                        this.hform.HEmpID2 = this.HEmpNameList[i].HItemID
                    }
                }
            },
            HEmpName3Change(e) {
                for (var i = 0; i < this.HEmpNameList.length; i++) {
                    if (this.HEmpNameList[i].HName == e) {
                        this.hform.HEmpID3 = this.HEmpNameList[i].HItemID
                    }
                }
            },
            HEmpName4Change(e) {
                for (var i = 0; i < this.HEmpNameList.length; i++) {
                    if (this.HEmpNameList[i].HName == e) {
                        this.hform.HEmpID4 = this.HEmpNameList[i].HItemID
                    }
                }
            },
            HEmpName5Change(e) {
                for (var i = 0; i < this.HEmpNameList.length; i++) {
                    if (this.HEmpNameList[i].HName == e) {
                        this.hform.HEmpID5 = this.HEmpNameList[i].HItemID
                    }
                }
            },
            //工作中心
            getHCenterList() {
                uni.request({
                    url: this.serverUrl + '/api/newBill/getWorkCenterList',
                    data: {
                        sWhere: ''
                    },
                    success: (res) => {
                        if (res.data.code == 1) {
                            this.HCenterNameList = res.data.data.Gy_Source
                            for (var i = 0; i < res.data.data.Gy_Source.length; i++) {
                                this.arrayHCenterName[i] = res.data.data.Gy_Source[i].工作中心
                            }
                            this.$forceUpdate();
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            //选择工作中心
            HCenterNameChange(e) {
                for (var i = 0; i < this.HCenterNameList.length; i++) {
                    if (this.HCenterNameList[i].工作中心 == e) {
                        this.hform.HCenterID = this.HCenterNameList[i].HItemID
                    }
                }
            },
            //序列获取
            getHSEQList(e){
                uni.request({
                    url: this.serverUrl + 'Cj_StationOutBill/getAllHSEQ',
                    data: {
                        HInterID:this.hform.HProcExchHinteID
                    },
                    success: (res) => {
                        if (res.data.code == 1) {
                            this.HSEQNameList = res.data.data
                            for (var i = 0; i < res.data.data.length; i++) {
                                this.arrayHSEQName[i] = res.data.data[i].HSEQName
                            }
                            this.$forceUpdate();
                            //没有序列号默认主序列
                            if(e==1){
                                //设置主序列
                                this.setMainHSEQ();
                                this.getHProcNoData2(this.hform.HBarCode,this.hform.HProcNo,this.hform.HSEQNumber)
                            }else if(e==2){
                                this.getHProcNoData2(this.hform.HBarCode,this.hform.HProcNo,this.hform.HSEQNumber)
                            }else{
                                //设置主序列
                                this.setMainHSEQ();
                            }
                        } else {
                            if(res.data.Message=="子序列缺失"){
                                this.getHProcNoData(this.hform.HBarCode,this.hform.HProcNo)
                            }else{
                                uni.showToast({
                                    title: res.data.Message,
                                    icon: 'none'
                                })
                            }
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            //选择序列
            HSEQNameChange(e) {
                for (var i = 0; i < this.HSEQNameList.length; i++) {
                    if (this.HSEQNameList[i].HSEQName == e) {
                        this.hform.HSEQNumber = this.HSEQNameList[i].HSEQNumber
                    }
                }
            },
            //设置主序列
            setMainHSEQ(){
                for (var i = 0; i < this.HSEQNameList.length; i++) {
                    if (this.HSEQNameList[i].HSEQType == 'M') {
                        this.hform.HSEQNumber = this.HSEQNameList[i].HSEQNumber
                        this.hform.HSEQName = this.HSEQNameList[i].HSEQName
                        break;
                    }
                }
            },
            //汇报
            huibao() {
                var datas = {
                    InterID: this.hform.HInterID,
                    BillNo: this.hform.HBillNo,
                    user: uni.getStorageSync('HUserName'),
                    OrganizationID: uni.getStorageSync('OrganizationID'),
                }
                console.log('汇报', datas)
                uni.request({
                    url: this.serverUrl + '/Sc_ProcessMangement/SaveICMOReportBill',
                    method: 'GET',
                    data: datas,
                    success: (res) => {
                        console.log(res)
                        uni.showToast({
                            title: res.data.Message,
                            icon: 'none'
                        })
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            //入库
            ruku() {
                console.log('ruku')
                uni.request({
                    url: this.serverUrl + '/Sc_ProcessMangement/SaveProcdutInBill',
                    method: 'GET',
                    data: {
                        BillNo: this.hform.HBillNo
                    },
                    success: (res) => {
                        console.log(res)
                        uni.showToast({
                            title: res.data.Message,
                            icon: 'none'
                        })
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            //报废
            baofei() {
                console.log('baofei')
                uni.request({
                    url: this.serverUrl + '/Sc_ProcessMangement/SaveBFBill',
                    method: 'GET',
                    data: {
                        BillNo: this.hform.HBillNo
                    },
                    success: (res) => {
                        console.log(res)
                        uni.showToast({
                            title: res.data.Message,
                            icon: 'none'
                        })
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            preEditOrAddCheck() {
                if(CommonUtils.isEmpty(this.hform.HQty) == true){
                    return {pass: false, message: '提交失败: 合格数量为空'}
                }
                if(CommonUtils.isEmpty(this.hform.HBadCount) == true){
                    return {pass: false, message: '提交失败: 不良数量为空'}
                }
                if(CommonUtils.isEmpty(this.hform.HQty) == true){
                    return {pass: false, message: '提交失败: 报废数量为空'}
                }
                if(this.hform.HIsTimeFlag == 1 && CommonUtils.isEmpty(this.hform.HWorkTimes, true, true)) {
                    return {pass: false, message: '提交失败: 开启计时,但工时为0或空'}
                }
                return {pass: true, message: ''}
            },
            //编辑
            ifEdit() {
                let {pass, message} = this.preEditOrAddCheck()
                if(pass == false) {
                    return uni.showToast({
                        icon: 'none',
                        title: message
                    })
                }
                //是否编辑
                uni.request({
                    url: this.serverUrl + '/Cj_StationOutBill/set_ShowBillJudge',
                    data: {
                        HBillNo: this.HBillNo,
                        // CurUserName: uni.getStorageSync('HUserName'),
                        // HInterID: this.linterid,
                    },
                    success: (res) => {
                        console.log(res)
                        if (res.data.count == 1) {
                            this.isEdit = true
                            this.OperationType = 3
                            this.hform.eventType = 'Modify'
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            getEditData(linterid, HBillNo) {
                //主表
                uni.request({
                    url: this.serverUrl + '/Cj_StationOutBill/GetStationOutBill',
                    data: {
                        HInterID: linterid
                    },
                    success: (res) => {
                        console.log(1, res.data.data[0]);
                        if (res.data.code == 1) {
                            var data = res.data.data[0]
                            this.getHBarCodeData(data.HBarCode,1)
                            //this.getHProcNoData(data.HBarCode, data.HProcNo)
                            this.hform.HInterID = data.HInterID
                            this.hform.HBillNo = data.HBillNo
                            this.hform.HBarCode = data.HBarCode
                            this.hform.HProcNo = data.HProcNo
                            // this.hform.HQty = data.HQty
                            // this.hform.HPieceQty= data.HPieceQty
                            this.hform.HIsTimeFlag = data.HIsTimeFlag || 0
                            this.hform.HNotReportQty = data.HNotReportQty
                            this.hform.HProcNumber = data.HProcNumber || ''
                            this.hform.HWasterQty = data.HWasterQty
                            this.hform.HBadCount = data.HBadCount
                            this.hform.HSourceID = data.HSourceID
                            this.hform.HSourceName = data.HSourceName
                            this.hform.HGroupID = data.HGroupID
                            this.hform.HGroupName = data.HGroupName
                            this.hform.HEmpID = data.HEmpID
                            this.hform.HEmpName = data.HEmpName
                            this.hform.HRemark = data.HRemark
                            this.hform.HDate = data.HDate.substr(0, 10)
                            this.hform.HWorkTimes = data.HWorkTimes
                            this.hform.HEmpID2 = data.HEmpID2
                            this.hform.HEmpName2 = data.HEmpName2
                            this.hform.HEmpID3 = data.HEmpID3
                            this.hform.HEmpName3 = data.HEmpName3
                            this.hform.HEmpID4 = data.HEmpID4
                            this.hform.HEmpName4 = data.HEmpName4
                            this.hform.HEmpID5 = data.HEmpID5
                            this.hform.HEmpName5 = data.HEmpName5
                            // this.hform.HLastSubProc= data.HLastSubProc
                            // this.hform.HQCCheckID= data.HQCCheckID
                            // this.hform.HQCCheckName= data.HQCCheckName
                            if (data.是否审核 == "true") {
                                this.btnType = 3
                            } else {
                                this.btnType = 2
                            }
                            this.hform.HMaker = data.HMaker
                            this.hform.HMakeDate = data.HMakeDate
                            this.hform.HUpDater = data.HUpDater
                            this.hform.HUpDateDate = data.HUpDateDate
                            this.hform.HChecker = data.HChecker
                            this.hform.HCheckDate = data.HCheckDate
                            // this.hform.HCloseMan= data.HCloseMan
                            // this.hform.HCloseDate= data.HCloseDate
                            this.hform.HDeleteMan = data.HDeleteMan
                            this.hform.HDeleteDate = data.HDeleteDate
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            getHBarCodeData(HBarCode, e) {
                var barNo = HBarCode.substr(0, 2);
                var barNo1 = HBarCode.substr(0, 4);
                uni.request({
                    url: this.serverUrl + '/Cj_StationBill/txtHBarCode_KeyDown2',
                    data: {
                        HBarCode: HBarCode,
                        HInterID: this.hform.HProcExchHinteID,
                        UserID: this.userInfo.Czybm,
                        HBillType: "Out"
                    },
                    success: (res) => {
                        console.log(2, res.data);
                        if (res.data.code == 1) {
                            var data = res.data.data[0]
                            if (barNo != 'OP') {
                                if (barNo1 == 'GXLZ' && data.流水号) {
                                    this.hform.HProcNo = data.流水号
                                } else if (barNo1 == 'GXLX' && data.工序号) {
                                    this.hform.HProcNo = data.工序号
                                }
                            }
                            this.hform.HICMOInterID = data.hicmointerid
                            this.hform.HICMOBillNo = data.任务单号
                            this.hform.HMaterID = data.HMaterID
                            this.hform.HMaterName = data.产品
                            this.hform.HMaterNumber = data.产品代码
                            this.hform.HMaterModel = data.规格型号
                            this.hform.HPlanQty = data.流转卡数量
                            this.hform.lngBillKey = data.hmainid
                            this.hform.HProcExchBillNo = data.单据号
                            this.hform.HProcExchHinteID = data.hmainid
                            this.hform.HICMOQty = data.任务单数量
                            this.hform.HOrderProcNO = data.订单跟踪号
                            this.hform.HPRDOrgID = data.组织
                            this.hform.HPRDOrg = data.组织名称
                            this.hform.lngBillSubKey = data.hsubid
                            this.hform.HProcName = data.工序
                            this.hform.HProcID = data.HProcID
                            this.hform.HCenterName = data.工作中心
                            this.hform.HCenterID = data.HCenterID
                            this.hform.NoOutboundHqty = (data.流转卡数量 - data.出站报废关联数量 - data.出站关联数量)
                            this.hform.HStyleNumber = data['款号']
                            //设置序列
                            this.getHSEQList(e);
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            getHProcNoData(HBarCode, HProcNo) {
                uni.request({
                    url: this.serverUrl + '/Cj_StationInBill/txtHProcNo_KeyDown',
                    data: {
                        sBillNo: HBarCode,
                        sProcNo: HProcNo
                    },
                    success: (res) => {
                        console.log(3, res);
                        if (res.data.code == 1) {
                            var data = res.data.data[0]
                            this.hform.lngBillSubKey = data.hsubid
                            this.hform.HProcName = data.工序
                            this.hform.HProcID = data.HProcID
                            this.hform.HCenterName = data.工作中心
                            this.hform.HCenterID = data.HCenterID
                            this.hform.NoOutboundHqty = (data.流转卡数量 - data.出站报废关联数量 - data.出站关联数量)
                            this.hform.HNotReportQty = data['未报工数量']
                            this.hform.HProcNumber = data['工序代码']
                            this.hform.HIsTimeFlag = data['是否计时'] ? 1 : 0
                           // this.hform.HStyleNumber = data['款号']
                            // this.hform.HQty = data.合格数量
                            if (data.首道工序 == "是") {
                                this.FirstEndHProcNo = 1
                            }
                            if (data.末道工序 == "是") {
                                this.FirstEndHProcNo = 2
                            }
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            getHProcNoData2(HBarCode, HProcNo,HSEQNumber) {
                uni.request({
                    url: this.serverUrl + '/Cj_StationOutBill/txtHProcNo_KeyDown',
                    data: {
                        sBillNo: HBarCode,
                        sProcNo: HProcNo,
                        HSEQNumber:HSEQNumber
                    },
                    success: (res) => {
                        console.log(3, res);
                        if (res.data.code == 1) {
                            var data = res.data.data[0]
                            this.hform.lngBillSubKey = data.hsubid
                            this.hform.HProcName = data.工序
                            this.hform.HProcID = data.HProcID
                            this.hform.HCenterName = data.工作中心
                            this.hform.HCenterID = data.HCenterID
                            this.hform.NoOutboundHqty = (data.流转卡数量 - data.出站报废关联数量 - data.出站关联数量)
                            this.hform.HNotReportQty = data['未报工数量']
                            this.hform.HProcNumber = data['工序代码']
                            this.hform.HIsTimeFlag = data['是否计时'] ? 1 : 0
                            if(data['是否计时']){
                                this.hform.HRelEndTime = getDateTime.dateTimeStr('y-m-d h:i');
                                this.getNewHRelBeginDate();
                            }
                            this.hform.HSEQName = data.序列名称
                           // this.hform.HStyleNumber = data['款号']
                            // this.hform.HQty = data.合格数量
                            if (data.首道工序 == "是") {
                                this.FirstEndHProcNo = 1
                            }
                            if (data.末道工序 == "是") {
                                this.FirstEndHProcNo = 2
                            }
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            //获取最新的报工日期
            getNewHRelBeginDate(){
                uni.request({
                    url: this.serverUrl + '/Cj_StationOutBill/get_Display',
                    data:{
                        sWhere: ` and HEmpID = N'${this.hform.HEmpID}'`,
                        user: uni.getStorageSync('HUserName'),
                        HBillSubType:'',
                    },
                    success: (res) => {
                        if(res.data.count == 1){
                            //获取列表数据
                            const listData = res.data.data
                            // 获取当前日期(去掉时间部分)
                            const today = new Date();
                            today.setHours(0, 0, 0, 0);
                            if(listData.length==0){
                                this.hform.HRelBeginTime = getDateTime.dateTimeSetHoureStr(7, 40, 0, 0,'y-m-d h:i');
                                this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime);
                            }else{
                                // 从对象数组中提取所有日期字段并找到最大值
                                const maxDate = listData.reduce((max, obj) => {
                                    const date = new Date(obj.出站时间);
                                    return date > max ? date : max;
                                }, new Date(0)); // 初始值为最小日期
                                // 比较最大日期和今天的日期部分(不比较时间)
                                const maxDateDateOnly = new Date(maxDate);
                                maxDateDateOnly.setHours(0, 0, 0, 0);
                                  // 比较最大日期和今天
                                if (maxDateDateOnly.getTime() !== today.getTime()) {
                                    // 如果不是今天,返回当前日期
                                    this.hform.HRelBeginTime = getDateTime.dateTimeSetHoureStr(7, 40, 0, 0,'y-m-d h:i');
                                    this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime);
                                }else{
                                    this.hform.HRelBeginTime = getDateTime.formatDate(maxDate);
                                    this.hform.HWorkTimes=getDateTime.calculateHoursDiff(this.hform.HRelBeginTime,this.hform.HRelEndTime);
                                }
                            }
                        }else{
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title:'接口请求失败',
                            icon:'none'
                        })
                    },
                });
            },
            //新增
            getNewData() {
                uni.request({
                    url: this.serverUrl + '/Web/GetMAXNum',
                    data: {
                        HBillType: '3791'
                    },
                    success: (res) => {
                        console.log(res.data)
                        if (res.data.count == 1) {
                            this.hform.HInterID = res.data.data[0].HInterID
                            this.hform.HBillNo = res.data.data[0].HBillNo
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            addNew() {
                uni.redirectTo({
                    url: '/pages/gongxuOut/form?OperationType=1'
                })
            },
            submit() {
                //去除分号以免后端分解报错
                this.hform.HMaterName= this.hform.HMaterName.replace(/;/g, '');
                this.hform.HMaterModel = this.hform.HMaterModel.replace(/;/g, '');
                if (!this.hform.HBarCode) {
                    uni.showToast({
                        title: '请扫描设备条形码',
                        icon: 'none'
                    })
                } else if (!this.hform.HProcNo) {
                    uni.showToast({
                        title: '请输入/扫描流水号',
                        icon: 'none'
                    })
                } else if (!this.hform.HEmpName) {
                    uni.showToast({
                        title: '请选择操作员',
                        icon: 'none'
                    })
                } else if (!this.hform.HCenterName) {
                    uni.showToast({
                        title: '请选择工作中心',
                        icon: 'none'
                    })
                } else {
                    let {pass, message} = this.preEditOrAddCheck()
                    if(pass == false) {
                        return uni.showToast({
                            icon: 'none',
                            title: message
                        })
                    }
                    uni.showLoading({
                        title: '请稍候'
                    })
                    var sMainStr = JSON.stringify(this.hform);
                    var sMainSub = sMainStr + ";" + uni.getStorageSync('HUserName') + ";" + this.OperationType;
                    console.log(sMainSub);
                    uni.request({
                        url: this.serverUrl + '/Cj_StationOutBill/AddBill',
                        method: 'POST',
                        dataType: "json",
                        data: {
                            oMain: sMainSub
                        },
                        success: (res) => {
                            console.log(1, res);
                            uni.hideLoading()
                            if (res.data.count == 1) {
                                // if (uni.getStorageSync('OrganizationID') == 100038) {
                                //     if (this.FirstEndHProcNo == 1) {
                                //         //汇报
                                //         this.huibao()
                                //     } else if (this.FirstEndHProcNo == 2) {
                                //         //入库
                                //         this.ruku()
                                //         //报废
                                //         this.baofei()
                                //     }
                                // }
                                // let pages = getCurrentPages();
                                // let prePage = pages[pages.length - 2];
                                // prePage.$vm.getList()
                                if (this.isEdit) {
                                    uni.showToast({
                                        title: '修改成功',
                                        icon: 'none'
                                    })
                                    setTimeout(() => {
                                        uni.redirectTo({
                                            url: '/pages/gongxuOut/table'
                                        })
                                    }, 1000)
                                } else {
                                    uni.showToast({
                                        title: res.data.Message,
                                        icon: 'none'
                                    })
            //                         uni.showModal({
            //                             title: '提示',
            //                             content: res.data.Message + '。是否继续新增下一道工序?(点击取消返回新增页面)',
            //                             success: (res) => {
            //                                 if (res.confirm) {
            //                                     console.log('用户点击确定');
                                                // this.getNextProc()
            //                                     // uni.redirectTo({
            //                                     //     url: '/pages/gongxuOut/form?OperationType=1'
            //                                     // })
            //                                 } else if (res.cancel) {
            //                                     console.log('用户点击取消');
            //                                     // setTimeout(() => {
            //                                     //     uni.navigateBack();
            //                                     // }, 50)
                                                // uni.redirectTo({
                                                //     url: '/pages/gongxuOut/form?OperationType=1'
                                                // })
            //                                 }
            //                             }
            //                         });
                                }
                            } else {
                                uni.showToast({
                                    title: res.data.Message,
                                    icon: 'none'
                                })
                            }
                        },
                        fail: (res) => {
                            console.log(res);
                            uni.showToast({
                                title: '接口请求失败',
                                icon: 'none'
                            })
                        },
                    });
                }
            },
            //审核
            check() {
                uni.request({
                    url: this.serverUrl + '/Cj_StationOutBill/set_CheckBill',
                    method: 'GET',
                    dataType: "json",
                    data: {
                        CurUserName: uni.getStorageSync('HUserName'),
                        HInterID: this.linterid,
                        HBillSubType: '',
                    },
                    success: (res) => {
                        console.log(1, res);
                        uni.hideLoading()
                        if (res.data.count == 1) {
                            this.btnType = 3
                            let pages = getCurrentPages();
                            let prePage = pages[pages.length - 2];
                            prePage.$vm.getList()
                            uni.showModal({
                                title: '操作成功',
                                content: '是否继续停留在当前页面?‘是’可进行反审核,‘否’则回到上一级列表',
                                confirmText: '是',
                                cancelText: '否',
                                success: (res) => {
                                    if (res.confirm) {
                                        console.log('用户点击是');
                                        this.btnType = 3
                                    } else if (res.cancel) {
                                        console.log('用户点击否');
                                        uni.navigateBack()
                                    }
                                }
                            });
                        }
                        uni.showToast({
                            title: res.data.Message,
                            icon: 'none'
                        })
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            //反审核
            abandonCheck() {
                uni.request({
                    url: this.serverUrl + '/Cj_StationOutBill/set_AbandonCheck',
                    method: 'GET',
                    dataType: "json",
                    data: {
                        CurUserName: uni.getStorageSync('HUserName'),
                        HInterID: this.linterid,
                        HBillSubType: '',
                    },
                    success: (res) => {
                        console.log(1, res);
                        uni.hideLoading()
                        if (res.data.count == 1) {
                            let pages = getCurrentPages();
                            let prePage = pages[pages.length - 2];
                            prePage.$vm.getList()
                            this.btnType = 2
                            uni.showModal({
                                title: '操作成功',
                                content: '是否继续停留在当前页面?‘是’可进行审核,‘否’则回到上一级列表',
                                confirmText: '是',
                                cancelText: '否',
                                success: (res) => {
                                    if (res.confirm) {
                                        console.log('用户点击是');
                                        this.btnType = 2
                                    } else if (res.cancel) {
                                        console.log('用户点击否');
                                        uni.navigateBack()
                                    }
                                }
                            });
                        }
                        uni.showToast({
                            title: res.data.Message,
                            icon: 'none'
                        })
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            goBack() {
                uni.showModal({
                    title: '提示',
                    content: '确认要退出当前页面吗?',
                    success: (res) => {
                        if (res.confirm) {
                            console.log('用户点击确定');
                            uni.navigateBack()
                        } else if (res.cancel) {
                            console.log('用户点击取消');
                        }
                    }
                });
            },
            getNextProc(){
                uni.request({
                    url: this.serverUrl + '/LEMS/MES_Sc_ProcessExchangeBillQuerySub_Json',
                    method: 'GET',
                    dataType: "json",
                    data: {
                        sWhere:this.hform.HProcExchHinteID
                    },
                    success: (res) => {
                        console.log(1, res);
                        if (res.data.count == 1) {
                            let processList = res.data.data
                            // 1. 先过滤出 HSEQNumber === 'N' 的数据
                            processList = processList.filter(item => item.HSEQNumber === this.hform.HSEQNumber);
                            //当前工序编号
                            const currentIndex = processList.findIndex(item => item["工序号"] === this.hform.HProcNo);
                            // 获取下一个工序(如果存在)
                            const nextProcess = currentIndex !== -1 && currentIndex < processList.length - 1
                              ? processList[currentIndex + 1] : null;
                            if(!nextProcess){
                                uni.showToast({
                                    title: '没有下一道工序即将跳转新增页面',
                                    icon: 'none'
                                })
                                uni.redirectTo({
                                    url: '/pages/gongxuOut/form?OperationType=1'
                                })
                            }else{
                                this.hform.HProcNo=nextProcess["工序号"];
                                const HNextBarCode = this.hform.HBarCode+"@"+this.hform.HProcNo+"@"+this.hform.HSEQNumber
                                uni.redirectTo({
                                    url: '/pages/gongxuOut/form?OperationType=1&HBarCode='+HNextBarCode
                                })
                            }
                        }else{
                            console.log(res);
                            uni.showToast({
                                title: '获取下一道工序失败',
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            }
        }
    }
</script>
<style lang="scss" scoped>
    .form {
        box-sizing: border-box;
        border-radius: 15rpx 15rpx 0 0;
        padding: 20rpx 20rpx 40rpx 20rpx;
        background-color: #fff;
        display: flex;
        flex-direction: column;
        gap: 10rpx;
        overflow-y: auto;
    }
    picker input{
        pointer-events: none;
    }
    .tab_area {
        width: 100%;
        height: 50rpx;
    }
    .other {
        margin-top: 8rpx;
        text-align: center;
        font-size: 28rpx;
        padding: 4rpx 18rpx;
        color: #1890FF;
    }
    .form-item {
        display: flex;
        align-items: center;
        font-size: 30rpx;
        padding: 6rpx 0;
        .title {
            width: 208rpx;
            text {
                color: red;
                font-weight: bold;
            }
        }
        .right {
            width: 450rpx;
            border-radius: 22rpx;
            border: 1px solid #acacac;
        }
        .righton {
            width: 450rpx;
            border-radius: 22rpx;
            border: 1px solid #e4e4e4;
            background-color: #e4e4e4;
        }
        input {
            width: 100%;
            padding: 8rpx 20rpx;
            font-size: 30rpx;
        }
        textarea {
            width: 98%;
            padding: 8rpx 20rpx;
            font-size: 30rpx;
        }
    }
    .op {
        display: flex;
        justify-content: space-around;
        button {
            padding: 0;
            width: 150rpx;
            font-size: 25rpx;
        }
        .op1 {
            border: 1px solid #3a78ff;
            color: #3a78ff;
            background-color: rgba(58, 120, 255, 0.1);
        }
        .op2 {
            border: 1px solid #41a863;
            color: #41a863;
            background-color: rgba(65, 168, 99, 0.1);
        }
        .op3 {
            border: 1px solid #da0000;
            color: #da0000;
            background-color: rgba(218, 0, 0, 0.1);
        }
    }
    .has-ticking {
        display: flex;
        flex-direction: row;
        justify-content: right;
    }
    .bottom-btn {
        width: 100%;
        box-sizing: border-box;
        // height: 120rpx;
        position: fixed;
        bottom: 0;
        left: 0;
        background-color: #fff;
        box-shadow: 0 2rpx 10rpx 2rpx rgba(0, 0, 0, 0.4);
        padding: 30rpx 40rpx 40rpx 40rpx;
        display: flex;
        flex-direction: row;
        gap: 10rpx;
        button {
            border-radius: 50rpx;
            width: 180rpx;
            height: 66rpx;
            line-height: 66rpx;
            font-size: 28rpx;
        }
        .btn-a {
            background-color: #3A78FF;
            color: #fff;
        }
        .btn-b {
            background-color: #41a863;
            color: #fff;
            // margin-left: 30rpx;
        }
        .btn-c {
            background-color: #acacac;
            color: #fff;
            // position: absolute;
            // right: 120rpx;
        }
        .btn-d {
            background-color: #ff8901;
            color: #fff;
            // margin-left: 30rpx;
        }
    }
    .tick-wrapper {
        display: flex;
        flex-direction: row;
        gap: 20rpx;
        .form-item:nth-child(1) {
            flex: 1;
            >.title {
                width: 208rpx;
                flex-shrink: 0;
            }
            >.right {
                width: inherit;
                display: flex;
                input {
                    width: inherit;
                }
            }
        }
        .form-item:nth-child(2) {}
    }
</style>