From 21599300cc73ff7384b74cc5e4ac2cbd82bdc293 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 28 十月 2026 18:34:29 +0800
Subject: [PATCH] feat(wls): 更新销售退货功能支持关联销售出库单
---
src/views/wls/returnsales/modules/line-form.vue | 45 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 44 insertions(+), 1 deletions(-)
diff --git a/src/views/wls/returnsales/modules/line-form.vue b/src/views/wls/returnsales/modules/line-form.vue
index 0b574d2..b80815a 100644
--- a/src/views/wls/returnsales/modules/line-form.vue
+++ b/src/views/wls/returnsales/modules/line-form.vue
@@ -8,6 +8,7 @@
import { message } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form';
+import { getReturnableProductSalesLineList } from '#/api/mes/wm/returnsales';
import {
createReturnSalesLine,
getReturnSalesLine,
@@ -20,6 +21,7 @@
const emit = defineEmits(['success']);
const formData = ref<MesWmReturnSalesLineApi.ReturnSalesLine>();
const returnId = ref<number>(); // 鎵�灞為��璐у崟缂栧彿
+const productSalesId = ref<number>(); // 鍏宠仈鐨勯攢鍞嚭搴撳崟缂栧彿
const getTitle = computed(() => {
return formData.value?.id
@@ -40,6 +42,39 @@
showDefaultActions: false,
wrapperClass: 'grid-cols-3',
});
+
+/**
+ * 璁$畻褰撳墠琛屽彲濉啓鐨勬渶澶ф暟閲忥細
+ * 鍙��琛屽垪琛ㄤ腑鐨勫彲閫�鏁伴噺涓嶅惈鏈崟鍗犵敤锛岄渶鍔犱笂鏈宸叉湁鏁伴噺
+ */
+async function loadReturnableQuantity(
+ line: MesWmReturnSalesLineApi.ReturnSalesLine,
+) {
+ if (!productSalesId.value) {
+ return;
+ }
+ const current = Number(line.quantity ?? 0);
+ await formApi.setFieldValue('returnableQuantity', current);
+ if (!line.productSalesLineId) {
+ return;
+ }
+ try {
+ const lines = await getReturnableProductSalesLineList(
+ productSalesId.value,
+ );
+ const matched = lines.find(
+ (item) => item.productSalesLineId === line.productSalesLineId,
+ );
+ if (matched) {
+ await formApi.setFieldValue(
+ 'returnableQuantity',
+ Number(matched.returnableQuantity ?? 0) + current,
+ );
+ }
+ } catch {
+ // 鍑哄簱鍗曞凡涓嶅彲閫�鏃朵繚鎸佹湰琛屾暟閲忎綔涓轰笂闄�
+ }
+}
const [Modal, modalApi] = useVbenModal({
async onConfirm() {
@@ -73,10 +108,17 @@
const data = modalApi.getData<{
clientId?: number;
id?: number;
+ productSalesId?: number;
returnId: number;
}>();
returnId.value = data.returnId;
- formApi.setState({ schema: useLineFormSchema(data.clientId) });
+ productSalesId.value = data.productSalesId;
+ formApi.setState({
+ schema: useLineFormSchema(
+ { clientId: data.clientId, productSalesId: data.productSalesId },
+ formApi,
+ ),
+ });
if (!data.id) {
return;
}
@@ -85,6 +127,7 @@
formData.value = await getReturnSalesLine(data.id);
// 璁剧疆鍒� values
await formApi.setValues(formData.value);
+ await loadReturnableQuantity(formData.value);
} finally {
modalApi.unlock();
}
--
Gitblit v1.9.3