管理端,商品回显修改

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 type: "multiple", // single multiple
skuList: [], // sku skuList: [], // sku
selectedWay: [], //
total: "", // total: "", //
goodsParams: { // goodsParams: { //
pageNumber: 1, pageNumber: 1,
@ -64,7 +62,12 @@ export default {
loading: false, // loading: false, //
}; };
}, },
props: ["clearFlag"], props: {
selectedWay: {
type: Array,
default: new Array()
}
},
watch: { watch: {
category(val) { category(val) {
this.goodsParams.categoryPath = val[0]; this.goodsParams.categoryPath = val[0];
@ -74,6 +77,7 @@ export default {
this.$emit("selected", this.selectedWay); this.$emit("selected", this.selectedWay);
}, },
deep: true, deep: true,
immediate: true
}, },
"goodsParams.categoryPath": { "goodsParams.categoryPath": {
@ -110,6 +114,11 @@ export default {
res.result.records.forEach((item) => { res.result.records.forEach((item) => {
item.selected = false; item.selected = false;
item.___type = "goods"; //goodspc wap 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.total = res.result.total;
this.goodsData.push(...res.result.records); this.goodsData.push(...res.result.records);
// console.log(this.goodsData);
} else { } else {
this.empty = true; this.empty = true;
} }
@ -193,9 +201,13 @@ export default {
this.selectedWay.push(val); this.selectedWay.push(val);
} else { } else {
val.selected = false; 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> <template>
<Modal :styles="{ top: '120px' }" width="1160" @on-cancel="clickClose" @on-ok="clickOK" v-model="flag" :mask-closable="false" scrollable> <Modal :styles="{ top: '120px' }" width="1160" @on-cancel="clickClose" @on-ok="clickOK" v-model="flag" :mask-closable="false" scrollable>
<goodsDialog @selected=" <goodsDialog @selected="(val) => {goodsData = val;}"
(val) => { v-if="goodsFlag" ref="goodsDialog" :selectedWay='goodsData'/>
goodsData = val;
}
" v-if="goodsFlag" ref="goodsDialog" />
<linkDialog @selectedLink=" <linkDialog @selectedLink="
(val) => { (val) => {
linkData = val; linkData = val;
@ -23,7 +20,7 @@ export default {
data() { data() {
return { return {
goodsFlag: false, // goodsFlag: false, //
goodsData: "", // goodsData: [], //
linkData: "", // linkData: "", //
flag: false, // modal flag: false, // modal
}; };

View File

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

View File

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

View File

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