peng
1 天以前 2fd269af9df3653b058deee57bcd7a9f39ff28e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<template>
    <div class="not-enough">
        <ul class="nav-bar setup-content">
            <li v-for="(item, index) in conData.options.navList" :class="currentIndex===index?'curr':''" @click="changeCurr(index)" :key="index">
                <p>{{item.title}}</p>
                <p>{{item.desc}}</p>
            </li>
            <div class="setup-box" style="width:100px;left:1100px;">
                <div>
                    <Button size="small" @click.stop="handleSelectModel">编辑</Button>
                </div>
            </div>
        </ul>
        <div class="content" v-if="showContent">
            <div v-for="(item, index) in conData.options.list[currentIndex]" :key="index" class="setup-content">
                <img :src="item.img" width="210" height="210" :alt="item.name">
                <p>{{item.name}}</p>
                <p>
                    <span>{{item.price | unitPrice('¥')}}</span>
                    <!-- <span>{{item.price | unitPrice('¥')}}</span> -->
                </p>
                <div class="setup-box">
                    <div>
                        <Button size="small" @click.stop="handleSelectGoods(item)">编辑</Button>
                    </div>
                </div>
            </div>
        </div>
        <Modal
            v-model="showModal"
            title="装修"
            draggable
            width="800"
            :z-index="100"
            :mask-closable="false"
            >
            <div class="modal-tab-bar">
                <Button type="primary" size='small' @click="handleAddNav">添加分类</Button>
                <table cellspacing="0">
                    <thead>
                        <tr>
                            <th width="250">主标题</th>
                            <th width="250">描述</th>
                            <th width="250">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="(item, index) in conData.options.navList" :key="index">
                            <td><Input v-model="item.title" /></td>
                            <td><Input v-model="item.desc" /></td>
                            <td v-if="index!=0">
                                <Button type="error" size="small" @click="handleDelNav(index)">删除</Button>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </Modal>
        <!-- 选择商品。链接 -->
        <liliDialog
            ref="liliDialog"
            @selectedGoodsData="selectedGoodsData"
        ></liliDialog>
    </div>
</template>
<script>
export default {
    props:{
        data:{
            type: Object,
            default: null
        }
    },
    data() {
        return {
            currentIndex:0, // 当前商品index
            conData:this.data, // 当前数据
            selected:{}, // 已选数据
            showModal:false, // modal显隐
            showContent:true, // 选择后刷新数据用
        }
    },
    watch:{
        data:function(val){
            this.conData = val
        },
        conData:function(val){
            this.$emit('content',val)
        }
    },
    methods:{
        // tab点击切换
        changeCurr(index){
            this.currentIndex = index;
        },
        // 编辑
        handleSelectModel (item,type) {
            this.selected = item;
            this.showModal = true
        },
        handleSelectGoods(item) { // 调起选择商品弹窗
            if(item) this.selected = item;
            this.$refs.liliDialog.flag = true;
            this.$refs.liliDialog.goodsFlag = true;
            this.$refs.liliDialog.singleGoods();
 
        },
        // 选择商品回调
        selectedGoodsData(val){
            console.log(val)
            let goods = val[0]
            this.selected.img = goods.thumbnail
            this.selected.price = goods.price
            this.selected.name = goods.goodsName
            this.selected.url = `/goodsDetail?skuId=${goods.id}&goodsId=${goods.goodsId}`
        },
        handleDelNav(index){ // 删除导航
            this.conData.options.navList.splice(index,1)
            this.conData.options.list.splice(index,1)
        },
        handleAddNav(){ // 添加导航
            this.conData.options.navList.push(
                {title:'',desc:''}
            )
            this.conData.options.list.push(
                [{ img:'', name:'', price:0, url:'' },
                { img:'', name:'', price:0, url:'' },
                { img:'', name:'', price:0, url:'' },
                { img:'', name:'', price:0, url:'' },
                { img:'', name:'', price:0, url:'' },
                { img:'', name:'', price:0, url:'' },
                { img:'', name:'', price:0, url:'' },
                { img:'', name:'', price:0, url:'' },
                { img:'', name:'', price:0, url:'' },
                { img:'', name:'', price:0, url:'' },
                ],
            )
            this.showContent = false
            this.$nextTick(()=>{
                this.showContent = true;
            })
        },
    }
}
</script>
<style lang="scss" scoped>
@import './setup-box.scss';
.nav-bar{
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 10px;
    background-color: rgb(218, 217, 217);
    height: 60px;
    align-items: center;
    position: relative;
    li{
        padding: 0 30px;
        text-align: center;
        p:nth-child(1){
            font-size: 16px;
            border-radius: 50px;
            padding: 0 7px;
        }
 
        p:nth-child(2){
            font-size: 14px;
            color: #999;
        }
 
        &:hover{
            p{
                color: $theme_color;
            }
            cursor: pointer;
        }
        border-right: 1px solid #eee;
 
    }
    li:last-of-type{
        border: none;
    }
 
    .curr{
        p:nth-child(1){
            background-color: $theme_color;
 
            color: #fff;
        }
        p:nth-child(2){
            color: $theme_color;
        }
    }
}
 
.content{
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    >div{
        padding: 10px;
        box-sizing: border-box;
        border: 1px solid #eee;
        margin-bottom: 10px;
        p:nth-of-type(1){
            overflow: hidden;
            width: 210px;
            white-space: nowrap;
            text-overflow:ellipsis;
            margin: 10px 0 5px 0;
        }
        p:nth-of-type(2){
            color: $theme_color;
            font-size: 16px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            span:nth-child(2){
                text-decoration: line-through;
                font-size: 12px;
                color: #999;
            }
        }
    }
}
</style>