更改商品添加初始化为undefined

This commit is contained in:
魏啾 2024-09-01 17:56:27 +08:00
parent d0f567209b
commit d99fb079c0
2 changed files with 35 additions and 12 deletions

View File

@ -103,8 +103,9 @@
<el-table :data="form.skuList" border>
<el-table-column label="售价" prop="salePrice">
<template v-slot="scope">
<el-input-number @change="priceFormat(scope.row, 'salePrice')" @blur="priceFormat(scope.row, 'salePrice')"
v-model="scope.row.salePrice" controls-position="right"></el-input-number>
<el-input-number size="mini" @change="priceFormat(scope.row, 'salePrice')"
@blur="priceFormat(scope.row, 'salePrice')" v-model="scope.row.salePrice"
controls-position="right"></el-input-number>
</template>
</el-table-column>
<el-table-column label="会员价" prop="memberPrice">
@ -214,10 +215,9 @@
</el-table-column>
<el-table-column label="图片" prop="coverImg" width="80">
<template v-slot="scope">
<uploadImg type="text" :limit="1" @success="res => (scope.row.coverImg = res[0])"
v-if="!scope.row.coverImg" />
<uploadImg v-if="!scope.row.coverImg" type="text" :limit="1" @success="res => (scope.row.coverImg = res[0])" />
<el-image style="width:30px;height:30px;" :src="scope.row.coverImg" v-else />
<i class="el-icon-error " v-if="scope.row.coverImg" @click="scope.row.coverImg = ''"></i>
<i class="el-icon-error " v-if="scope.row.coverImg" @click="scope.row.coverImg = ''" />
</template>
</el-table-column>
<el-table-column label="售价" prop="salePrice">
@ -427,15 +427,15 @@ export default {
selectSpec: [],
selectSpecResult: false,
defaultSku: {
salePrice: 0,
memberPrice: 0,
costPrice: 0,
originPrice: 0,
stockNumber: 0,
firstShared: 0,
salePrice: undefined,
memberPrice: undefined,
costPrice: undefined,
originPrice: undefined,
stockNumber: undefined,
firstShared: undefined,
barCode: `${localStorage.getItem("shopId")}${dayjs().valueOf()}`,
isGrounding: 1,
productId: this.$route.query.goods_id,
productId: this.$route.query.goods_id ? this.$route.query.goods_id : '',
shopId: localStorage.getItem("shopId"),
suit: 0
},
@ -690,8 +690,30 @@ export default {
console.log(error);
}
},
//
submitHandle() {
console.log(this.form.skuList)
const hasUndefined = this.form.skuList.some(obj => {
for (const key in obj) {
if (obj[key] === undefined) {
return true; // undefinedtrue
}
}
return false; // undefinedfalse
});
//
if (hasUndefined) {
this.$message({
message: '请完善规格属性的参数!',
type: 'warning'
});
return false;
}
this.imgList.forEach(ele => {
arr.push(ele.url)
})
let arr = []
this.imgList.forEach(ele => {
arr.push(ele.url)

View File

@ -52,6 +52,7 @@
<el-table-column label="售价">
<template v-slot="scope">
<span>{{ scope.row.lowPrice }}</span>
<span v-if="scope.row.typeEnum == '多规格'">~{{ scope.row.maxPrice }}</span>
</template>
</el-table-column>
<el-table-column label="商品规格" prop="typeEnum">