From 342439b018786854ec0b49a2cf26fe422ca9121d Mon Sep 17 00:00:00 2001
From: ZN <zhang_12370@163.com>
Date: 星期一, 23 三月 2026 09:43:21 +0800
Subject: [PATCH] feat(采购退货): 增加删除采购退货单功能并优化相关操作
---
src/api/procurementManagement/purchase_return_order.js | 9 +++
src/components/PIMTable/PIMTable.vue | 6 +-
src/views/procurementManagement/purchaseReturnOrder/New.vue | 86 ++++++++++++++++++++++++++--
src/views/procurementManagement/purchaseReturnOrder/index.vue | 48 +++++++++++++---
4 files changed, 130 insertions(+), 19 deletions(-)
diff --git a/src/api/procurementManagement/purchase_return_order.js b/src/api/procurementManagement/purchase_return_order.js
index 06a57f9..aeb380d 100644
--- a/src/api/procurementManagement/purchase_return_order.js
+++ b/src/api/procurementManagement/purchase_return_order.js
@@ -26,4 +26,13 @@
url: "/purchaseReturnOrders/selectById/" + id,
method: "get",
});
+}
+
+// 閲囪喘閫�璐у崟鍒犻櫎
+// POST purchaseReturnOrders/deleteById/xxx
+export function deletePurchaseReturnOrder(id) {
+ return request({
+ url: "/purchaseReturnOrders/deleteById/" + id,
+ method: "post",
+ });
}
\ No newline at end of file
diff --git a/src/components/PIMTable/PIMTable.vue b/src/components/PIMTable/PIMTable.vue
index eb0cf87..8e22459 100644
--- a/src/components/PIMTable/PIMTable.vue
+++ b/src/components/PIMTable/PIMTable.vue
@@ -367,11 +367,11 @@
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) => {
diff --git a/src/views/procurementManagement/purchaseReturnOrder/New.vue b/src/views/procurementManagement/purchaseReturnOrder/New.vue
index f130733..17e36dc 100644
--- a/src/views/procurementManagement/purchaseReturnOrder/New.vue
+++ b/src/views/procurementManagement/purchaseReturnOrder/New.vue
@@ -334,12 +334,17 @@
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="璇疯緭鍏ユ暣鍗曟姌鎵g巼"/>
+ @change="totalDiscount"
+ placeholder="璇疯緭鍏ユ暣鍗曟姌鎵g巼">
+ <template #append>
+ %
+ </template>
+ </el-input>
</el-form-item>
<el-form-item
@@ -412,7 +417,24 @@
}
});
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锛�
@@ -509,6 +531,26 @@
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涔嬮棿鐨勬姌鎵g巼")
+ 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) {
@@ -541,14 +583,39 @@
};
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))
@@ -594,6 +661,11 @@
// 澶勭悊鏀瑰彉閲囪喘鍙拌处鏁版嵁
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,
diff --git a/src/views/procurementManagement/purchaseReturnOrder/index.vue b/src/views/procurementManagement/purchaseReturnOrder/index.vue
index 1ac769e..8de2877 100644
--- a/src/views/procurementManagement/purchaseReturnOrder/index.vue
+++ b/src/views/procurementManagement/purchaseReturnOrder/index.vue
@@ -36,6 +36,7 @@
>
<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>
@@ -113,7 +114,7 @@
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([])
@@ -218,13 +219,24 @@
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: {
@@ -240,9 +252,27 @@
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
@@ -257,7 +287,7 @@
payload.purchaseReturnOrderProductsDetailVoList.map(item => ({ ...item, ...item.salesLedgerProduct })) ||
[]
}).catch(() => {
- proxy?.$modal?.msgError('鑾峰彇璇︽儏澶辫触')
+ proxy?.$modal?.msgError?.('鑾峰彇璇︽儏澶辫触')
}).finally(() => {
detailLoading.value = false
})
--
Gitblit v1.9.3