update product edit
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
</t-cell>
|
||||
<template #right>
|
||||
<t-button class="delete-action swipe-cell-button" theme="danger" @click.stop="requestRemove">
|
||||
停用
|
||||
移除
|
||||
</t-button>
|
||||
</template>
|
||||
</t-swipe-cell>
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
<div class="editor-context">
|
||||
<strong>批量配置销售单位</strong>
|
||||
<span v-text="`以下单位将应用到全部 ${props.skuCount} 个 SKU 明细`" />
|
||||
<t-form-item label="基础单位换算比例" help="切换已有 SKU 的基础单位时填写:1 个旧基础单位等于多少个新基础单位;最多六位小数">
|
||||
<t-input v-model.trim="baseUnitMigrationRatioText" type="number" align="right" borderless placeholder="无需切换时留空" />
|
||||
</t-form-item>
|
||||
</div>
|
||||
|
||||
<div class="unit-list">
|
||||
@@ -71,6 +74,7 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const unitList = defineModel<ProductSkuUnitForm[]>("unitList", { required: true });
|
||||
const baseUnitMigrationRatioText = defineModel<string>("baseUnitMigrationRatioText", { default: "" });
|
||||
const emit = defineEmits<{
|
||||
"update:modelValue": [value: boolean];
|
||||
apply: [];
|
||||
|
||||
@@ -27,8 +27,7 @@
|
||||
theme="danger"
|
||||
variant="text"
|
||||
size="extra-small"
|
||||
:content="unit.id ? '停售' : '删除'"
|
||||
:disabled="!!unit.id && unit.allowSale === false && unit.allowPurchase === false"
|
||||
content="移除"
|
||||
@click="removeUnit(unitIndex)"
|
||||
/>
|
||||
</div>
|
||||
@@ -39,6 +38,9 @@
|
||||
<t-form-item label="基础单位" content-align="right">
|
||||
<t-switch v-model="unit.isBase" size="small" :disabled="sku.unitList.length === 1" @change="setBaseUnit(unitIndex)" />
|
||||
</t-form-item>
|
||||
<t-form-item v-if="isBaseUnitMigrationRequired" label="新旧基础单位比例" help="填写 1 个旧基础单位等于多少个新基础单位;最多六位小数" required-mark>
|
||||
<t-input v-model.trim="sku.baseUnitMigrationRatioText" type="number" align="right" borderless placeholder="例如 30" />
|
||||
</t-form-item>
|
||||
<t-form-item label="换算数量" help="1 个当前单位对应的基础单位数量" required-mark>
|
||||
<t-input v-model.trim="unit.baseQuantityPerUnit" type="number" align="right" borderless :disabled="unit.isBase" placeholder="1" />
|
||||
</t-form-item>
|
||||
@@ -91,6 +93,12 @@ const visible = computed({
|
||||
set: value => handleVisibleChange(value)
|
||||
});
|
||||
const unitEditorZIndex = 12100;
|
||||
const isBaseUnitMigrationRequired = computed(() => {
|
||||
if (!sku.value?.originalBaseUnitId) {
|
||||
return false;
|
||||
}
|
||||
return sku.value.unitList.find(unit => unit.isBase)?.id !== sku.value.originalBaseUnitId;
|
||||
});
|
||||
|
||||
function handleVisibleChange(value: boolean): void {
|
||||
emit("update:modelValue", value);
|
||||
@@ -135,10 +143,7 @@ function removeUnit(index: number): void {
|
||||
}
|
||||
const unit = sku.value.unitList[index];
|
||||
if (unit?.id) {
|
||||
unit.allowSale = false;
|
||||
unit.allowPurchase = false;
|
||||
Message.success("单位已停售并禁止采购,历史订单仍可履约");
|
||||
return;
|
||||
Message.info("已移除单位将在保存时由后端检查引用后处理");
|
||||
}
|
||||
const wasBase = sku.value.unitList[index]?.isBase;
|
||||
sku.value.unitList.splice(index, 1);
|
||||
|
||||
Reference in New Issue
Block a user