Authored by 李奇

库存为0的商品上架修改

... ... @@ -205,15 +205,37 @@
this.productList(params);
},
setOnSale(skns) {
setOnSale(rows) {
const params = {
targetStatus: 1
};
if (_.isArray(skns)) {
params.productSkns = `[${skns.join(',')}]`;
let inValid = [];
let sknArray = [];
if (_.isArray(rows)) {
_.each(rows, item => {
if (item.stock < 1) {
inValid.push(item.productSkn);
}
sknArray.push(item.productSkn);
});
if (inValid.length) {
const error = inValid.join(':库存为0不能上架;');
this.$Message.error(`${error}:库存为0不能上架;`, 5);
return;
}
params.productSkns = `[${sknArray.join(',')}]`;
} else {
params.productSkns = `[${skns}]`;
if (rows.stock < 1) {
this.$Message.error('库存为0的商品不能上架');
return;
}
params.productSkns = `[${rows.productSkn}]`;
}
service.setOnSale(params)
... ... @@ -229,13 +251,7 @@
return;
}
let skns = [];
_.each(this.batchOnSale, (item) => {
skns.push(item.productSkn);
});
this.setOnSale(skns);
this.setOnSale(this.batchOnSale);
},
editPrice(row) {
row.changePrice = true;
... ...
... ... @@ -241,7 +241,7 @@ export default () => {
</div>
<div class="cell-action-row">
<i-button type="success" size="small"
@click="setOnSale(${row.productSkn})">商品上架</i-button>
@click="setOnSale(row)">商品上架</i-button>
</div>
</div>`;
},
... ...