| | |
| | | label="整单折扣率:" |
| | | prop="totalDiscountAmount" |
| | | > |
| | | <el-input-number v-model="formState.totalDiscountRate" |
| | | <el-input v-model="formState.totalDiscountRate" |
| | | controls-position="right" |
| | | :step="0.01" |
| | | :precision="2" |
| | | style="width: 100%;" |
| | | placeholder="请输入整单折扣率"/> |
| | | @change="totalDiscount" |
| | | placeholder="请输入整单折扣率"> |
| | | <template #append> |
| | | % |
| | | </template> |
| | | </el-input> |
| | | </el-form-item> |
| | | |
| | | <el-form-item |
| | |
| | | } |
| | | }); |
| | | let { proxy } = getCurrentInstance() |
| | | const { payment_methods } = proxy.useDict("payment_methods"); |
| | | const payment_methods = [ |
| | | { |
| | | "label": "现金", |
| | | "value": "0", |
| | | }, |
| | | { |
| | | "label": "支票", |
| | | "value": "1", |
| | | }, |
| | | { |
| | | "label": "银行转账", |
| | | "value": "2", |
| | | }, |
| | | { |
| | | "label": "其他", |
| | | "value": "3", |
| | | }, |
| | | ] |
| | | const emit = defineEmits(['update:visible', 'completed']); |
| | | |
| | | // 响应式数据(替代选项式的 data) |
| | |
| | | row.taxInclusiveTotalPrice = getReturnTotal(row) |
| | | } |
| | | |
| | | const getBaseAmount = () => { |
| | | const rows = formState.value.purchaseReturnOrderProductsDtos || [] |
| | | return rows.reduce((sum, item) => { |
| | | return sum + toNumber(item.taxInclusiveTotalPrice) |
| | | }, 0) |
| | | } |
| | | |
| | | // 同步折扣额 |
| | | const totalDiscount = () => { |
| | | const discountRate = toNumber(formState.value.totalDiscountRate) |
| | | if (discountRate < 0 || discountRate > 100) { |
| | | proxy.$modal.msgError("请输入0-100之间的折扣率") |
| | | return |
| | | } |
| | | const baseAmount = getBaseAmount() |
| | | // 折扣额 = 产品退货总价合计 * 折扣率 |
| | | formState.value.totalDiscountAmount = Number((baseAmount * (discountRate / 100)).toFixed(2)) |
| | | syncTotalAmount() |
| | | } |
| | | |
| | | const getReturnQtyMax = (row) => { |
| | | const max = Number(row?.availableQuality) |
| | | if (Number.isNaN(max) || max < 0) { |
| | |
| | | }; |
| | | |
| | | const handleChangeTotalDiscountAmount= () => { |
| | | const discountAmount = toNumber(formState.value.totalDiscountAmount) |
| | | if (discountAmount < 0) { |
| | | proxy.$modal.msgError("整单折扣额不能小于0") |
| | | formState.value.totalDiscountAmount = 0 |
| | | } |
| | | |
| | | const baseAmount = getBaseAmount() |
| | | const normalizedAmount = toNumber(formState.value.totalDiscountAmount) |
| | | if (baseAmount <= 0) { |
| | | formState.value.totalDiscountRate = 0 |
| | | syncTotalAmount() |
| | | return |
| | | } |
| | | |
| | | if (normalizedAmount > baseAmount) { |
| | | proxy.$modal.msgError("整单折扣额不能大于产品退货总价合计") |
| | | formState.value.totalDiscountAmount = Number(baseAmount.toFixed(2)) |
| | | } |
| | | |
| | | const discountRate = (toNumber(formState.value.totalDiscountAmount) / baseAmount) * 100 |
| | | formState.value.totalDiscountRate = Number(discountRate.toFixed(2)) |
| | | syncTotalAmount() |
| | | } |
| | | |
| | | const resetFeeInfo = () => { |
| | | formState.value.totalDiscountAmount = 0 |
| | | formState.value.totalDiscountRate = undefined |
| | | formState.value.totalAmount = 0 |
| | | formState.value.incomeType = undefined |
| | | } |
| | | |
| | | const syncTotalAmount = () => { |
| | | const rows = formState.value.purchaseReturnOrderProductsDtos || [] |
| | | const baseAmount = rows.reduce((sum, item) => { |
| | | return sum + toNumber(item.taxInclusiveTotalPrice) |
| | | }, 0) |
| | | const baseAmount = getBaseAmount() |
| | | const discount = toNumber(formState.value.totalDiscountAmount) |
| | | // 成交金额 = 产品退货总价合计 - 折扣额 |
| | | formState.value.totalAmount = Number((baseAmount - discount).toFixed(2)) |
| | |
| | | |
| | | // 处理改变采购台账数据 |
| | | const handleChangePurchaseLedgerId = async () => { |
| | | resetFeeInfo() |
| | | if (!formState.value.purchaseLedgerId) { |
| | | formState.value.purchaseReturnOrderProductsDtos = [] |
| | | return |
| | | } |
| | | const res = await productList({ salesLedgerId: formState.value.purchaseLedgerId, type: 2 }); |
| | | formState.value.purchaseReturnOrderProductsDtos = res.data.map(item => ({ |
| | | ...item, |