<template>
    <div class="container-box">
        <div class="bread-crumb">
            <el-breadcrumb separator="/" style="float: left;margin:15px ">
                <el-breadcrumb-item :to="{ path: 'home' }">{{$i18n.locale=='en'? 'Home': '首页'}}</el-breadcrumb-item>
                <el-breadcrumb-item :to="{ path: 'ApplicationHistory'}">{{$i18n.locale=='en'? 'userCenter': '用户中心'}}</el-breadcrumb-item>
                <el-breadcrumb-item>{{$i18n.locale=='en'? 'Upload speech materials': '发言材料上传'}}</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="content-box">
            <div class="speech-material">
                <!-- <p class="speech-material-appellation">{{$i18n.locale=='en'? 'Dear guest!': '亲爱的嘉宾，您好！'}}</p>
                <p class="speech-material-tip">{{$i18n.locale=='en'? "You are already our guest speaker at this meeting. Please finish uploading your speech materials by 7 o'clock tomorrow morning.": '您已经是我们本次会议的发言嘉宾，请您在明天早上7点前，完成发言材料上传。'}}</p> -->
                <!-- <el-form :model="ruleForm" :rules="rules" ref="ruleForm" class="demo-ruleForm"> -->
                <el-form :model="ruleForm" ref="ruleForm" class="demo-ruleForm">
                    <el-form-item label="" prop="resource">
                        <UpLoadFile @getFileUrl="getPreviousPositions"></UpLoadFile>
                        <!-- <p class="tip-custom">{{$i18n.locale=='en'? 'Drag and drop the material directly to this area or click to select the speech material to complete the upload. Support word, pdf format. Please use the name + file name format to facilitate data management and storage for you.': '直接拖拽材料放到本区域或者点击选择发言材料，完成上传。支持word、pdf格式。请您以姓名+文件名格式，方便为你做数据管理储存。'}}</p> -->
                    </el-form-item>
                    <el-form-item prop="desc">
                        <span class="label-custom">{{$i18n.locale=='en'? 'Description': '描述'}}</span>
                        <el-input type="textarea" v-model="ruleForm.materialDescribe" :rows="8"></el-input>
                    </el-form-item>
                    <el-form-item :label="$i18n.locale=='en'? 'Is it public': '是否公开'" prop="resource" label-width="100px">
                        <el-radio-group v-model="ruleForm.isPublic">
                        <el-radio label="1">{{$i18n.locale=='en'? 'Yes': '是'}}</el-radio>
                        <el-radio label="2">{{$i18n.locale=='en'? 'No': '否'}}</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item style="text-align: center">
                        <el-button type="primary" @click="submitForm('ruleForm')">{{$i18n.locale=='en'? 'Submit': '提交材料'}}</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>

<script>
import Base from "@/views/base/Base";
import { addSpeakMaterial } from "@/api/meeting/meetingApply";
import UpLoadFile from "@/views/conferenceServices/UpLoadFile";
export default {
    extends: Base,
    components: {
        UpLoadFile
    },
    data() {
        return {
        ruleForm: {
            meetingId: '1297382531911983104',
            materialName: '',
            materialDescribe: '',
            isPublic: '2',
            isPublish: '2',
            isBackUpload: '2',
            meetingApplyName: this.$route.params.key.applyWay=='zh'? this.$route.params.key.name: this.$route.params.key.nameEn, 
            meetingApplyId: this.$route.params.key.id,
            logoAttachmentId: '', //未确定
            annexAttachmentId: '', //附件id
            annexAttachmentPath: '' //附件路径
        },
        rules: {
            // resource: [
            // { required: true, message: '请选择活动资源', trigger: 'change' }
            // ],
            // desc: [
            // { required: true, message: '请填写活动形式', trigger: 'blur' }
            // ]
        }
        };
    },
    mounted(){
        console.log(this.$route.params.key)
    },
    methods: {
        getPreviousPositions(fileData){
            this.ruleForm.materialName = fileData.fileName;
            this.ruleForm.annexAttachmentId = fileData.id;
            this.ruleForm.annexAttachmentPath = fileData.path;
        },
        submitForm(formName) {
            // this.$refs[formName].validate((valid) => {
            //     if (valid) {
            //     alert('submit!');
            //     } else {
            //     console.log('error submit!!');
            //     return false;
            //     }
            // });
            this.submitHandler((token) => {
                addSpeakMaterial(this.ruleForm).then(res=>{
                    this.$message({
                        message: this.$i18n.locale == "en"? 'Successfully' :'提交成功',
                        type: 'success'
                    });
                    this.$router.go(-1);
                }).catch(err=>{
                    this.resetToken();
                })
            })
            
        },
    }
}
</script>

<style scoped>
.container-box {
  width: 1200px;
  margin: 10px auto;
}
.bread-crumb{
    height: 40px;
    background: #fff;
    margin: 10px 0;
}
.content-box {
  width: 100%;
  background: #fff;
}
.speech-material{
    min-height: 700px;
    padding: 100px 200px 20px 200px;
}
.speech-material-appellation{
    font-size: 20px;
    font-weight: bold;
    margin: 0;
    line-height: 60px;
}
.speech-material-tip{
    font-size: 18px;
    text-indent: 2em;
    margin-top: 0;
    margin-bottom: 20px;
}
.speech-material /deep/ .el-textarea__inner{
    border-style: dashed;
}
.speech-material /deep/ .el-form-item__label{
    color: #333;
    font-weight: bold;
    text-align: left;
}
.label-custom{
    color: #333;
    font-weight: bold;
}
.tip-custom{
    color: #de571a;
    text-indent: 2em;
    margin-top: 10px;
    margin-bottom: 0;
    line-height: 26px;
}
</style>