mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
fix: 编辑商品内调价后同步刷新表单 SKU 成本展示
This commit is contained in:
+35
-1
@@ -1,5 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import type { ProductDTO, ProductVO } from '#/api/ec/product/types';
|
||||
import type { ProductSkuVO } from '#/api/ec/product/sku/types';
|
||||
|
||||
import type { DropdownRender } from 'ant-design-vue/es/vc-select/BaseSelect';
|
||||
import { computed, h, nextTick, onUnmounted, ref } from 'vue';
|
||||
@@ -80,6 +81,39 @@ function openCostDrawer() {
|
||||
productSkuCostDrawerRef.value?.open(product);
|
||||
}
|
||||
|
||||
/** 成本抽屉调价/删段后,同步刷新本表单只读成本列 */
|
||||
function applySkuCostFromDrawer(vo: ProductSkuVO.Info) {
|
||||
const skuId = vo.id;
|
||||
if (skuId == null) return;
|
||||
|
||||
const patch = {
|
||||
productCost: Number(vo.productCost ?? 0),
|
||||
shippingCost: Number(vo.shippingCost ?? 0),
|
||||
otherCost: Number(vo.otherCost ?? 0),
|
||||
costEffectiveFrom: vo.costEffectiveFrom,
|
||||
};
|
||||
|
||||
const idx = skus.value.findIndex((s) => s.id === skuId);
|
||||
if (idx >= 0) {
|
||||
skus.value[idx] = { ...skus.value[idx]!, ...patch };
|
||||
}
|
||||
|
||||
const productSkus = currentProductData.value?.skus;
|
||||
if (productSkus) {
|
||||
const pIdx = productSkus.findIndex((s) => s.id === skuId);
|
||||
if (pIdx >= 0) {
|
||||
productSkus[pIdx] = { ...productSkus[pIdx]!, ...patch };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onCostDrawerSuccess(payload?: { sku?: ProductSkuVO.Info }) {
|
||||
if (payload?.sku) {
|
||||
applySkuCostFromDrawer(payload.sku);
|
||||
}
|
||||
emit('success');
|
||||
}
|
||||
|
||||
// 内部状态管理
|
||||
const isEdit = ref(false);
|
||||
const currentProductData = ref<null | Partial<ProductVO.Info> | ProductVO.Info>(
|
||||
@@ -1141,7 +1175,7 @@ onUnmounted(() => {
|
||||
|
||||
<ProductSkuCostDrawer
|
||||
ref="productSkuCostDrawerRef"
|
||||
@success="emit('success')"
|
||||
@success="onCostDrawerSuccess"
|
||||
/>
|
||||
|
||||
<ProductSkuMigrateModal
|
||||
|
||||
+4
-3
@@ -25,7 +25,8 @@ import ProductSkuCostFormModal from './ProductSkuCostFormModal.vue';
|
||||
defineOptions({ name: 'ProductSkuCostDrawer' });
|
||||
|
||||
const emit = defineEmits<{
|
||||
success: [];
|
||||
/** 成本变更后通知外层;带上最新 SKU 便于编辑表单就地刷新 */
|
||||
success: [payload?: { sku?: ProductSkuVO.Info }];
|
||||
}>();
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
@@ -225,7 +226,7 @@ async function onCostFormSuccess(payload: {
|
||||
if (selectedSkuId.value != null) {
|
||||
await loadHistory(selectedSkuId.value);
|
||||
}
|
||||
emit('success');
|
||||
emit('success', { sku: payload.sku });
|
||||
if (payload.costChanged) {
|
||||
message.info('已标记 BI 待重算,请在工作台查看数据健康度');
|
||||
}
|
||||
@@ -239,7 +240,7 @@ async function handleDeleteHistory(row: ProductSkuCostVO.History) {
|
||||
if (selectedSkuId.value != null) {
|
||||
await loadHistory(selectedSkuId.value);
|
||||
}
|
||||
emit('success');
|
||||
emit('success', { sku: vo ?? undefined });
|
||||
message.success('已删除成本段,已标记 BI 待重算');
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
Reference in New Issue
Block a user