chenhaozhe
2025-12-23 8024deba5db85072bf95aa9d740a53b7ea94d3b1
Merge branch 'Dev' of http://101.37.171.70:10101/r/~jhz/STUWMS into Dev

# Conflicts:
# pages/MJGL/mujulingliaochukudan/MouldProdOutBill.vue
3个文件已修改
1942 ■■■■■ 已修改文件
pages.json 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/MJGL/mujulingliaochukudan/MouldProdOutBill.vue 1934 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/common.js 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages.json
@@ -1110,8 +1110,7 @@
        {
            "path": "pages/MJGL/mujulingliaochukudan/MouldProdOutBill",
            "style": {
                "navigationBarTitleText": "模具领料出库单",
                "enablePullDownRefresh": true
                "navigationBarTitleText": "模具领料出库单"
            }
        },
        {
pages/MJGL/mujulingliaochukudan/MouldProdOutBill.vue
@@ -1,855 +1,1097 @@
<template>
    <view>
        <view class="form">
            <view class="form-item">
                <view class="title">条码</view>
                <view class="right" style="width: 350rpx;">
                    <input v-model="hform.HBarCode" placeholder="请扫描(或输入)条码" @confirm="getCode(hform.HBarCode)"
                        @blur="getCode(hform.HBarCode)" />
                </view>
                <uni-icons type="scan"
                    style="margin-left: 10rpx;background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;"
                    size="20" @click="toScanCode"></uni-icons>
            </view>
            <view class="form-item">
                <view class="title">仓库:</view>
                <view class="right">
                    <uni-combox :candidates="arrayHWHName" placeholder="请输入(或扫描)仓库" v-model="hform.HWHName"
                        @input="HWHNameChange"></uni-combox>
                </view>
            </view>
            <view class="form-item">
                <view class="title">仓位:</view>
                <view class="right" v-show="showHStockPlaceName">
                    <uni-combox :candidates="arrayHStockPlaceName" placeholder="请输入(或扫描)仓位"
                        v-model="hform.HStockPlaceName" @input="HStockPlaceNameChange"></uni-combox>
                </view>
                <view class="righton" v-show="!showHStockPlaceName">
                    <input v-model="hform.HStockPlaceName" :disabled="!showHStockPlaceName" placeholder="不可操作" />
                </view>
            </view>
            <view class="form-item">
                <view class="title">发料:</view>
                <view class="right">
                    <uni-combox :candidates="arrayHEmpName" placeholder="请输入(或扫描)发料人" v-model="hform.HSactterUser"
                        @input="HScatterUserChange"></uni-combox>
                </view>
            </view>
            <view class="form-item">
                <view class="title">领料:</view>
                <view class="right">
                    <uni-combox :candidates="arrayHEmpName" placeholder="请输入(或扫描)领料人" v-model="hform.HCollectUser"
                        @input="HCollectUserChange"></uni-combox>
                </view>
            </view>
            <view class="form-item">
                <view class="title">部门:</view>
                <view class="right">
                    <uni-combox :candidates="arrayHDeptName" placeholder="请选择部门" v-model="hform.HDeptName"
                        @input="HDeptNameChange"></uni-combox>
                </view>
            </view>
            <view class="form-item">
                <view class="title">往来类型:</view>
                <view class="right">
                    <uni-combox :candidates="['供应商','客户','部门']" placeholder="请选择类型" v-model="hform.TypeName"
                        @input="HSelectTypeChange"></uni-combox>
                </view>
            </view>
            <view class="form-item">
                <view class="title">往来单位:</view>
                <view class="right">
                    <uni-combox :candidates="arrayHSelectType" placeholder="请选择" v-model="hform.Selection"
                        @input=""></uni-combox>
                </view>
            </view>
            <view class="tabs">
                <view :class="tabs == 0 ? 'on':''" @tap="tabs = 0">表头信息</view>
                <view :class="tabs == 2 ? 'on':''" @tap="tabs = 2">模具列表</view>
                <view :class="tabs == 1 ? 'on':''" @tap="tabs = 1">模具信息</view>
            </view>
            <view v-if="tabs == 0">
                <view class="form-item">
                    <view class="title">日期:</view>
                    <view class="right">
                        <picker mode="date" v-model="hform.HDate" @change="HDateChange">
                            <view class="picker-overlay"></view>
                            <input disabled v-model="hform.HDate" placeholder="请选择日期" />
                        </picker>
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">制单人:</view>
                    <view class="righton">
                        <input name="HMaker" disabled v-model="hform.HMaker" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">单据号:</view>
                    <view class="righton">
                        <input name="HBillNo" disabled v-model="hform.HBillNo" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">单据ID:</view>
                    <view class="righton">
                        <input name="HInterID" disabled v-model="hform.HInterID" />
                    </view>
                </view>
            </view>
            <view v-if="tabs==2">
                器具列表
            </view>
            <view v-if="tabs==1">
<!--                <view class="form-item">
                    <view class="title">器具条码:</view>
                    <view class="righton">
                        <input name="HBarCode_B" disabled v-model="hform.HBarCode_B" />
                    </view>
                </view> -->
                <view class="form-item">
                    <view class="title">器具名称:</view>
                    <view class="righton">
                        <input disabled v-model="hform.HMouldName_B" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">器具号:</view>
                    <view class="righton">
                        <input disabled v-model="hform.HMouldID_B" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">数量:</view>
                    <view class="righton">
                        <input disabled v-model="hform.HMouldCount_B" />
                    </view>
                </view>
            </view>
            <view class="bottom-btn">
                <button class="btn-c" size="mini" @tap="goBack">退出</button>
                <button v-if="btnType == 1 && !isEdit" class="btn-a" size="mini" @tap="submit">提交</button>
                <!-- <button v-if="btnType != 1 && !isEdit" class="btn-a" size="mini" @tap="ifEdit">修改</button> -->
                <button v-if="btnType != 1 " class="btn-a" size="mini" @tap="submit">提交</button>
            </view>
        </view>
    </view>
    <view>
        <view class="form">
            <view class="form-item">
                <view class="title">条码</view>
                <view class="right" style="width: 350rpx;">
                    <input :focus="barCodeFocus" v-model="hform.HBarCode" placeholder="请扫描(或输入)条码" @confirm="getCode(hform.HBarCode)"/>
                </view>
                <uni-icons type="scan"
                    style="margin-left: 10rpx;background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;"
                    size="20" @click="toScanCode"></uni-icons>
            </view>
            <view class="form-item">
                <view class="title">仓库:</view>
                <view class="right">
                    <uni-combox :candidates="arrayHWHName" placeholder="请输入(或扫描)仓库" v-model="hform.HWHName"
                        @input="HWHNameChange"></uni-combox>
                </view>
            </view>
            <view class="form-item">
                <view class="title">仓位:</view>
                <view class="right" v-show="showHStockPlaceName">
                    <uni-combox :candidates="arrayHStockPlaceName" placeholder="请输入(或扫描)仓位"
                        v-model="hform.HStockPlaceName" @input="HStockPlaceNameChange"></uni-combox>
                </view>
                <view class="righton" v-show="!showHStockPlaceName">
                    <input v-model="hform.HStockPlaceName" :disabled="!showHStockPlaceName"
                        placeholder="不可操作" /></view>
            </view>
            <view class="form-item">
                <view class="title">发料:</view>
                <view class="right">
                    <uni-combox :candidates="arrayHEmpName" placeholder="请输入(或扫描)发料人" v-model="hform.HKeeperName"
                        @input="HScatterUserChange"></uni-combox>
                </view>
            </view>
            <view class="form-item">
                <view class="title">领料:</view>
                <view class="right">
                    <uni-combox :candidates="arrayHEmpName" placeholder="请输入(或扫描)领料人" v-model="hform.HSecManagerName"
                        @input="HCollectUserChange"></uni-combox>
                </view>
            </view>
            <view class="form-item">
                <view class="title">部门:</view>
                <view class="right">
                    <uni-combox :candidates="arrayHDeptName" placeholder="请选择部门" v-model="hform.HDeptName"
                        @input="HDeptNameChange"></uni-combox>
                </view>
            </view>
            <view class="form-item">
                <view class="title">往来类型:</view>
                <view class="right" v-show="showHSourceBillNo">
                    <uni-combox :candidates="['供应商','客户','部门']" placeholder="请选择类型" v-model="hform.TypeName"
                        @input="HSelectTypeChange"></uni-combox>
                </view>
                <view class="right" v-show="!showHSourceBillNo">
                    <input name="TypeName" disabled v-model="hform.TypeName" placeholder="" />
                </view>
            </view>
            <view class="form-item">
                <view class="title">往来单位:</view>
                <view class="right" v-show="showHSourceBillNo">
                    <uni-combox :candidates="arrayHSelectType" placeholder="请选择" v-model="hform.HSupName"
                        @input="" ></uni-combox>
                </view>
                <view class="right" v-show="!showHSourceBillNo">
                    <input name="HSupName" disabled v-model="hform.HSupName" placeholder="" />
                </view>
            </view>
            <view class="tabs">
                <view :class="tabs == 0 ? 'on':''" @tap="tabs = 0">表头信息</view>
                <view :class="tabs == 1 ? 'on':''" @tap="tabs = 1">模具信息</view>
            </view>
            <view v-if="tabs == 0">
                <view class="form-item">
                    <view class="title">日期:</view>
                    <view class="right">
                        <picker mode="date" v-model="hform.HDate" @change="HDateChange">
                            <view class="picker-overlay"></view>
                            <input disabled v-model="hform.HDate" placeholder="请选择日期" />
                        </picker>
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">源单类型:</view>
                    <view class="right" v-show="showHMainSourceBillType">
                        <picker :range="arrayHMainSourceBillType" v-model="HMainSourceBillType"
                            @change="HMainSourceBillTypeChange">
                            <input name="HMainSourceBillType" disabled 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">源单单号:</view>
                    <view class="right" v-show="showHSourceBillNo">
                        <!-- <uni-combox v-if="reHSourceBillNo" :candidates="arrayHSourceBillNo" placeholder="请输入源单单号"
                            v-model="hform.HSourceBillNo" @input="HSourceBillNoChange"></uni-combox> -->
                        <input :focus="HSourceBillNoFocus" type="text" name="HSourceBillNo"
                            v-model="hform.HSourceBillNo" @confirm="onSourceBillBlurHandler" placeholder="请输入源单单号" />
                    </view>
                    <view class="icon-wrapper" v-show="showHSourceBillNo" :disabled="hform.HMainSourceBillType === -1">
                        <uni-icons type="search" size="20" @click="showBillList"></uni-icons>
                    </view>
                    <view class="righton" v-show="!showHSourceBillNo">
                        <input name="HSourceBillNo" disabled v-model="hform.HSourceBillNo" placeholder="请输入源单单号" />
                    </view>
                    <!-- <view class="right" v-show="showHSourceBillNo">
                        <uni-combox ref="uniComboxSourceBill" :isFocus="HSourceBillNoFocus"
                            :confirm-call="onSourceBillBlurHandler" v-if="reHSourceBillNo"
                            :candidates="arrayHSourceBillNo" placeholder="请输入源单单号" v-model="hform.HSourceBillNo"
                            @input="HSourceBillNoChange"></uni-combox>
                    </view>
                    <view class="righton" v-show="!showHSourceBillNo">
                        <input name="HSourceBillNo" disabled v-model="hform.HSourceBillNo" placeholder="请输入源单单号" />
                    </view> -->
                </view>
                <view class="form-item">
                    <view class="title">制单人:</view>
                    <view class="righton">
                        <input name="HMaker" disabled v-model="hform.HMaker" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">单据号:</view>
                    <view class="righton">
                        <input name="HBillNo" disabled v-model="hform.HBillNo" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">单据ID:</view>
                    <view class="righton">
                        <input name="HInterID" disabled v-model="hform.HInterID" />
                    </view>
                </view>
            </view>
            <view v-if="tabs==1">
                <view class="list" v-for="(item,index) in HMouldList" :key="index">
                     <uni-card :title="item.器具名称" style="margin: 10px;" @tap="delMater(item, $event)">
                                <!-- 器具代码作为可点击链接 -->
                                <view class="card-header">
                                    <text class="link-text">器具号:{{item.器具号}}</text>
                                </view>
                                <view class="card-detail">
                                    <view class="detail">
                                        <text>数量:</text>{{item.数量}}
                                    </view>
                                    <view class="detail">
                                        <text>器具条码:</text>{{item.器具条码}}
                                    </view>
                                </view>
                            </uni-card>
                </view>
                <view class="over" v-if="HMouldList.length == 0">暂无数据</view>
            </view>
            <view class="bottom-btn">
                <button class="btn-c" size="mini" @tap="goBack">退出</button>
                <button v-if="btnType == 1 && !isEdit" class="btn-a" size="mini" @tap="submit">提交</button>
                <!-- <button v-if="btnType != 1 && !isEdit" class="btn-a" size="mini" @tap="ifEdit">修改</button> -->
                <button v-if="btnType != 1 " class="btn-a" size="mini" @tap="submit">提交</button>
            </view>
        </view>
        <BillListPopupVue ref="billList" :HBillType="hform.HBillType" :HSourceBillType="hform.HMainSourceBillType"
            :HStockOrgID="hform.HStockOrgID"></BillListPopupVue>
    </view>
</template>
<script>
    import getDateTime from '@/utils/getdateTime.js';
    import {
        getUserInfo
    } from "@/utils/auth.js";
    import {
        CommonUtils
    } from '@/utils/common';
import { List } from 'echarts';
    import getDateTime from '@/utils/getdateTime.js';
    import {
        getUserInfo
    } from "@/utils/auth.js";
    import { CommonUtils } from '@/utils/common';
    import BillListPopupVue from '../../../components/BillListPopup/BillListPopup.vue';
    export default {
        data() {
            return {
                HSourceBillNoFocus: false,
                barCodeFocus: true,//条码光标
                userInfo: getUserInfo(),
                serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
                tabs: 0,
                btnType:1,//1新增,3修改
                linterid:'',
                arrayHEmpName: [],
                HEmpNameList: [],
                arrayHWHName: [], //仓库
                HWHNameList: [],
                arrayHStockPlaceName: [], //仓位
                HStockPlaceNameList: [],
                arrayHDeptName: [], //部门
                HDeptNameList: [],
                arrayHCusName: [], //客户
                HCusNameList: [],
                arrayHSupplierName:[],//供应商
                HSuplierList:[],
                linterid: '',
                HBillNo: '',
                arrayHSelectType: [], // 往来单位下拉列表
                HSelectTypeList: [], // 往来单位完整数据列表
                showHStockPlaceName: true,
                HMouldList:[],
                isEdit: false,
                showHMainSourceBillType: true,
                showHSourceBillNo: true,
                HMainSourceBillType: uni.getStorageSync('billTypeName_3802') ? uni.getStorageSync('billTypeName_3802'):'领用申请单',
                arrayHMainSourceBillType: ['领用申请单', '手工录入'],
                arrayHMainSourceBillValue: ['3849', '-1'],
                hform: {
                    HBarCode: '',
                    HInterID: '',
                    HBillType: 3802,
                    HWHName: getUserInfo().HWHName,
                    HWHID: getUserInfo().HWhID,
                    HStockPlaceName: getUserInfo().HSPName,
                    HStockPlaceID: getUserInfo().HSPID,
                    HKeeperName: getUserInfo().User,
                    HKeeperID: getUserInfo().User,//发料人
                    HSecManagerName: getUserInfo().HEmpName,
                    HSecManagerID: getUserInfo().HEmpID,//领料人
                    HDeptName: getUserInfo().HDept,
                    HDeptID: getUserInfo().HDeptID,
                    //源单信息
                    HMainSourceBillType: uni.getStorageSync('billType_3802') ? uni.getStorageSync('billType_3802'):3849,
                    HSourceBillNo: '', //CGDD000200
                    //往来类型
                    TypeName:uni.getStorageSync('typeName_3802'),
                    HSupName: '', // 往来单位选中的值
                    HSupID: '' ,// 往来单位对应的ID
                    HSupTypeID:uni.getStorageSync('typeID_3802')?uni.getStorageSync('typeID_3802'):0,
                    HDate: getDateTime.dateTimeStr('y-m-d'),
                    HMaker: uni.getStorageSync('HUserName'),
                    HRedBlueFlag:'false',
                    HStockOrgName: uni.getStorageSync('Organization'),
                    HStockOrgID: uni.getStorageSync('OrganizationID'),
                    HStockOutOrgID:uni.getStorageSync('OrganizationID'),
                    HBarCode_B:'',
                    HMouldName_B:'',
                    HMouldID_B:'',
                    HMouldCount_B:'',
                }
            }
        },
        components: {
            BillListPopupVue
        },
        methods: {
            //扫码
            toScanCode() {
                var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
                mpaasScanModule.mpaasScan({
                    'hideAlbum': true,
                    'timeoutInterval': '10', //超时时间
                    'timeoutText': '未识别到二维码' //超时提醒
                }, (ret) => {
                    console.log(ret.resp_result)
                    if (this.hform.HBarCode == '*') {
                        this.hform.HBarCode = this.hform.HBarCode + ret.resp_result
                    } else {
                        this.hform.HBarCode = ret.resp_result
                    }
    export default {
        data() {
            return {
                userInfo: getUserInfo(),
                serverUrl: uni.getStorageSync('serverUrl') || 'http://47.96.97.237/API',
                tabs: 0,
                btnType: 1, //1新增,3修改
                linterid: '',
                arrayHEmpName: [],
                HEmpNameList: [],
                arrayHWHName: [], //仓库
                HWHNameList: [],
                arrayHStockPlaceName: [], //仓位
                HStockPlaceNameList: [],
                arrayHDeptName: [], //部门
                HDeptNameList: [],
                arrayHSupName: [], //客户
                HSupNameList: [],
                arrayHSupplierName: [], //供应商
                HSuplierList: [],
                linterid: '',
                HBillNo: '',
                arrayHSelectType: [], // 往来单位下拉列表
                HSelectTypeList: [], // 往来单位完整数据列表
                showHStockPlaceName: true,
                HMouldList: [],
                HMouldFields: [], // 模具字段缓存
                isEdit: false,
                hform: {
                    HBarCode: '',
                    HInterID: '',
                    HBillType: 3802,
                    HWHName: getUserInfo().HWHName,
                    HWHID: getUserInfo().HWhID,
                    HStockPlaceName: getUserInfo().HSPName,
                    HStockPlaceID: getUserInfo().HSPID,
                    HSactterUserName: getUserInfo().User,
                    HSactterUserID: getUserInfo().User,
                    HCollectUserName: getUserInfo().User,
                    HCollectUserID: getUserInfo().User,
                    HDeptName: getUserInfo().HDept,
                    HDeptID: getUserInfo().HDeptID,
                    HSupName: '',
                    HSupID: '',
                    HSecManagerID: '',
                    HKeeperID: '',
                    //往来类型
                    TypeName: '',
                    TypeID: '',
                    Selection: '', // 往来单位选中的值
                    SelectionID: '', // 往来单位对应的ID
                    HSupTypeID: '',
                    HDate: getDateTime.dateTimeStr('y-m-d'),
                    HMaker: uni.getStorageSync('HUserName'),
                    this.getCode(this.hform.HBarCode)
                })
            },
            getNewData() {
                CommonUtils.doRequest("/WEBSController/GetMaxBillNoAndID_Json", {
                        HBillType: this.hform.HBillType
                    },
                    (res) => {
                        let res1 = res.data;
                        let {
                            data,
                            count
                        } = res1
                        if (count == 1) {
                            this.hform.HInterID = data[0].HInterID
                            this.hform.HBillNo = data[0].HBillNo
                        } else {
                            uni.showToast({
                                title: data.Message,
                                icon: 'none'
                            })
                        }
                    })
            },
            async getCode(HBarCode) {
                //仓库、仓位文本框为空时,清空对应ID
                if (!this.hform.HWHName) {
                    this.hform.HWHID = 0
                }
                if (!this.hform.HStockPlaceName) {
                    this.hform.HStockPlaceID = 0
                }
                var sHWHID = this.hform.HWHID
                var sHSPID = this.hform.HStockPlaceID
                var sOldBarCode = HBarCode;
                var HDeleteFlag = sOldBarCode.substring(0, 1); //取条码第一个字符
                var sBarCode = sOldBarCode.slice(1); //获取第一个字符以外的全部字符
                var sSourceBillNo = this.hform.HSourceBillNo
                var sSourceBillType =this.hform.HMainSourceBillType
                if(sSourceBillType != -1&&sSourceBillNo==""){
                    uni.showToast({
                        title: "请先选择源单",
                        icon: 'none'
                    })
                    return
                }
                if (HDeleteFlag == '*') {
                    if (sBarCode == "") {
                        uni.showToast({
                            title: '请输入要删除的条码',
                            icon: 'none'
                        });
                    } else {
                        try {
                            let res = await CommonUtils.doRequest2Sync({
                                url: '/MouldController/set_DelMouldStockBillMain_Temp_Json',
                                data: {
                                    HInterID: this.hform.HInterID,
                                    HBillType: this.hform.HBillType,
                                    HBarCode: sBarCode
                                },
                            })
                            if (!res) {
                                return
                            }
                            console.log('删除条码', res.data);
                            this.hform.HBarCode = '';
                            if (res.data.count == 1) {
                                this.hform.HQty = ''
                            } else {
                                uni.showToast({
                                    title: res.data.Message,
                                    icon: 'none'
                                })
                            }
                        } catch (err) {
                            console.log(res);
                            uni.showToast({
                                title: '接口请求失败',
                                icon: 'none'
                            })
                        }
                    }
                }else
                {
                    var sBarCode = this.hform.HBarCode
                    try {
                        let res = await CommonUtils.doRequest2Sync({
                            url: '/MouldController/Get_CheckTypeByMouldBarCode_Json',
                            data: {
                                sBarCode: sBarCode,
                                HInterID: this.hform.HInterID,
                                HBillType: this.hform.HBillType,
                                HBillNo: this.hform.HBillNo,
                                HMaker: this.hform.HMaker,
                                HWhID: sHWHID,
                                HSPID: sHSPID,
                                HSCWhID:0,
                                HSCSPID: 0,
                                HRedBlueFlag: this.hform.HRedBlueFlag,
                                HSourceBillNo: sSourceBillNo,
                                HSourceBillType: sSourceBillType,
                                HStockOrgID: this.hform.HStockOrgID,
                                HStockOutOrgID: this.hform.HStockOutOrgID,
                            },
                        })
                        if (!res) {
                            return
                        }
                        console.log('检查扫码返回的数据', res.data);
                        this.hform.HBarCode=''
                        if(res.data.count==1){
                            this.tabs = 1
                            this.DisBillEntryList()
                            this.showHMainSourceBillType = false
                            this.showHSourceBillNo = false
                        }
                        else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    } catch (err) {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    }
                }
            },
            //仓库监听事件
            HWHNameChange(e) {
                for (var i = 0; i < this.HWHNameList.length; i++) {
                    if (this.HWHNameList[i]["HName"] == e) {
                        this.hform.HWHName = this.HWHNameList[i]["HName"]
                        this.hform.HWHID = this.HWHNameList[i].HItemID
                    HRedBlueFlag: 'false',
                    HStockOrgName: uni.getStorageSync('Organization'),
                    HStockOrgID: uni.getStorageSync('OrganizationID'),
                    HStockOutOrgID: uni.getStorageSync('OrganizationID'),
                    HBarCode_B: '',
                    HMouldName_B: '',
                    HMouldID_B: '',
                    HMouldCount_B: '',
                }
            }
        },
        methods: {
            //扫码
            toScanCode() {
                var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
                mpaasScanModule.mpaasScan({
                    'hideAlbum': true,
                    'timeoutInterval': '10', //超时时间
                    'timeoutText': '未识别到二维码' //超时提醒
                }, (ret) => {
                    console.log(ret.resp_result)
                    if (this.hform.HBarCode == '*') {
                        this.hform.HBarCode = this.hform.HBarCode + ret.resp_result
                    } else {
                        this.hform.HBarCode = ret.resp_result
                    }
                    this.getCode(this.hform.HBarCode)
                })
            },
            getNewData() {
                CommonUtils.doRequest("/WEBSController/GetMaxBillNoAndID_Json", {
                        HBillType: this.hform.HBillType
                    },
                    (res) => {
                        let res1 = res.data;
                        let {
                            data,
                            count
                        } = res1
                        if (count == 1) {
                            this.hform.HInterID = data[0].HInterID
                            this.hform.HBillNo = data[0].HBillNo
                        } else {
                            uni.showToast({
                                title: data.Message,
                                icon: 'none'
                            })
                        }
                    })
            },
            async getCode(HBarCode) {
                //仓库、仓位文本框为空时,清空对应ID
                if (!this.hform.HWHName) {
                    this.hform.HWHID = 0
                }
                if (!this.hform.HStockPlaceName) {
                    this.hform.HStockPlaceID = 0
                }
                var sHWHID = this.hform.HWHID
                var sHSPID = this.hform.HStockPlaceID
                var sOldBarCode = HBarCode;
                var HDeleteFlag = sOldBarCode.substring(0, 1); //取条码第一个字符
                var sBarCode = sOldBarCode.slice(1); //获取第一个字符以外的全部字符
                var sSourceBillNo = ""
                var sSourceBillType = "-1"
                if (HDeleteFlag == '*') {
                    if (sBarCode == "") {
                        uni.showToast({
                            title: '请输入要删除的条码',
                            icon: 'none'
                        });
                    } else {
                        try{
                            let res = await CommonUtils.doRequest2Sync({
                                url: "/MouldController/set_DelMouldStockBillMain_Temp_Json",
                                data: {
                                    HInterID: this.hform.HInterID,
                                    HBillType: this.hform.HBillType,
                                    HBarCode: sBarCode
                                }
                            })
                            // 出现竞态时 直接退出非首次提交的后续处理
                            if(!res){
                                return
                            }
                            console.log('删除条码', res.data);
                            this.hform.HBarCode = '';
                            if (res.data.count == 1) {
                                this.hform.HQty = ''
                            } else {
                                uni.showToast({
                                    title: res.data.Message,
                                    icon: 'none'
                                })
                            }
                        }catch(error) {
                            console.log(error);
                            uni.showToast({
                                title: '接口请求失败',
                                icon: 'none'
                            })
                        }
                    }
                } else {
                    try {
                        var sBarCode = this.hform.HBarCode
                        // 同步请求确保 @confirm 和 @blur 请求只会触发一次(避免竞态)
                        let res = await CommonUtils.doRequest2Sync({
                            url: '/MouldController/Get_CheckTypeByMouldBarCode_Json',
                            data: {
                                sBarCode: sBarCode,
                                HInterID: this.hform.HInterID,
                                HBillType: this.hform.HBillType,
                                HBillNo: this.hform.HBillNo,
                                HMaker: this.hform.HMaker,
                                HWhID: sHWHID,
                                HSPID: sHSPID,
                                HSCWhID: 0,
                                HSCSPID: 0,
                                HRedBlueFlag: this.hform.HRedBlueFlag,
                                HSourceBillNo: sSourceBillNo,
                                HSourceBillType: sSourceBillType,
                                HStockOrgID: this.hform.HStockOrgID,
                                HStockOutOrgID: this.hform.HStockOutOrgID,
                            }
                        })
                        if (!res) {
                            // 当触发竞态时,后触发的请求会被直接被禁止发送,并返回空值
                            return
                        }
                        console.log('检查扫码返回的数据', res.data);
                        this.hform.HBarCode = ''
                        if (res.data.count == 1) {
                            this.tabs = 1
                            this.DisBillEntryList()
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    } catch (error) {
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    }
                }
            },
            //仓库监听事件
            HWHNameChange(e) {
                for (var i = 0; i < this.HWHNameList.length; i++) {
                    if (this.HWHNameList[i]["HName"] == e) {
                        this.hform.HWHName = this.HWHNameList[i]["HName"]
                        this.hform.HWHID = this.HWHNameList[i].HItemID
                        this.showHStockPlaceName = this.HWHNameList[i].HIsStockMgr
                    }
                }
            },
            HStockPlaceNameChange(e) {
                for (var i = 0; i < this.HStockPlaceNameList.length; i++) {
                    if (this.HStockPlaceNameList[i]["HWhName"] == e) {
                        this.hform.HStockPlaceID = this.HStockPlaceNameList[i].HItemID
                        this.hform.HStockPlaceName = this.HStockPlaceNameList[i]["HWhName"]
                    }
                }
            },
            HScatterUserChange(e) {
                for (var i = 0; i < this.HEmpNameList.length; i++) {
                    if (this.HEmpNameList[i].HName == e) {
                        this.hform.HSactterUserID = this.HEmpNameList[i].HItemID
                        this.hform.HSactterUserName = this.HEmpNameList[i].HName
                        this.hform.HSecManagerID = this.HEmpNameList[i].HItemID
                    }
                }
            },
            HCollectUserChange(e) {
                for (var i = 0; i < this.HEmpNameList.length; i++) {
                    if (this.HEmpNameList[i].HName == e) {
                        this.hform.HCollectUserID = this.HEmpNameList[i].HItemID
                        this.hform.HCollectUserName = this.HEmpNameList[i].HName
                        this.hform.HKeeperID = this.HEmpNameList[i].HItemID
                    }
                }
            },
            /* #region 仓库仓位获取下拉框 */
            getHBaseList() {
                CommonUtils.doRequest(
                    "/Web/GetWarehouseList_Json_New", {
                        Warehouse: "",
                        HOrgID: uni.getStorageSync('OrganizationID')
                    },
                    (res) => {
                        let res1 = res.data
                        let {
                            data,
                            count
                        } = res1
                        if (count == 1) {
                            this.HWHNameList = data
                            for (var i = 0; i < data.length; i++) {
                                this.arrayHWHName[i] = data[i]["HName"]
                            }
                        } else {
                            uni.showToast({
                                title: '仓库数据请求失败',
                                icon: 'none'
                            })
                        }
                    },
                )
                CommonUtils.doRequest(
                    "/WEBSController/GetStockPlaceList_Json", {
                        StockPlace: '',
                        HWhID: this.hform.HWHID,
                        HStockOrgID: uni.getStorageSync('OrganizationID')
                    },
                    (res) => {
                        let res1 = res.data
                        console.log(res1)
                        let {
                            data,
                            count
                        } = res1
                        if (count == 1) {
                            this.HStockPlaceNameList = data
                            for (var i = 0; i < data.length; i++) {
                                this.arrayHStockPlaceName[i] = data[i]["HWhName"]
                            }
                        } else {
                            uni.showToast({
                                title: '仓位数据请求失败',
                                icon: 'none'
                            })
                        }
                    },
                )
            },
            /* #endregion */
            getHEmpList() {
                CommonUtils.doRequest("/Web/GetEmployeeList_Json", {
                        Employee: '',
                        HGroupID: 0
                    },
                    (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: '人员数据请求失败',
                                icon: 'none'
                            })
                        }
                    },
                )
            },
            //获取使用部门数据
            getHDeptList() {
                uni.request({
                    url: this.serverUrl + '/Gy_Department/list',
                    data: {
                        sWhere: "",
                        user: uni.getStorageSync('HUserName'),
                        Organization: uni.getStorageSync('Organization')
                    },
                    success: (res) => {
                        if (res.data.count == 1) {
                            this.HDeptNameList = res.data.data
                            for (var i = 0; i < res.data.data.length; i++) {
                                this.arrayHDeptName[i] = res.data.data[i].部门名称
                            }
                            this.$forceUpdate();
                        } else {
                            uni.showToast({
                                title: '部门数据请求失败',
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            getHSupList() {
                CommonUtils.doRequest(
                    "/Gy_Customer/list", {
                        sWhere: "",
                        user: uni.getStorageSync('HUserName'),
                        Organization: uni.getStorageSync('Organization')
                    },
                    (res) => {
                        let res1 = res.data
                        let {
                            data,
                            count
                        } = res1
                        if (count == 1) {
                            this.HSupNameList = data
                            for (var i = 0; i < data.length; i++) {
                                this.arrayHSupName[i] = data[i].客户名称
                            }
                            this.$forceUpdate();
                        } else {
                            uni.showToast({
                                title: data.Message,
                                icon: 'none'
                            })
                        }
                    }
                )
            },
            getSupplier() {
                CommonUtils.doRequest(
                    "/WEBSController/GetSupplier_Json", {
                        HBarCode: uni.getStorageSync(''),
                        Organization: uni.getStorageSync('Organization')
                    },
                    (res) => {
                        let res1 = res.data
                        let {
                            data,
                            count
                        } = res1
                        if (count == 1) {
                            this.HSupNameList = data
                            for (var i = 0; i < data.length; i++) {
                                this.arrayHSupName[i] = data[i].客户名称
                            }
                            this.$forceUpdate();
                        } else {
                            uni.showToast({
                                title: data.Message,
                                icon: 'none'
                            })
                        }
                    }
                )
            },
            //选择使用部门
            HDeptNameChange(e) {
                for (var i = 0; i < this.HDeptNameList.length; i++) {
                    if (this.HDeptNameList[i].部门名称 == e) {
                        this.hform.HDeptID = this.HDeptNameList[i].HItemID
                        this.hform.HDeptName = this.HDeptNameList[i].部门名称
                    }
                }
            },
            //选择客户
            HSupNameChange(e) {
                for (var i = 0; i < this.HSupNameList.length; i++) {
                    if (this.HSupNameList[i].客户名称 == e) {
                        this.hform.HSupID = this.HSupNameList[i].HItemID
                        this.hform.HSupName = this.HSupNameList[i].客户名称
                    }
                }
            },
            HDateChange(e) {
                console.log(e.detail.value)
                this.hform.HDate = e.detail.value
            },
            HSelectTypeChange(e) {
                this.hform.TypeName = e;
                this.hform.Selection = ''; // 清空往来单位选择
                this.hform.SelectionID = '';
                if (e == '部门') {
                    this.hform.HSupTypeID = 3;
                    this.arrayHSelectType = this.arrayHDeptName;
                    this.HSelectTypeList = this.HDeptNameList;
                } else if (e === '供应商') {
                    this.hform.HSupTypeID = 1;
                    this.arrayHSelectType = [];
                    this.HSelectTypeList = [];
                } else if (e === '客户') {
                    // 客户数据 - 这里留空,后续添加获取客户数据的逻辑
                    this.hform.HSupTypeID = 2;
                    this.arrayHSelectType = this.arrayHSupName;
                    this.HSelectTypeList = this.HSupNameList;
                } else {
                    this.arrayHSelectType = [];
                    this.HSelectTypeList = [];
                }
            },
            //器具信息
            DisBillEntryList() {
                CommonUtils.doRequest(
                    "/MouldController/GetMouldBillEntryTmpList_Json", {
                        HInterID: this.hform.HInterID,
                        HBillNo: this.hform.HBillNo,
                        HBillType: this.hform.HBillType
                    },
                    (res) => {
                        console.log('器具', res.data)
                        var data = res.data.data
                        this.HMouldList = data
                        if(this.HMouldFields.length != res.data.list.length) {
                            this.HMouldFields =  CommonUtils.fieldListFilterRole({
                                FieldList: res.data.list,
                            })
                        }
                        console.log('this.HMouldFields: ',this.HMouldFields);
                        if (data.count == 0) {
                            this.hform.HMouldCount_B = ''
                            this.hform.HMouldID_B = ''
                            this.hform.HMouldName_B = ''
                        } else {
                            this.hform.HMouldCount_B = data[0]['数量']
                            this.hform.HMouldID_B = data[0].HMouldID
                            this.hform.HMouldName_B = data[0]['器具名称']
                            // this.hform.HBarCode_B = data[0]['器具条码']
                        }
                    },
                )
            },
            goBack() {
                uni.showModal({
                    title: '提示',
                    content: '确认要退出当前页面吗?',
                    success: (res) => {
                        if (res.confirm) {
                            console.log('用户点击确定');
                            uni.redirectTo({
                                url: '/pages/MJGL/mujulingliaochukudan/MouldProdOutBillList'
                            })
                        } else if (res.cancel) {
                            console.log('用户点击取消');
                        }
                    }
                });
            },
            ifEdit() {
                this.isEdit = true
                this.hform.eventType = 'Modify'
            },
            //编辑回显
            getEditData(linterid, HBillNo) {
                //主表
                var sWhere = " and hmainid='" + linterid + "'";
                uni.request({
                    url: this.serverUrl + '/Sc_MouldProdOutBill/list_byPage',
                    data: {
                        sWhere: this.sWhere,
                        user: uni.getStorageSync('HUserName'),
                        Organization: uni.getStorageSync('Organization'),
                        page: 1,
                        size: 100
                    },
                    success: (res) => {
                        console.log(1, res.data.data[0]);
                        if (res.data.code == 1) {
                            var data = res.data.data[0]
                            this.btnType = 3
                            this.hform.HInterID = data.hmainid
                            this.hform.HBillNo = data.单据号
                            // this.hform.HBarCode= data.条形码 视图中没有该字段
                            this.hform.HDeptID = data.HDeptID
                            this.hform.HDeptName = data.部门
                            this.hform.HCollectUserName = data.发料人
                            this.hform.HCollectUserID = data.hkeeperid
                            this.hform.HKeeperID = data.hkeeperid
                            this.hform.HSactterUserName = data.领料人
                            this.hform.HSactterUserID = data.hsecmanagerid
                            this.hform.HSecManagerID = data.hsecmanagerid
                            this.hform.HMangerName = data.负责人
                            // this.hform.HRemark= data.表头备注
                            this.hform.HDate = data.日期.substr(0, 10)
                            this.hform.HWHID = data.HWHID,
                                this.hform.HWHName = data.仓库,
                                this.hform.HStockPlaceID = data.HSPID,
                                this.hform.HStockPlaceName = data.仓位,
                                this.hform.Selection = data.往来单位,
                                this.hform.SelectionID = data.HSupID,
                                this.hform.TypeName = data.往来类型名称,
                                this.hform.HSupTypeID = data.往来类型,
                                this.hform.TypeID = data.往来类型,
                                this.hform.HMouldID_B = data.hmaterid,
                                // this.hform.HMouldID_B=data.模具代码,
                                this.hform.HMouldName_B = data.模具名称,
                                // this.hform.HMouldModel=data.模具规格,
                                this.hform.HMouldCount_B = 1,
                                this.hform.HRedBlueFlag = data.红蓝单标记 == '蓝字' ? false : true,
                                this.hform.HStockOrgID = data.HStockOrgID,
                                this.hform.HStockOrgName = data.库存组织,
                                // this.hform.HICMOEntryID=data.HICMOEntryID,
                                // this.hform.HProcExchBillNo=data.HProcExchBillNo,
                                // this.hform.HProcExchInterID=data.HProcExchInterID,
                                // this.hform.HProcExchEntryID=data.HProcExchEntryID,
                                // this.hform.HOrgID=data.HOrgID,
                                this.hform.HMaker = data.制单人
                            //this.hform.HMakeDate= data.制单日期
                            //this.hform.HUpDater= data.修改人
                            //this.hform.HUpDateDate= data.修改日期
                            // this.hform.HChecker= data.审核人
                            // this.hform.HCheckDate= data.审核日期
                            // this.hform.HDeleteMan= data.作废人
                            // this.hform.HDeleteDate= data.作废日期
                        } else {
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            submit() {
                //仓库、仓位、保管、验收、部门、供应商文本框为空时,清空对应ID
                if (!this.hform.HWHName) {
                    this.hform.HWHID = 0
                }
                if (!this.hform.HStockPlaceName) {
                    this.hform.HStockPlaceID = 0
                }
                if (!this.hform.HSactterUserName) {
                    this.hform.HSactterUserID = 0
                } else {
                    this.HSecManagerID = this.hform.HSactterUserID
                }
                if (!this.hform.HCollectUserName) {
                    this.hform.HCollectUserID = 0
                } else {
                    this.HKeeperID = this.hform.HCollectUserID
                }
                if (!this.hform.HDeptName) {
                    this.hform.HDeptID = 0
                }
                if (!this.hform.HSupName) {
                    this.hform.HSupID = 0
                }
                if (this.hform.HInterID == 0 || !this.hform.HInterID) {
                    uni.showToast({
                        title: '单据内码获取失败,错误的单据内码!',
                        icon: 'none'
                    })
                } else if (!this.hform.HBillNo) {
                    uni.showToast({
                        title: '单据号获取失败,错误的单据号!',
                        icon: 'none'
                    })
                } else {
                    if (this.hform.HMouldID_B == 0 || this.hform.HMouldID_B == null) {
                        uni.showToast({
                            title: '没有扫描器具条码,请先扫描器具条码,确认无误后再提交!',
                            icon: 'none'
                        })
                    } else {
                        uni.showLoading({
                            title: '请稍候'
                        })
                        let sMainStr = JSON.stringify(this.hform);
                        console.log("主表:" + sMainStr)
                        CommonUtils.doRequest(
                            '/MouldController/set_SaveMouldProdOutBill_Json', {
                                oMain: sMainStr
                            },
                            (res) => {
                                console.log(1, res);
                                uni.hideLoading()
                                if (res.data.count == 1) {
                                    uni.showModal({
                                        title: '提示',
                                        content: res.data.Message + '。是否继续新增?(点击取消返回上级页面)',
                                        success: (res) => {
                                            if (res.confirm) {
                                                console.log('用户点击确定');
                                                uni.redirectTo({
                                                    url: '/pages/MJGL/mujulingliaochukudan/MouldProdOutBill?OperationType=1'
                                                })
                                            } else if (res.cancel) {
                                                console.log('用户点击取消');
                                                setTimeout(() => {
                                                    uni.navigateBack();
                                                }, 50)
                                            }
                                        }
                                    });
                                } else {
                                    // uni.showToast({
                                    //     title: res.data.Message,
                                    //     icon: 'none'
                                    // })
                                    uni.showModal({
                                        content: res.data.Message,
                                        showCancel: false,
                                        complete() {
                                            uni.hideLoading()
                                        }
                                    })
                                }
                            },
                            null,
                            "POST"
                        )
                    }
                }
            },
            onLoad(e) {
                console.log(e, this.userInfo)
                if (e.linterid) {
                    this.btnType = 3
                    this.linterid = e.linterid
                    this.HBillNo = e.HBillNo
                    this.getEditData(e.linterid, e.HBillNo)
                } else {
                    this.getNewData()
                }
                this.getHBaseList()
                this.getHSupList()
                this.getHEmpList()
                this.getHDeptList()
                //this.getHEmpList()
            }
        }
    }
                        this.showHStockPlaceName = this.HWHNameList[i].HIsStockMgr
                    }
                }
            },
            HStockPlaceNameChange(e) {
                for (var i = 0; i < this.HStockPlaceNameList.length; i++) {
                    if (this.HStockPlaceNameList[i]["HWhName"] == e) {
                        this.hform.HStockPlaceID = this.HStockPlaceNameList[i].HItemID
                        this.hform.HStockPlaceName = this.HStockPlaceNameList[i]["HWhName"]
                    }
                }
            },
            HScatterUserChange(e) {
                for (var i = 0; i < this.HEmpNameList.length; i++) {
                    if (this.HEmpNameList[i].HName == e) {
                        this.hform.HKeeperID = this.HEmpNameList[i].HItemID
                        this.hform.HKeeperName = this.HEmpNameList[i].HName
                    }
                }
            },
            HCollectUserChange(e) {
                for (var i = 0; i < this.HEmpNameList.length; i++) {
                    if (this.HEmpNameList[i].HName == e) {
                        this.hform.HSecManagerID = this.HEmpNameList[i].HItemID
                        this.hform.HSecManagerName = this.HEmpNameList[i].HName
                    }
                }
            },
            /* #region 仓库仓位获取下拉框 */
            getHBaseList() {
                CommonUtils.doRequest(
                    "/Web/GetWarehouseList_Json_New", {
                        Warehouse: "",
                        HOrgID: uni.getStorageSync('OrganizationID')
                    },
                    (res) => {
                        let res1 = res.data
                        let {
                            data,
                            count
                        } = res1
                        if (count == 1) {
                            this.HWHNameList = data
                            for (var i = 0; i < data.length; i++) {
                                this.arrayHWHName[i] = data[i]["HName"]
                            }
                        } else {
                            uni.showToast({
                                title: '仓库数据请求失败',
                                icon: 'none'
                            })
                        }
                    },
                )
                CommonUtils.doRequest(
                    "/WEBSController/GetStockPlaceList_Json", {
                        StockPlace: '',
                        HWhID: this.hform.HWHID,
                        HStockOrgID: uni.getStorageSync('OrganizationID')
                    },
                    (res) => {
                        let res1 = res.data
                        console.log(res1)
                        let {
                            data,
                            count
                        } = res1
                        if (count == 1) {
                            this.HStockPlaceNameList = data
                            for (var i = 0; i < data.length; i++) {
                                this.arrayHStockPlaceName[i] = data[i]["HWhName"]
                            }
                        } else {
                            uni.showToast({
                                title: '仓位数据请求失败',
                                icon: 'none'
                            })
                        }
                    },
                )
            },
            /* #endregion */
            getHEmpList() {
                CommonUtils.doRequest("/Web/GetEmployeeList_Json", {
                        Employee: '',
                        HGroupID: 0
                    },
                    (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: '人员数据请求失败',
                                icon: 'none'
                            })
                        }
                    },
                )
            },
            //获取使用部门数据
            getHDeptList() {
                uni.request({
                    url: this.serverUrl + '/Gy_Department/list',
                    data: {
                        sWhere: "",
                        user: uni.getStorageSync('HUserName'),
                        Organization: uni.getStorageSync('Organization')
                    },
                    success: (res) => {
                        if (res.data.count == 1) {
                            this.HDeptNameList = res.data.data
                            for (var i = 0; i < res.data.data.length; i++) {
                                this.arrayHDeptName[i] = res.data.data[i].部门名称
                            }
                            this.$forceUpdate();
                        } else {
                            uni.showToast({
                                title: '部门数据请求失败',
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            getHCusList() {
                CommonUtils.doRequest(
                    "/Gy_Customer/list", {
                        sWhere: "",
                        user: uni.getStorageSync('HUserName'),
                        Organization: uni.getStorageSync('Organization')
                    },
                    (res) => {
                        let res1 = res.data
                        let {
                            data,
                            count
                        } = res1
                        if (count == 1) {
                            this.HCusNameList = data
                            for (var i = 0; i < data.length; i++) {
                                this.arrayHCusName[i] = data[i].客户名称
                            }
                            this.$forceUpdate();
                        } else {
                            uni.showToast({
                                title: data.Message,
                                icon: 'none'
                            })
                        }
                    }
                )
            },
            getHSupList()
            {
                CommonUtils.doRequest(
                    "/Gy_Supplier/list", {
                        sWhere: "",
                        user: uni.getStorageSync('HUserName'),
                        Organization: uni.getStorageSync('Organization')
                    },
                    (res) => {
                        let res1 = res.data
                        let {
                            data,
                            count
                        } = res1
                        if (count == 1) {
                            this.HSuplierList = data
                            for (var i = 0; i < data.length; i++) {
                                this.arrayHSupplierName[i] = data[i].供应商名称
                            }
                            this.$forceUpdate();
                        } else {
                            uni.showToast({
                                title: data.Message,
                                icon: 'none'
                            })
                        }
                    }
                )
            },
            //选择使用部门
            HDeptNameChange(e) {
                for (var i = 0; i < this.HDeptNameList.length; i++) {
                    if (this.HDeptNameList[i].部门名称 == e) {
                        this.hform.HDeptID = this.HDeptNameList[i].HItemID
                        this.hform.HDeptName = this.HDeptNameList[i].部门名称
                    }
                }
            },
            HDateChange(e) {
                console.log(e.detail.value)
                this.hform.HDate = e.detail.value
            },
            HSelectTypeChange(e)
            {
                this.hform.TypeName=e;
                this.hform.HSupName = ''; // 清空往来单位选择
                this.hform.HSupID = '';
                uni.setStorageSync("typeName_3802",e);
                if(e=='部门')
                {
                    this.hform.HSupTypeID=3;
                    uni.setStorageSync("typeID_3802",3);
                    this.arrayHSelectType = this.arrayHDeptName;
                    this.HSelectTypeList = this.HDeptNameList;
                }
                else if(e === '供应商') {
                    this.hform.HSupTypeID=1;
                    uni.setStorageSync("typeID_3802",1);
                    this.arrayHSelectType = this.arrayHSupplierName;
                    this.HSelectTypeList = this.HSuplierList;
                } else if(e === '客户') {
                // 客户数据 - 这里留空,后续添加获取客户数据的逻辑
                    this.hform.HSupTypeID=2;
                    uni.setStorageSync("typeID_3802",2);
                    this.arrayHSelectType =this.arrayHCusName;
                    this.HSelectTypeList = this.HCusNameList;
                } else {
                    uni.setStorageSync("typeID_3802",0);
                    this.arrayHSelectType = [];
                    this.HSelectTypeList = [];
                }
            },
            //器具信息
            DisBillEntryList() {
                CommonUtils.doRequest(
                    "/MouldController/GetMouldBillEntryTmpList_Json", {
                        HInterID: this.hform.HInterID,
                        HBillNo: this.hform.HBillNo,
                        HBillType: this.hform.HBillType
                    },
                    (res) => {
                        console.log('器具', res.data)
                        var data = res.data.data
                        this.HMouldList = data;
                        if (res.data.count==0) {
                            this.HMouldList = [];
                            this.hform.HMouldCount_B = ''
                            this.hform.HMouldID_B = ''
                            this.hform.HMouldName_B = ''
                        } else {
                            this.hform.HMouldCount_B = data[0].HQty
                            this.hform.HMouldID_B = data[0].HMouldID
                            this.hform.HMouldName_B = data[0].HMouldName
                            this.hform.HBarCode_B=data[0].HBarCode
                        }
                    },
                )
            },
            goBack() {
                uni.showModal({
                    title: '提示',
                    content: '确认要退出当前页面吗?',
                    success: (res) => {
                        if (res.confirm) {
                            console.log('用户点击确定');
                            uni.redirectTo({
                                url: '/pages/MJGL/mujulingliaochukudan/MouldProdOutBillList'
                            })
                        } else if (res.cancel) {
                            console.log('用户点击取消');
                        }
                    }
                });
            },
            ifEdit(){
                this.isEdit = true
                this.hform.eventType = 'Modify'
            },
            //编辑回显
            getEditData(linterid,HBillNo){
                //主表
                var sWhere = " and hmainid='" + linterid + "'";
                uni.request({
                    url: this.serverUrl + '/Sc_MouldProdOutBill/list_byPage',
                    data: { sWhere: this.sWhere,
                        user: uni.getStorageSync('HUserName'),
                        Organization: uni.getStorageSync('Organization'),
                        page:1,
                        size:100 },
                    success: (res) => {
                        console.log(1,res.data.data[0]);
                        if(res.data.code == 1){
                            var data = res.data.data[0]
                            this.btnType=3
                            this.hform.HInterID= data.hmainid
                            this.hform.HBillNo= data.单据号
                            // this.hform.HBarCode= data.条形码 视图中没有该字段
                            this.hform.HDeptID= data.HDeptID
                            this.hform.HDeptName= data.部门
                            this.hform.HSecManagerName= data.领料人
                            this.hform.HSecManagerID= data.hsecmanagerid
                            this.hform.HKeeperID= data.hkeeperid
                            this.hform.HKeeperName= data.发料人
                            // this.hform.HRemark= data.表头备注
                            this.hform.HDate = data.日期.substr(0,10)
                            this.hform.HWHID=data.HWHID,
                            this.hform.HWHName=data.仓库,
                            this.hform.HStockPlaceID=data.HSPID,
                            this.hform.HStockPlaceName=data.仓位,
                            this.hform.HSupName=data.往来单位,
                            this.hform.HSupID=data.HSupID,
                            this.hform.TypeName=data.往来类型名称,
                            this.hform.HSupTypeID=data.往来类型,
                            this.hform.HMouldID_B=data.hmaterid,
                            // this.hform.HMouldID_B=data.模具代码,
                            this.hform.HMouldName_B=data.模具名称,
                            // this.hform.HMouldModel=data.模具规格,
                            this.hform.HMouldCount_B=1,
                            this.hform.HRedBlueFlag=data.红蓝单标记=='蓝字'?false:true,
                            this.hform.HStockOrgID=data.HStockOrgID,
                            this.hform.HStockOrgName=data.库存组织,
                            // this.hform.HICMOEntryID=data.HICMOEntryID,
                            // this.hform.HProcExchBillNo=data.HProcExchBillNo,
                            // this.hform.HProcExchInterID=data.HProcExchInterID,
                            // this.hform.HProcExchEntryID=data.HProcExchEntryID,
                            // this.hform.HOrgID=data.HOrgID,
                            this.hform.HMaker= data.制单人
                            //this.hform.HMakeDate= data.制单日期
                            //this.hform.HUpDater= data.修改人
                            //this.hform.HUpDateDate= data.修改日期
                            // this.hform.HChecker= data.审核人
                            // this.hform.HCheckDate= data.审核日期
                            // this.hform.HDeleteMan= data.作废人
                            // this.hform.HDeleteDate= data.作废日期
                        }else{
                            uni.showToast({
                                title:res.data.Message,
                                icon:'none'
                            })
                        }
                    },
                    fail: (res) => {
                        console.log(res);
                        uni.showToast({
                            title:'接口请求失败',
                            icon:'none'
                        })
                    },
                });
            },
            async submit() {
                //仓库、仓位、保管、验收、部门、供应商文本框为空时,清空对应ID
                if (!this.hform.HWHName) {
                    this.hform.HWHID = 0
                }
                if (!this.hform.HStockPlaceName) {
                    this.hform.HStockPlaceID = 0
                }
                if (!this.hform.HKeeperName) {
                    this.hform.HKeeperID = 0
                }
                if (!this.hform.HSecManagerName) {
                    this.hform.HSecManagerID = 0
                }
                if (!this.hform.HDeptName) {
                    this.hform.HDeptID = 0
                }
                if (!this.hform.HSupName) {
                    this.hform.HSupID = 0
                }
                if (this.hform.HInterID == 0 || !this.hform.HInterID) {
                    uni.showToast({
                        title: '单据内码获取失败,错误的单据内码!',
                        icon: 'none'
                    })
                } else if (!this.hform.HBillNo) {
                    uni.showToast({
                        title: '单据号获取失败,错误的单据号!',
                        icon: 'none'
                    })
                } else {
                    if (this.hform.HMouldID_B == 0||this.hform.HMouldID_B ==null) {
                        uni.showToast({
                            title: '没有扫描器具条码,请先扫描器具条码,确认无误后再提交!',
                            icon: 'none'
                        })
                    } else {
                        uni.showLoading({
                            title: '请稍候'
                        })
                        let sMainStr = JSON.stringify(this.hform);
                        console.log("主表:" + sMainStr)
                        try {
                            let res = await CommonUtils.doRequest2Sync({
                                url: '/MouldController/set_SaveMouldProdOutBill_Json',
                                method: 'POST',
                                data: {
                                   oMain: sMainStr
                                },
                            })
                            if (!res) {
                                return
                            }
                            console.log(1, res);
                            uni.hideLoading()
                            if (res.data.count == 1) {
                                uni.showModal({
                                    title: '提示',
                                    content: res.data.Message + '。是否继续新增?(点击取消返回上级页面)',
                                    success: (res) => {
                                        if (res.confirm) {
                                            console.log('用户点击确定');
                                            uni.redirectTo({
                                                url: '/pages/caigouruku/POStockInBill?OperationType=1'
                                            })
                                        } else if (res.cancel) {
                                            console.log('用户点击取消');
                                            setTimeout(() => {
                                                uni.navigateBack();
                                            }, 50)
                                        }
                                    }
                                });
                            } else {
                                // uni.showToast({
                                //     title: res.data.Message,
                                //     icon: 'none'
                                // })
                                uni.showModal({
                                    content: res.data.Message,
                                    showCancel: false,
                                    complete() {
                                        uni.hideLoading()
                                    }
                                })
                            }
                        } catch (err) {
                            console.warn(err);
                            uni.showToast({
                                title: '接口请求失败:' + err,
                                icon: 'none'
                            })
                        }
                    }
                }
            },
            showBillList() {
                this.$refs.billList.showPopup()
            },
            //选择源单类型
            HMainSourceBillTypeChange(e) {
                this.HMainSourceBillType = this.arrayHMainSourceBillType[e.detail.value]
                let index = this.arrayHMainSourceBillType.findIndex(e => e == this.HMainSourceBillType)
                if (index != -1) {
                    this.hform.HMainSourceBillType = this.arrayHMainSourceBillValue[index]
                    // this.getHYDList()
                }
                console.log(this.hform.HMainSourceBillType)
                uni.setStorageSync("billType_3802",this.hform.HMainSourceBillType);
                uni.setStorageSync("billTypeName_3802",this.HMainSourceBillType);
            },
            //选中源单
            getHBarCodeData(HBarCode) {
                uni.request({
                    url: this.serverUrl + '/MouldController/Get_SourceBarCode_ProdOut_Json',
                    data: {
                        HInterID: this.hform.HInterID,
                        HBillNo: this.hform.HBillNo,
                        HBillType: this.hform.HBillType,
                        HSourceBillNo: HBarCode,
                        HSourceBillType: this.hform.HMainSourceBillType,
                        HMaker: this.hform.HMaker,
                        HStockOrgID: this.hform.HStockOrgID
                    },
                    success: (res) => {
                        if (res.data.count == 1) {
                            var data = res.data.data[0]
                            console.log(2, data);
                            this.hform.HSourceBillNo = data.HSourceBillNo
                            this.showHMainSourceBillType = false
                            //默认非多源单
                            this.showHSourceBillNo = false
                            //设置往来单位
                            this.hform.HSupTypeID = data.HCorrespondentTypeID
                            this.hform.HSupID = data.HCorrespondentID
                            this.hform.HSupName = data.HCorrespondentName
                            if(data.HCorrespondentTypeID==1){
                                this.hform.TypeName = "供应商"
                            }else if(data.HCorrespondentTypeID==2){
                                this.hform.TypeName = "部门"
                            }else{
                                this.hform.TypeName = "客户"
                            }
                            this.tabs = 1
                            CommonUtils.playSound(1)
                            //光标对准条码
                            this.refreshBarCodeState()
                            this.DisBillEntryList()
                        } else {
                            console.log('res.data.Message: ', res.data.Message);
                            CommonUtils.playSound(0)
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
                            })
                        }
                    },
                    fail: (res) => {
                        CommonUtils.playSound(0)
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
                            icon: 'none'
                        })
                    },
                });
            },
            async refreshBarCodeState() {
                this.barCodeFocus = false
                await this.$nextTick(() => {
                    this.barCodeFocus = true
                    this.hform.HBarCode = ""
                })
            },
            delMater(item) {
                if (event && event.target.classList && event.target.classList.contains('link-text')) {
                            return; // 如果是链接点击,不执行删除
                        }
                uni.showModal({
                    title: '提示',
                    content: '确认要删除 "' + item.物料名称 + '" 所有扫码记录?删除后将不可恢复!',
                    success: (res) => {
                        if (res.confirm) {
                            uni.request({
                                url: this.serverUrl +
                                    '/WEBSController/set_DelPonderationBillMain_Temp_InterIDAndSource_Json',
                                data: {
                                    HInterID: this.hform.HInterID,
                                    HMaterID: item.HMaterID,
                                    HAuxPropID: item.HAuxPropID,
                                    HMTONo: item.HMTONo,
                                    HSourceInterID: item.HSourceInterID,
                                    HSourceEntryID: item.HSourceEntryID,
                                    HBillType: this.hform.HBillType
                                },
                                success: (res) => {
                                    if (res.data.count == 1) {
                                        this.DisBillEntryList()
                                    } else {
                                        uni.showToast({
                                            title: res.data.Message,
                                            icon: 'none'
                                        })
                                    }
                                },
                                fail: (res) => {
                                    console.log(res);
                                    uni.showToast({
                                        title: '接口请求失败',
                                        icon: 'none'
                                    })
                                }
                            });
                        }
                    }
                });
            },
            delMater(item) {
                uni.showModal({
                    title: '提示',
                    content: '确认要删除 "' + item.器具号 + '" 所有扫码记录?删除后将不可恢复!',
                    success: (res) => {
                        if (res.confirm) {
                            uni.request({
                                url: this.serverUrl +
                                    '/MouldController/set_DelMouldStockBillMain_Temp_Json',
                                data: {
                                    HInterID: this.hform.HInterID,
                                    HBarCode: item.HBarCode,
                                    HBillType: this.hform.HBillType
                                },
                                success: (res) => {
                                    if (res.data.count == 1) {
                                        this.DisBillEntryList()
                                    } else {
                                        uni.showToast({
                                            title: res.data.Message,
                                            icon: 'none'
                                        })
                                    }
                                },
                                fail: (res) => {
                                    console.log(res);
                                    uni.showToast({
                                        title: '接口请求失败',
                                        icon: 'none'
                                    })
                                }
                            });
                        }
                    }
                });
            },
            onLoad(e) {
                console.log(e, this.userInfo)
                console.log(getUserInfo().HEmpName)
                if(e.linterid){
                    this.btnType = 3
                    this.linterid = e.linterid
                    this.HBillNo = e.HBillNo
                    this.getEditData(e.linterid, e.HBillNo)
                }else{
                    this.getNewData()
                }
                this.getHBaseList()
                this.getHCusList()
                this.getHEmpList()
                this.getHDeptList()
                this.getHSupList()
                setTimeout(() => {
                  this.HSelectTypeChange(this.hform.TypeName)
                  //初始化往来单位
                  if(this.hform.TypeName=='部门')
                  {
                      this.hform.HSupName = getUserInfo().HDept; // 清空往来单位选择
                      this.hform.HSupID = getUserInfo().HDeptID;
                  }
                  else if(this.hform.TypeName === '供应商') {
                      this.hform.HSupName = getUserInfo().HSupName; // 清空往来单位选择
                      this.hform.HSupID = getUserInfo().HSupID;
                  } else if(this.hform.TypeName === '客户') {
                  }
                }, 300);
                uni.$on('BillSelectComplete', (e) => {
                    console.log("接收到的消息: ", e.HBillNo)
                    this.getHBarCodeData(e.HBillNo)
                    this.$refs.billList.exit()
                })
                //this.getHEmpList()
            },
            //重要选择源单必须添加这个否则出现严重bug
            onUnload() {
                uni.$off('BillSelectComplete')
            },
        }
    }
</script>
<style lang="scss" scoped>
    .form {
utils/common.js
@@ -395,10 +395,7 @@
            console.log('播放暂停,销毁');
            innerAudioContext.destroy();
        });
        innerAudioContext.onStop(function() {
            console.log('播放暂停,销毁');
            innerAudioContext.destroy();
        })
    }
    // playSound(e) {
    //     // 全局维护一个音频实例,防止缓存溢出