index.vue
2.39 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
<template>
<GLDialog mode="mid" :close-on-click-modal="false" title="创建封面" :visible.sync="visible" :before-close="onCancel" @onOk="onOk" @onCancel="onCancel">
<glsx-combi-form class="glsx-combi-form" ref="detailRef" labelWidth="154px" defaultWidth="432px" :isInline="false" :formObj.sync="detailFormObj" :formData="detailFormData" :formRules="detailRules">
<div slot="coverSlot">
<Upload tip="建议尺寸:最大5M,176*120px" :formObj="detailFormObj" btnName="上传封面" attr="url"></Upload>
</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
},
formObj: {
type: Object,
default: ()=>{
return {
title: '',
url: ''
}
}
}
},
data(){
return {
detailFormObj: {
title: '',
url: ''
},
detailFormData: [
{
label: '产品名称',
name: 'title',
type: 'input',
maxlength: 12,
showLimit: true
},
{
label: '产品封面',
name: 'url',
addHtml: 'coverSlot'
}
],
detailRules: {
title: [{ required: true, message: '请输入产品名称', trigger: 'change' }],
url: [{ required: true, message: '请上传产品封面', trigger: 'change' }]
},
}
},
created(){
const {title, url } = this.formObj
this.detailFormObj = { title, url }
},
methods: {
onCancel(){
this.$emit('closeDialog')
},
onOk() {
this.$refs.detailRef.$refs.formRef.validate(valid => {
if(valid){
const { title, url} = this.detailFormObj
this.$emit('confirmDialog',{ title, url })
}
})
},
}
}
</script>
<style lang="scss" scoped>
</style>