zrg
2026-03-12 e58a76edc522beafd461b6d5158499ff2d9e13cf
pages/caigouruku/POStockInBill.vue
@@ -2,7 +2,8 @@
    <view>
        <view class="form">
            <view class="form-item">
                <view class="title">条码:</view>
                <!-- <view class="title">条码:</view> -->
                <view class="title">{{ $t(`Gy.HBarCode`) == "Gy.HBarCode"?"条码": $t(`Gy.HBarCode`) }}:</view>
                <view class="right" style="width: 380rpx;">
                    <input :focus="barCodeFocus" v-model="hform.HBarCode" placeholder="请扫描(或输入)条码"
                        @confirm="getCode(hform.HBarCode)" />
@@ -12,39 +13,51 @@
                    size="20" @click="toScanCode"></uni-icons>
            </view>
            <view class="form-item">
                <view class="title">数量:</view>
                <view class="title">{{ $t(`Gy.HQty`) == "Gy.HQty"?"数量": $t(`Gy.HQty`) }}:</view>
                <view class="right">
                    <input v-model="hform.HQty" placeholder="请输入数量" />
                </view>
            </view>
            <view class="form-item">
                <view class="title">仓库:</view>
                <view class="title">{{ $t(`Gy.HWHName`) == "Gy.HWHName"?"仓库": $t(`Gy.HWHName`) }}:</view>
                <view class="right">
                    <uni-combox :candidates="arrayHWHName" placeholder="请输入(或扫描)仓库" v-model="hform.HWHName"
                        @input="HWHNameChange" @confirm="HWHNameScan"></uni-combox>
                    <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">
                <view class="title">
                    {{ $t(`Gy.HStockPlaceName`) == "Gy.HStockPlaceName"?"仓位": $t(`Gy.HStockPlaceName`) }}:
                </view>
                <view class="right" v-show="true">
                    <uni-combox :candidates="arrayHStockPlaceNameComputed" placeholder="请输入(或扫描)仓位"
                        v-model="hform.HStockPlaceName" @input="HStockPlaceNameChange"
                        @confirm="HStockPlaceNameScan"></uni-combox>
                </view>
                <view class="righton" v-show="!showHStockPlaceName"><input v-model="hform.HStockPlaceName"
                        placeholder="不可操作" :disabled="!showHStockPlaceName" /></view>
                <view class="righton" v-show="false"><input v-model="hform.HStockPlaceName" placeholder="不可操作"
                        :disabled="!showHStockPlaceName" /></view>
            </view>
            <view class="tabs">
                <view :class="tabs == 0 ? 'on':''" @tap="tabs = 0">选择源单</view>
                <view :class="tabs == 1 ? 'on':''" @tap="tabs = 1">表头信息</view>
                <view :class="tabs == 2 ? 'on':''" @tap="tabs = 2">物料信息</view>
                <view :class="tabs == 3 ? 'on':''" @tap="tabs = 3">条码信息</view>
                <view :class="tabs == 0 ? 'on':''" @tap="tabs = 0">
                    {{ $t(`Gy.SourceBillSelect`) == "Gy.SourceBillSelect"?"选择源单": $t(`Gy.SourceBillSelect`) }}
                </view>
                <view :class="tabs == 1 ? 'on':''" @tap="tabs = 1">
                    {{ $t(`Gy.TableHeaderInfo`) == "Gy.TableHeaderInfo"?"表头信息": $t(`Gy.TableHeaderInfo`) }}
                </view>
                <view :class="tabs == 2 ? 'on':''" @tap="tabs = 2">
                    {{ $t(`Gy.MaterInfo`) == "Gy.MaterInfo"?"物料信息": $t(`Gy.MaterInfo`) }}
                </view>
                <view :class="tabs == 3 ? 'on':''" @tap="tabs = 3">
                    {{ $t(`Gy.BarCodeInfo`) == "Gy.BarCodeInfo"?"条码信息": $t(`Gy.BarCodeInfo`) }}
                </view>
            </view>
            <view v-if="tabs == 0">
                <view class="form-item">
                    <view class="title">源单类型:</view>
                    <view class="title">
                        {{ $t(`Gy.HMainSourceBillType`) == "Gy.HMainSourceBillType"?"源单类型": $t(`Gy.HMainSourceBillType`) }}:
                    </view>
                    <view class="right" v-show="showHMainSourceBillType">
                        <picker :range="arrayHMainSourceBillType" v-model="HMainSourceBillType"
                            @change="HMainSourceBillTypeChange">
@@ -59,7 +72,9 @@
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">源单单号:</view>
                    <view class="title">
                        {{$t(`Gy.HMainSourceBillNo`) == "Gy.HMainSourceBillNo"?"源单单号": $t(`Gy.HMainSourceBillNo`) }}:
                    </view>
                    <view class="right" v-show="showHSourceBillNo">
                        <!-- <uni-combox v-if="reHSourceBillNo" :candidates="arrayHSourceBillNo" placeholder="请输入源单单号"
                     v-model="hform.HSourceBillNo" @input="HSourceBillNoChange"></uni-combox> -->
@@ -85,7 +100,7 @@
               </view> -->
                </view>
                <view class="form-item">
                    <view class="title">日期:</view>
                    <view class="title">{{ $t(`Gy.HDate`) == "Gy.HDate"?"日期": $t(`Gy.HDate`) }}:</view>
                    <view class="right">
                        <picker mode="date" v-model="hform.HDate" @change="HDateChange">
                            <input disabled v-model="hform.HDate" placeholder="请选择日期" />
@@ -94,13 +109,13 @@
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">制单人:</view>
                    <view class="title">{{ $t(`Gy.HMaker`) == "Gy.HMaker"?"制单人": $t(`Gy.HMaker`) }}:</view>
                    <view class="righton">
                        <input name="HMaker" disabled v-model="hform.HMaker" />
                    </view>
                </view>
                <view class="form-item">
                    <view class="title">单据号:</view>
                    <view class="title">{{ $t(`Gy.HBillNo`) == "Gy.HBillNo"?"单据号": $t(`Gy.HBillNo`) }}:</view>
                    <view class="righton">
                        <input name="HBillNo" disabled v-model="hform.HBillNo" />
                    </view>
@@ -158,7 +173,12 @@
            <view v-if="tabs == 2">
                <view class="list" v-for="(item,index) in Materlist" :key="index">
                    <uni-card :title="item.物料名称" :extra="item.物料代码" style="margin: 10px;" @tap="delMater(item)">
                    <uni-card :title="item.物料名称" style="margin: 10px;" @tap="delMater(item, $event)">
                        <!-- 物料代码作为可点击链接 -->
                        <view class="card-header" @tap.stop="gotoInventoryQuery(item.物料代码)">
                            <text class="link-text">物料代码:{{item.物料代码}}</text>
                        </view>
                        <view class="card-detail">
                            <view class="detail">
                                <text>源单单号:</text>{{item.源单单号}}
@@ -187,8 +207,7 @@
                            <view class="detail" v-if="item.单价">
                                <text>单价:</text>{{item.单价}}
                            </view>
                            <view class="detail" v-if="materMeta[0].HWHName && /兴达/.test(hform.HStockOrgName
                            )">
                            <view class="detail" v-if="materMeta[0].HWHName && /兴达/.test(hform.HStockOrgName)">
                                <text>仓库:</text>{{materMeta[0].HWHName}}
                            </view>
                        </view>
@@ -348,11 +367,11 @@
                    HBillNo: '',
                    HInterID: '',
                    HKeeperName: getUserInfo().HKeeper,
                    HKeeperName: getUserInfo().HKeeperName,
                    HKeeperID: getUserInfo().HKeeperID,
                    HSecManagerName: getUserInfo().HSecManager,
                    HSecManagerName: getUserInfo().HSecManagerName,
                    HSecManagerID: getUserInfo().HSecManagerID,
                    HDeptName: getUserInfo().HDept,
                    HDeptName: getUserInfo().HDeptName,
                    HDeptID: getUserInfo().HDeptID,
                    HSupName: '',
                    HSupID: '',
@@ -420,6 +439,7 @@
        },
        methods: {
            async HWHNameScan(e) {
                return
                // 扫描仓库码
                console.log('仓库码: ', e);
                let index = this.HWHNameList.findIndex(elem => elem['条码编号'] == e)
@@ -434,20 +454,38 @@
            },
            async HStockPlaceNameScan(e) {
                // 扫描仓位码
                console.log('仓位码: ', e);
                let index = this.HStockPlaceNameList.findIndex(elem => elem['条码编号'] == e)
                console.log('index: ', index);
                console.log('Code: ', e);
                // 不先置空的话,数据再次扫描相同的仓位码 不会触发组件内的刷新
                this.hform.HStockPlaceID = 0
                this.hform.HStockPlaceName = ''
                await this.$nextTick()
                if (index == -1) {
                    uni.showToast({
                        icon: 'none',
                        title: '扫描仓位条码对应的仓位不存在...'
                try {
                    let res = await CommonUtils.doRequest2Async({
                        url: '/Gy_StockPlace/list',
                        data: {
                            sWhere: ` and 条码编号 = '${e}'`,
                            user: uni.getStorageSync('HUserName'),
                            Organization: uni.getStorageSync('Organization')
                        },
                    })
                } else {
                    this.HStockPlaceNameChange(this.HStockPlaceNameList[index]['仓位名称'])
                    if (res.data.count == 1) {
                        this.hform.HStockPlaceID = res.data.data[0].HMainID
                        this.hform.HStockPlaceName = res.data.data[0].仓位名称
                        this.hform.HWHID = res.data.data[0].HWHID
                        this.hform.HWHName = res.data.data[0].所属仓库
                    } else {
                        uni.showToast({
                            title: '仓位数据请求失败',
                            icon: 'none'
                        })
                    }
                } catch (err) {
                    uni.showToast({
                        title: '仓位数据请求失败',
                        icon: 'none'
                    })
                }
            },
            async qrCodeDisplay() {
@@ -499,15 +537,7 @@
                    this.hform.HBarCode = ""
                })
            },
            playSound(e) {
                const innerAudioContext = uni.createInnerAudioContext();
                if (e == 1) {
                    innerAudioContext.src = '/static/success.wav';
                } else {
                    innerAudioContext.src = '/static/jingbao.wav';
                }
                innerAudioContext.play(); // 播放音频
            },
            //扫码
            toScanCode() {
                var mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
@@ -607,7 +637,7 @@
            },
            async onSourceBillBlurHandler() {
                if (this.hform.HMainSourceBillType == -1) {
                    this.playSound(1)
                    CommonUtils.playSound(1)
                    this.barCodeFocus = true
                    return
                }
@@ -648,6 +678,7 @@
                            for (var i = 0; i < res.data.data.length; i++) {
                                this.arrayHWHName[i] = res.data.data[i].仓库名称
                            }
                            this.HWHNameChange(getUserInfo()["HWhName"])
                        } else {
                            uni.showToast({
                                title: '仓库数据请求失败',
@@ -781,13 +812,11 @@
                    if (this.HWHNameList[i].仓库名称 == e) {
                        this.hform.HWHName = this.HWHNameList[i].仓库名称
                        this.hform.HWHID = this.HWHNameList[i].HItemID
                        this.HStockPlaceNameChange(null)
                        this.showHStockPlaceName = false
                        if (this.HWHNameList[i]['启用仓位'] == 'Y') {
                            this.showHStockPlaceName = true
                            this.getStockPlaceRemote(this.HWHNameList[i]["HSPGroupID"])
                        } else {
                            this.hform.HStockPlaceName = ''
                            this.showHStockPlaceName = false
                        }
                    }
                }
@@ -955,7 +984,8 @@
                    url: this.serverUrl + '/Web/GetEmployeeList_Json',
                    data: {
                        Employee: '',
                        HGroupID: 0
                        HGroupID: 0,
                        HDeptID: uni.getStorageSync("HDeptID")
                    },
                    success: (res) => {
                        if (res.data.count == 1) {
@@ -1030,12 +1060,12 @@
                            this.tabs = 2
                            this.showHSupName = false
                            this.barCodeFocus = true
                            this.playSound(1)
                            CommonUtils.playSound(1)
                            this.DisBillEntryList()
                        } else {
                            console.log('res.data.Message: ', res.data.Message);
                            this.refreshHSourceBillState()
                            this.playSound(0)
                            CommonUtils.playSound(0)
                            uni.showToast({
                                title: res.data.Message,
                                icon: 'none'
@@ -1044,7 +1074,7 @@
                    },
                    fail: (res) => {
                        this.refreshHSourceBillState()
                        this.playSound(0)
                        CommonUtils.playSound(0)
                        console.log(res);
                        uni.showToast({
                            title: '接口请求失败',
@@ -1075,7 +1105,7 @@
                console.log(this.hform.HSourceBillNo, HSourceFlag)
                if (HDeleteFlag == "*") {
                    if (sBarCode == "") {
                        this.playSound(0)
                        CommonUtils.playSound(0)
                        this.refreshBarCodeState()
                        uni.showToast({
                            title: '请输入要删除的条码',
@@ -1099,11 +1129,11 @@
                            console.log('删除条码', res.data);
                            this.hform.HBarCode = ''
                            if (res.data.count == 1) {
                                this.playSound(1)
                                CommonUtils.playSound(1)
                                this.hform.HQty = ''
                                this.DisBillEntryList()
                            } else {
                                this.playSound(0)
                                CommonUtils.playSound(0)
                                this.refreshBarCodeState()
                                uni.showToast({
                                    title: res.data.Message,
@@ -1112,7 +1142,7 @@
                            }
                        } catch (err) {
                            this.refreshBarCodeState()
                            this.playSound(0)
                            CommonUtils.playSound(0)
                            uni.showToast({
                                title: '接口请求失败: ' + err,
                                icon: 'none'
@@ -1132,11 +1162,11 @@
                        //         console.log('删除条码', res.data);
                        //         this.hform.HBarCode = ''
                        //         if (res.data.count == 1) {
                        //             this.playSound(1)
                        //             CommonUtils.playSound(1)
                        //             this.hform.HQty = ''
                        //             this.DisBillEntryList()
                        //         } else {
                        //             this.playSound(0)
                        //             CommonUtils.playSound(0)
                        //             this.refreshBarCodeState()
                        //             uni.showToast({
                        //                 title: res.data.Message,
@@ -1147,7 +1177,7 @@
                        //     fail: (res) => {
                        //         console.log(res);
                        //         this.refreshBarCodeState()
                        //         this.playSound(0)
                        //         CommonUtils.playSound(0)
                        //         uni.showToast({
                        //             title: '接口请求失败',
                        //             icon: 'none'
@@ -1191,7 +1221,7 @@
                        console.log('扫码返回', res.data);
                        this.hform.HBarCode = ''
                        if (res.data.count == 1) {
                            this.playSound(1)
                            CommonUtils.playSound(1)
                            var data = res.data.data
                            if (data.hBarTypeField == '仓库条码') {
                                this.hform.HWHName = data.hWhNameField
@@ -1297,7 +1327,7 @@
                            //光标对准条码
                            this.refreshBarCodeState()
                        } else {
                            this.playSound(0)
                            CommonUtils.playSound(0)
                            this.refreshBarCodeState()
                            uni.showToast({
                                title: res.data.Message,
@@ -1306,7 +1336,7 @@
                        }
                    } catch (err) {
                        this.playSound(0)
                        CommonUtils.playSound(0)
                        this.refreshBarCodeState()
                        console.log(res);
                        uni.showToast({
@@ -1339,7 +1369,7 @@
                    //         console.log('扫码返回', res.data);
                    //         this.hform.HBarCode = ''
                    //         if (res.data.count == 1) {
                    //             this.playSound(1)
                    //             CommonUtils.playSound(1)
                    //             var data = res.data.data
                    //             if (data.hBarTypeField == '仓库条码') {
                    //                 this.hform.HWHName = data.hWhNameField
@@ -1448,7 +1478,7 @@
                    //             //光标对准条码
                    //             this.refreshBarCodeState()
                    //         } else {
                    //             this.playSound(0)
                    //             CommonUtils.playSound(0)
                    //             this.refreshBarCodeState()
                    //             uni.showToast({
                    //                 title: res.data.Message,
@@ -1457,7 +1487,7 @@
                    //         }
                    //     },
                    //     fail: (res) => {
                    //         this.playSound(0)
                    //         CommonUtils.playSound(0)
                    //         this.refreshBarCodeState()
                    //         console.log(res);
                    //         uni.showToast({
@@ -1527,7 +1557,30 @@
                    },
                });
            },
            gotoInventoryQuery(HMaterNumber) {
                console.log('跳转到库存查询,物料代码:', HMaterNumber);
                // 使用uni.navigateTo跳转到新页面
                uni.navigateTo({
                    url: `/pages/jishikucunchaxun/table?OperationType=2&HMaterNumber=${HMaterNumber}`,
                    success: (res) => {
                        console.log('跳转成功');
                    },
                    fail: (err) => {
                        console.error('跳转失败:', err);
                        // 如果页面不存在,可以跳转到默认页面
                        uni.showToast({
                            title: '功能正在开发中',
                            icon: 'none'
                        });
                    }
                });
            },
            delMater(item) {
                if (event && event.target.classList && event.target.classList.contains('link-text')) {
                    return; // 如果是链接点击,不执行删除
                }
                uni.showModal({
                    title: '提示',
                    content: '确认要删除 "' + item.物料名称 + '" 所有扫码记录?删除后将不可恢复!',
@@ -2006,6 +2059,12 @@
        }
    }
    /* 添加链接样式 */
    .link-text {
        color: #3a78ff;
        /* 蓝色,类似超链接 */
    }
    .list {
        width: 100%;
@@ -2027,6 +2086,7 @@
                    color: #999;
                    font-size: 26rpx;
                }
            }
        }