添加注释,修改分销设置提交方式,左侧菜单无法选中问题

This commit is contained in:
mabo
2021-07-23 18:05:05 +08:00
parent ae329419a6
commit 9130485631
66 changed files with 301 additions and 2758 deletions

View File

@@ -1,246 +0,0 @@
<template>
<div class="wrapper">
<div class="wap-content">
<div class="query-wrapper">
<div class="query-item">
<div>搜索范围</div>
<Input placeholder="商品名称" @on-clear="goodsData=[]; goodsParams.goodsName=''; goodsParams.pageNumber = 1; getQueryGoodsList()" @on-enter="()=>{goodsData=[];goodsParams.pageNumber =1; getQueryGoodsList();}" icon="ios-search" clearable
style="width: 150px" v-model="goodsParams.goodsName" />
</div>
<div class="query-item">
<Cascader v-model="category" placeholder="请选择商品分类" style="width: 250px" :data="skuList"></Cascader>
</div>
<div class="query-item">
<Button type="primary" @click="goodsData=[]; getQueryGoodsList();" icon="ios-search">搜索</Button>
</div>
</div>
<div style="positon:retavle;">
<Scroll class="wap-content-list" :on-reach-bottom="handleReachBottom" :distance-to-edge="[3,3]">
<div class="wap-content-item" :class="{ active: item.selected }" @click="checkedGoods(item, index)" v-for="(item, index) in goodsData" :key="index">
<div>
<img :src="item.thumbnail" alt="" />
</div>
<div class="wap-content-desc">
<div class="wap-content-desc-title">{{ item.goodsName }}</div>
<div class="wap-sku">{{ item.goodsUnit }}</div>
<div class="wap-content-desc-bottom">
<div>¥{{ item.price | unitPrice }}</div>
</div>
</div>
</div>
<Spin size="large" fix v-if="loading"></Spin>
<div v-if="empty" class="empty">暂无商品信息</div>
</Scroll>
</div>
</div>
</div>
</template>
<script>
import * as API_Goods from "@/api/goods";
export default {
data() {
return {
type: "multiple", //单选或者多选 single multiple
skuList: [], // 商品sku列表
total: "", // 商品总数
goodsParams: { // 商品请求参数
pageNumber: 1,
pageSize: 18,
order: "desc",
goodsName: "",
sn: "",
categoryPath: "",
marketEnable: "UPPER",
isAuth: "PASS",
},
category: [], // 分类
goodsData: [], // 商品数据
empty: false, // 空数据
loading: false, // 加载状态
};
},
props: {
selectedWay: {
type: Array,
default: new Array()
}
},
watch: {
category(val) {
this.goodsParams.categoryPath = val[0];
},
selectedWay: {
handler() {
this.$emit("selected", this.selectedWay);
},
deep: true,
immediate: true
},
"goodsParams.categoryPath": {
handler: function () {
this.goodsData = [];
(this.goodsParams.pageNumber = 0), this.getQueryGoodsList();
},
deep: true,
},
},
mounted() {
this.init();
},
methods: {
handleReachBottom() {
setTimeout(() => {
if (
this.goodsParams.pageNumber * this.goodsParams.pageSize <=
this.total
) {
this.goodsParams.pageNumber++;
this.getQueryGoodsList();
}
}, 1500);
},
getQueryGoodsList() {
API_Goods.getGoodsSkuData(this.goodsParams).then((res) => {
this.initGoods(res);
});
},
initGoods(res) {
if (res.result.records.length !=0) {
res.result.records.forEach((item) => {
item.selected = false;
item.___type = "goods"; //设置为goods让pc wap知道标识
this.selectedWay.forEach(e => {
if (e.id === item.id) {
item.selected = true
}
})
});
/**
* 解决数据请求中,滚动栏会一直上下跳动
*/
this.total = res.result.total;
this.goodsData.push(...res.result.records);
} else {
this.empty = true;
}
},
// 查询商品
init() {
API_Goods.getGoodsSkuData(this.goodsParams).then((res) => {
// 商品
this.initGoods(res);
});
if (localStorage.getItem('category')) {
this.deepGroup(JSON.parse(localStorage.getItem('category')))
} else {
setTimeout(() => {
this.deepGroup(JSON.parse(localStorage.getItem('category')))
},3000)
}
},
deepGroup(val) {
val.forEach((item) => {
let childWay = []; //第二级
// 第二层
if (item.children) {
item.children.forEach((child) => {
// // 第三层
if (child.children) {
child.children.forEach((grandson, index, arr) => {
arr[index] = {
value: grandson.id,
label: grandson.name,
children: "",
};
});
}
let children = {
value: child.id,
label: child.name,
children: child.children,
};
childWay.push(children);
});
}
// 第一层
let way = {
value: item.id,
label: item.name,
children: childWay,
};
this.skuList.push(way);
});
},
/**
* 点击商品
*/
checkedGoods(val, index) {
// 如果单选的话
if (this.type != "multiple") {
this.goodsData.forEach((item) => {
item.selected = false;
});
this.selectedWay = [];
val.selected = true;
this.selectedWay.push(val);
return false;
}
if (val.selected == false) {
val.selected = true;
this.selectedWay.push(val);
} else {
val.selected = false;
for (let i = 0; i<this.selectedWay.length; i++ ) {
if (this.selectedWay[i].id===val.id) {
this.selectedWay.splice(i,1)
break;
}
}
}
},
},
};
</script>
<style scoped lang="scss">
@import "./style.scss";
.wap-content {
width: 100%;
}
.empty {
text-align: center;
padding: 8px 0;
width: 100%;
}
.wap-content {
flex: 1;
padding: 0;
}
.wap-content-list {
position: relative;
}
.wap-content-item {
width: 210px;
margin: 10px 7px;
padding: 6px 0;
}
// .wap-content-item{
// }
.active {
background: url("../../assets/selected.png") no-repeat;
background-position: right;
background-size: 10%;
}
</style>

View File

@@ -45,7 +45,7 @@ export default {
type: "multiple", //单选或者多选 single multiple
skuList: [], // 商品sku列表
total: "", // 商品总数
total: 0, // 商品总数
goodsParams: { // 商品请求参数
pageNumber: 1,
pageSize: 18,
@@ -79,7 +79,6 @@ export default {
deep: true,
immediate: true
},
"goodsParams.categoryPath": {
handler: function () {
this.goodsData = [];
@@ -92,6 +91,7 @@ export default {
this.init();
},
methods: {
// 触底加载更多方法
handleReachBottom() {
setTimeout(() => {
if (
@@ -103,12 +103,13 @@ export default {
}
}, 1500);
},
// 获取商品列表
getQueryGoodsList() {
API_Goods.getGoodsSkuData(this.goodsParams).then((res) => {
this.initGoods(res);
});
},
// 获取列表方法
initGoods(res) {
if (res.result.records.length !=0) {
res.result.records.forEach((item) => {

View File

@@ -14,12 +14,10 @@
<script>
import goodsDialog from "./goods-dialog";
import linkDialog from "./link-dialog";
import couponDialog from "./coupon-dialog";
export default {
components: {
goodsDialog,
linkDialog,
couponDialog,
linkDialog
},
data() {
return {
@@ -44,6 +42,7 @@ export default {
}
}, 100);
},
// 点击确认
clickOK() {
if (this.goodsFlag) {
this.$emit("selectedGoodsData", this.goodsData);
@@ -52,6 +51,7 @@ export default {
}
this.clickClose();
},
// 打开组件方法
open(type, mutiple) {
this.flag = true;
if (type == "goods") {
@@ -64,6 +64,7 @@ export default {
}
},
// 关闭组件
close() {
this.flag = false;
},

View File

@@ -1,96 +1,112 @@
.wrapper {
width: 100%;
height: 100%;
display: flex;
.wap-list {
flex: 2;
text-align: center;
overflow-y: auto;
height: 100%;
}
> .wap-list,
width: 100%;
height: 100%;
display: flex;
.wap-content {
flex: 8;
}
}
.wap-sku {
font-size: 12px;
color: #999;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.query-wrapper {
display: flex;
margin: 8px 0;
> .query-item {
display: flex;
align-items: center;
> * {
margin: 0 4px;
}
}
}
/deep/ .ivu-scroll-container {
width: 100% !important;
height: 400px !important;
}
/deep/ .ivu-scroll-content {
/* */
display: flex;
flex-wrap: wrap;
}
.wap-content-list {
.wap-list {
flex: 2;
text-align: center;
overflow-y: auto;
height: 100%;
}
>.wap-list,
.wap-content {
flex: 8;
}
}
.wap-sku {
font-size: 12px;
color: #999;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.query-wrapper {
display: flex;
margin: 8px 0;
>.query-item {
display: flex;
align-items: center;
>* {
margin: 0 4px;
}
}
}
/deep/ .ivu-scroll-container {
width: 100% !important;
height: 400px !important;
}
/deep/ .ivu-scroll-content {
/* */
display: flex;
flex-wrap: wrap;
}
.wap-content-list {
overflow-y: auto;
}
.wap-item {
padding: 10px 0;
cursor: pointer;
padding: 10px 0;
cursor: pointer;
}
.wap-item:hover {
background: #ededed;
background: #ededed;
}
.wap-content-item {
cursor: pointer;
cursor: pointer;
display: flex;
height: 80px;
padding: 2px;
overflow: hidden;
align-items: center;
margin: 10px ;
/deep/ img {
width: 60px;
height: 60px;
text-align: center;
}
.wap-content-desc {
width: 180px;
padding: 8px;
> .wap-content-desc-title {
display: -webkit-box;
font-size: 12px;
color: #666;
display: flex;
height: 80px;
padding: 2px;
overflow: hidden;
align-items: center;
margin: 10px;
-webkit-box-orient: vertical;
overflow: hidden;
-webkit-line-clamp: 2;
}
> .wap-content-desc-bottom {
font-size: 12px;
padding: 4px 0;
color: #999;
display: flex;
justify-content: space-between;
> div:nth-of-type(1) {
color: $theme_color;
}
}
/deep/ img {
width: 60px;
height: 60px;
text-align: center;
}
.wap-content-desc {
width: 180px;
padding: 8px;
>.wap-content-desc-title {
display: -webkit-box;
font-size: 12px;
color: #666;
-webkit-box-orient: vertical;
overflow: hidden;
-webkit-line-clamp: 2;
}
>.wap-content-desc-bottom {
font-size: 12px;
padding: 4px 0;
color: #999;
display: flex;
justify-content: space-between;
>div:nth-of-type(1) {
color: $theme_color;
}
}
}
}