fix(mall): 修复商品 SKU 名称校验失败的问题

pull/860/head
puhui999 2026-01-28 11:06:59 +08:00
parent 7a7228aed8
commit c656f87575
3 changed files with 12 additions and 1 deletions

View File

@ -318,6 +318,7 @@ const props = defineProps({
const formData: Ref<Spu | undefined> = ref<Spu>() //
const skuList = ref<Sku[]>([
{
name: '', // SKU
price: 0, //
marketPrice: 0, //
costPrice: 0, //
@ -449,6 +450,7 @@ const generateTableData = (propertyList: any[]) => {
}
for (const item of buildSkuList) {
const row = {
name: '', // SKU 使 SPU
properties: Array.isArray(item) ? item : [item], // property
price: 0,
marketPrice: 0,
@ -525,6 +527,7 @@ watch(
if (props.isBatch) {
skuList.value = [
{
name: '', // SKU
price: 0,
marketPrice: 0,
costPrice: 0,

View File

@ -173,6 +173,7 @@ const onChangeSpec = () => {
// sku
formData.skus = [
{
name: '', // SKU 使 SPU
price: 0,
marketPrice: 0,
costPrice: 0,

View File

@ -62,6 +62,7 @@ import OtherForm from './OtherForm.vue'
import SkuForm from './SkuForm.vue'
import DeliveryForm from './DeliveryForm.vue'
import { convertToInteger, floatToFixed2, formatToFraction } from '@/utils'
import { isEmpty } from '@/utils/is'
defineOptions({ name: 'ProductSpuAdd' })
@ -94,6 +95,7 @@ const formData = ref<ProductSpuApi.Spu>({
subCommissionType: false, //
skus: [
{
name: '', // SKU 使 SPU
price: 0, //
marketPrice: 0, //
costPrice: 0, //
@ -158,8 +160,13 @@ const submitForm = async () => {
await unref(otherRef)?.validate()
// , server
const deepCopyFormData = cloneDeep(unref(formData.value)) as ProductSpuApi.Spu
// SKU name
if (isEmpty(deepCopyFormData.name)) {
message.error('商品名称不能为空')
return
}
deepCopyFormData.skus!.forEach((item) => {
// sku name
// sku name使 SKU
item.name = deepCopyFormData.name
// sku
item.price = convertToInteger(item.price)