管理端,商品回显修改

master
mabo 2021-05-25 14:26:48 +08:00
parent a36946de1a
commit 7e668cc6d5
5 changed files with 84 additions and 91 deletions

View File

@ -45,8 +45,6 @@ export default {
type: "multiple", // single multiple
skuList: [], // sku
selectedWay: [], //
total: "", //
goodsParams: { //
pageNumber: 1,
@ -64,7 +62,12 @@ export default {
loading: false, //
};
},
props: ["clearFlag"],
props: {
selectedWay: {
type: Array,
default: new Array()
}
},
watch: {
category(val) {
this.goodsParams.categoryPath = val[0];
@ -74,6 +77,7 @@ export default {
this.$emit("selected", this.selectedWay);
},
deep: true,
immediate: true
},
"goodsParams.categoryPath": {
@ -110,6 +114,11 @@ export default {
res.result.records.forEach((item) => {
item.selected = false;
item.___type = "goods"; //goodspc wap
this.selectedWay.forEach(e => {
if (e.id === item.id) {
item.selected = true
}
})
});
/**
* 解决数据请求中滚动栏会一直上下跳动
@ -117,7 +126,6 @@ export default {
this.total = res.result.total;
this.goodsData.push(...res.result.records);
// console.log(this.goodsData);
} else {
this.empty = true;
}
@ -193,9 +201,13 @@ 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;
}
}
}
// console.log(this.selectedWay);
},
},
};

View File

@ -1,10 +1,7 @@
<template>
<Modal :styles="{ top: '120px' }" width="1160" @on-cancel="clickClose" @on-ok="clickOK" v-model="flag" :mask-closable="false" scrollable>
<goodsDialog @selected="
(val) => {
goodsData = val;
}
" v-if="goodsFlag" ref="goodsDialog" />
<goodsDialog @selected="(val) => {goodsData = val;}"
v-if="goodsFlag" ref="goodsDialog" :selectedWay='goodsData'/>
<linkDialog @selectedLink="
(val) => {
linkData = val;
@ -23,7 +20,7 @@ export default {
data() {
return {
goodsFlag: false, //
goodsData: "", //
goodsData: [], //
linkData: "", //
flag: false, // modal
};

View File

@ -7,9 +7,7 @@
<div class="form-item-view">
<FormItem astyle="width: 100%">
<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
@ -20,22 +18,19 @@
</div>
<Table
border
v-if="showTable"
:columns="columns"
:data="form.promotionGoodsList"
:data="promotionGoodsList"
@on-selection-change="changeSelect"
>
<template slot-scope="{ row }" slot="skuId">
<div>{{ row.skuId }}</div>
</template>
<template slot-scope="{ row, index }" slot="settlementPrice">
<template slot-scope="{ index }" slot="settlementPrice">
<Input
type="number"
v-model="row.settlementPrice"
@input="
pointsGoodsList[index].settlementPrice =
row.settlementPrice
"
v-model="promotionGoodsList[index].settlementPrice"
/>
</template>
@ -44,7 +39,7 @@
slot="pointsGoodsCategory"
>
<Select
v-model="pointsGoodsList[index].pointsGoodsCategoryId"
v-model="promotionGoodsList[index].pointsGoodsCategoryId"
transfer="true"
label-in-value="true"
@on-change="
@ -62,21 +57,17 @@
</Select>
</template>
<template slot-scope="{ row, index }" slot="activeStock">
<template slot-scope="{ index }" slot="activeStock">
<Input
type="number"
v-model="row.activeStock"
@input="
pointsGoodsList[index].activeStock = row.activeStock
"
v-model="promotionGoodsList[index].activeStock"
/>
</template>
<template slot-scope="{ row, index }" slot="points">
<template slot-scope="{ index }" slot="points">
<Input
type="number"
v-model="row.points"
@input="pointsGoodsList[index].points = row.points"
v-model="promotionGoodsList[index].points"
/>
</template>
</Table>
@ -151,22 +142,10 @@ export default {
};
return {
form: {
/** 店铺承担比例 */
sellerCommission: 0,
/** 发行数量 */
publishNum: 1,
/** 运费承担者 */
scopeType: "ALL",
/** 限领数量 */
couponLimitNum: 1,
/** 活动类型 */
couponType: "PRICE",
/** 优惠券名称 */
couponName: "",
getType: "FREE",
promotionGoodsList: [],
promotionGoodsList: [], //
},
pointsGoodsList: [], //
showTable: true,
promotionGoodsList: [], //
categoryList: [], //
submitLoading: false, //
selectedGoods: [], // 便
@ -226,6 +205,12 @@ export default {
title: "商品名称",
key: "goodsName",
minWidth: 120,
render: (h, params) => {
return h(
"div",
params.row.goodsSku.goodsName
);
},
},
{
title: "SKU编码",
@ -236,6 +221,12 @@ export default {
title: "店铺名称",
key: "storeName",
minWidth: 60,
render: (h, params) => {
return h(
"div",
params.row.goodsSku.storeName
);
},
},
{
title: "商品价格",
@ -244,7 +235,7 @@ export default {
render: (h, params) => {
return h(
"div",
this.$options.filters.unitPrice(params.row.price, "¥")
this.$options.filters.unitPrice(params.row.goodsSku.price, "¥")
);
},
},
@ -252,6 +243,12 @@ export default {
title: "库存",
key: "quantity",
minWidth: 20,
render: (h, params) => {
return h(
"div",
params.row.goodsSku.quantity
);
},
},
{
title: "结算价格",
@ -313,11 +310,11 @@ export default {
let res = await getPointsGoodsCategoryList();
this.categoryList = res.result.records;
},
/** 保存平台优惠券 */
/** 保存积分商品 */
handleSubmit() {
this.$refs.form.validate((valid) => {
if (valid) {
let params = this.pointsGoodsList;
let params = this.promotionGoodsList;
const start = this.$options.filters.unixToDate(
this.form.startTime / 1000
);
@ -355,7 +352,8 @@ export default {
this.$router.go(-1);
},
changeCategory(val, index) {
this.pointsGoodsList[index].pointsGoodsCategoryName = val.label;
this.promotionGoodsList[index].pointsGoodsCategoryName = val.label;
console.log(this.promotionGoodsList);
},
changeSelect(e) {
//
@ -363,7 +361,7 @@ export default {
},
delSelectGoods() {
//
if (this.pointsGoodsList.length <= 0) {
if (this.selectedGoods.length <= 0) {
this.$Message.warning("您还未选择要删除的数据");
return;
}
@ -375,55 +373,42 @@ export default {
this.selectedGoods.forEach(function (e) {
ids.push(e.id);
});
this.form.promotionGoodsList = this.form.promotionGoodsList.filter(
this.promotionGoodsList = this.promotionGoodsList.filter(
(item) => {
return !ids.includes(item.id);
}
);
this.pointsGoodsList = this.pointsGoodsList.filter((item) => {
return !ids.includes(item.id);
});
},
});
},
delGoods(index) {
//
this.form.promotionGoodsList.splice(index, 1);
this.pointsGoodsList.splice(index, 1);
this.promotionGoodsList.splice(index, 1);
},
openSkuList() { //
this.$refs.skuSelect.open("goods");
let data = JSON.parse(JSON.stringify(this.promotionGoodsList))
data.forEach(e => {
e.id = e.skuId
})
this.$refs.skuSelect.goodsData = data;
},
selectedGoodsData(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,
originalPrice: e.price,
quantity: e.quantity,
storeId: e.storeId,
storeName: e.storeName,
skuId: e.id,
...e,
});
this.pointsGoodsList.push({
settlementPrice: 0,
pointsGoodsCategoryId: 0,
pointsGoodsCategoryName: "",
activeStock: 0,
points: 0,
goodsSku: {
...e,
},
skuId: e.id,
});
const obj = {
settlementPrice: e.settlementPrice || 0,
pointsGoodsCategoryId: e.pointsGoodsCategoryId || 0,
pointsGoodsCategoryName:e.pointsGoodsCategoryName || "",
activeStock:e.activeStock || 0,
points:e.points || 0,
skuId: e.id,
goodsSku: e.goodsSku || e
}
list.push(obj);
});
this.form.promotionGoodsList.push(...list);
this.promotionGoodsList = list;
},
},
};

View File

@ -127,7 +127,7 @@
</Row>
<Row type="flex" justify="end" class="page">
<Page
:current="searchForm.pageNumber + 1"
:current="searchForm.pageNumber"
:total="total"
:page-size="searchForm.pageSize"
@on-change="changePage"
@ -157,7 +157,7 @@ export default {
loading: true, //
searchForm: {
//
pageNumber: 0, //
pageNumber: 1, //
pageSize: 10, //
order: "desc", //
},
@ -248,18 +248,17 @@ export default {
this.$router.push({ name: "add-points-goods" });
},
changePage(v) {
this.searchForm.pageNumber = v - 1;
this.searchForm.pageNumber = v;
this.getDataList();
this.clearSelectAll();
},
changePageSize(v) {
this.searchForm.pageSize = v;
this.getDataList();
},
handleSearch() {
this.searchForm.pageNumber = 0;
this.searchForm.pageNumber = 1;
this.searchForm.pageSize = 10;
if (this.searchForm.pointsS !== "") {
if (this.searchForm.pointsS) {
this.searchForm.points =
this.searchForm.pointsS +
"_" +

View File

@ -330,7 +330,7 @@ export default {
this.$Message.success("删除成功!");
// }
},
delAll() {
delAll() { //
if (this.selectCount <= 0) {
this.$Message.warning("您还未选择要删除的数据");
return;