From 858df78951d5c29e8d4217cffcf81d2cc4fabcd4 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 03 八月 2026 14:58:59 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_pro2.0' into dev_pro2.0
---
src/views/erp/sale/return/modules/item-form.vue | 75 ++++++++++++++++++++++++++++++++++++-
1 files changed, 72 insertions(+), 3 deletions(-)
diff --git a/src/views/erp/sale/return/modules/item-form.vue b/src/views/erp/sale/return/modules/item-form.vue
index af30c83..04cb817 100644
--- a/src/views/erp/sale/return/modules/item-form.vue
+++ b/src/views/erp/sale/return/modules/item-form.vue
@@ -1,5 +1,6 @@
<script lang="ts" setup>
import type { MdmItemApi } from '#/api/mdm/item';
+import type { ErpSaleOrderApi } from '#/api/erp/sale/order';
import type { ErpSaleReturnApi } from '#/api/erp/sale/return';
import { computed, nextTick, onMounted, ref, watch } from 'vue';
@@ -24,6 +25,7 @@
disabled?: boolean;
discountPercent?: number;
otherPrice?: number;
+ orderItems?: ErpSaleOrderApi.SaleOrderItem[];
}
const props = withDefaults(defineProps<Props>(), {
@@ -31,6 +33,7 @@
disabled: false,
discountPercent: 0,
otherPrice: 0,
+ orderItems: () => [],
});
const emit = defineEmits([
@@ -141,6 +144,57 @@
emit('update:items', [...tableData.value]);
}
+/** 澶勭悊鏂板鐗╂枡琛� */
+function handleAdd() {
+ const newRow: ErpSaleReturnApi.SaleReturnItem = {
+ seq: Date.now(),
+ productId: undefined,
+ productName: '',
+ productPrice: 0,
+ productUnitId: undefined,
+ productUnitName: '',
+ count: 0,
+ totalProductPrice: 0,
+ taxPercent: 0,
+ taxPrice: 0,
+ totalPrice: 0,
+ remark: '',
+ };
+ tableData.value.push(newRow);
+ emit('update:items', [...tableData.value]);
+}
+
+/** 澶勭悊浜у搧鍙樻洿锛氫紭鍏堜粠鍏宠仈璁㈠崟鐗╂枡涓~鍏咃紝鍏滃簳浠庡叏閮ㄧ墿鏂欎腑鏌ユ壘 */
+function handleProductChange(row: ErpSaleReturnApi.SaleReturnItem) {
+ // 浼樺厛浠庡叧鑱旇鍗曠殑鐗╂枡涓煡鎵�
+ const orderItem = props.orderItems.find(
+ (item) => item.productId === row.productId,
+ );
+ if (orderItem) {
+ row.productName = orderItem.productName;
+ row.productPrice = orderItem.productPrice ?? 0;
+ row.productUnitId = orderItem.productUnitId;
+ row.productUnitName = orderItem.productUnitName;
+ row.productBarCode = orderItem.productBarCode;
+ row.taxPercent = orderItem.taxPercent ?? 0;
+ row.count = row.count || 1;
+ handleRowChange(row);
+ return;
+ }
+ // 鍏滃簳锛氫粠鍏ㄩ儴鐗╂枡涓煡鎵�
+ const product = productOptions.value.find((item) => item.id === row.productId);
+ if (product) {
+ row.productName = product.name || '';
+ row.productPrice = product.salesPrice ?? 0;
+ row.productUnitId = product.unitMeasureId;
+ row.productUnitName = product.unitMeasureName;
+ row.productBarCode = product.barCode;
+ row.taxPercent = 0;
+ row.count = row.count || 1;
+ handleRowChange(row);
+ }
+}
+
/** 澶勭悊浠撳簱鍙樻洿 */
async function handleWarehouseChange(row: ErpSaleReturnApi.SaleReturnItem) {
const stockCount = await getWarehouseStockCount({
@@ -177,6 +231,9 @@
for (let i = 0; i < tableData.value.length; i++) {
const item = tableData.value[i];
if (item) {
+ if (!item.productId) {
+ throw new Error(`绗� ${i + 1} 琛岋細浜у搧涓嶈兘涓虹┖`);
+ }
if (!item.warehouseId) {
throw new Error(`绗� ${i + 1} 琛岋細浠撳簱涓嶈兘涓虹┖`);
}
@@ -215,13 +272,14 @@
</template>
<template #productId="{ row }">
<Select
- disabled
+ :disabled="disabled"
v-model:value="row.productId"
- :options="productOptions"
- :field-names="{ label: 'name', value: 'id' }"
+ :options="orderItems?.length ? orderItems : productOptions"
+ :field-names="orderItems?.length ? { label: 'productName', value: 'productId' } : { label: 'name', value: 'id' }"
class="w-full"
placeholder="璇烽�夋嫨浜у搧"
show-search
+ @change="handleProductChange(row)"
/>
</template>
<template #count="{ row }">
@@ -291,6 +349,17 @@
</div>
</div>
</div>
+ <TableAction
+ v-if="!disabled"
+ class="mt-2 flex justify-center"
+ :actions="[
+ {
+ label: '娣诲姞閫�璐т骇鍝�',
+ type: 'default',
+ onClick: handleAdd,
+ },
+ ]"
+ />
</template>
</Grid>
</template>
--
Gitblit v1.9.3