index.vue 2.08 KB
<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
        }
    },
    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' }]
            },
        }
    },
    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>