修改在已有秒杀商品情况下添加新的秒杀商品 数据保存错误问题
parent
f33efac045
commit
db919a57f3
|
@ -74,7 +74,7 @@
|
||||||
v-if="row.promotionApplyStatus == 'REFUSE'"
|
v-if="row.promotionApplyStatus == 'REFUSE'"
|
||||||
@click="showReason(row.failReason)"
|
@click="showReason(row.failReason)"
|
||||||
class="reason"
|
class="reason"
|
||||||
>(拒绝原因)</span
|
>(拒绝原因)</span
|
||||||
>
|
>
|
||||||
<Badge
|
<Badge
|
||||||
status="error"
|
status="error"
|
||||||
|
@ -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,279 +128,305 @@
|
||||||
</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 {
|
|
||||||
components: {
|
|
||||||
skuSelect,
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
promotionStatus: "", // 活动状态
|
|
||||||
loading: false, // 表单加载状态
|
|
||||||
searchForm: {
|
|
||||||
// 搜索框初始化对象
|
|
||||||
pageNumber: 0, // 当前页数
|
|
||||||
pageSize: 1000, // 页面大小
|
|
||||||
},
|
|
||||||
tabIndex: 0, // 选择商品的下标
|
|
||||||
submitLoading: false, // 添加或编辑提交状态
|
|
||||||
selectList: [], // 多选数据
|
|
||||||
selectCount: 0, // 多选计数
|
|
||||||
data: [{}], // 表单数据
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
title: "活动名称",
|
|
||||||
key: "promotionName",
|
|
||||||
minWidth: 120,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "活动开始时间",
|
|
||||||
key: "startTime",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "报名截止时间",
|
|
||||||
slot: "applyEndTime",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "时间场次",
|
|
||||||
slot: "hours",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
goodsColumns: [
|
|
||||||
{
|
|
||||||
title: "商品名称",
|
|
||||||
key: "goodsName",
|
|
||||||
minWidth: 120,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "商品价格",
|
|
||||||
slot: "originalPrice",
|
|
||||||
minWidth: 50,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "库存",
|
|
||||||
slot: "quantity",
|
|
||||||
minWidth: 40,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "活动价格",
|
|
||||||
slot: "price",
|
|
||||||
minWidth: 50,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "状态",
|
|
||||||
slot: "promotionApplyStatus",
|
|
||||||
minWidth: 30,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "操作",
|
|
||||||
slot: "action",
|
|
||||||
minWidth: 50,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
goodsList: [] // 商品列表
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 关闭当前页面
|
|
||||||
closeCurrentPage() {
|
|
||||||
this.$store.commit("removeTag", "seckill-goods");
|
|
||||||
localStorage.storeOpenedList = JSON.stringify(
|
|
||||||
this.$store.state.app.storeOpenedList
|
|
||||||
);
|
|
||||||
this.$router.go(-1);
|
|
||||||
},
|
|
||||||
// 提交秒杀商品
|
|
||||||
save() {
|
|
||||||
|
|
||||||
let list = JSON.parse(JSON.stringify(this.goodsList));
|
export default {
|
||||||
let params = {
|
components: {
|
||||||
seckillId: this.$route.query.id,
|
skuSelect,
|
||||||
applyVos: [],
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
promotionStatus: "", // 活动状态
|
||||||
|
loading: false, // 表单加载状态
|
||||||
|
searchForm: {
|
||||||
|
// 搜索框初始化对象
|
||||||
|
pageNumber: 0, // 当前页数
|
||||||
|
pageSize: 1000, // 页面大小
|
||||||
|
},
|
||||||
|
tabIndex: 0, // 选择商品的下标
|
||||||
|
submitLoading: false, // 添加或编辑提交状态
|
||||||
|
selectList: [], // 多选数据
|
||||||
|
selectCount: 0, // 多选计数
|
||||||
|
data: [{}], // 表单数据
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
title: "活动名称",
|
||||||
|
key: "promotionName",
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "活动开始时间",
|
||||||
|
key: "startTime",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "报名截止时间",
|
||||||
|
slot: "applyEndTime",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "时间场次",
|
||||||
|
slot: "hours",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
goodsColumns: [
|
||||||
|
{
|
||||||
|
title: "商品名称",
|
||||||
|
key: "goodsName",
|
||||||
|
minWidth: 120,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "商品价格",
|
||||||
|
slot: "originalPrice",
|
||||||
|
minWidth: 50,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "库存",
|
||||||
|
slot: "quantity",
|
||||||
|
minWidth: 40,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "活动价格",
|
||||||
|
slot: "price",
|
||||||
|
minWidth: 50,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "状态",
|
||||||
|
slot: "promotionApplyStatus",
|
||||||
|
minWidth: 30,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "操作",
|
||||||
|
slot: "action",
|
||||||
|
minWidth: 50,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
goodsList: [] // 商品列表
|
||||||
};
|
};
|
||||||
list.forEach((e, index) => {
|
|
||||||
e.list.forEach((i) => {
|
|
||||||
// if(e.id) delete e.id
|
|
||||||
params.applyVos.push(i);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
this.submitLoading = true;
|
|
||||||
setSeckillGoods(params).then((res) => {
|
|
||||||
this.submitLoading = false;
|
|
||||||
if (res && res.success) {
|
|
||||||
this.$Message.success("提交活动商品成功");
|
|
||||||
this.closeCurrentPage();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
// 初始化数据
|
|
||||||
init() {
|
|
||||||
this.getSeckillMsg();
|
|
||||||
},
|
|
||||||
// 清除选中状态
|
|
||||||
clearSelectAll() {
|
|
||||||
this.$refs.table.selectAll(false);
|
|
||||||
},
|
|
||||||
// 获取选择数据
|
|
||||||
changeSelect(e) {
|
|
||||||
this.selectList = e;
|
|
||||||
this.selectCount = e.length;
|
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
// 关闭当前页面
|
||||||
|
closeCurrentPage() {
|
||||||
|
this.$store.commit("removeTag", "seckill-goods");
|
||||||
|
localStorage.storeOpenedList = JSON.stringify(
|
||||||
|
this.$store.state.app.storeOpenedList
|
||||||
|
);
|
||||||
|
this.$router.go(-1);
|
||||||
|
},
|
||||||
|
// 提交秒杀商品
|
||||||
|
save() {
|
||||||
|
|
||||||
getDataList() {
|
let list = JSON.parse(JSON.stringify(this.goodsList));
|
||||||
// 获取商品详情
|
|
||||||
this.loading = true;
|
|
||||||
this.searchForm.seckillId = this.$route.query.id;
|
|
||||||
// 处理过的时间 为‘1:00’
|
|
||||||
let hours = this.unixHours(this.data[0].hours);
|
|
||||||
hours.forEach((e) => {
|
|
||||||
this.goodsList.push({
|
|
||||||
hour: e,
|
|
||||||
list: [],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
seckillGoodsList(this.searchForm).then((res) => {
|
|
||||||
this.loading = false;
|
|
||||||
if (res.success && res.result) {
|
|
||||||
let data = res.result.records;
|
|
||||||
// 未处理时间 为'1'
|
|
||||||
let noFilterhours = this.data[0].hours.split(",");
|
|
||||||
if (data.length) {
|
|
||||||
noFilterhours.forEach((e, index) => {
|
|
||||||
data.forEach((i) => {
|
|
||||||
if (i.timeLine == e) {
|
|
||||||
this.goodsList[index].list.push(i);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
getSeckillMsg() {
|
console.warn(list)
|
||||||
// 获取活动详情
|
let params = {
|
||||||
seckillDetail(this.$route.query.id).then((res) => {
|
|
||||||
if (res.success && res.result) {
|
|
||||||
this.data = [];
|
|
||||||
this.data.push(res.result);
|
|
||||||
this.promotionStatus = res.result.promotionStatus;
|
|
||||||
this.getDataList();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
delGoods(index, row) {
|
|
||||||
// 删除商品
|
|
||||||
if (row.promotionApplyStatus === 'PASS') {
|
|
||||||
const params = {
|
|
||||||
seckillId: row.seckillId,
|
|
||||||
id: row.id
|
|
||||||
}
|
|
||||||
delSeckillGoods(params).then(res => {
|
|
||||||
if (res.success) {
|
|
||||||
this.goodsList[this.tabIndex].list.splice(index, 1);
|
|
||||||
this.$Message.success("删除成功!");
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
this.goodsList[this.tabIndex].list.splice(index, 1);
|
|
||||||
this.$Message.success("删除成功!");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
selectedGoodsData(item) {
|
|
||||||
// 选择器添加商品
|
|
||||||
let list = [];
|
|
||||||
console.log(item);
|
|
||||||
item.forEach((e) => {
|
|
||||||
list.push({
|
|
||||||
goodsName: e.goodsName,
|
|
||||||
price: e.price,
|
|
||||||
originalPrice: e.price,
|
|
||||||
promotionApplyStatus: e.promotionApplyStatus || '',
|
|
||||||
quantity: e.quantity,
|
|
||||||
seckillId: this.$route.query.id,
|
seckillId: this.$route.query.id,
|
||||||
storeId: e.storeId,
|
applyVos: [],
|
||||||
storeName: e.storeName,
|
};
|
||||||
skuId: e.id,
|
list.forEach((e, index) => {
|
||||||
timeLine: this.data[0].hours.split(",")[this.tabIndex],
|
e.list.forEach((i) => {
|
||||||
|
// if(e.id) delete e.id
|
||||||
|
params.applyVos.push(i);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
this.submitLoading = true;
|
||||||
|
|
||||||
this.goodsList[this.tabIndex].list = list;
|
console.log(list)
|
||||||
this.$nextTick(()=> {
|
|
||||||
this.$forceUpdate()
|
setSeckillGoods(params).then((res) => {
|
||||||
})
|
this.submitLoading = false;
|
||||||
},
|
if (res && res.success) {
|
||||||
openSkuList() { // 显示商品选择器
|
this.$Message.success("提交活动商品成功");
|
||||||
this.$refs.skuSelect.open("goods");
|
this.closeCurrentPage();
|
||||||
let data = JSON.parse(JSON.stringify(this.goodsList[this.tabIndex].list))
|
}
|
||||||
data.forEach(e => {
|
});
|
||||||
e.id = e.skuId
|
},
|
||||||
})
|
// 初始化数据
|
||||||
this.$refs.skuSelect.goodsData = data;
|
init() {
|
||||||
},
|
this.getSeckillMsg();
|
||||||
unixDate(time) {
|
},
|
||||||
// 处理报名截止时间
|
// 清除选中状态
|
||||||
return this.$options.filters.unixToDate(new Date(time) / 1000);
|
clearSelectAll() {
|
||||||
},
|
this.$refs.table.selectAll(false);
|
||||||
unixHours(item) {
|
},
|
||||||
if (item) {
|
// 获取选择数据
|
||||||
// 处理小时场次
|
changeSelect(e) {
|
||||||
let hourArr = item.split(",");
|
this.selectList = e;
|
||||||
for (let i = 0; i < hourArr.length; i++) {
|
this.selectCount = e.length;
|
||||||
hourArr[i] += ":00";
|
},
|
||||||
|
|
||||||
|
getDataList() {
|
||||||
|
// 获取商品详情
|
||||||
|
this.loading = true;
|
||||||
|
this.searchForm.seckillId = this.$route.query.id;
|
||||||
|
// 处理过的时间 为‘1:00’
|
||||||
|
let hours = this.unixHours(this.data[0].hours);
|
||||||
|
hours.forEach((e) => {
|
||||||
|
this.goodsList.push({
|
||||||
|
hour: e,
|
||||||
|
list: [],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
seckillGoodsList(this.searchForm).then((res) => {
|
||||||
|
this.loading = false;
|
||||||
|
if (res.success && res.result) {
|
||||||
|
let data = res.result.records;
|
||||||
|
// 未处理时间 为'1'
|
||||||
|
let noFilterhours = this.data[0].hours.split(",");
|
||||||
|
if (data.length) {
|
||||||
|
noFilterhours.forEach((e, index) => {
|
||||||
|
data.forEach((i) => {
|
||||||
|
if (i.timeLine == e) {
|
||||||
|
this.goodsList[index].list.push(i);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
getSeckillMsg() {
|
||||||
|
// 获取活动详情
|
||||||
|
seckillDetail(this.$route.query.id).then((res) => {
|
||||||
|
if (res.success && res.result) {
|
||||||
|
this.data = [];
|
||||||
|
this.data.push(res.result);
|
||||||
|
this.promotionStatus = res.result.promotionStatus;
|
||||||
|
this.getDataList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
delGoods(index, row) {
|
||||||
|
// 删除商品
|
||||||
|
if (row.promotionApplyStatus === 'PASS') {
|
||||||
|
const params = {
|
||||||
|
seckillId: row.seckillId,
|
||||||
|
id: row.id
|
||||||
|
}
|
||||||
|
delSeckillGoods(params).then(res => {
|
||||||
|
if (res.success) {
|
||||||
|
this.goodsList[this.tabIndex].list.splice(index, 1);
|
||||||
|
this.$Message.success("删除成功!");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.goodsList[this.tabIndex].list.splice(index, 1);
|
||||||
|
this.$Message.success("删除成功!");
|
||||||
}
|
}
|
||||||
return hourArr;
|
},
|
||||||
|
selectedGoodsData(item) {
|
||||||
|
// 选择器添加商品
|
||||||
|
item.forEach((e) => {
|
||||||
|
if(this.goodsList[this.tabIndex].list.length == 0){
|
||||||
|
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],
|
||||||
|
});
|
||||||
|
}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.$nextTick(() => {
|
||||||
|
this.$forceUpdate()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
openSkuList() { // 显示商品选择器
|
||||||
|
this.$refs.skuSelect.open("goods");
|
||||||
|
let data = JSON.parse(JSON.stringify(this.goodsList[this.tabIndex].list))
|
||||||
|
data.forEach(e => {
|
||||||
|
e.id = e.skuId
|
||||||
|
})
|
||||||
|
this.$refs.skuSelect.goodsData = data;
|
||||||
|
},
|
||||||
|
unixDate(time) {
|
||||||
|
// 处理报名截止时间
|
||||||
|
return this.$options.filters.unixToDate(new Date(time) / 1000);
|
||||||
|
},
|
||||||
|
unixHours(item) {
|
||||||
|
if (item) {
|
||||||
|
// 处理小时场次
|
||||||
|
let hourArr = item.split(",");
|
||||||
|
for (let i = 0; i < hourArr.length; i++) {
|
||||||
|
hourArr[i] += ":00";
|
||||||
|
}
|
||||||
|
return hourArr;
|
||||||
|
}
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
// 格式化申请状态
|
||||||
|
promotionApplyStatus(key) {
|
||||||
|
switch (key) {
|
||||||
|
case "APPLY":
|
||||||
|
return "申请";
|
||||||
|
case "PASS":
|
||||||
|
return "通过";
|
||||||
|
case "REFUSE":
|
||||||
|
return "拒绝";
|
||||||
|
default:
|
||||||
|
return "未申请";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 展示审核拒绝原因
|
||||||
|
showReason(reason) {
|
||||||
|
this.$Modal.info({
|
||||||
|
title: "拒绝原因",
|
||||||
|
content: reason,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.init();
|
||||||
|
},
|
||||||
|
// 如果是从详情页返回列表页,修改列表页keepAlive为true,确保不刷新页面
|
||||||
|
beforeRouteLeave(to, from, next) {
|
||||||
|
if (to.name === 'seckill') {
|
||||||
|
to.meta.keepAlive = true
|
||||||
}
|
}
|
||||||
return [];
|
next()
|
||||||
},
|
|
||||||
// 格式化申请状态
|
|
||||||
promotionApplyStatus(key) {
|
|
||||||
switch (key) {
|
|
||||||
case "APPLY":
|
|
||||||
return "申请";
|
|
||||||
case "PASS":
|
|
||||||
return "通过";
|
|
||||||
case "REFUSE":
|
|
||||||
return "拒绝";
|
|
||||||
default:
|
|
||||||
return "未申请";
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 展示审核拒绝原因
|
|
||||||
showReason(reason) {
|
|
||||||
this.$Modal.info({
|
|
||||||
title: "拒绝原因",
|
|
||||||
content: reason,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.init();
|
|
||||||
},
|
|
||||||
// 如果是从详情页返回列表页,修改列表页keepAlive为true,确保不刷新页面
|
|
||||||
beforeRouteLeave(to, from, next){
|
|
||||||
if(to.name === 'seckill') {
|
|
||||||
to.meta.keepAlive = true
|
|
||||||
}
|
}
|
||||||
next()
|
};
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.operation {
|
.operation {
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
}
|
}
|
||||||
.reason {
|
|
||||||
cursor: pointer;
|
.reason {
|
||||||
color: #2d8cf0;
|
cursor: pointer;
|
||||||
font-size: 12px;
|
color: #2d8cf0;
|
||||||
}
|
font-size: 12px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue