|
|
@@ -132,10 +132,12 @@ export default {
|
|
|
maxStock() {
|
|
|
const spec = this.info.specEnabled == 1 && this.info.specList ? this.info.specList[this.selIndex] : this.info;
|
|
|
let max = Number(spec && spec.stockSet == 1 ? spec.stock : 9999) || 9999;
|
|
|
- const goodsStock = Number(this.info && this.info.stock);
|
|
|
- // 商品本身有库存时,数量上限不超过 data.stock(未开启库存限制时后端会写成 9999)
|
|
|
- if (goodsStock > 0) {
|
|
|
- max = Math.min(max, goodsStock);
|
|
|
+ // 多规格按当前规格库存限制;主记录承载首规格后,不能再用主记录库存截断其他规格
|
|
|
+ if (this.info.specEnabled != 1) {
|
|
|
+ const goodsStock = Number(this.info && this.info.stock);
|
|
|
+ if (goodsStock > 0) {
|
|
|
+ max = Math.min(max, goodsStock);
|
|
|
+ }
|
|
|
}
|
|
|
if (this.isSeckill) {
|
|
|
const actStock = Number(this.activityStock) || 0;
|
|
|
@@ -212,19 +214,14 @@ export default {
|
|
|
return false;
|
|
|
}
|
|
|
const sale = spec || this.info || {};
|
|
|
- const goodsStock = Number(this.info && this.info.stock);
|
|
|
- const specStock = Number(sale.stock);
|
|
|
+ const saleStock = Number(sale.stock);
|
|
|
const stockSet = Number(sale.stockSet != null ? sale.stockSet : (this.info && this.info.stockSet));
|
|
|
- // 商品库存不足,或本次数量超过库存
|
|
|
- if (!(goodsStock > 0) || (stockSet === 1 && !(specStock > 0))) {
|
|
|
- this.$msg('库存不足哦');
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (stockSet === 1 && buyNum > specStock) {
|
|
|
+ // 按当前售卖 SKU 校验库存:多规格时不能拿主记录(首规格)库存去卡其他规格
|
|
|
+ if (!(saleStock > 0) || (stockSet === 1 && buyNum > saleStock)) {
|
|
|
this.$msg('库存不足哦');
|
|
|
return false;
|
|
|
}
|
|
|
- if (goodsStock > 0 && buyNum > goodsStock) {
|
|
|
+ if (stockSet !== 1 && buyNum > saleStock) {
|
|
|
this.$msg('库存不足哦');
|
|
|
return false;
|
|
|
}
|