fix off product sku for keep fulfillment
This commit is contained in:
@@ -418,11 +418,19 @@ function closeBatchUnitEditor(): void {
|
||||
|
||||
function applyBatchUnitTemplate(): void {
|
||||
const templateList = batchUnitList.value;
|
||||
for (const sku of form.skuList) {
|
||||
const templateNameSet = new Set(templateList.map(unit => unit.name.trim()));
|
||||
if (sku.unitList.some(unit => !!unit.id && !templateNameSet.has(unit.name.trim()))) {
|
||||
Message.warning("统一配置不能删除或重命名已保存单位,请在 SKU 明细中停售");
|
||||
return;
|
||||
}
|
||||
}
|
||||
form.skuList.forEach(sku => {
|
||||
const oldUnitList = sku.unitList;
|
||||
const oldUnitMap = new Map(oldUnitList.filter(unit => !!unit.id).map(unit => [unit.name.trim(), unit]));
|
||||
sku.unitList = templateList.map((unit, unitIndex) => ({
|
||||
...unit,
|
||||
id: oldUnitList[unitIndex]?.id,
|
||||
id: oldUnitMap.get(unit.name.trim())?.id,
|
||||
skuId: sku.id,
|
||||
clientKey: window.crypto.randomUUID(),
|
||||
sort: unitIndex
|
||||
|
||||
@@ -28,7 +28,15 @@
|
||||
<div v-for="(unit, unitIndex) in sku.unitList" :key="unit.clientKey" class="unit-card">
|
||||
<div class="unit-card-header">
|
||||
<strong v-text="`单位 ${unitIndex + 1}`" />
|
||||
<t-button v-if="1 < sku.unitList.length" theme="danger" variant="text" size="extra-small" content="删除" @click="removeUnit(unitIndex)" />
|
||||
<t-button
|
||||
v-if="1 < sku.unitList.length"
|
||||
theme="danger"
|
||||
variant="text"
|
||||
size="extra-small"
|
||||
:content="unit.id ? '停售' : '删除'"
|
||||
:disabled="!!unit.id && unit.allowSale === false && unit.allowPurchase === false"
|
||||
@click="removeUnit(unitIndex)"
|
||||
/>
|
||||
</div>
|
||||
<t-form class="unit-form" label-align="left" label-width="6rem">
|
||||
<t-form-item label="单位名称" required-mark>
|
||||
@@ -134,6 +142,13 @@ function removeUnit(index: number): void {
|
||||
Message.warning("每个 SKU 至少需要一个单位");
|
||||
return;
|
||||
}
|
||||
const unit = sku.value.unitList[index];
|
||||
if (unit?.id) {
|
||||
unit.allowSale = false;
|
||||
unit.allowPurchase = false;
|
||||
Message.success("单位已停售并禁止采购,历史订单仍可履约");
|
||||
return;
|
||||
}
|
||||
const wasBase = sku.value.unitList[index]?.isBase;
|
||||
sku.value.unitList.splice(index, 1);
|
||||
if (wasBase && sku.value.unitList[0]) {
|
||||
|
||||
Reference in New Issue
Block a user