feat: 楼层装修新增绑定分类功能

master
学习很差啦 2022-10-19 11:56:08 +08:00
parent 17a4131bf1
commit bb93be2fb1
6 changed files with 178 additions and 23 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<Modal :styles="{ top: '120px' }" width="1160" z-index="10000" @on-cancel="clickClose" @on-ok="clickOK" v-model="flag" :mask-closable="false" scrollable> <Modal :styles="{ top: '120px' }" width="1160" :z-index="10000" @on-cancel="clickClose" @on-ok="clickOK" v-model="flag" :mask-closable="false" scrollable>
<template v-if="flag"> <template v-if="flag">
<goodsDialog @selected="(val) => {goodsData = val;}" <goodsDialog @selected="(val) => {goodsData = val;}"
v-if="goodsFlag" ref="goodsDialog" :selectedWay='goodsData'/> v-if="goodsFlag" ref="goodsDialog" :selectedWay='goodsData'/>

View File

@ -89,7 +89,7 @@ export default {
// this.handleClickChild(category[0], 0); // this.handleClickChild(category[0], 0);
},3000) },3000)
} }
}, },
}, },
}; };
@ -114,5 +114,6 @@ export default {
} }
.wrapper { .wrapper {
overflow: hidden; overflow: hidden;
display: flex;
} }
</style> </style>

View File

@ -521,21 +521,25 @@ export const modelData = [
title: "精选", title: "精选",
desc: "电子推荐", desc: "电子推荐",
___index: 0, ___index: 0,
bindCategory:""
}, },
{ {
title: "实惠", title: "实惠",
desc: "便宜好货", desc: "便宜好货",
___index: 1, ___index: 1,
bindCategory:""
}, },
{ {
title: "进口", title: "进口",
desc: "国际自营", desc: "国际自营",
___index: 2, ___index: 2,
bindCategory:""
}, },
{ {
title: "推荐", title: "推荐",
desc: "喂奶推荐", desc: "喂奶推荐",
___index: 3, ___index: 3,
bindCategory:""
} }
], ],
listWay: [ listWay: [
@ -561,6 +565,7 @@ export const modelData = [
] ]
} }
}, },
{ {
type: "notice", type: "notice",
name: "公告", name: "公告",

View File

@ -6,8 +6,18 @@
.decorate-view-link { .decorate-view-link {
font-size: 12px; font-size: 12px;
margin: 0 4px; margin: 0 4px;
flex:8;
color: #999; color: #999;
} }
.decorate-view-btn{
flex: 2;
display: flex;
flex-direction: column;
>button{
width: 70px;
}
}
.decorate-view-style { .decorate-view-style {
border: 1px solid #ededed; border: 1px solid #ededed;
@ -97,6 +107,7 @@
.decorate-view-title { .decorate-view-title {
margin-right: 10px; margin-right: 10px;
} }
.decorate-item { .decorate-item {
@ -160,4 +171,26 @@
.active { .active {
background: #ededed; background: #ededed;
} }
.title-item{
border-bottom: 1px solid #ededed;
padding:10px 10px 10px 0;
display: flex;
align-items: center;
justify-content: space-between;
cursor: pointer;
>.title-btn{
display: flex;
}
}
.title-goodsName{
/* 适用于webkit内核和移动端 */
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
}
.title-tooltip{
white-space: normal;
}

View File

@ -2,6 +2,7 @@
<div class="decorate"> <div class="decorate">
<div class="decorate-title"> <div class="decorate-title">
{{ res.name }} {{ res.name }}
<Button <Button
style="margin-left: 20px" style="margin-left: 20px"
size="small" size="small"
@ -25,6 +26,12 @@
>选择促销活动</Button >选择促销活动</Button
> >
</div> </div>
<Alert type="warning" v-if="res.name == '商品分类'">
<template slot="desc">
<div style="color:red"> 如果当前装修内容不是最后一项且绑定为分类则会默认展示当前分类的100条商品内容</div>
<div style="color:red"> 如果当前装修内容是最后一项且绑定为分类则会默认会根据当前分类触底加载</div>
</template>
</Alert>
<!-- 右侧显示抽屉 --> <!-- 右侧显示抽屉 -->
<Drawer title="选择风格" :closable="false" width="400" v-model="styleFlag"> <Drawer title="选择风格" :closable="false" width="400" v-model="styleFlag">
@ -110,12 +117,14 @@
</div> </div>
</div> </div>
<div class="decorate-view"> <div class="decorate-view">
<div class="decorate-view-title">绑定商品</div> <div class="decorate-view-title">绑定</div>
<div class="decorate-view-link">
<div <div
class="decorate-view-link"
v-if="res.options.list[0].listWay.length != 0" v-if="res.options.list[0].listWay.length != 0"
> >
<!-- 绑定商品选择器回调已选择的商品 --> <!-- 绑定商品选择器回调已选择的商品 -->
<div <div
v-if=" v-if="
title_item.___index == bindGoods.___index || title_item.___index == bindGoods.___index ||
@ -124,18 +133,53 @@
v-for="(bindGoods, bindGoodsIndex) in res.options.list[0] v-for="(bindGoods, bindGoodsIndex) in res.options.list[0]
.listWay" .listWay"
:key="bindGoodsIndex" :key="bindGoodsIndex"
class="title-item wes-2"
> >
{{ bindGoods.title }}, <Tooltip max-width="200" placement="left">
<div slot="content" class="title-tooltip">
{{ bindGoods.title }}
</div>
<div class="title-goodsName">
{{ bindGoods.title }}
</div>
</Tooltip>
<div class="title-btn">
<Button
@click="
slotGoods(
res.options.list[0].listWay,
title_item.___index,
bindGoods,
'up'
)
"
style="margin-right: 10px"
size="small"
>上移</Button
>
</div>
</div>
</div>
<!-- 显示绑定分类 -->
<div v-if="title_item.bindCategory" >
绑定分类为{{ title_item.bindCategory.name }}
</div> </div>
</div> </div>
<div>
<div class="decorate-view-btn">
<Button <Button
@click="bindGoodsId(title_item)" @click="bindGoodsId(title_item,title_index)"
size="small" size="small"
ghost
type="primary"
>选择商品</Button >选择商品</Button
> >
<Button
@click="bindGoodsCategory(title_index)"
size="small"
style='margin-top:20px'
>选择分类</Button
>
</div> </div>
</div> </div>
</div> </div>
@ -339,9 +383,11 @@
{{ {{
ways.find((e) => { ways.find((e) => {
return item.url.___type == e.name; return item.url.___type == e.name;
}) ? ways.find((e) => { })
return item.url.___type == e.name; ? ways.find((e) => {
}).title : '发现' return item.url.___type == e.name;
}).title
: "发现"
}} }}
- -
<!-- 当选择完链接之后的专题名称 --> <!-- 当选择完链接之后的专题名称 -->
@ -428,6 +474,10 @@
@selectedGoodsData="selectedGoodsData" @selectedGoodsData="selectedGoodsData"
></liliDialog> ></liliDialog>
<Modal width='800px' title="选择分类" v-model="enableSelectCategory">
<categoryTemplate v-if="enableSelectCategory" @selected="confirmCategory" />
</Modal>
<hotzone ref="hotzone" @changeZone="changeZone"></hotzone> <hotzone ref="hotzone" @changeZone="changeZone"></hotzone>
<Modal width="1200px" v-model="picModelFlag"> <Modal width="1200px" v-model="picModelFlag">
@ -440,10 +490,12 @@ import ossManage from "@/views/sys/oss-manage/ossManage";
import { modelData } from "./config"; import { modelData } from "./config";
import hotzone from "@/components/hotzone"; import hotzone from "@/components/hotzone";
import ways from "@/components/lili-dialog/wap.js"; // import ways from "@/components/lili-dialog/wap.js"; //
import categoryTemplate from "@/components/lili-dialog/template/category"; //
export default { export default {
components: { components: {
ossManage, ossManage,
hotzone, hotzone,
categoryTemplate
}, },
data() { data() {
return { return {
@ -460,6 +512,8 @@ export default {
selectedGoods: "", // selectedGoods: "", //
selectedLinks: "", // selectedLinks: "", //
modelList: "", // modelList: "", //
enableSelectCategory:false, //
goodsSelectedIndex:0, //
}; };
}, },
watch: { watch: {
@ -470,7 +524,60 @@ export default {
}, },
props: ["res"], props: ["res"],
methods: { methods: {
slotBanner(val, key, index, down) { //
confirmCategory(val){
let data = {...this.res.options.list[0].titleWay[this.goodsSelectedIndex]}
let callback = {
id:val[0].id,
name:val[0].name,
categoryIdWay:val[0].id
};
data = {
...data,
bindCategory:callback
}
this.res.options.list[0].listWay = this.res.options.list[0].listWay.filter(item=>{
return item.___index != this.goodsSelectedIndex
})
this.res.options.list[0].titleWay[this.goodsSelectedIndex] = data
console.log( this.res.options.list[0])
},
//
slotGoods(list, key, val) {
const newVal = [];
let newValIndex = 0;
//
list.forEach((item, index) => {
if (item.___index == key) {
newVal.push(item);
}
});
//
newVal.forEach((item, index) => {
if (item.id == val.id) {
newValIndex = index;
}
});
//
this.upData(newVal, newValIndex);
if (list.length == newVal.length) {
list = newVal;
} else {
let newList;
newVal.forEach((item, index) => {
newList = list.filter((child) => {
return child.id != item.id && child.___index != key;
});
});
list = [...newList, ...newVal];
}
this.$set(this.res.options.list[0], "listWay", list);
},
//
slotBanner(val, key, index, down) {
console.log(val); console.log(val);
if (down == "down") { if (down == "down") {
this.downData(val.options.list, index); this.downData(val.options.list, index);
@ -489,7 +596,7 @@ export default {
arr[index1] = arr.splice(index2, 1, arr[index1])[0]; arr[index1] = arr.splice(index2, 1, arr[index1])[0];
return arr; return arr;
}, },
downData(arr,index) { downData(arr, index) {
let newArr = []; let newArr = [];
if (arr.length > 1 && index !== arr.length - 1) { if (arr.length > 1 && index !== arr.length - 1) {
newArr = this.swapItems(arr, index, index + 1); newArr = this.swapItems(arr, index, index + 1);
@ -534,13 +641,22 @@ export default {
}; };
}); });
this.res.options.list[0].listWay.push(...data); this.res.options.list[0].listWay.push(...data);
//
this.res.options.list[0].titleWay[this.goodsSelectedIndex].bindCategory = ""
this.linkType = ""; this.linkType = "";
}, },
// //
bindGoodsId(val) { bindGoodsId(val,index) {
this.selectedGoods = val; this.selectedGoods = val;
this.goodsSelectedIndex = index
this.liliDialogFlag(true); this.liliDialogFlag(true);
}, },
//
bindGoodsCategory(index,key){
this.enableSelectCategory = true
this.goodsSelectedIndex = index
},
// //
clickDrawer(item, index) { clickDrawer(item, index) {
this.$emit("handleDrawer", item); this.$emit("handleDrawer", item);

View File

@ -97,13 +97,13 @@ export default {
}; };
}, },
watch: { watch: {
// params: { params: {
// handler(val) { handler(val) {
// // this.pageNumber++; // this.pageNumber++;
// this.init(); this.init();
// }, },
// deep: true, deep: true,
// }, },
}, },
mounted() { mounted() {
this.init(); this.init();