From 05a846985da950e828350429200855c6472ca1b5 Mon Sep 17 00:00:00 2001 From: qb <1191961160@qq.com> Date: Tue, 24 Sep 2024 11:35:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BC=80=E5=8D=95=E5=BD=95?= =?UTF-8?q?=E5=8D=95=E5=8D=95=E4=BB=B7=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ArteryPrintTemplate.vue | 6 +- .../TripartiteTransferPrintTemplate.vue | 4 +- src/utils/util.js | 11 + .../artery/TripartiteTransfer.vue | 5 +- .../artery/addTripartiteTransfer.vue | 2 +- .../distribution/inventory/CreateOrder.vue | 730 ++++++++++++++---- .../signfor/distributionSignforedt.vue | 2 - src/views/waybill/CreateZeroOrder.vue | 451 ++++++++++- 8 files changed, 1025 insertions(+), 186 deletions(-) diff --git a/src/components/ArteryPrintTemplate/ArteryPrintTemplate.vue b/src/components/ArteryPrintTemplate/ArteryPrintTemplate.vue index ff2e89eb..a6bfb5ea 100644 --- a/src/components/ArteryPrintTemplate/ArteryPrintTemplate.vue +++ b/src/components/ArteryPrintTemplate/ArteryPrintTemplate.vue @@ -121,9 +121,9 @@ - 投诉电话:4000184668 - 营业部电话:4000184668 - 系统单调度:4000184668 + 投诉电话:4000184668 + 营业部电话: + 系统单调度: diff --git a/src/components/TripartiteTransferPrintTemplate/TripartiteTransferPrintTemplate.vue b/src/components/TripartiteTransferPrintTemplate/TripartiteTransferPrintTemplate.vue index 85d161d3..ce42e2f9 100644 --- a/src/components/TripartiteTransferPrintTemplate/TripartiteTransferPrintTemplate.vue +++ b/src/components/TripartiteTransferPrintTemplate/TripartiteTransferPrintTemplate.vue @@ -108,8 +108,8 @@ 投诉电话:4000184668 - 营业部电话:4000184668 - 系统单调度:4000184668 + 营业部售后电话: + 系统单调度: diff --git a/src/utils/util.js b/src/utils/util.js index 4187322d..fd53c818 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -660,6 +660,17 @@ export const isNumber = value => { return !isNaN(parseFloat(value)) && isFinite(value); }; +/** + * 向下保留小数位 + * @param {*} num -- 被截取数 + * @param {*} decimalPlaces -- 保留小数位 + * @returns + */ +export function floorToDecimalPlaces(num, decimalPlaces) { + const factor = Math.pow(10, decimalPlaces); + return Math.floor(num * factor) / factor; +} + /** 防抖函数 */ export function debounce(func, delay) { let timer; diff --git a/src/views/distribution/artery/TripartiteTransfer.vue b/src/views/distribution/artery/TripartiteTransfer.vue index 41f4b119..14630aaa 100644 --- a/src/views/distribution/artery/TripartiteTransfer.vue +++ b/src/views/distribution/artery/TripartiteTransfer.vue @@ -745,7 +745,6 @@ const permissionObj = reactive({ /** 转换码值 */ const handleConversionCodeValue = (item, label, Arr) => { const codes = Arr.map(item => item.value); - console.log('codes :>> ', codes); let _index = codes.indexOf(Number(item[label])); if (_index === -1) _index = codes.indexOf(item[label]); @@ -781,8 +780,8 @@ const onLoad = debounce(async (params = {}) => { // 承运时间 if (getObjType(carrierTimeArr) === 'array' && carrierTimeArr.length > 0) { - params.carrierTimeStartStr = startArr[0]; - params.carrierTimeEndStr = startArr[1]; + params.carrierTimeStartStr = carrierTimeArr[0]; + params.carrierTimeEndStr = carrierTimeArr[1]; } // 发车时间 diff --git a/src/views/distribution/artery/addTripartiteTransfer.vue b/src/views/distribution/artery/addTripartiteTransfer.vue index 6e49cb82..d8e94fb8 100644 --- a/src/views/distribution/artery/addTripartiteTransfer.vue +++ b/src/views/distribution/artery/addTripartiteTransfer.vue @@ -701,7 +701,7 @@ const details = reactive({ transferVisited: false, }, form: { - customerType: '', + customerType: [], }, /** 页面数据 */ pageInfo: {}, diff --git a/src/views/distribution/inventory/CreateOrder.vue b/src/views/distribution/inventory/CreateOrder.vue index ecdb6eee..8cadeff0 100644 --- a/src/views/distribution/inventory/CreateOrder.vue +++ b/src/views/distribution/inventory/CreateOrder.vue @@ -706,6 +706,7 @@ @@ -1413,7 +1414,6 @@ import { mapGetters, useStore } from 'vuex'; /** 获取字典 */ import { getDictionaryBiz } from '@/api/system/dict'; import { - downloadXls, computeNumber, deepClone, isNumber, @@ -1424,6 +1424,7 @@ import { handleFilterData, handleClearTableQuery, handleSelectQuery, + floorToDecimalPlaces, } from '@/utils/util'; import { columnList, packageColumnList } from '@/option/waybill/TemporaryStorageList'; import { getopenOrderAdvancePageList } from '@/api/waybill/TemporaryStorageList'; @@ -1554,7 +1555,7 @@ const details = reactive({ /** 紧急度 */ urgency: '1', /** 回单方式(多选) */ - receipt: '', + receipt: [], /** 运输方式 */ transportType: '', /** 开单人 */ @@ -1627,6 +1628,14 @@ const details = reactive({ goodsId: '', /** 计费方式 */ chargeType: 1, + /** 系统维护 -- 干线计价方式 */ + systemChargeType: 1, + /** 系统维护 -- 配送计价方式 */ + systemDeliveryChargeType: 1, + /** 系统维护 -- 提货计价方式 */ + systemPickupChargeType: 1, + /** 系统维护 -- 仓库计价方式 */ + systemWarehouseChargeType: 1, /** 件数 */ num: 0, /** 重量(kg) */ @@ -1635,6 +1644,12 @@ const details = reactive({ volume: 0, /** 单价 */ price: 0, + /** 系统维护 -- 运费单价 */ + freightPrice: 0, + /** 系统维护 -- 配送单价 */ + deliveryPrice: 0, + /** 系统维护 -- 提货单价 */ + pickupPrice: 0, /** 运费小计 */ subtotalFreight: 0, /** 货物名称list */ @@ -2127,7 +2142,7 @@ const totalCost = computed(() => { .next('+', details.query.otherFee || 0) .next('+', details.query.insuranceFee || 0) .next('+', details.query.installFee || 0) - .next('+', details.query.claimingValue || 0).result; + .next('+', details.query.thirdOperationFee || 0).result; handlePayWay(_num); return _num; @@ -2234,6 +2249,14 @@ const onLoad = async (idsArr = []) => { goodsId: '', /** 计费方式 */ chargeType: 1, + /** 系统维护 -- 干线计价方式 */ + systemChargeType: 1, + /** 系统维护 -- 配送计价方式 */ + systemDeliveryChargeType: 1, + /** 系统维护 -- 提货计价方式 */ + systemPickupChargeType: 1, + /** 系统维护 -- 仓库计价方式 */ + systemWarehouseChargeType: 1, /** 件数 */ num: 0, /** 重量(kg) */ @@ -2242,6 +2265,12 @@ const onLoad = async (idsArr = []) => { volume: 0, /** 单价 */ price: 0, + /** 系统维护 -- 运费单价 */ + freightPrice: 0, + /** 系统维护 -- 配送单价 */ + deliveryPrice: 0, + /** 系统维护 -- 提货单价 */ + pickupPrice: 0, /** 运费小计 */ subtotalFreight: 0, /** 货物list */ @@ -2252,6 +2281,10 @@ const onLoad = async (idsArr = []) => { details.goodsList = data.goodsList.map(val => { val.num = isNumber(val.num) ? Number(val.num) : 0; val.price = isNumber(val.price) ? Number(val.price) : 0; + val.freightPrice = isNumber(val.freightPrice) ? Number(val.freightPrice) : 0; + val.deliveryPrice = isNumber(val.deliveryPrice) ? Number(val.deliveryPrice) : 0; + val.pickupPrice = isNumber(val.pickupPrice) ? Number(val.pickupPrice) : 0; + val.volume = isNumber(val.volume) ? Number(val.volume) : 0; val.weight = isNumber(val.weight) ? Number(val.weight) : 0; @@ -2393,6 +2426,14 @@ const onEditLoad = async () => { goodsId: '', /** 计费方式 */ chargeType: 1, + /** 系统维护 -- 干线计价方式 */ + systemChargeType: 1, + /** 系统维护 -- 配送计价方式 */ + systemDeliveryChargeType: 1, + /** 系统维护 -- 提货计价方式 */ + systemPickupChargeType: 1, + /** 系统维护 -- 仓库计价方式 */ + systemWarehouseChargeType: 1, /** 件数 */ num: 0, /** 重量(kg) */ @@ -2401,6 +2442,12 @@ const onEditLoad = async () => { volume: 0, /** 单价 */ price: 0, + /** 系统维护 -- 运费单价 */ + freightPrice: 0, + /** 系统维护 -- 配送单价 */ + deliveryPrice: 0, + /** 系统维护 -- 提货单价 */ + pickupPrice: 0, /** 运费小计 */ subtotalFreight: 0, /** 货物名称list */ @@ -2415,8 +2462,18 @@ const onEditLoad = async () => { val.volume = Number(val.volume); val.weight = Number(val.weight); val.price = Number(val.price); + val.freightPrice = isNumber(val.freightPrice) ? Number(val.freightPrice) : 0; + val.deliveryPrice = isNumber(val.deliveryPrice) ? Number(val.deliveryPrice) : 0; + val.pickupPrice = isNumber(val.pickupPrice) ? Number(val.pickupPrice) : 0; val.subtotalFreight = Number(val.subtotalFreight); - + /** 系统维护 -- 干线计价方式 */ + val.systemChargeType = 1; + /** 系统维护 -- 配送计价方式 */ + val.systemDeliveryChargeType = 1; + /** 系统维护 -- 提货计价方式 */ + val.systemPickupChargeType = 1; + /** 系统维护 -- 仓库计价方式 */ + val.systemWarehouseChargeType = val.systemWarehouseChargeType || 1; val.goodsName = val.productName; val.goodsId = val.productId; @@ -2531,7 +2588,7 @@ const initPageInfo = async (idsArr = []) => { const handleCloseSelcet = () => { shipperNodeList.forEach(val => val.value.handleClose()); consigneeNodeList.forEach(val => val.value.handleClose()); - goodsNameRef.value.forEach(val => val.handleClose()); + goodsNameRef.value && goodsNameRef.value.forEach(val => val.handleClose()); }; /** 新增货物 */ @@ -2581,6 +2638,14 @@ const handleAdd = () => { waybillDetailList: '', /** 计费方式 */ chargeType: 1, + /** 系统维护 -- 干线计价方式 */ + systemChargeType: 1, + /** 系统维护 -- 配送计价方式 */ + systemDeliveryChargeType: 1, + /** 系统维护 -- 提货计价方式 */ + systemPickupChargeType: 1, + /** 系统维护 -- 仓库计价方式 */ + systemWarehouseChargeType: 1, /** 件数 */ num: 0, /** 重量(kg) */ @@ -2589,6 +2654,12 @@ const handleAdd = () => { volume: 0, /** 单价 */ price: 0, + /** 系统维护 -- 运费单价 */ + freightPrice: 0, + /** 系统维护 -- 配送单价 */ + deliveryPrice: 0, + /** 系统维护 -- 提货单价 */ + pickupPrice: 0, /** 运费小计 */ subtotalFreight: 0, goodsListOptions: [], @@ -2812,7 +2883,7 @@ const destinationWarehouseNameChange = val => { * row -- 行数据 * onlyComputedTrunline -- 是否只计算干线的价格 */ -const handleComputed = (row: any, onlyComputedTrunline = false) => { +const handleComputed = debounce((row: any, onlyComputedTrunline = false) => { const { template, trunkLine } = details.priceTemplate; if (Boolean(isDisabled.value && template && trunkLine)) @@ -2823,8 +2894,8 @@ const handleComputed = (row: any, onlyComputedTrunline = false) => { const typeArr = { 1: 'num', 2: 'volume', 3: 'weight' }; const _trunklineKey = typeArr[row.chargeType]; - const _pickupKey = typeArr[row.pickupType]; - const _dispatchKey = typeArr[row.dispatchType]; + const _pickupKey = typeArr[row.systemPickupChargeType]; + const _dispatchKey = typeArr[row.systemDeliveryChargeType]; const _warehouseKey = typeArr[row.warehouseManagementType]; // 计算干线价格 -- 行 @@ -2841,10 +2912,10 @@ const handleComputed = (row: any, onlyComputedTrunline = false) => { : 0; // 计算配送价格 -- 行 - if (_dispatchKey) - row.subtotalDispatch = _dispatchKey - ? computeNumber(row.deliveryPrice || 0, '*', row[_dispatchKey]).result - : 0; + // if (_dispatchKey) + // row.subtotalDispatch = _dispatchKey + // ? computeNumber(row.deliveryPrice || 0, '*', row[_dispatchKey]).result + // : 0; if (_warehouseKey) row.subtotalWarehouseManagement = _warehouseKey @@ -2854,7 +2925,7 @@ const handleComputed = (row: any, onlyComputedTrunline = false) => { } handlePrice(!onlyComputedTrunline, 'trunkline'); -}; +}, 10); /** 查询客户信息 */ const handleFindClientInfo = async (type, isClearId = 0) => { @@ -3172,57 +3243,142 @@ const handleTrunkLinePrice = (trunkLine, template) => { const handleDispatchPrice = (dispatch, template) => { // 是否存在模板和维护价格 if (!dispatch || !template) return; + // 根据订单号分组 + const _orderObj = {}; + + for (let i = 0; i < details.package.data.length; i++) { + const value = details.package.data[i]; - console.log('dispatch :>> ', dispatch); + // 根据订单分组 + !_orderObj[value.orderCode] && (_orderObj[value.orderCode] = {}); + const _item = _orderObj[value.orderCode]; - // 非整车 - let _total = 0; + const _key = value.incomeCategoryName + value.incomeCategoryId; - for (let i = 0; i < details.goodsList.length; i++) { - const value = details.goodsList[i]; - if (value.subtotalDispatch) _total += computeNumber(_total, '+', value.subtotalDispatch).result; + // 根据品类分组 + for (let j = 0; j < details.goodsList.length; j++) { + const val = details.goodsList[j]; + + if (_key !== val.goodsName + val.goodsId) continue; + // orderGoodsNum为品类数量 + if (!_item[_key]) { + // 单个体积 + const singleVolume = floorToDecimalPlaces( + computeNumber(val.volume, '/', val.num).result, + 4 + ); + // 单个重量 + const singleWeight = floorToDecimalPlaces( + computeNumber(val.weight, '/', val.num).result, + 4 + ); + + _item[_key] = { + ...val, + orderGoodsNum: 1, + orderGoodsVolume: singleVolume, + singleVolume, + orderGoodsWeight: singleWeight, + singleWeight, + }; + + continue; + } + _item[_key].orderGoodsNum++; + // 单个体积 + _item[_key].orderGoodsVolume = floorToDecimalPlaces( + computeNumber(_item[_key].singleVolume, '*', _item[_key].orderGoodsNum).result, + 4 + ); + // 单个重量 + _item[_key].orderGoodsWeight = floorToDecimalPlaces( + computeNumber(_item[_key].singleWeight, '*', _item[_key].orderGoodsNum).result, + 4 + ); + break; + } } - // 是否存在最低计费 - if ( - (dispatch || template) && - template.trunklineIsMinCost && - Number(template.dispatchMinCostMode) === 1 - ) { - switch (Number(template.dispatchMinCostType)) { - // 价格 - case 1: - details.query.deliveryFee = dispatch.minCost > _total ? dispatch.minCost : _total; - break; + const typeArr = { 1: 'orderGoodsNum', 2: 'orderGoodsVolume', 3: 'orderGoodsWeight' }; - // 件 - case 2: - details.query.deliveryFee = - dispatch.minCost > details.totalObj.totalCount - ? _total + (dispatch.additionalCost || 0) - : _total; - break; + let _totalPrce = 0; + for (const key in _orderObj) { + const element = _orderObj[key]; - // 方 - case 3: - details.query.deliveryFee = - dispatch.minCost > details.totalObj.totalVolume - ? _total + (dispatch.additionalCost || 0) - : _total; - break; + // 订单总配送费 + let _orderSubtotalDispatch = 0; + // 订单总重量 + let _orderWeight = 0; + // 订单总体积 + let _orderVolume = 0; + // 订单总数 + let _orderNum = 0; - // 重量 - case 4: - details.query.deliveryFee = - dispatch.minCost > details.totalObj.totalWeghit - ? _total + (dispatch.additionalCost || 0) - : _total; - break; + for (const childKey in element) { + const item = element[childKey]; - default: - break; + _orderWeight = computeNumber(_orderWeight, '+', item.orderGoodsWeight).result; + _orderVolume = computeNumber(_orderVolume, '+', item.orderGoodsVolume).result; + _orderNum += item.orderGoodsNum; + + const _dispatchKey = typeArr[item.systemDeliveryChargeType]; + item.subtotalDispatch = _dispatchKey + ? computeNumber(item.deliveryPrice || 0, '*', item[_dispatchKey]).result + : 0; + _orderSubtotalDispatch = computeNumber( + _orderSubtotalDispatch, + '+', + item.subtotalDispatch + ).result; } - } else details.query.deliveryFee = _total; + + // 是否存在最低费 + if ( + dispatch && + template && + template.dispatchIsMinCost && + Number(template.dispatchMinCostMode) === 1 + ) { + switch (Number(template.dispatchMinCostType)) { + // 价格 + case 1: + _orderSubtotalDispatch = + dispatch.minCost > _orderSubtotalDispatch ? dispatch.minCost : _orderSubtotalDispatch; + break; + + // 件 + case 2: + _orderSubtotalDispatch = + dispatch.minCost > _orderNum + ? _orderSubtotalDispatch + (dispatch.additionalCost || 0) + : _orderSubtotalDispatch; + break; + + // 方 + case 3: + _orderSubtotalDispatch = + dispatch.minCost > _orderVolume + ? _orderSubtotalDispatch + (dispatch.additionalCost || 0) + : _orderSubtotalDispatch; + break; + + // 重量 + case 4: + _orderSubtotalDispatch = + dispatch.minCost > _orderWeight + ? _orderSubtotalDispatch + (dispatch.additionalCost || 0) + : _orderSubtotalDispatch; + break; + + default: + break; + } + } + + _totalPrce = computeNumber(_totalPrce, '+', _orderSubtotalDispatch).result; + } + + details.query.deliveryFee = _totalPrce; }; /** 处理仓库管理费 */ @@ -3261,32 +3417,300 @@ const handleRefreshText = (key, value, refreshValue?: string | number) => { query.value[key] = refreshValue ? refreshValue : ''; }; -/** 重置数据 */ -const resetForm = (formEl: FormInstance | undefined) => { - if (!formEl) return; - formEl.resetFields(); - details.goodsList = [ - { - /** 货物名称 */ - goodsName: '', - /** 品类Id */ - goodsId: '', - /** 计费方式 */ - chargeType: 1, - /** 件数 */ - num: 0, - /** 重量(kg) */ - weight: 0, - /** 体积(方) */ - volume: 0, - /** 单价 */ - price: 0, - /** 运费小计 */ - subtotalFreight: 0, - goodsListOptions: [], - }, - ]; - initPageInfo(); +/** 计算品类单价 -- 系统单价 */ +const handleComputedPlanPrice = submitData => { + const { dispatch, pickup, template, trunkLine } = details.priceTemplate; + + const { addList } = submitData; + const typeArr = { 1: 'num', 2: 'volume', 3: 'weight' }; + + // 计算 运费 & 提货费 & 送货费 & 仓库管理费 基础合计 + let _total = 0; + /** 干线 */ + let _planTrunklineFee = 0; + let _trunklineFee = 0; + /** 提货 */ + let _planSubtotalPickup = 0; + let _subtotalPickup = 0; + /** 送货 */ + let _totalPlanPrce = 0; + let _totalPrce = 0; + + for (let i = 0; i < addList.length; i++) { + const _val = addList[i]; + const _trunklineKey = typeArr[_val.chargeType]; + const _pickupKey = typeArr[_val.systemPickupChargeType]; + + // 干线费 + _trunklineFee = computeNumber( + _trunklineFee, + '+', + _trunklineKey ? computeNumber(_val.freightPrice || 0, '*', _val[_trunklineKey]).result : 0 + ).result; + + // 提货费 + _subtotalPickup = computeNumber( + _subtotalPickup, + '+', + _pickupKey ? computeNumber(_val.pickupPrice || 0, '*', _val[_pickupKey]).result : 0 + ).result; + } + + // 是否存在最低计费 -- 干线 + if (trunkLine && template && template.trunklineIsMinCost) { + switch (Number(template.trunklineMinCostType)) { + // 价格 + case 1: + _planTrunklineFee = trunkLine.minCost > _trunklineFee ? trunkLine.minCost : _trunklineFee; + break; + + // 件 + case 2: + _planTrunklineFee = + trunkLine.minCost > details.totalObj.totalCount + ? _trunklineFee + (trunkLine.additionalCost || 0) + : _trunklineFee; + break; + + // 方 + case 3: + _planTrunklineFee = + trunkLine.minCost > details.totalObj.totalVolume + ? _trunklineFee + (trunkLine.additionalCost || 0) + : _trunklineFee; + break; + + // 重量 + case 4: + _planTrunklineFee = + trunkLine.minCost > details.totalObj.totalWeghit + ? _trunklineFee + (trunkLine.additionalCost || 0) + : _trunklineFee; + break; + + default: + break; + } + } + + // 是否存在最低计费 -- 提货 + if (pickup && template && template.pickupIsMinCost) { + switch (Number(template.pickupMinCostType)) { + // 价格 + case 1: + _planSubtotalPickup = pickup.minCost > _subtotalPickup ? pickup.minCost : _subtotalPickup; + break; + + // 件 + case 2: + _planSubtotalPickup = + pickup.minCost > details.totalObj.totalCount + ? _subtotalPickup + (pickup.additionalCost || 0) + : _subtotalPickup; + break; + + // 方 + case 3: + _planSubtotalPickup = + pickup.minCost > details.totalObj.totalVolume + ? _subtotalPickup + (pickup.additionalCost || 0) + : _subtotalPickup; + break; + + // 重量 + case 4: + _planSubtotalPickup = + pickup.minCost > details.totalObj.totalWeghit + ? _subtotalPickup + (pickup.additionalCost || 0) + : _subtotalPickup; + break; + + default: + break; + } + } + + // 配送 + if (dispatch && template && template.dispatchIsMinCost) { + // 根据订单号分组 + const _orderObj = {}; + + for (let i = 0; i < details.package.data.length; i++) { + const value = details.package.data[i]; + + // 根据订单分组 + !_orderObj[value.orderCode] && (_orderObj[value.orderCode] = {}); + const _item = _orderObj[value.orderCode]; + + const _key = value.incomeCategoryName + value.incomeCategoryId; + + // 根据品类分组 + for (let j = 0; j < addList.length; j++) { + const val = addList[j]; + + if (_key !== val.goodsName + val.goodsId) continue; + // orderGoodsNum为品类数量 + if (!_item[_key]) { + // 单个体积 + const singleVolume = floorToDecimalPlaces( + computeNumber(val.volume, '/', val.num).result, + 4 + ); + // 单个重量 + const singleWeight = floorToDecimalPlaces( + computeNumber(val.weight, '/', val.num).result, + 4 + ); + + _item[_key] = { + ...val, + orderGoodsNum: 1, + orderGoodsVolume: singleVolume, + singleVolume, + orderGoodsWeight: singleWeight, + singleWeight, + }; + continue; + } + _item[_key].orderGoodsNum++; + // 单个体积 + _item[_key].orderGoodsVolume = floorToDecimalPlaces( + computeNumber(_item[_key].singleVolume, '*', _item[_key].orderGoodsNum).result, + 4 + ); + // 单个重量 + _item[_key].orderGoodsWeight = floorToDecimalPlaces( + computeNumber(_item[_key].singleWeight, '*', _item[_key].orderGoodsNum).result, + 4 + ); + break; + } + } + + for (const key in _orderObj) { + const element = _orderObj[key]; + + // 订单总配送费 + let _orderSubtotalDispatch = 0; + // 订单总重量 + let _orderWeight = 0; + // 订单总体积 + let _orderVolume = 0; + // 订单总数 + let _orderNum = 0; + + for (const childKey in element) { + const item = element[childKey]; + + _orderWeight = computeNumber(_orderWeight, '+', item.orderGoodsWeight).result; + _orderVolume = computeNumber(_orderVolume, '+', item.orderGoodsVolume).result; + _orderNum += item.orderGoodsNum; + + const _dispatchKey = typeArr[item.systemDeliveryChargeType]; + item.subtotalDispatch = _dispatchKey + ? computeNumber(item.deliveryPrice || 0, '*', item[_dispatchKey]).result + : 0; + _orderSubtotalDispatch = computeNumber( + _orderSubtotalDispatch, + '+', + item.subtotalDispatch + ).result; + } + + _totalPlanPrce = computeNumber(_totalPlanPrce, '+', _orderSubtotalDispatch).result; + + switch (Number(template.dispatchMinCostType)) { + // 价格 + case 1: + _orderSubtotalDispatch = + dispatch.minCost > _orderSubtotalDispatch ? dispatch.minCost : _orderSubtotalDispatch; + break; + + // 件 + case 2: + _orderSubtotalDispatch = + dispatch.minCost > _orderNum + ? _orderSubtotalDispatch + (dispatch.additionalCost || 0) + : _orderSubtotalDispatch; + break; + + // 方 + case 3: + _orderSubtotalDispatch = + dispatch.minCost > _orderVolume + ? _orderSubtotalDispatch + (dispatch.additionalCost || 0) + : _orderSubtotalDispatch; + break; + + // 重量 + case 4: + _orderSubtotalDispatch = + dispatch.minCost > _orderWeight + ? _orderSubtotalDispatch + (dispatch.additionalCost || 0) + : _orderSubtotalDispatch; + break; + + default: + break; + } + + _totalPrce = computeNumber(_totalPrce, '+', _orderSubtotalDispatch).result; + } + + if (_totalPrce - _totalPlanPrce === 0) { + return; + } + } + + console.log('addList :>> ', addList); + + for (let i = 0; i < addList.length; i++) { + const val = addList[i]; + // 干线 + if (trunkLine && template && template.trunklineIsMinCost) { + const differenceValue = computeNumber(_planTrunklineFee, '-', _trunklineFee).next( + '/', + info.value.maxNum + ).result; + + val.freightPrice = floorToDecimalPlaces( + computeNumber(differenceValue, '*', val.num) + .next('/', val[typeArr[val.chargeType]]) + .next('+', val.freightPrice).result, + 2 + ); + } + + // 提货 + if (pickup && template && template.pickupIsMinCost) { + const differenceValue = computeNumber(_planSubtotalPickup, '-', _subtotalPickup).next( + '/', + info.value.maxNum + ).result; + + val.pickupPrice = floorToDecimalPlaces( + computeNumber(differenceValue, '*', val.num) + .next('/', val[typeArr[val.systemPickupChargeType]]) + .next('+', val.pickupPrice).result, + 2 + ); + } + + // 配送 + if (dispatch && template && template.dispatchIsMinCost) { + const differenceValue = computeNumber(_totalPrce, '-', _totalPlanPrce).next( + '/', + info.value.maxNum + ).result; + + val.deliveryPrice = floorToDecimalPlaces( + computeNumber(differenceValue, '*', val.num) + .next('/', val[typeArr[val.systemDeliveryChargeType]]) + .next('+', val.deliveryPrice).result, + 2 + ); + } + } }; /** 提交 */ @@ -3311,7 +3735,9 @@ const handleSubmit = (formEl: FormInstance | undefined) => { }); } - if (!(details.query.totalFreight > 0)) return ElMessage.warning('请输入大于零的运费'); + if (!(details.query.totalFreight > 0)) { + return ElMessage.warning('请输入大于零的运费'); + } const submitData = { ...details.totalObj, @@ -3330,8 +3756,9 @@ const handleSubmit = (formEl: FormInstance | undefined) => { if (destination.length === 1) { return ElMessage({ message: '请选择正确到站地址', type: 'warning' }); } - if (departure.length === 1) + if (departure.length === 1) { return ElMessage({ message: '请选择正确发站地址', type: 'warning' }); + } // 筛选到站 const _findeLocation = details.regionOptione @@ -3376,19 +3803,21 @@ const handleSubmit = (formEl: FormInstance | undefined) => { // if (numFlag) return ElMessage.warning('小计费用存在异常'); const _content = handleDetectionPayWay(); - if (_content) return ElMessage.warning(_content); + if (_content) { + return ElMessage.warning(_content); + } submitData.goodsName = submitData.waybillDetailList.map(val => val.goodsName).join(','); let res: any = {}; // 新增提交 if (details.pageInfo.type !== 'edit') { - submitData.addList = details.goodsList; + submitData.addList = deepClone(details.goodsList); submitData.removeList = []; delete submitData.goodsList; submitData.waybillType = 1; - if (typeof submitData.receipt === 'object') + if (getObjType(submitData.receipt) === 'array') submitData.receipt = submitData.receipt.join(','); submitData.updateAdvanceDetailList = []; @@ -3406,11 +3835,11 @@ const handleSubmit = (formEl: FormInstance | undefined) => { submitData.updateAdvanceDetailList.push(_obj); } - - // 记录提交参数 - // details.submitData = submitData; + console.log('submitData :>> ', submitData); + handleComputedPlanPrice(submitData); // 有数据开单 + if (details.submitType === 'haveData') res = await postOpenOrderOpenWaybill(submitData); else { submitData.waybillType = 2; @@ -3461,7 +3890,7 @@ const handleSubmit = (formEl: FormInstance | undefined) => { delete submitData.goodsList; submitData.waybillType = 1; - if (typeof submitData.receipt === 'object') + if (getObjType(submitData.receipt) === 'array') submitData.receipt = submitData.receipt.join(','); submitData.updateAdvanceDetailList = []; @@ -3485,6 +3914,7 @@ const handleSubmit = (formEl: FormInstance | undefined) => { submitData.updateAdvanceDetailList.push(_obj); } + handleComputedPlanPrice(submitData); // 记录提交参数 details.submitData = submitData; @@ -3619,8 +4049,11 @@ const handleAssignmentItemPriceTrunkline = (value, trunkLine, template, chargeTy // 是否区分品类 if (template.trunklineIsByCategory) { // 品类是否存在id - if (!value.goodsId) value.price = 0; - else if (chargeType === undefined) { + if (!value.goodsId) { + value.price = 0; + value.freightPrice = 0; + value.systemChargeType = 1; + } else if (chargeType === undefined) { let _item: any = {}; // 件 if (getObjType(pieceCategory) === 'array') { @@ -3661,14 +4094,18 @@ const handleAssignmentItemPriceTrunkline = (value, trunkLine, template, chargeTy } } - if (!_item.chargeType) value.price = 0; - else { + if (!_item.chargeType) { + value.price = 0; + value.freightPrice = 0; + value.systemChargeType = 1; + } else { value.chargeType = _item.chargeType; + value.systemChargeType = _item.chargeType; value.price = _item.price; + value.freightPrice = _item.price || 0; } } else { - console.log('123 :>> ', 123); - + // 定义计价方式 -- 不改变系统值 const _arr = _obj[chargeType]; let _item: any = {}; @@ -3688,8 +4125,11 @@ const handleAssignmentItemPriceTrunkline = (value, trunkLine, template, chargeTy } else { // 不区分品类 const _arr = _obj[value.chargeType]; + const _price = getObjType(_arr) === 'array' && _arr.length > 0 ? _arr[0].price || 0 : 0; - value.price = getObjType(_arr) === 'array' && _arr.length > 0 ? _arr[0].price || 0 : 0; + value.price = _price; + value.freightPrice = _price; + value.systemChargeType = value.chargeType; } }; @@ -3702,19 +4142,25 @@ const handleSpecialBrandPrice = (value, trunkLine, template) => { if (totalCount < 15 && totalVolume < 0.8 && totalVolume / (totalCount || 1) < 0.11) { value.chargeType = 1; + value.systemChargeType = 1; - if (getObjType(trunkLine) !== 'object' || getObjType(template) !== 'object') + if (getObjType(trunkLine) !== 'object' || getObjType(template) !== 'object') { + value.freightPrice = 0; return (value.price = 0); + } const { pieceCategory } = trunkLine; value.price = 5; + value.freightPrice = 5; // 是否区分品类 if (template.trunklineIsByCategory) { // 品类是否存在id - if (!value.goodsId) value.price = 0; - else { + if (!value.goodsId) { + value.freightPrice = 0; + value.price = 0; + } else { let _item: any = {}; // 件 if (getObjType(pieceCategory) === 'array') { @@ -3729,24 +4175,30 @@ const handleSpecialBrandPrice = (value, trunkLine, template) => { } value.price = _item.price || 0; + value.freightPrice = _item.price || 0; } } else { - // 不区分品类 - value.price = + const _price = getObjType(pieceCategory) === 'array' && pieceCategory.length > 0 ? pieceCategory[0].price || 0 : 0; + // 不区分品类 + value.price = _price; + value.freightPrice = _price; } } else { value.chargeType = 2; + value.systemChargeType = 2; const { cubeCategory } = trunkLine; // 是否区分品类 if (template.trunklineIsByCategory) { // 品类是否存在id - if (!value.goodsId) value.price = 0; - else { + if (!value.goodsId) { + value.freightPrice = 0; + value.price = 0; + } else { let _item: any = {}; // 方 @@ -3761,24 +4213,23 @@ const handleSpecialBrandPrice = (value, trunkLine, template) => { } value.price = _item.price || 0; + value.freightPrice = _item.price || 0; } } else { - // 不区分品类 - value.price = + const _price = getObjType(cubeCategory) === 'array' && cubeCategory.length > 0 ? cubeCategory[0].price || 0 : 0; + // 不区分品类 + value.price = _price; + + value.freightPrice = _price; } } }; /** 提货价格赋值 */ -const handleAssignmentItemPricePickUp = ( - value, - pickup, - template, - chargeType?: number | undefined -) => { +const handleAssignmentItemPricePickUp = (value, pickup, template) => { const { pieceCategory, cubeCategory, weightCategory } = pickup; const _obj = { @@ -3815,7 +4266,7 @@ const handleAssignmentItemPricePickUp = ( // 赋值 - value.pickupType = _item.chargeType || 0; + value.systemPickupChargeType = _item.chargeType || 0; value.pickupPrice = _item.price || 0; } } else { @@ -3824,17 +4275,12 @@ const handleAssignmentItemPricePickUp = ( value.pickupPrice = getObjType(_arr) === 'array' && _arr.length > 0 ? _arr[0].price || 0 : 0; - value.pickupType = 1; + value.systemPickupChargeType = 1; } }; /** 配送价格赋值 */ -const handleAssignmentItemPriceDispatch = ( - value, - dispatch, - template, - chargeType?: number | undefined -) => { +const handleAssignmentItemPriceDispatch = (value, dispatch, template) => { const { pieceCategory, cubeCategory, weightCategory } = dispatch; const _obj = { @@ -3870,7 +4316,7 @@ const handleAssignmentItemPriceDispatch = ( } // 赋值 - value.dispatchType = _item.chargeType || 0; + value.systemDeliveryChargeType = _item.chargeType || 0; value.deliveryPrice = _item.price || 0; } } else { @@ -3879,17 +4325,12 @@ const handleAssignmentItemPriceDispatch = ( value.deliveryPrice = getObjType(_arr) === 'array' && _arr.length > 0 ? _arr[0].price || 0 : 0; - value.dispatchType = 1; + value.systemDeliveryChargeType = 1; } }; /** 仓储管理价格赋值 */ -const handleAssignmentItemPriceWarehouseManagementPrice = ( - value, - warehouse, - template, - chargeType?: number | undefined -) => { +const handleAssignmentItemPriceWarehouseManagementPrice = (value, warehouse, template) => { if (!template || !template.warehouseIsAddFee || !template.warehouseIsManageFee) { value.warehouseManagementPrice = 0; value.warehouseManagementType = 1; @@ -3945,18 +4386,19 @@ const handleAssignmentItemPrice = (value, isOnload = false, chargeType?: number if (isDisabled.value) handleSpecialBrandPrice(value, trunkLine, template); else handleAssignmentItemPriceTrunkline(value, trunkLine, template, chargeType); // 是否为区分品类 - } else value.price = 0; - console.log('123123 :>> ', 123123); + } else { + value.freightPrice = 0; + value.price = 0; + } } // 提货 if (pickup && template) { - handleAssignmentItemPricePickUp(value, pickup, template, chargeType); + handleAssignmentItemPricePickUp(value, pickup, template); } else value.pickupPrice = 0; // 配送 - if (dispatch && template) - handleAssignmentItemPriceDispatch(value, dispatch, template, chargeType); + if (dispatch && template) handleAssignmentItemPriceDispatch(value, dispatch, template); else value.deliveryPrice = 0; // 仓库 @@ -3995,8 +4437,6 @@ const handleFindPrice = async (isOnload = false) => { endCountyId: endArea[2], }; - console.log('submitData :>> ', submitData); - const res = await postFindArrPrice(submitData); const { code, data } = res.data; @@ -4168,7 +4608,7 @@ const handleBatchEdit = () => { .then(() => { for (let i = 0; i < details.package.selectionList.length; i++) { const value = details.package.selectionList[i]; - // 成本 + // 收入 value.incomeCategoryId = details.package.incomeCategoryId || ''; value.incomeCategoryName = details.package.incomeCategoryName || '其它'; value.incomeCategory = details.package.incomeCategoryName || '其它'; @@ -4180,7 +4620,7 @@ const handleBatchEdit = () => { for (let i = 0; i < details.package.selectionList.length; i++) { const value = details.package.selectionList[i]; - // 结算 + // 成本 value.costCategoryId = details.package.incomeCategoryId || ''; value.costCategoryName = details.package.incomeCategoryName || '其它'; value.costCategory = details.package.incomeCategoryName || '其它'; @@ -4214,7 +4654,7 @@ const handleSubmitPackage = () => { value.confirmCostCategoryId = value.costCategoryId; value.confirmCostCategoryName = value.costCategoryName; value.confirmIncomeCategoryId = value.incomeCategoryId; - value.confirmIncomeCategoryName = value.costCategoryName; + value.confirmIncomeCategoryName = value.incomeCategoryName; // 是否已添加此品类 let _flag = false; @@ -4238,6 +4678,14 @@ const handleSubmitPackage = () => { goodsId: value.incomeCategoryId, /** 计费方式 */ chargeType: 1, + /** 系统维护 -- 干线计价方式 */ + systemChargeType: 1, + /** 系统维护 -- 配送计价方式 */ + systemDeliveryChargeType: 1, + /** 系统维护 -- 提货计价方式 */ + systemPickupChargeType: 1, + /** 系统维护 -- 仓库计价方式 */ + systemWarehouseChargeType: 1, /** 件数 */ num: 1, /** 重量(kg) */ @@ -4246,6 +4694,12 @@ const handleSubmitPackage = () => { volume: isNumber(value.volume) ? Number(value.volume) : 0, /** 单价 */ price: 0, + /** 系统维护 -- 运费单价 */ + freightPrice: 0, + /** 系统维护 -- 配送单价 */ + deliveryPrice: 0, + /** 系统维护 -- 提货单价 */ + pickupPrice: 0, /** 运费小计 */ subtotalFreight: 0, goodsListOptions: [], diff --git a/src/views/distribution/signfor/distributionSignforedt.vue b/src/views/distribution/signfor/distributionSignforedt.vue index 9c0412d0..042acb1a 100644 --- a/src/views/distribution/signfor/distributionSignforedt.vue +++ b/src/views/distribution/signfor/distributionSignforedt.vue @@ -1331,7 +1331,6 @@ const menuData2 = ref([ checkarr: [], fixed: false, sortable: true, - isshowSummary: true, head: false, }, { @@ -1502,7 +1501,6 @@ const menuData3 = ref([ checkarr: [], fixed: false, sortable: true, - isshowSummary: true, head: false, }, { diff --git a/src/views/waybill/CreateZeroOrder.vue b/src/views/waybill/CreateZeroOrder.vue index 8a3043a4..9301c23c 100644 --- a/src/views/waybill/CreateZeroOrder.vue +++ b/src/views/waybill/CreateZeroOrder.vue @@ -654,6 +654,7 @@ :value-on-clear="0" :controls="false" :precision="2" + disabled :min="0" :step="0.1" v-model="query.deliveryFee" @@ -663,7 +664,7 @@ @@ -1074,6 +1075,12 @@ + +