商品选择器回显

master
mabo 2021-05-24 18:14:06 +08:00
parent 44c88468d4
commit 882e222c5a
12 changed files with 164 additions and 134 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -119,8 +119,10 @@
<p>使用范围{{useScope(item.scopeType)}}</p>
<p>有效期{{item.endTime}}</p>
</div>
<img class="used" v-if="usedCouponId.includes(item.id)" src="../../assets/images/geted.png" alt="">
<b></b>
<a class="c-right" @click="useCoupon(item.id)">使</a>
<a class="c-right" @click="useCoupon(item.id, true)">立即使用</a>
<a class="c-right" v-if="usedCouponId.includes(item.id)" @click="useCoupon(item.id, false)"></a>
<i class="circle-top"></i>
<i class="circle-bottom"></i>
</li>
@ -207,7 +209,9 @@ export default {
moreAddr: false, //
canUseCouponNum: 0, //
couponList: [], //
logoImg: '' // logo
logoImg: '', // logo
usedCouponId: [], // 使id
selectedCoupon: {} //
};
},
mounted () {
@ -250,7 +254,10 @@ export default {
this.goodsList = res.result.cartList;
this.priceDetailDTO = res.result.priceDetailDTO;
this.skuList = res.result.skuList;
let notSupArea = res.result.notSupportFreight
let notSupArea = res.result.notSupportFreight;
this.selectedCoupon = {}
if (res.result.platformCoupon) this.selectedCoupon.platformCoupon = res.result.platformCoupon
Object.assign(this.selectedCoupon, res.result.storeCoupons)
if (notSupArea) {
let content = [];
let title = ''
@ -295,8 +302,22 @@ export default {
storeId: storeArr.toString(),
totalPrice: this.priceDetailDTO.goodsPrice
}
canUseCouponList(params).then(res => {
canUseCouponList(params).then(res => { //
if (res.success) this.couponList = res.result.records
const couponKeys = Object.keys(this.selectedCoupon)
this.usedCouponId = []
if (couponKeys.length) {
this.couponList.forEach(e => {
if (e.id === this.selectedCoupon[couponKeys].memberCoupon.id) {
this.usedCouponId.push(e.id)
}
})
this.$nextTick(() => {
this.$forceUpdate()
})
}
})
}
})
@ -361,16 +382,14 @@ export default {
});
},
useCoupon (id) { // 使
useCoupon (id, used) { // 使
let params = {
way: this.$route.query.way,
memberCouponId: id,
used: true
used: used // true 使 false
}
selectCoupon(params).then(res => {
if (res.success) {
this.init()
}
if (res.success) this.init()
})
},
editInvoice () { //
@ -774,5 +793,16 @@ export default {
.circle-top,.circle-bottom{
right: 22px;
}
.used {
position: absolute;
top: 60px;
right: 40px;
width: 50px;
height: 50px;
}
}
.coupon-list {
max-height: 260px;
overflow: scroll;
}
</style>

View File

@ -41,12 +41,17 @@
<script>
import * as API_Goods from "@/api/goods";
export default {
data() {
props: {
selectedWay: {
type: Array,
default: new Array()
}
},
data () {
return {
type: "multiple", // single multiple
cateList: [], //
selectedWay: [], //
total: "", //
goodsParams: { //
pageNumber: 1,
@ -64,18 +69,17 @@ export default {
loading: false, // loading
};
},
props: ["clearFlag"],
watch: {
category(val) {
this.goodsParams.categoryPath = val[2];
},
selectedWay: {
handler() {
handler(val) {
this.$emit("selected", this.selectedWay);
},
deep: true,
immediate: true
},
"goodsParams.categoryPath": {
handler: function () {
this.goodsData = [];
@ -88,7 +92,7 @@ export default {
this.init();
},
methods: {
handleReachBottom() {
handleReachBottom() { //
setTimeout(() => {
if (
this.goodsParams.pageNumber * this.goodsParams.pageSize <=
@ -99,17 +103,24 @@ export default {
}
}, 1500);
},
getQueryGoodsList() {
getQueryGoodsList() { //
API_Goods.getGoodsSkuData(this.goodsParams).then((res) => {
this.initGoods(res);
});
},
initGoods(res) {
initGoods(res) { //
if (res.result.records.length !=0) {
res.result.records.forEach((item) => {
let data = res.result.records;
data.forEach((item) => {
item.selected = false;
item.___type = "goods"; //goodspc wap
this.selectedWay.forEach(e => {
if (e.id === item.id) {
item.selected = true
}
})
});
/**
* 解决数据请求中滚动栏会一直上下跳动
@ -141,7 +152,6 @@ export default {
deepGroup(val) {
val.forEach((item) => {
let childWay = []; //
let grandWay = []; //
//
if (item.children) {
item.children.forEach((child) => {
@ -196,7 +206,12 @@ export default {
this.selectedWay.push(val);
} else {
val.selected = false;
this.selectedWay.splice(index, 1);
for (let i = 0; i<this.selectedWay.length; i++ ) {
if (this.selectedWay[i].id===val.id) {
this.selectedWay.splice(i,1)
break;
}
}
}
},
},

View File

@ -10,20 +10,13 @@
scrollable
>
<goodsDialog
@selected="
(val) => {
goodsData = val;
}
"
@selected="(val) => {goodsData = val;}"
:selectedWay='goodsData'
ref="goodsDialog"
v-if="goodsFlag"
/>
<linkDialog
@selectedLink="
(val) => {
linkData = val;
}
"
@selectedLink="(val) => {linkData = val;}"
v-else
class="linkDialog"
/>
@ -41,14 +34,11 @@ export default {
return {
title: "选择", //
goodsFlag: false, //
goodsData: "", //
goodsData: [], //
linkData: "", //
flag: false, //
};
},
props: ["types"],
watch: {},
mounted() {},
methods: {
//
clickClose() {
@ -58,7 +48,6 @@ export default {
//
singleGoods(){
var timer = setInterval(() => {
if (this.$refs.goodsDialog) {
@ -66,19 +55,16 @@ export default {
clearInterval(timer);
}
}, 100);
},
clickOK() {
clickOK() { //
if (this.goodsFlag) {
this.$emit("selectedGoodsData", this.goodsData);
} else {
this.$emit("selectedLink", this.linkData);
}
this.clickClose();
// this.clearFlag = false
},
open(type){
open (type) { // ref
this.flag = true;
if(type == 'goods'){
this.goodsFlag = true;
@ -87,7 +73,7 @@ export default {
}
},
close(){
close(){ //
this.flag = false;
}
},

View File

@ -223,7 +223,7 @@ export default {
{
title: "状态",
key: "promotionStatus",
minWidth: 100,
width: 100,
fixed: "right",
render: (h, params) => {
let text = "未知",
@ -250,9 +250,9 @@ export default {
},
},
text
),
)
]);
},
}
},
{
title: "操作",

View File

@ -114,9 +114,8 @@
v-if="form.scopeType == 'PORTION_GOODS'"
>
<div style="display: flex; margin-bottom: 10px">
<Button type="primary" @click="$refs.skuSelect.open('goods')"
>选择商品</Button
>
<Button type="primary" @click="openSkuList"
>选择商品</Button>
<Button
type="error"
ghost
@ -466,6 +465,14 @@ export default {
name: "coupon",
});
},
openSkuList() { //
this.$refs.skuSelect.open("goods");
let data = JSON.parse(JSON.stringify(this.form.promotionGoodsList))
data.forEach(e => {
e.id = e.skuId
})
this.$refs.skuSelect.goodsData = data;
},
changeSelect(e) {
//
this.selectedGoods = e;
@ -497,15 +504,9 @@ export default {
this.form.promotionGoodsList.splice(index, 1);
},
selectedGoodsData(item) {
console.log(item);
//
let ids = [];
let list = [];
this.form.promotionGoodsList.forEach((e) => {
ids.push(e.skuId);
});
item.forEach((e) => {
if (!ids.includes(e.id)) {
list.push({
goodsName: e.goodsName,
price: e.price,
@ -515,9 +516,8 @@ export default {
sellerName: e.sellerName,
skuId: e.id,
});
}
});
this.form.promotionGoodsList.push(...list);
this.form.promotionGoodsList = list;
},
getGoodsCategory(e) {
// id

View File

@ -140,12 +140,12 @@ export default {
{
title: "活动类型",
slot: "promotionType",
minWidth: 60,
width: 100,
},
{
title: "活动状态",
key: "promotionStatus",
minWidth: 60,
width: 100,
render: (h, params) => {
let text = "未知",
color = "default";

View File

@ -183,7 +183,7 @@
style="display: flex; margin-bottom: 10px"
v-if="form.promotionStatus == 'NEW'"
>
<Button type="primary" @click="$refs.skuSelect.open('goods')"
<Button type="primary" @click="openSkuList"
>选择商品</Button
>
<Button
@ -376,6 +376,14 @@ export default {
);
this.$router.go(-1);
},
openSkuList() { //
this.$refs.skuSelect.open("goods");
let data = JSON.parse(JSON.stringify(this.form.promotionGoodsList))
data.forEach(e => {
e.id = e.skuId
})
this.$refs.skuSelect.goodsData = data;
},
getDetail() {
//
getFullDiscountById(this.id).then((res) => {
@ -496,15 +504,9 @@ export default {
this.form.promotionGoodsList.splice(index, 1);
},
selectedGoodsData(item) {
console.log(item);
//
let ids = [];
let list = [];
this.form.promotionGoodsList.forEach((e) => {
ids.push(e.skuId);
});
item.forEach((e) => {
if (!ids.includes(e.id)) {
list.push({
goodsName: e.goodsName,
price: e.price,
@ -514,10 +516,8 @@ export default {
thumbnail: e.thumbnail,
skuId: e.id,
});
}
});
console.log(list);
this.form.promotionGoodsList.push(...list);
this.form.promotionGoodsList = list;
},
getCouponList(query) {
//

View File

@ -155,17 +155,15 @@ export default {
{
title: "活动开始时间",
key: "startTime",
minWidth: 120
},
{
title: "活动结束时间",
key: "endTime",
minWidth: 120
},
{
title: "状态",
key: "promotionStatus",
minWidth: 100,
width: 100,
render: (h, params) => {
let text = "未知",
color = "default";

View File

@ -36,7 +36,7 @@
</Row>
</Card>
<sku-select ref="skuSelect" @selectedGoodsData="selectedGoodsData"></sku-select>
<sku-select ref="skuSelect" :goodsData="goodsData" @selectedGoodsData="selectedGoodsData"></sku-select>
</div>
</template>
<script>
@ -65,7 +65,7 @@ export default {
data: [], //
total: 0, //
status: this.$route.query.status, //
columns: [
columns: [ //
{
title: "活动名称",
key: "promotionName",
@ -111,7 +111,7 @@ export default {
},
},
],
goodsColumns: [
goodsColumns: [ //
{ type: "selection", width: 60, align: "center" },
{
title: "商品名称",
@ -202,7 +202,6 @@ export default {
handleReset() {
//
// this.$refs.searchForm.resetFields();
this.searchForm.pageNumber = 0;
this.searchForm.promotionName = "";
this.selectDate = null;
@ -211,7 +210,7 @@ export default {
this.getDataList();
},
clearSelectAll() {
clearSelectAll() { //
this.$refs.table.selectAll(false);
},
changeSelect(e) {
@ -220,7 +219,7 @@ export default {
this.selectCount = e.length;
},
getDataList() {
getDataList() { //
this.loading = true;
this.searchForm.pintuanId = this.$route.query.id;
@ -233,14 +232,12 @@ export default {
});
},
getPintuanMsg() {
//
getPintuanMsg() { //
getPintuanDetail(this.$route.query.id).then((res) => {
if (res.success) this.data.push(res.result);
});
},
delGoods(index) {
//
delGoods(index) { //
this.goodsData.splice(index, 1);
},
delAll() { //
@ -263,13 +260,9 @@ export default {
});
},
selectedGoodsData(item) { //
let ids = [];
console.log(item);
let list = [];
this.goodsData.forEach((e) => {
ids.push(e.skuId);
});
item.forEach((e) => {
if (!ids.includes(e.id)) {
list.push({
goodsName: e.goodsName,
price: e.price,
@ -281,15 +274,19 @@ export default {
skuId: e.id,
categoryPath: e.categoryPath,
});
}
});
this.goodsData.push(...list);
this.goodsData = list;
},
openSkuList() { //
this.$refs.skuSelect.open("goods");
let data = JSON.parse(JSON.stringify(this.goodsData))
data.forEach(e => {
e.id = e.skuId
})
this.$refs.skuSelect.goodsData = data;
},
},
mounted() {
mounted () {
this.init();
},
};

View File

@ -134,6 +134,7 @@ export default {
{
title: "状态",
key: "promotionStatus",
width: 100,
render: (h, params) => {
let text = "未知",
color = "default";

View File

@ -318,17 +318,17 @@ export default {
},
delGoods(index, id) {
//
if (id) {
removeSeckillGoods(this.$route.query.id, id).then((res) => {
if (res.success) {
// if (id) {
// removeSeckillGoods(this.$route.query.id, id).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("删除成功!");
}
});
} else {
this.goodsList[this.tabIndex].list.splice(index, 1);
this.$Message.success("删除成功!");
}
// }
},
delAll() {
if (this.selectCount <= 0) {
@ -350,43 +350,46 @@ export default {
].list.filter((item) => {
return !ids.includes(item.id);
});
removeSeckillGoods(this.$route.query.id, ids).then((res) => {
if (res.success) {
this.$Message.success("删除成功!");
}
});
// removeSeckillGoods(this.$route.query.id, ids).then((res) => {
// if (res.success) {
// this.$Message.success("");
// }
// });
},
});
},
selectedGoodsData(item) {
//
let ids = [];
let list = [];
this.goodsList[this.tabIndex].list.forEach((e) => {
ids.push(e.skuId);
});
console.log(item);
item.forEach((e) => {
if (!ids.includes(e.id)) {
list.push({
goodsName: e.goodsName,
price: e.price,
originalPrice: e.price,
promotionApplyStatus: "",
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.push(...list);
this.goodsList[this.tabIndex].list = list;
this.$nextTick(()=> {
this.$forceUpdate()
})
},
openSkuList() {
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) {
//