|
@@ -25,9 +25,7 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item
|
|
|
label="商品规格:"
|
|
|
- :rules="[
|
|
|
- { required: true, message: '请选择商品规格', trigger: 'blur' },
|
|
|
- ]"
|
|
|
+ :rules="[{ required: true, message: '请选择商品规格', trigger: 'blur' }]"
|
|
|
>
|
|
|
<el-card shadow="never" class="cardBg">
|
|
|
<div v-for="(productAttr, idx) in selectProductAttr">
|
|
@@ -84,11 +82,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</el-card>
|
|
|
- <el-table
|
|
|
- style="width: 100%; margin-top: 20px"
|
|
|
- :data="skuStockList"
|
|
|
- border
|
|
|
- >
|
|
|
+ <el-table style="width: 100%; margin-top: 20px" :data="skuStockList" border>
|
|
|
<el-table-column
|
|
|
v-for="(item, index) in selectProductAttr"
|
|
|
:label="item.name"
|
|
@@ -101,41 +95,31 @@
|
|
|
</el-table-column>
|
|
|
<el-table-column label="销售价格" width="80" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-input
|
|
|
- v-model="scope.row.price"
|
|
|
- :disabled="!isEdit"
|
|
|
- ></el-input>
|
|
|
+ <el-input v-model="scope.row.price" :disabled="!isEdit"></el-input>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="商品库存" width="80" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-input
|
|
|
- v-model="scope.row.stock"
|
|
|
- :disabled="!isEdit"
|
|
|
- ></el-input>
|
|
|
+ <el-input v-model="scope.row.stock" :disabled="!isEdit"></el-input>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="库存预警值" width="80" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-input
|
|
|
- v-model="scope.row.lowStock"
|
|
|
- :disabled="!isEdit"
|
|
|
- ></el-input>
|
|
|
+ <el-input v-model="scope.row.lowStock" :disabled="!isEdit"></el-input>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="SKU编号" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
<el-input
|
|
|
-
|
|
|
v-model="scope.row.skuCode"
|
|
|
- :disabled="(scope.row.platformLock ||!isEdit )"
|
|
|
+ :disabled="scope.row.platformLock || !isEdit"
|
|
|
></el-input>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="操作" width="80" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
<el-button
|
|
|
- v-if="!scope.row.platformLock"
|
|
|
+ v-if="!scope.row.platformLock"
|
|
|
:disabled="!isEdit"
|
|
|
type="text"
|
|
|
@click="handleRemoveProductSku(scope.$index, scope.row)"
|
|
@@ -209,10 +193,7 @@
|
|
|
</el-card>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="商品相册:">
|
|
|
- <multi-upload
|
|
|
- v-model="selectProductPics"
|
|
|
- :disabled="!isEdit"
|
|
|
- ></multi-upload>
|
|
|
+ <multi-upload v-model="selectProductPics" :disabled="!isEdit"></multi-upload>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="规格参数:">
|
|
|
<el-tabs v-model="activeHtmlName" type="card">
|
|
@@ -235,9 +216,7 @@
|
|
|
</el-tabs>
|
|
|
</el-form-item>
|
|
|
<el-form-item style="text-align: center">
|
|
|
- <el-button size="medium" @click="handlePrev"
|
|
|
- >上一步,填写商品促销</el-button
|
|
|
- >
|
|
|
+ <el-button size="medium" @click="handlePrev">上一步,填写商品促销</el-button>
|
|
|
<!-- <el-button type="primary" size="medium" @click="handleNext"
|
|
|
>下一步,选择商品关联</el-button
|
|
|
> -->
|
|
@@ -350,7 +329,7 @@ export default {
|
|
|
},
|
|
|
created() {},
|
|
|
mounted() {
|
|
|
- console.log(this.value.skuStockList,'skuStockList');
|
|
|
+ console.log(this.value.skuStockList, "skuStockList");
|
|
|
this.handleEditCreated();
|
|
|
this.getProductAttrCateList();
|
|
|
},
|
|
@@ -412,7 +391,7 @@ export default {
|
|
|
}
|
|
|
if (this.isEdit) {
|
|
|
//编辑模式下刷新商品属性图片
|
|
|
- console.log('编辑模式刷新属性')
|
|
|
+ console.log("编辑模式刷新属性");
|
|
|
this.refreshProductAttrPics();
|
|
|
}
|
|
|
} else {
|
|
@@ -542,15 +521,9 @@ export default {
|
|
|
cancelButtonText: "取消",
|
|
|
type: "warning",
|
|
|
}).then(() => {
|
|
|
- if (
|
|
|
- this.value.skuStockList !== null &&
|
|
|
- this.value.skuStockList.length > 0
|
|
|
- ) {
|
|
|
+ if (this.value.skuStockList !== null && this.value.skuStockList.length > 0) {
|
|
|
let tempSkuList = [];
|
|
|
- tempSkuList = tempSkuList.concat(
|
|
|
- tempSkuList,
|
|
|
- this.value.skuStockList
|
|
|
- );
|
|
|
+ tempSkuList = tempSkuList.concat(tempSkuList, this.value.skuStockList);
|
|
|
let price = this.value.skuStockList[0].price;
|
|
|
for (let i = 0; i < tempSkuList.length; i++) {
|
|
|
tempSkuList[i].price = price;
|
|
@@ -569,15 +542,9 @@ export default {
|
|
|
cancelButtonText: "取消",
|
|
|
type: "warning",
|
|
|
}).then(() => {
|
|
|
- if (
|
|
|
- this.value.skuStockList !== null &&
|
|
|
- this.value.skuStockList.length > 0
|
|
|
- ) {
|
|
|
+ if (this.value.skuStockList !== null && this.value.skuStockList.length > 0) {
|
|
|
let tempSkuList = [];
|
|
|
- tempSkuList = tempSkuList.concat(
|
|
|
- tempSkuList,
|
|
|
- this.value.skuStockList
|
|
|
- );
|
|
|
+ tempSkuList = tempSkuList.concat(tempSkuList, this.value.skuStockList);
|
|
|
let stock = this.value.skuStockList[0].stock;
|
|
|
let lowStock = this.value.skuStockList[0].lowStock;
|
|
|
for (let i = 0; i < tempSkuList.length; i++) {
|
|
@@ -609,9 +576,7 @@ export default {
|
|
|
for (let i = 0; i < attr0.values.length; i++) {
|
|
|
if (attr1.values.length === 0) {
|
|
|
skuList.push({
|
|
|
- spData: JSON.stringify([
|
|
|
- { key: attr0.name, value: attr0.values[i] },
|
|
|
- ]),
|
|
|
+ spData: JSON.stringify([{ key: attr0.name, value: attr0.values[i] }]),
|
|
|
});
|
|
|
continue;
|
|
|
}
|
|
@@ -631,9 +596,7 @@ export default {
|
|
|
for (let i = 0; i < attr0.values.length; i++) {
|
|
|
if (attr1.values.length === 0) {
|
|
|
skuList.push({
|
|
|
- spData: JSON.stringify([
|
|
|
- { key: attr0.name, value: attr0.values[i] },
|
|
|
- ]),
|
|
|
+ spData: JSON.stringify([{ key: attr0.name, value: attr0.values[i] }]),
|
|
|
});
|
|
|
continue;
|
|
|
}
|
|
@@ -689,11 +652,7 @@ export default {
|
|
|
this.value.productAttributeValueList = [];
|
|
|
for (let i = 0; i < this.selectProductAttr.length; i++) {
|
|
|
let attr = this.selectProductAttr[i];
|
|
|
- if (
|
|
|
- attr.handAddStatus === 1 &&
|
|
|
- attr.options != null &&
|
|
|
- attr.options.length > 0
|
|
|
- ) {
|
|
|
+ if (attr.handAddStatus === 1 && attr.options != null && attr.options.length > 0) {
|
|
|
this.value.productAttributeValueList.push({
|
|
|
productAttributeId: attr.id,
|
|
|
value: this.getOptionStr(attr.options),
|
|
@@ -755,7 +714,18 @@ export default {
|
|
|
this.$message.error("请编辑商品规格");
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+ let flag = false;
|
|
|
+ const reg = /(?!(^[0.]*$))((^[1-9]\d*$)|(?!(^0{2,}.))(?!(^0{1,}[1-9]+))(^[0-9]+.\d{1,2}$))/;
|
|
|
+ this.value.skuStockList.forEach((element) => {
|
|
|
+ console.log(element, "element.price", (element.price + "").match(reg));
|
|
|
+ if (!(element.price + "").match(reg)) {
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (flag) {
|
|
|
+ this.$message.error("请填写正确的销售价格");
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.mergeProductAttrValue();
|
|
|
this.mergeProductAttrPics();
|
|
|
this.$emit("nextStep");
|
|
@@ -773,7 +743,18 @@ export default {
|
|
|
this.$message.error("请编辑商品规格");
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+ let flag = false;
|
|
|
+ const reg = /(?!(^[0.]*$))((^[1-9]\d*$)|(?!(^0{2,}.))(?!(^0{1,}[1-9]+))(^[0-9]+.\d{1,2}$))/;
|
|
|
+ this.value.skuStockList.forEach((element) => {
|
|
|
+ console.log(element, "element.price", (element.price + "").match(reg));
|
|
|
+ if (!(element.price + "").match(reg)) {
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (flag) {
|
|
|
+ this.$message.error("请填写正确的销售价格");
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.mergeProductAttrValue();
|
|
|
this.mergeProductAttrPics();
|
|
|
this.$emit("finishCommit", this.isEdit);
|