add product sku
This commit is contained in:
@@ -70,9 +70,9 @@ import ProductAPI from "@/api/ProductAPI";
|
||||
import PhotoScroller from "@/components/PhotoScroller.vue";
|
||||
import type {
|
||||
Product,
|
||||
ProductSku,
|
||||
ProductStock,
|
||||
ProductStockChangeRequest,
|
||||
ProductUnit,
|
||||
StockOperationType
|
||||
} from "@/types/Product";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
@@ -86,6 +86,7 @@ type PickerValue = string | number;
|
||||
|
||||
interface Props {
|
||||
product: Product;
|
||||
sku: ProductSku;
|
||||
stock?: ProductStock;
|
||||
operation: ManualStockOperation;
|
||||
}
|
||||
@@ -108,7 +109,7 @@ const unitPickerZIndex = 12001;
|
||||
const unitPickerOverlayZIndex = unitPickerZIndex - 1;
|
||||
|
||||
const isInbound = computed(() => props.operation === "MANUAL_IN" || props.operation === "STOCKTAKE_GAIN");
|
||||
const selectableUnits = computed<ProductUnit[]>(() => (props.product.unitList || []).filter(unit => isInbound.value ? unit.allowPurchase : unit.allowSale));
|
||||
const selectableUnits = computed(() => (props.sku.unitList || []).filter(unit => isInbound.value ? unit.allowPurchase : unit.allowSale));
|
||||
const unitOptions = computed(() => [selectableUnits.value.map(unit => ({ label: unit.name || "未命名单位", value: unit.id || "" }))]);
|
||||
const selectedUnitName = computed(() => selectableUnits.value.find(unit => unit.id === selectedUnitId.value)?.name || "选择业务单位");
|
||||
const quickRemarkText = computed(() => props.operation === "MANUAL_IN" ? "正常入库" : props.operation === "MANUAL_OUT" ? "正常出库" : "");
|
||||
@@ -148,7 +149,7 @@ function validate(): boolean {
|
||||
Message.warning("数量必须是大于 0 的数字,最多三位小数");
|
||||
return false;
|
||||
}
|
||||
if (!props.product.allowDecimalQuantity && !/^\d+$/.test(quantity.value)) {
|
||||
if (!props.sku.allowDecimalQuantity && !/^\d+$/.test(quantity.value)) {
|
||||
Message.warning("该产品不允许输入小数数量");
|
||||
return false;
|
||||
}
|
||||
@@ -166,8 +167,8 @@ function validate(): boolean {
|
||||
function buildRequest(): ProductStockChangeRequest {
|
||||
return {
|
||||
requestNo: requestNo.value || (requestNo.value = createProductRequestNo()),
|
||||
productId: props.product.id || "",
|
||||
productUnitId: selectedUnitId.value,
|
||||
skuId: props.sku.id || "",
|
||||
skuUnitId: selectedUnitId.value,
|
||||
quantity: quantity.value,
|
||||
remark: remark.value.trim(),
|
||||
attachmentList: photoItems.value.flatMap(item => item.tempFileId ? [{ tempFileId: item.tempFileId, attachType: item.attachType || "PHOTO" }] : [])
|
||||
|
||||
Reference in New Issue
Block a user