wtt
2025-09-17 4a1454246bfe04025ffd63fe348e76ef89cb0050
生产领料添加扫码选择源单
1个文件已添加
1个文件已修改
374 ■■■■■ 已修改文件
components/BillListPopup/BillListPopup_Check.vue 310 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/shengchanlingliao/form.vue 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
components/BillListPopup/BillListPopup_Check.vue
New file
@@ -0,0 +1,310 @@
<template>
    <view>
        <uni-popup ref="popup" type="bottom" @change="popupChangeHandler">
            <view class="content">
                <view class="search-condition">
                    <view class="title"><text>单据号: </text></view>
                    <view class="right"><input type="text" v-model="HBillNo" @confirm="getBillList" /></view>
                </view>
                <view class="search-condition">
                    <view class="title"><text>物料: </text></view>
                    <view class="right"><input type="text" :focus="enablefocus" v-model="HMater"
                            @confirm="getBillList" /></view>
                </view>
                <view class="search-condition">
                    <view class="title"><text>关联项: </text></view>
                    <view class="right"><input type="text" v-model="HCustom" @confirm="getBillList" /></view>
                </view>
                <view class="buttons">
                    <view style="flex: 1;"></view>
                    <button size="mini" type="primary" @click="search">搜索</button>
                    <button v-if="MultiSourceBill" size="mini" type="primary" @click="ret">返回</button>
                    <button size="mini" type="primary" @click="exit">退出</button>
                </view>
                <scroll-view id="#BillListPanel" scroll-y="true" style="height: 55vh;">
                    <view class="options-wrapper" v-show="HBillList.length != 0">
                        <uni-card :is-active="bill.isActive" :class="bill.isActive?'uni-card--is-active':''"
                            v-for="(bill, index) in HBillList[curPage-1]" :key="index" :title="bill['物料名称']"
                            :extra="`数量: ${bill['数量']}`" @tap="clickCard(bill['HInterID'], bill['单据号'], index)">
                            <view class="item">
                                <view class="left">单据号: </view>
                                <view class="right">{{bill['单据号']}}</view>
                            </view>
                            <view class="item">
                                <view class="left">物料代码: </view>
                                <view class="right">{{bill['物料代码']}}</view>
                            </view>
                            <!-- <view class="item">
                                <view class="left">物料名称: </view>
                                <view class="right">{{}}</view>
                            </view> -->
                            <view class="item">
                                <view class="left">规格型号: </view>
                                <view class="right">{{bill['规格型号']}}</view>
                            </view>
                            <view class="item" v-if="bill['生产任务单号']">
                                <view class="left">生产订单号: </view>
                                <view class="right">{{bill['生产任务单号']}}</view>
                            </view>
                            <view class="item" v-if="bill['款号']">
                                <view class="left">款号: </view>
                                <view class="right">{{bill['款号']}}</view>
                            </view>
                        </uni-card>
                    </view>
                    <view class="over" v-show="HBillList.length == 0">暂无数据</view>
                </scroll-view>
                <uni-pagination id="#pagination" title="标题文字" v-model="curPage" :pageSize="size"
                    :total="length"></uni-pagination>
            </view>
        </uni-popup>
    </view>
</template>
<script>
    import {
        CommonUtils
    } from '../../utils/common';
    export default {
        name: "BillListPopup_Check",
        data() {
            return {
                enablefocus: false,
                size: 20,
                curPage: 1,
                length: 0,
                page: 0,
                HBillNo: '',
                HMater: this.HMater,
                HCustom: '',
                HBillList: [],
                panelHeight: 0,
                multiSouceBillList: []
            };
        },
        props: {
            HBillType: {
                type: [String, Number],
                required: true
            },
            HStockOrgID: {
                type: [String, Number],
                required: true
            },
            MultiSourceBill: {
                type: Boolean,
                default: false,
                required: false
            },
            HMater:{
                type: [String, Number],
                default: '',
                required: false
            }
        },
        model: {
            prop: "HSourceBill",
            event: 'change'
        },
        methods: {
            popupChangeHandler(e) {
                if (e.show === true) {
                    this.getBillList()
                }
            },
            async exit() {
                this.size = 20
                this.curPage = 1
                this.length = 0
                this.page = 0
                this.HBillNo = ''
                this.HMater = ''
                this.HCustom = ''
                this.HBillList = []
                this.enablefocus = false
                this.multiSouceBillList = []
                // 需要等待页面内的数据赋值完毕
                await this.$nextTick()
                this.$refs.popup.close();
            },
            search() {
                this.getBillList()
            },
            ret() {
                console.log('this.MultiSourceBill: ', this.MultiSourceBill);
                uni.$emit('BillSelectComplete', {
                    HInterID: 0,
                    HBillNo: 0,
                    enableMultiSourceBill: this.MultiSourceBill,
                    MultiSourceBillList: this.multiSouceBillList
                })
            },
            showPopup() {
                this.$refs.popup.open();
            },
            clickCard(interid, billno, index) {
                if (this.MultiSourceBill == false) { // 非多源单模式
                    uni.$emit('BillSelectComplete', {
                        HInterID: interid,
                        HBillNo: billno,
                        enableMultiSourceBill: this.MultiSourceBill
                    })
                } else {
                    this.$set(this.HBillList[this.curPage - 1][index], 'isActive', !this.HBillList[this.curPage - 1][
                        index
                    ]['isActive'])
                    console.log(this.HBillList[this.curPage - 1][index])
                    // 设置了多源单模式
                    this.setMultiSourceBillList({
                        HInterID: interid,
                        HBillNo: billno,
                        HIsActive: this.HBillList[this.curPage - 1][index]['isActive']
                    })
                }
                // this.exit()
            },
            setMultiSourceBillList(billInfo) {
                let index = this.multiSouceBillList.findIndex(item => item.HInterID == billInfo.HInterID)
                if (index == -1) {
                    billInfo['count'] = 1
                    this.multiSouceBillList.push(billInfo)
                } else {
                    if (billInfo.HIsActive) {
                        // 如果对应单据传入的是否激活数是true,则计数器+1
                        this.multiSouceBillList[index]['count']++;
                    } else {
                        // 如果对应单据传入的是否激活数是false,则计数器-1
                        this.multiSouceBillList[index]['count']--;
                    }
                    if(this.multiSouceBillList[index]['count'] == 0){
                        // 没有选中的单据,则移除缓存中的数据
                        this.multiSouceBillList.splice(index, 1)
                    }
                }
                console.log('this.multiSouceBillList: ', this.multiSouceBillList);
            },
            getBillList() {
                this.HBillList = []
                this.length = 0
                this.page = 0
                this.curPage = 1
                CommonUtils.doRequest(
                    "/WEBSController/GetCheckBillList_Json", {
                        HBillType: this.HBillType,
                        HStockOrgID: this.HStockOrgID,
                        HBillNo: this.HBillNo || "",
                        HMater: this.HMater || "",
                        HCustom: this.HCustom || ""
                    },
                    (res) => {
                        let {
                            data,
                            count,
                            Message
                        } = res.data
                        if (count == 1) {
                            this.length = Array.from(data).length
                            const result = [];
                            for (let i = 0; i < data.length; i += this.size) {
                                result.push(data.slice(i, i + this.size));
                            }
                            this.HBillList = result
                            this.page = result.length
                            setTimeout(() => {
                                this.enablefocus = true
                            }, 500)
                        } else {
                            setTimeout(() => {
                                this.enablefocus = true
                            }, 500)
                            uni.showToast({
                                icon: 'none',
                                title: Message
                            })
                        }
                    }
                )
            },
        },
    }
</script>
<style lang="scss">
    .content {
        box-sizing: border-box;
        border-radius: 15rpx 15rpx 0 0;
        padding: 20rpx 20rpx 40rpx 20rpx;
        background-color: #fff;
        display: flex;
        flex-direction: column;
        gap: 10rpx;
        .search-condition {
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 20rpx;
            .title {
                width: 5rem;
                text-align: right;
            }
            .right {
                flex: 1;
                border-radius: 22rpx;
                border: 1px solid #acacac;
                height: auto;
                input {
                    width: 100%;
                    padding: 8rpx 20rpx;
                    font-size: 24rpx;
                }
            }
        }
        .buttons {
            display: flex;
            flex-direction: row;
            gap: 20rpx;
            justify-content: flex-end;
            >button {
                display: inline-flex;
                width: 4rem;
            }
        }
        .options-wrapper {
            padding: 20rpx;
            display: grid;
            grid-template-columns: repeat(1, 1fr);
            gap: 20rpx;
            >view {
                margin: 0 !important;
                box-sizing: border-box;
            }
            .item {
                .left {
                    display: inline-block;
                    width: 6rem;
                }
                .right {
                    display: inline-block;
                }
            }
        }
        .uni-card--is-active {
            background-color: rgba(0, 122, 255, 0.2);
        }
    }
</style>
pages/shengchanlingliao/form.vue
@@ -51,6 +51,16 @@
                        style="margin-left: 10rpx;background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;"
                        size="20" @click="toScanCode"></uni-icons>
                </view>
                <view class="form-item" v-show="showHBillNo">
                    <view class="title">单据号(物料):</view>
                    <view class="right" style="width: 380rpx;">
                        <input name="HBillNoMater" :focus="HBillNoFocusMater" v-model="HBillNoMater" placeholder="请扫描(或输入)条码"
                            @confirm="showBillList()" />
                    </view>
                    <uni-icons type="scan"
                        style="margin-left: 10rpx;background-color: #3A78FF;padding: 6rpx;color: #fff;border-radius: 100%;"
                        size="20" @click="toScanCodeMater"></uni-icons>
                </view>
                <view class="form-item" v-show="!showHBillNo">
                    <view class="title">单据号:</view>
                    <view class="righton">
@@ -175,10 +185,13 @@
                <button class="btn-c" size="mini" @tap="goBack">退出</button>
            </view>
        </view>
        <BillListPopupVue ref="billList" :HBillType="hform.HBillType" :HMater='HBillNoMater'
            :HStockOrgID="hform.HStockOrgID" :MultiSourceBill="false"></BillListPopupVue>
    </view>
</template>
<script>
    import getDateTime from '@/utils/getdateTime.js';
    import BillListPopupVue from '../../components/BillListPopup/BillListPopup_Check.vue';
    import {
        getUserInfo
    } from "@/utils/auth.js";
@@ -195,6 +208,8 @@
                OperationType: 1,
                HBillNoFocus: false,
                HBillNoFocusMater:false,
                HBillNoMater:'',
                showHBillNo: true,
                tabs: 1,
                linterid: '',
@@ -242,6 +257,9 @@
                }
            }
        },
        components:{
            BillListPopupVue
        },
        onLoad(e) {
            console.log(e, this.userInfo)
            this.OperationType = e.OperationType
@@ -253,6 +271,29 @@
                this.refreshHBillNoFocus()
            }
            this.getHBaseList()
            uni.$on('BillSelectComplete', async (e) => {
                console.log("接收到的消息: ", e)
                console.log("是否应用多源单: ", e.enableMultiSourceBill)
                if(e.enableMultiSourceBill){
                    for(let item of e.MultiSourceBillList) {
                        try{
                            this.hform.HBillNo = e.HBillNo
                            await this.GetMeesageByBillNo()
                        }catch {
                            return
                        }
                    }
                    this.$refs.billList.exit()
                    // if(e.MultiSourceBillList.length != 0){
                    //      this.showHSourceBillNo = false
                    // }
                }else {
                    this.hform.HBillNo = e.HBillNo
                    this.GetMeesageByBillNo()
                    this.$refs.billList.exit()
                }
            })
        },
        methods: {
            toScanCode2() {
@@ -848,7 +889,28 @@
                        }
                    }
                });
            }
            },
            //单据查询列表显示
            showBillList(){
                this.$refs.billList.showPopup()
            },
            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.HBillNoMater = ret.resp_result
                    this.$refs.billList.showPopup()
                })
            },
        }
    }
</script>