修改在已有秒杀商品情况下添加新的秒杀商品 数据保存错误问题

master
pikachu 2021-08-16 19:54:18 +08:00
parent f33efac045
commit db919a57f3
1 changed files with 293 additions and 265 deletions

View File

@ -99,7 +99,8 @@
size="small" size="small"
ghost ghost
@click="delGoods(index, row)" @click="delGoods(index, row)"
>删除</Button >删除
</Button
> >
</template> </template>
</Table> </Table>
@ -114,7 +115,8 @@
:loading="submitLoading" :loading="submitLoading"
v-if="promotionStatus === 'NEW'" v-if="promotionStatus === 'NEW'"
@click="save" @click="save"
>提交</Button >提交
</Button
> >
</Row> </Row>
</Card> </Card>
@ -126,14 +128,15 @@
</div> </div>
</template> </template>
<script> <script>
import { import {
seckillGoodsList, seckillGoodsList,
seckillDetail, seckillDetail,
setSeckillGoods, setSeckillGoods,
delSeckillGoods delSeckillGoods
} from "@/api/promotion.js"; } from "@/api/promotion.js";
import skuSelect from "@/views/lili-dialog"; import skuSelect from "@/views/lili-dialog";
export default {
export default {
components: { components: {
skuSelect, skuSelect,
}, },
@ -218,6 +221,8 @@ export default {
save() { save() {
let list = JSON.parse(JSON.stringify(this.goodsList)); let list = JSON.parse(JSON.stringify(this.goodsList));
console.warn(list)
let params = { let params = {
seckillId: this.$route.query.id, seckillId: this.$route.query.id,
applyVos: [], applyVos: [],
@ -229,6 +234,9 @@ export default {
}); });
}); });
this.submitLoading = true; this.submitLoading = true;
console.log(list)
setSeckillGoods(params).then((res) => { setSeckillGoods(params).then((res) => {
this.submitLoading = false; this.submitLoading = false;
if (res && res.success) { if (res && res.success) {
@ -313,10 +321,9 @@ export default {
}, },
selectedGoodsData(item) { selectedGoodsData(item) {
// //
let list = [];
console.log(item);
item.forEach((e) => { item.forEach((e) => {
list.push({ if(this.goodsList[this.tabIndex].list.length == 0){
this.goodsList[this.tabIndex].list.push({
goodsName: e.goodsName, goodsName: e.goodsName,
price: e.price, price: e.price,
originalPrice: e.price, originalPrice: e.price,
@ -327,12 +334,32 @@ export default {
storeName: e.storeName, storeName: e.storeName,
skuId: e.id, skuId: e.id,
timeLine: this.data[0].hours.split(",")[this.tabIndex], timeLine: this.data[0].hours.split(",")[this.tabIndex],
});
}); });
}else{
this.goodsList[this.tabIndex].list.forEach(goods => {
if (e.id != goods.skuId) {
this.goodsList[this.tabIndex].list.push(
{
goodsName: e.goodsName,
price: e.price,
originalPrice: e.price,
promotionApplyStatus: e.promotionApplyStatus || '',
quantity: e.quantity,
seckillId: this.$route.query.id,
storeId: e.storeId,
storeName: e.storeName,
skuId: e.id,
timeLine: this.data[0].hours.split(",")[this.tabIndex],
}
)
}
})
}
this.goodsList[this.tabIndex].list = list; })
this.$nextTick(()=> {
this.$nextTick(() => {
this.$forceUpdate() this.$forceUpdate()
}) })
}, },
@ -384,21 +411,22 @@ export default {
this.init(); this.init();
}, },
// keepAlivetrue // keepAlivetrue
beforeRouteLeave(to, from, next){ beforeRouteLeave(to, from, next) {
if(to.name === 'seckill') { if (to.name === 'seckill') {
to.meta.keepAlive = true to.meta.keepAlive = true
} }
next() next()
} }
}; };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.operation { .operation {
margin: 10px 0; margin: 10px 0;
} }
.reason {
.reason {
cursor: pointer; cursor: pointer;
color: #2d8cf0; color: #2d8cf0;
font-size: 12px; font-size: 12px;
} }
</style> </style>