index.vue
11.2 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
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<template>
<GLDialog mode="mid" :close-on-click-modal="false" :title="title" :visible.sync="visible" @onOk="onOk" :before-close="onCancel" @onCancel="onCancel">
<glsx-combi-form class="glsx-combi-form" ref="videoRef" labelWidth="154px" defaultWidth="432px" :isInline="false" :formObj.sync="formObj" :formData="formData" :formRules="rules">
<div slot="moduleSlot" class="radio-slot">
<el-radio-group @change="menuRadioChange('firstMenu')" v-model="contentObj.menuId">
<el-radio v-for="item in menuList" :key="item.id" :label="item.id">{{item.name}}</el-radio>
</el-radio-group>
</div>
<div slot="attrSlot" class="radio-slot">
<el-radio-group @change="menuRadioChange()" v-model="contentObj.secondaryMenuId">
<el-radio v-for="item in secondaryMenuList" :key="item.id" :label="item.id">{{item.name}}</el-radio>
</el-radio-group>
</div>
<div slot="sceneSlot" class="radio-slot">
<el-radio-group v-model="contentObj.thirdMenuId">
<el-radio v-for="item in thirdMenuList" :key="item.id" :label="item.id">{{item.name}}</el-radio>
</el-radio-group>
</div>
<div slot="contentSlot" class="radio-slot">
<el-radio-group v-model="formObj.type">
<el-radio :label="formObj.type">{{contentType[contentObj.type]}}</el-radio>
</el-radio-group>
</div>
<div slot="businessSlot" class="global-menu">
<span class="module">{{contentObj.menuName}}</span>
<i class="el-icon-arrow-right arrow-right"></i>
<span class="module">{{contentObj.secondaryMenuName}}</span>
<i class="el-icon-arrow-right arrow-right"></i>
<template v-if="contentObj.thirdMenuId">
<span class="module">{{contentObj.thirdMenuName}}</span>
<i class="el-icon-arrow-right arrow-right"></i>
</template>
<span class="module active">{{contentType[contentObj.type]}}</span>
</div>
<div slot="mainVideoSlot" class="main-video-slot">
<Upload tip="建议尺寸:最大5M" :formObj="formObj" btnName="上传海报" attr="prodImg"></Upload>
</div>
<div slot="linkConfigSlot">
<el-switch v-model="formObj.isLink" active-value="1" inactive-value="2" active-color="#5850FF" inactive-color="#E8E8EA"></el-switch>
<div class="link-tip"> 默认链接内容为特色产品中第一个产品内容详情</div>
</div>
</glsx-combi-form>
</GLDialog>
</template>
<script>
import Upload from '@/components/Upload'
import glsxCombiForm from '@/components/glsx-combi-form'
export default {
name: 'AddVideo',
components: {
glsxCombiForm,
Upload
},
props: {
visible: {
type: Boolean,
default: false
},
contentObj: {
type: Object,
default: ()=>{
return {}
}
}
},
data(){
return {
contentType: {
1: '特色产品',
2: '案例视频',
3: '营销海报',
4: '操作指引'
},
detailVisible: false,
formObj: {
id: '',
menuId: '',
subMenuId: '',
type: '',
proName: '',
prodImg: '',
isLink: '2',
},
formData:[
{
label: '业务模块',
name: 'module',
isHide: true,
addHtml: 'moduleSlot'
},
{
label: '业务属性',
name: 'zone',
isHide: true,
addHtml: 'attrSlot'
},
{
label: '场景细分',
name: 'scene',
isHide: true,
addHtml: 'sceneSlot'
},
{
label: '内容专区',
name: 'contZone',
isHide: true,
addHtml: 'contentSlot'
},
{
label: '业务模块',
name: 'business',
isHide: false,
addHtml: 'businessSlot'
},
{
label: '海报标题',
name: 'proName',
isHide: false,
type: 'input',
maxlength: 8,
showLimit: true
},
{
label: '海报图片',
name: 'prodImg',
isHide: false,
addHtml: 'mainVideoSlot'
},
{
label: '是否配置链接',
isHide: true,
name: 'isLink',
addHtml: 'linkConfigSlot'
}
],
rules: {
isLink: [{required: true, validator: (rule, value, callback) => {return callback() }, trigger: 'change'}],
proName: [{ required: true, message: '请输入海报标题', trigger: 'change' }],
business: [{required: true, validator: (rule, value, callback) => {return callback() }, trigger: 'change'}],
module: [{required: true, validator: (rule, value, callback) => {return callback() }, trigger: 'change'}],
zone: [{
required: true,
validator: (rule, value, callback) => {
if (!this.contentObj.secondaryMenuId) {
return callback(new Error('请选择业务属性'))
}else {
return callback()
}
},
trigger: 'change'
}
],
contZone: [{required: true, validator: (rule, value, callback) => {return callback() }, trigger: 'change'}],
scene: [
{
required: true,
validator: (rule, value, callback) => {
if (this.thirdMenuList.length && !this.contentObj.thirdMenuId) {
return callback(new Error('请选择场景细分'))
}else {
return callback()
}
},
trigger: 'change'
}
],
prodImg: [
{
required: true,
validator: (rule, value, callback) => {
if (!this.formObj.prodImg) {
return callback(new Error('请上传海报图片'))
} else {
return callback()
}
},
trigger: 'change'
}
]
},
menuList: []
}
},
computed: {
title(){
return `${this.formObj.id ? '编辑': '新增'}${this.formObj.type==5 ? 'banner' : '内容'}`
},
secondaryMenuList(){
const target = this.menuList.find(item => item.id == this.contentObj.menuId)
return target?.subList || []
},
thirdMenuList(){
const target = this.secondaryMenuList.find(item => item.id == this.contentObj.secondaryMenuId)
return target?.subList || []
}
},
created() {
const { secondaryMenuId ,thirdMenuId , type} = this.contentObj
this.formObj = {...this.formObj, subMenuId: thirdMenuId || secondaryMenuId, type}
if(this.contentObj.id) {
this.formData.forEach(item => {
if(type==5){
item.isHide = !(item.name == 'isLink' || item.name == 'prodImg')
if(item.name == 'prodImg') item.label == 'banner'
}else{
const hideItemList = ['module', 'zone', 'contZone', 'scene']
if(hideItemList.includes(item.name)){
item.isHide = false
}
if(item.name=='business') item.isHide = true
}
});
this.getMenuList()
}
},
methods: {
menuRadioChange(level){
this.contentObj.thirdMenuId = ''
if(level=='firstMenu') this.contentObj.secondaryMenuId = ''
},
getMenuList() {
this.$apis.discover.getMenuListApi({}).then(res => {
this.getContentDetail()
if(res?.length){
this.menuList = res
}
})
},
closeDetailDialog(){
this.detailVisible = false
},
onCancel(){
this.contentObj.imageDialogVisible = false
// this.$emit('closeVideoDialog')
},
async getContentDetail(){
this.$apis.discover.getContentDetailApi({id: this.contentObj.id}).then(res => {
if(res?.id){
for(const key in this.formObj){
this.formObj[key] = res[key]
}
}
})
},
onOk() {
console.log(this.formObj)
this.$refs.videoRef.$refs.formRef.validate(valid => {
if(valid) {
const params = JSON.parse(JSON.stringify(this.formObj))
if(!this.contentObj.id) delete params.id
if(this.contentObj.type==3){
params.subMenuId = this.contentObj.thirdMenuId || this.contentObj.secondaryMenuId
delete params.isLink
}else{
params.subMenuId = this.contentObj.secondaryMenuId
delete params.proName
}
this.$apis.discover.addContentApi(params).then(res => {
if(res) {
this.$message.success('操作成功')
this.onCancel()
this.$parent.handleSearch();
}
})
}
})
},
}
}
</script>
<style lang="scss" scoped>
.main-video-slot{
display: flex;
/deep/ .upload-ctnr{
margin-right: 8px;
}
}
.radio-slot{
/deep/ .el-radio{
margin-right: 20px;
line-height: 25px;
.el-radio__label{
width: 100px;
display: inline-block;
}
}
}
.link-tip{
height: 17px;
line-height: 17px;
font-family: PingFangSC-Regular;
font-weight: 400;
font-size: 12px;
color: #999999;
}
</style>