feat(采购退货): 增加删除采购退货单功能并优化相关操作
| | |
| | | method: "get", |
| | | }); |
| | | } |
| | | |
| | | // 采购退货单删除 |
| | | // POST purchaseReturnOrders/deleteById/xxx |
| | | export function deletePurchaseReturnOrder(id) { |
| | | return request({ |
| | | url: "/purchaseReturnOrders/deleteById/" + id, |
| | | method: "post", |
| | | }); |
| | | } |
| | |
| | | return format(val); |
| | | } else return val; |
| | | }; |
| | | const validTagTypes = ["primary", "success", "info", "warning", "danger"]; |
| | | |
| | | const formatType = (val, format) => { |
| | | if (typeof format === "function") { |
| | | return format(val); |
| | | } else return ""; |
| | | const type = typeof format === "function" ? format(val) : undefined; |
| | | return validTagTypes.includes(type) ? type : undefined; |
| | | }; |
| | | |
| | | const isOperationDisabled = (operation, row) => { |
| | |
| | | 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, |
| | |
| | | > |
| | | <template #operation="{ row }"> |
| | | <el-button link type="primary" size="small" style="color: #67C23A" @click="handleDetail(row)">详情</el-button> |
| | | <el-button link size="small" @click="handleDelete(row)">删除</el-button> |
| | | </template> |
| | | </PIMTable> |
| | | </div> |
| | |
| | | import PIMTable from '@/components/PIMTable/PIMTable.vue' |
| | | import { ref, reactive, toRefs, onMounted, defineAsyncComponent, getCurrentInstance } from 'vue' |
| | | const { proxy } = getCurrentInstance() |
| | | import {findPurchaseReturnOrderListPage, getPurchaseReturnOrderDetail} from "@/api/procurementManagement/purchase_return_order.js"; |
| | | import {findPurchaseReturnOrderListPage, getPurchaseReturnOrderDetail, deletePurchaseReturnOrder} from "@/api/procurementManagement/purchase_return_order.js"; |
| | | const New = defineAsyncComponent(() => import("@/views/procurementManagement/purchaseReturnOrder/New.vue")); |
| | | const tableData = ref([]) |
| | | const selectedRows = ref([]) |
| | |
| | | width: 180, |
| | | }, |
| | | { |
| | | fixed: 'right', |
| | | label: '操作', |
| | | dataType: 'slot', |
| | | slot: 'operation', |
| | | width: 100, |
| | | align: 'center', |
| | | dataType: "action", |
| | | width: 120, |
| | | label: "操作", |
| | | align: "center", |
| | | fixed: "right", |
| | | operation: [ |
| | | { |
| | | name: "详情", |
| | | type: "text", |
| | | clickFun: row => {handleDetail(row);}, |
| | | }, |
| | | { |
| | | name: "删除", |
| | | clickFun: row => {handleDelete(row)}, |
| | | }, |
| | | ], |
| | | }, |
| | | |
| | | ]) |
| | | const data = reactive({ |
| | | searchForm: { |
| | |
| | | getList() |
| | | } |
| | | |
| | | // 删除操作 |
| | | const handleDelete = (row) => { |
| | | console.log('删除行数据:', row) |
| | | proxy?.$modal?.confirm('确定要删除吗?删除将无法恢复').then(() => { |
| | | // 这里调用删除接口,传入 row.id |
| | | deletePurchaseReturnOrder(row.id).then(() => { |
| | | proxy?.$modal?.msgSuccess?.("删除成功"); |
| | | getList() |
| | | }).catch(() => { |
| | | proxy?.$modal?.msgError?.('删除失败') |
| | | }) |
| | | }).catch(() => { |
| | | // 取消删除 |
| | | proxy?.$modal?.msgInfo?.('已取消删除') |
| | | |
| | | }) |
| | | } |
| | | // 查看详情 |
| | | const handleDetail = (row) => { |
| | | if (!row?.id) { |
| | | proxy?.$modal?.msgWarning('未获取到单据ID') |
| | | proxy?.$modal?.msgWarning?.('未获取到单据ID') |
| | | return |
| | | } |
| | | detailVisible.value = true |
| | |
| | | payload.purchaseReturnOrderProductsDetailVoList.map(item => ({ ...item, ...item.salesLedgerProduct })) || |
| | | [] |
| | | }).catch(() => { |
| | | proxy?.$modal?.msgError('获取详情失败') |
| | | proxy?.$modal?.msgError?.('获取详情失败') |
| | | }).finally(() => { |
| | | detailLoading.value = false |
| | | }) |