chenhaozhe
2026-01-21 84bc1af19f5dded03d1bbdf89be546b35bf115b9
src/views/logistics/transportGPS/Add_Edit_WL_YayBill.vue
@@ -54,7 +54,7 @@
                                <el-form-item label="始发地" prop="HBeginAddrName">
                                    <el-input v-model="form.HBeginAddrName" placeholder="请输入始发地">
                                        <el-button slot="append" icon="el-icon-search"
                                            @click="openDataDialog('暂无')"></el-button>
                                            @click="openDataDialog(3, areaType = 'b')"></el-button>
                                    </el-input>
                                </el-form-item>
                            </el-col>
@@ -62,7 +62,7 @@
                                <el-form-item label="目的地" prop="HEndAddrName">
                                    <el-input v-model="form.HEndAddrName" placeholder="请输入目的地">
                                        <el-button slot="append" icon="el-icon-search"
                                            @click="openDataDialog('暂无')"></el-button>
                                            @click="openDataDialog(3, areaType = 'e')"></el-button>
                                    </el-input>
                                </el-form-item>
                            </el-col>
@@ -434,7 +434,9 @@
                            </el-table-column>
                            <el-table-column align="center" label="器具代码" width="120">
                                <template slot-scope="scope">
                                    <el-input v-model="scope.row.HMouldNumber" placeholder="请输入器具代码" />
                                    <el-input v-model="scope.row.HMouldNumber" placeholder="请输入器具代码"
                                        @keyup.native.f7="openDataDialog(8, scope.row)"
                                        @dblclick.native="openDataDialog(8, scope.row)" />
                                </template>
                            </el-table-column>
                            <el-table-column align="center" label="器具名称" width="120">
@@ -476,7 +478,8 @@
                            <el-table-column align="center" label="物料数量" width="120">
                                <template slot-scope="scope">
                                    <el-input-number v-model="scope.row.HQty" :min="0" style="width: 90px;"
                                        controls-position="right"></el-input-number>
                                        controls-position="right"
                                        @change="checkTotalQtyExceed(scope.row)"></el-input-number>
                                </template>
                            </el-table-column>
                            <el-table-column align="center" label="体积" width="120">
@@ -513,11 +516,13 @@
                    :propsHOrgID="form.HOrgID" v-if="xsSeOutStockBillShow" />
                <GyCustomer @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" v-if="gyCustomerShow" />
                <GySupplier @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" v-if="gySupplierShow" />
                <GyCartype @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" v-if="gyCartypeShow" />
                <GyCartype @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" :volume="form.HCarTypeMaxVolume" v-if="gyCartypeShow" />
                <GyCar @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" v-if="gyCarShow" />
                <GyDriver @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" v-if="gyDriverShow" />
                <ContractTransport @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName"
                    v-if="ContractTransportShow" />
                <GyMould @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" v-if="gyMouldShow" />
                <AreaDialog @deptEmitDb="dbEmitData" @deptEmit="emitData" :openPage="HModName" :HBeginAddrName="form.HBeginAddrName" :HEndAddrName="form.HEndAddrName"  v-if="AreaDialogShow" />
                <div slot="footer" class="dialog-footer">
                    <el-button type="primary" @click="deptClickSub">确 定</el-button>
                    <el-button @click="deptClose">取 消</el-button>
@@ -545,9 +550,11 @@
import GyCar from "@/views/basic/gyCar/gyCarList.vue"
import GyDriver from "@/views/system/user/GyDriver.vue"
import ContractTransport from "@/views/basic/gytransport/cgContractTransportBillList/Cg_ContractTransportBillList.vue"
import GyMould from '@/views/scMould/basicModeling/Gy_MouldFileList.vue'
import AreaDialog from "@/views/component/AreaDialog"
export default {
    name: 'SellOutBill',
    components: { Dept, Warehouse, Material, RowSettings, XsSeOutStockBill, GyCustomer, GySupplier, GyCartype, GyCar, GyDriver, ContractTransport },
    components: { Dept, Warehouse, Material, RowSettings, XsSeOutStockBill, GyCustomer, GySupplier, GyCartype, GyCar, GyDriver, ContractTransport, GyMould, AreaDialog },
    props: {
        OperationType: { type: Number, },
        linterid: { type: Number, },
@@ -588,7 +595,10 @@
            gyCarShow: false,                                                          //车辆数据组件显示标记
            gyDriverShow: false,                                                       //司机数据组件显示标记
            ContractTransportShow: false,                                              //承运合同数据组件显示标记
            gyMouldShow: false,                                                       //容器数据组件显示标记
            AreaDialogShow: false,                                                    //目的地数据组件显示标记
            deptform: {},                                                              //弹窗选中数据
            areaType: '',//地区选择类型
            temp: undefined,                                                           //临时变量
            btResList: [],                                                             // 列设置
@@ -1050,8 +1060,8 @@
                this.warehouseShow = true
                this.openData = true
            } else if (num == 3) {
                this.dialogTitle = '物料列表'
                this.materialShow = true
                this.dialogTitle = '地区列表'
                this.AreaDialogShow = true;
                this.openData = true
            } else if (num == 4) {
                this.dialogTitle = '仓位列表'
@@ -1064,6 +1074,10 @@
            } else if (num == 7) {
                this.dialogTitle = '客户列表'
                this.gyCustomerShow = true
                this.openData = true
            } else if (num == 8) {
                this.dialogTitle = '容器列表'
                this.gyMouldShow = true
                this.openData = true
            } else if (num == 12) {
                this.dialogTitle = '源单列表'
@@ -1099,6 +1113,7 @@
            this.gyCarShow = false
            this.gyDriverShow = false
            this.ContractTransportShow = false
            this.gyMouldShow = false
        },
        //#endregion
        //#endregion
@@ -1119,15 +1134,15 @@
                this.editData[this.zbIndex].HSPID = deptRow.HItemID;
                this.editData[this.zbIndex].仓位名称 = deptRow.仓位名称;
                this.openData = false
            } else if (num == 3) {                                                      //物料
                this.editData[this.zbIndex].HMaterID = deptRow.HItemID;
                this.editData[this.zbIndex].物料代码 = deptRow.物料代码;
                this.editData[this.zbIndex].物料名称 = deptRow.物料名称;
                this.editData[this.zbIndex].HUnitID = deptRow.HUnitID;
                this.editData[this.zbIndex].规格型号 = deptRow.规格型号
                this.editData[this.zbIndex].计量单位 = deptRow.计量单位名称
                this.editData[this.zbIndex].HTaxPrice = deptRow.含税成本价
                this.editData[this.zbIndex].HTaxRate = deptRow.默认税率
            } else if (num == 3) {                                                      //地区
                if (this.areaType == 'b') {
                    this.form.HBeginAddrName = deptRow.地区名称
                    this.form.HBeginAddr = deptRow.HItemID
                } else if (this.areaType == 'e') {
                    this.form.HEndAddrName = deptRow.地区名称
                    this.form.HEndAddr = deptRow.HItemID
                }
                this.AreaDialogShow = false;
                this.openData = false
            } else if (num == 6) {
                this.form.HCarrierName = deptRow.供应商名称
@@ -1139,6 +1154,16 @@
                this.form.HCusID = deptRow.HItemID
                this.gyCustomerShow = false
                this.openData = false
            } else if (num == 8) {
                console.log(deptRow)
                this.editData[this.zbIndex].HMouldID = deptRow.hmainid
                this.editData[this.zbIndex].HMouldNumber = deptRow.模具编号
                this.editData[this.zbIndex].HMouldName = deptRow.模具名称
                this.editData[this.zbIndex].HMouldLength = deptRow.长
                this.editData[this.zbIndex].HMouldWidth = deptRow.宽
                this.editData[this.zbIndex].HMouldFoldHeight = deptRow.折叠高度
                this.gyMouldShow = false
                this.openData = false
            } else if (num == 12) {
                // 使用异步方式处理源单数据
                this.processSourceDataAsync(deptRow);
@@ -1146,7 +1171,7 @@
                this.form.HCarTypeName = deptRow.车型名称
                this.form.HCarTypeID = deptRow.HItemID
                this.form.HCarTypeMaxVolume = deptRow["最大体积(立方米)"]
                this.calculateLoadingRate(parseFloat($('#HTotalVolume').val()) || 0);
                this.calculateLoadingRate(parseFloat(this.form.HTotalVolume || 0));
                this.gyCartypeShow = false
                this.openData = false
            } else if (num == 14) {
@@ -1236,10 +1261,10 @@
                    this.form.HCusName = deptRow[0]["客户"];
                }
                console.log(deptRow)
                this.form.HMainSourceInterID=deptRow[0]["hmainid"]
                this.form.HMainSourceEntryID=deptRow[0]["hsubid"]
                this.form.HMainSourceBillType=deptRow[0]["HBillType"]
                this.form.HMainSourceBillNo=deptRow[0]["单据号"]
                this.form.HMainSourceInterID = deptRow[0]["hmainid"]
                this.form.HMainSourceEntryID = deptRow[0]["hsubid"]
                this.form.HMainSourceBillType = deptRow[0]["HBillType"]
                this.form.HMainSourceBillNo = deptRow[0]["单据号"]
                // 检查是否所有记录属于同一客户
                for (var i = 0; i < deptRow.length; i++) {
                    if (deptRow[i]["HCusID"] != this.form.HCusID) {
@@ -1382,7 +1407,6 @@
                                var qty = materialInfo.HSNP || 0;
                                var snp = materialInfo.HSNP || 1;
                                var mouldQty = snp > 0 ? Math.ceil(qty / snp) : 0;
                                var length = parseFloat(materialInfo.长度) || 0;
                                var width = parseFloat(materialInfo.宽度) || 0;
                                var height = parseFloat(materialInfo.高度) || 0;
@@ -1766,7 +1790,7 @@
        // 计算装载率函数
        calculateLoadingRate(totalVolume) {
            var maxVolume = parseFloat((this.form.HCarTypeMaxVolume).val()) || 0;
            var maxVolume = parseFloat(this.form.HCarTypeMaxVolume) || 0;
            if (maxVolume > 0) {
                var loadingRate = (totalVolume / maxVolume * 100).toFixed(2);
                this.form.HLoadingRate = loadingRate + "%"
@@ -1775,7 +1799,73 @@
            }
        },
        //#endregion
        checkTotalQtyExceed(selRow) {
            var tableData = this.editData
            console.log(tableData)
            if (!tableData || tableData.length === 0) return;
            var sourceQtyMap = {};
            var currentQtyMap = {};
            tableData.forEach(function (row) {
                if (row.HSourceInterID && row.HSourceEntryID) {
                    var key = row.HSourceInterID + '_' + row.HSourceEntryID;
                    if (row.HQty_origin) {
                        sourceQtyMap[key] = parseFloat(row.HQty_origin) || 0;
                    }
                }
            });
            tableData.forEach(function (row) {
                if (row.HSourceInterID && row.HSourceEntryID) {
                    var key = row.HSourceInterID + '_' + row.HSourceEntryID;
                    var currentQty = parseFloat(row.HQty) || 0;
                    if (!currentQtyMap[key]) {
                        currentQtyMap[key] = 0;
                    }
                    currentQtyMap[key] += currentQty;
                }
            });
            // 检查是否超出
            var exceedSources = [];
            for (var key in sourceQtyMap) {
                var sourceQty = sourceQtyMap[key];
                var currentTotal = currentQtyMap[key] || 0;
                if (currentTotal > sourceQty) {
                    var sourceBillNo = '';
                    tableData.some(function (row) {
                        if (row.HSourceInterID + '_' + row.HSourceEntryID === key) {
                            sourceBillNo = row.HSourceBillNo || '未知源单';
                            return true;
                        }
                        return false;
                    });
                    exceedSources.push({
                        sourceBillNo: sourceBillNo,
                        sourceQty: sourceQty,
                        currentTotal: currentTotal
                    });
                }
            }
            console.log(exceedSources)
            if (exceedSources.length > 0) {
                var message = '物料数量之和超过源单数量:';
                exceedSources.forEach(function (item, index) {
                    message += (index + 1) + '. 源单号:' + item.sourceBillNo +
                        ',源单数量:' + item.sourceQty +
                        ',当前数量:' + item.currentTotal;
                });
                this.$modal.msgError(message);
                return true; // 表示有超出
            }
            return false; // 表示没有超出
        },
        //#region 附件上传相关方法
        // 文件选择变化时的处理
        handleFileChange(file, fileList) {