linkConfig.vue
4.16 KB
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
<template>
<div class="link-config">
<div v-if="linkType === 1">
<span class="name">{{ value.name }}</span>
<el-button v-if="value.name" type="text" @click="editProduct">修改</el-button>
<el-button
v-else
size="mini"
type="primary"
@click="addProduct"
>
添加商品
</el-button>
<product-table ref="productTable" @doSubmit="proSubmit" />
</div>
<div v-if="linkType === 2">
<el-cascader
ref="cascader"
v-model="value.id"
:options="categoryList"
:props="{ checkStrictly: true,label: 'categoryName',value: 'id',children: 'childs' }"
clearable
@change="categoryChange"
/>
</div>
<div v-if="linkType === 3">
<ul v-if="value && value.items && value.items.length > 0" class="coupon-list">
<li v-for="(item,index) in value.items" :key="index">
<span class="name">{{ item.activityName }}</span>
<el-button v-if="item.activityId" type="text" @click="editCoupon">修改</el-button>
</li>
</ul>
<el-button
v-else
size="mini"
type="primary"
@click="addCoupon"
>
添加平台券
</el-button>
<coupon-table ref="couponTable" :is-multiple="true" @doSubmit="couponSubmit" />
</div>
<div v-if="linkType === 4">
<el-form class="link-form" :model="value" label-width="100px">
<el-form-item label="小程序app id">
<el-input v-model="value.appId" class="input-sub" />
</el-form-item>
<el-form-item label="页面路径">
<el-input v-model="value.link" class="input-sub" />
</el-form-item>
</el-form>
</div>
<div v-if="linkType === 5">
<el-form :model="value" label-width="100px">
<el-form-item label="页面路径">
<el-input v-model="value.link" class="input-sub" />
</el-form-item>
</el-form>
</div>
</div>
</template>
<script>
import ProductTable from '../basics/productTable'
import CouponTable from '../basics/couponTable'
import {
getClassify
} from '@/api/public'
import { checkEmptyChild } from '@@/config/common'
export default {
name: 'LinkConfig',
components: { CouponTable, ProductTable },
props: {
value: {
type: Object,
default: () => {}
},
linkType: {
type: Number,
default: 0
}
},
data () {
return {
categoryList: []
}
},
mounted () {
this.getCategoryList()
},
methods: {
addProduct () {
this.$refs.productTable.visible = true
},
editProduct () {
this.$refs.productTable.visible = true
},
proSubmit (val) {
this.$set(this.value, 'id', val.productId)
this.$set(this.value, 'shopId', val.shopId)
this.$set(this.value, 'skuId', val.skuId)
this.$set(this.value, 'name', val.productName)
},
addCoupon () {
this.$refs.couponTable.visible = true
},
editCoupon () {
this.$refs.couponTable.visible = true
},
couponSubmit (items) {
this.$set(this.value, 'items', items)
},
// 获取前端分类
getCategoryList () {
getClassify().then(res => {
this.categoryList = res.data
checkEmptyChild(this.categoryList)
}).catch(res => {
console.log('err:' + res)
return this.$message({
message: res.msg,
type: 'error'
})
})
},
// 类别改变
categoryChange (val) {
const nodesObj = this.$refs['cascader'].getCheckedNodes(); const pathLabels = nodesObj[0].pathLabels.join('/')
this.$set(this.value, 'name', pathLabels)
}
}
}
</script>
<style scoped lang="scss">
.link-config{
.radio{
padding: 5px 0;
}
.coupon-list{
margin: 0;
padding: 0;
li{
list-style: none;
}
.el-button{
margin-left: 10px;
font-size: 14px;
}
}
.input-sub{
width: 300px;
::v-deep .el-input__inner{
height: 32px;
line-height: 32px;
}
}
.link-form{
.el-form-item{
margin-top: 10px;
&:first-child{
margin-top: 0px;
}
}
}
.el-button--text{
font-size: 14px;
margin-left: 10px;
}
}
</style>