修复 foreach循环 发送请求时,可能会导致死锁的问题,切换成for...of 加 同步请求
2个文件已修改
100 ■■■■ 已修改文件
components/BillListPopup/BillListPopup.vue 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/shengchanlingliaoshengdan/form.vue 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
components/BillListPopup/BillListPopup.vue
@@ -4,25 +4,27 @@
            <view class="content">
                <view class="search-condition">
                    <view class="title"><text>源单单号: </text></view>
                    <view class="right"><input type="text" v-model="HSourceBillNo" /></view>
                    <view class="right"><input type="text" v-model="HSourceBillNo" @confirm="getBillList" /></view>
                </view>
                <view class="search-condition">
                    <view class="title"><text>物料: </text></view>
                    <view class="right"><input type="text" v-model="HMater" /></view>
                    <view class="right"><input auto-focus type="text" 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" /></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 v-for="(bill, index) in HBillList[curPage-1]" :key="index" :title="bill['物料名称']"
                            :extra="`数量: ${bill['数量']}`" @tap="clickCard(bill['HSourceInterID'], bill['单据号'])">
                        <uni-card :is-active="bill.isActive" v-for="(bill, index) in HBillList[curPage-1]" :key="index"
                            :title="bill['物料名称']" :extra="`数量: ${bill['数量']}`"
                            @tap="clickCard(bill['HSourceInterID'], bill['单据号'], index)">
                            <view class="item">
                                <view class="left">单据号: </view>
                                <view class="right">{{bill['单据号']}}</view>
@@ -68,6 +70,8 @@
                HCustom: '',
                HBillList: [],
                panelHeight: 0,
                multiSouceBillList: []
            };
        },
        props: {
@@ -83,6 +87,11 @@
                type: [String, Number],
                required: true
            },
            MultiSourceBill: {
                type: Boolean,
                default: false,
                required: false
            }
        },
        model: {
            prop: "HSourceBill",
@@ -110,15 +119,45 @@
            search() {
                this.getBillList()
            },
            ret() {
                uni.$emit('BillSelectComplete', {
                    HInterID: 0,
                    HBillNo: 0,
                    enableMultiSourceBill: this.MultiSourceBill,
                    MultiSourceBillList: this.multiSouceBillList
                })
            },
            showPopup() {
                this.$refs.popup.open();
            },
            clickCard(interid, billno) {
            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
                })
                }
                // this.exit()
            },
            setMultiSourceBillList(billInfo) {
                let index = this.multiSouceBillList.findIndex(item => item.HInterID == billInfo.HInterID)
                if (index == -1) {
                    this.multiSouceBillList.push(billInfo)
                } else {
                    this.multiSouceBillList.splice(index, 1)
                }
            },
            getBillList() {
                this.HBillList = []
@@ -141,7 +180,6 @@
                            Message
                        } = res.data
                        if (count == 1) {
                            console.log(data)
                            this.length = Array.from(data).length
                            const result = [];
                            for (let i = 0; i < data.length; i += this.size) {
@@ -232,5 +270,9 @@
                }
            }
        }
        .uni-card[is-active] {
           background-color: rgba(0, 122, 255, 0.2);
        }
    }
</style>
pages/shengchanlingliaoshengdan/form.vue
@@ -280,7 +280,7 @@
            </view>
        </view>
        <BillListPopupVue ref="billList" :HBillType="hform.HBillType" :HSourceBillType="hform.HMainSourceBillType"
            :HStockOrgID="hform.HStockOrgID"></BillListPopupVue>
            :HStockOrgID="hform.HStockOrgID" :MultiSourceBill="enableMultiSourceBill"></BillListPopupVue>
        <BarCodePopupVue ref="barcodePopup"></BarCodePopupVue>
    </view>
</template>
@@ -409,14 +409,44 @@
            
            this.getRelationStore()
            uni.$on('BillSelectComplete', (e) => {
                console.log("接收到的消息: ", e.HBillNo)
            uni.$on('BillSelectComplete', async (e) => {
                console.log("接收到的消息: ", e)
                console.log("是否应用多源单: ", e.enableMultiSourceBill)
                if(e.enableMultiSourceBill){
                    for(let item of e.MultiSourceBillList) {
                        try{
                            await this.getHBarCodeData(item.HBillNo)
                        }catch {
                            return
                        }
                    }
                    this.$refs.billList.exit()
                    if(e.MultiSourceBillList.length != 0){
                         this.showHSourceBillNo = false
                    }
                }else {
                this.getHBarCodeData(e.HBillNo)
                this.$refs.billList.exit()
                }
            })
        },
        onUnload() {
            uni.$off('BillSelectComplete')
        },
        computed: {
            enableMultiSourceBill: {
                get() {
                    if(uni.getStorageSync("Organization").includes("海诚") && this.hform.HMainSourceBillType ==  3720){
                        return true
                    }
                    return false
                }
            }
        },
        methods: {
            async qrCodeDisplay() {
@@ -909,10 +939,11 @@
                }
            },
            //选中源单
            getHBarCodeData(HBarCode) {
            async getHBarCodeData(HBarCode) {
                if (!this.hform.HFIFOWHName) {
                    this.hform.HFIFOWHID = 0
                }
                return new Promise((resolve, reject) => {
                uni.request({
                    url: this.serverUrl + '/WEBSController/get_SourceBarCode_MateOut_Json',
                    data: {
@@ -947,6 +978,7 @@
                            this.barCodeFocus = true
                            this.playSound(1)
                            this.DisBillEntryList()
                                resolve()
                        } else {
                            this.playSound(0)
                            this.refreshHSourceBillState()
@@ -954,6 +986,7 @@
                                title: res.data.Message,
                                icon: 'none'
                            })
                                reject()
                        }
                    },
                    fail: (res) => {
@@ -964,8 +997,11 @@
                            title: '接口请求失败',
                            icon: 'none'
                        })
                            reject()
                    },
                });
                })
            },
            //扫条码处理
            getCode(HBarCode) {