<template>
    <div class="ficc-add-activity-wrap">
        <el-form ref="form" :model="formData" :rules="formRules">
            <el-form-item label="活动类型" label-width="100px" disabled style="display:inline-block;margin-right:20px" prop="firstTypeVal">
                <el-select
                    v-model="formData.firstTypeVal"
                    placeholder="请选择活动类型"
                    @change="firstTypeChange"
                    disabled
                >
                    <el-option
                        v-for="item in typeList"
                        :key="item.ActivityTypeId"
                        :label="item.ActivityTypeName"
                        :value="item.ActivityTypeId"
                    >
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="活动类别" label-width="100px" disabled style="display:inline-block;margin-right:20px" prop="childTypeVal">
                <el-select
                    v-model="formData.childTypeVal"
                    no-data-text="请先选择活动类型"
                    placeholder="请选择活动类别"
                    @change="childTypeChange"
                    disabled
                >
                    <el-option
                        v-for="item in childTypeList"
                        :key="item.ActivityTypeId"
                        :label="item.ActivityTypeName"
                        :value="item.ActivityTypeId"
                    >
                    </el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="活动时间" label-width="100px" style="display:inline-block" prop="time">
                <el-date-picker
                    v-model="formData.time"
                    type="datetimerange"
                    range-separator="至"
                    start-placeholder="活动开始时间"
                    end-placeholder="活动结束时间"
                    :default-time="['15:30:00','16:00:00']"
                    value-format="yyyy-MM-dd HH:mm:ss">
                </el-date-picker>
            </el-form-item>

            <template v-if="formData.firstTypeVal&&formData.childTypeVal">
            <el-form-item label="活动类别" label-width="100px" prop="ActivityTypeName" v-if="showActivityTypeName">
                <el-input placeholder="请输入活动类别" v-model="formData.ActivityTypeName"></el-input>
            </el-form-item>
            <el-form-item label="活动标题" label-width="100px" prop="ActivityName">
                <el-input placeholder="请输入活动标题" v-model="formData.ActivityName"></el-input>
            </el-form-item>
            <el-form-item :label="formData.firstTypeVal==2||formData.firstTypeVal==4?'主讲嘉宾':'主讲人'" label-width="100px" prop="Speaker">
                <template v-if="showSelectSpeaker">
                    <el-select 
                        v-model="formData.Speaker" 
                        placeholder="请选择主讲人" 
                        style="width:100%"
                        multiple
                        filterable>
                        <el-option
                            v-for="item in speakerList"
                            :key="item.SpeakerId"
                            :label="item.SpeakerName"
                            :value="item.SpeakerName"
                        ></el-option>
                    </el-select>
                    <el-image 
                        v-for="item in speakerAvatar"
                        :key="item"
                        style="width: 80px; height: 80px;margin-top:10px"
                        :src="item" 
                        :preview-src-list="[item]">
                    </el-image>
                </template>
                <el-input :placeholder="formData.firstTypeVal==2||formData.firstTypeVal==4?'请输入主讲嘉宾':'请输入主讲人'" v-model="formData.Speaker" v-else></el-input>
            </el-form-item>

            <el-form-item label="参会地址" label-width="100px" prop="address" v-if="showAddressOrLimitPeople">
                <div style="display:flex;justify-content: space-between;">
                    <el-select
                        v-model="formData.City"
                        placeholder="请选择城市"
                        style="width:15%">
                        <el-option 
                            v-for="item in cityArr" 
                            :key="item"
                            :label="item"
                            :value="item">
                        </el-option>
                    </el-select>
                    <el-input style="width:84%;display:inline-block" placeholder="请输入详细地址" v-model="formData.Address"></el-input>
                </div>
                
            </el-form-item>
            <el-form-item label="参会人数" label-width="100px" prop="LimitPeopleNum" v-if="showAddressOrLimitPeople">
                <el-input v-model="formData.LimitPeopleNum" placeholder="请输入线下参会人数限制"></el-input>
            </el-form-item>
            <el-form-item prop="Permission" v-if="showPermission">
                <p>请选择参会权限（拥有以下任一勾选的权限，才可参会）：</p>
                <ul class="menu_lists">
					<li v-for="item in PermissionList" :key="item.ClassifyName" class="menu_item">
						<el-checkbox :indeterminate="item.isIndeterminate" v-model="item.checkAll" @change="handleCheckAll(item)" style="marginRight:30px;fontWeight:bold;minWidth:90px;">{{item.ClassifyName+':'}}</el-checkbox>
						<el-checkbox-group v-model="item.CheckList" @change="handleChecked(item)">
							<el-checkbox v-for="list in item.Items" :label="list.ChartPermissionId" :key="list.ChartPermissionId" class="list_item">{{list.PermissionName}}</el-checkbox>
						</el-checkbox-group>
					</li>
				</ul>
            </el-form-item>
            <template v-if="formData.firstTypeVal!=3">
            <el-form-item label="大陆拨入号" label-width="100px" prop="MainlandTel">
                <el-input placeholder="请输入大陆拨入号" v-model="formData.MainlandTel"></el-input>
            </el-form-item>
            <el-form-item label="香港拨入号" label-width="100px" prop="HongKongTel">
                <el-input placeholder="请输入香港拨入号" v-model="formData.HongKongTel"></el-input>
            </el-form-item>
            <el-form-item label="台湾拨入号" label-width="100px" prop="TaiwanTel">
                <el-input placeholder="请输入台湾拨入号" v-model="formData.TaiwanTel"></el-input>
            </el-form-item>
            <el-form-item label="新加坡拨入号" label-width="100px" prop="SingaporeTel">
                <el-input placeholder="请输入新加坡拨入号" v-model="formData.SingaporeTel"></el-input>
            </el-form-item>
            <el-form-item label="美国拨入号" label-width="100px" prop="AmericaTel">
                <el-input placeholder="请输入美国拨入号" v-model="formData.AmericaTel"></el-input>
            </el-form-item>
            <el-form-item label="拨入密码" label-width="100px" prop="ParticipationCode">
                <el-input placeholder="请输入拨入密码" type="number" v-model="formData.ParticipationCode"></el-input>
            </el-form-item>
            </template>

            <el-form-item label="参会链接" label-width="100px" prop="LinkParticipants" v-if="formData.firstTypeVal!=1">
                <el-input placeholder="请输入参会链接" v-model="formData.LinkParticipants"></el-input>
            </el-form-item>

            <el-form-item label="报告链接" label-width="100px" prop="ReportLinkUrl" v-if="showSelectReportUrl">
                <el-input placeholder="请选择报告链接" v-model="formData.ReportLink" readonly style="width:500px;margin-right:20px"></el-input>
                <el-button type="primary" @click="handleShowSelectReport">选择报告</el-button>
            </el-form-item>

            <el-form-item label="活动海报" label-width="100px" prop="poster" v-if="showUploadPoster">
                <el-upload
                class="ficc-upload-wrap"
                :action="baseApi+'/resource/image/upload'"
                :on-remove="handlePosterRemove"
                :on-success="handleUploadPosterSuccess"
                accept="image/*"
                :on-preview="handlePreImg"
                multiple
                :file-list="formData.Poster">
                    <el-button type="primary">上传活动海报</el-button>
                </el-upload>
            </el-form-item>

            <el-form-item label="会议音频" label-width="100px" prop="Audios">
                <el-upload
                class="ficc-upload-wrap"
                :action="baseApi+'/resource/voice/upload'"
                :on-remove="handleAudioRemove"
                :on-success="handleUploadAudioSuccess"
                :before-upload="handleAudioBeforeUpload"
                accept="audio/*"
                multiple
                :file-list="formData.Audios">
                    <el-button type="primary">上传会议音频</el-button>
                </el-upload>
            </el-form-item>
            
            <div style="text-align:center;margin:30px 0">
                <el-button type="primary" style="width:120px" @click="handleSubmit('save')">保存</el-button>
                <el-button type="primary" style="width:120px" @click="handleSubmit('publish')" v-if="PublishStatus!=1">发布</el-button>
                <el-button type="primary" plain style="width:120px" @click="handleSubmit('cancel')">取消</el-button>
            </div>
            </template>

        </el-form>

        <!-- 选择报告弹窗 -->
        <el-dialog 
            v-dialogDrag 
            :append-to-body="true" 
            :visible.sync="showSelectReport" 
            width="50vw" 
            title="选择报告"
            center
        >
            <div class="ficc-activity-selectreport-wrap">
                <div class="left-btn-box">
                    <el-button 
                        v-for="item in reportTypeList"
                        :key="item.val"
                        :type="selectReportTtype==item.val?'primary':''" 
                        @click="handleReportTypeChange(item.val)">{{item.name}}</el-button>
                </div>
                <div class="right-box">
                    <el-input v-model="searchReportVal" @input="handleSearchReportList" placeholder="标题关键字搜索" style="width:100%"></el-input>
                    <el-table :data="reportList" border style="margin-top:20px">
                        <el-table-column align="center" label="报告标题">
                            <template slot-scope="scope">
                                <div style="text-align:left">
                                    <el-radio v-model="formData.ReportId" :label="scope.row.ResearchReportId">
                                        <span style="white-space: normal;">{{ scope.row.ResearchReportName }}</span>
                                    </el-radio>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column align="center" label="创建时间">
                            <template slot-scope="scope">
                                {{scope.row.CreatedTime}}
                            </template>
                        </el-table-column>
                    </el-table>
                    <div style="text-align:center;margin:30px 0">
                        <el-button type="primary" @click="handleSaveSelectReport">保存</el-button>
                        <el-button type="primary" plain @click="showSelectReport=false">取消</el-button>
                    </div>
                </div>
            </div>
        </el-dialog>

        <!-- 图片预览弹窗 -->
        <el-image-viewer 
		v-if="showPreImg" 
        :on-close="closePreImg" 
		:url-list="preImgList" />
    </div>
</template>

<script>
import moment from 'moment'
import ElImageViewer from 'element-ui/packages/image/src/image-viewer'
import { ficcManageInterface,customInterence,resourceInterface,classifyTelList } from "@/api/api";
import { isArray } from 'highcharts';
export default {
    components:{ElImageViewer},
    computed:{
        showActivityTypeName(){//是否显示手动输入活动类别
            let flag=false
            if(this.formData.childTypeVal==39
                ||this.formData.childTypeVal==41
                ||this.formData.firstTypeVal==4){
                flag=true
            }

            return flag
        },

        showUploadPoster(){//显示上传活动海报
            let flag=false
            if(this.formData.firstTypeVal!=1){
                flag=true
            }

            return flag
        },

        showSelectReportUrl(){//显示选择报告链接
            let flag=false
            if(this.formData.firstTypeVal!=2){
                flag=true 
            }

            return flag 
        },

        showAddressOrLimitPeople(){//显示地址或着参会限制人数
            let flag=false

            if(this.formData.firstTypeVal==3||this.formData.firstTypeVal==4) flag=true
            return flag 
        },

        showPermission(){//显示选择参会权限
            let flag=false

            if(this.formData.firstTypeVal==3) flag=true
            return flag 

        },

        showSelectSpeaker(){//显示选择主讲人
            let flag=false
            if(this.formData.firstTypeVal==1||(this.formData.firstTypeVal==3&&this.formData.childTypeVal!=41)) flag=true
            return flag 

        },

        speakerAvatar(){
            if(this.formData.Speaker){
                let img=this.formData.Speaker.map(item=>{
                    let str=''
                    this.speakerList.forEach(_item=>{
                        if(_item.SpeakerName==item){
                            str=_item.SpeakerHeadPic
                        }
                    })
                    return str
                })
                return img
            }
        }
    },
    beforeRouteLeave(to, from, next){
        // 清除session 
        sessionStorage.removeItem('ficcActivityDetail')
        next()
    },
    data() {
        return {
            PublishStatus:0,//发布状态
            baseApi:process.env.API_ROOT,
            typeList: [],
            childTypeList: [],
            speakerList:[],
            
            formData:{
                firstTypeVal: "",
                childTypeVal: "",
                ActivityTypeName:'',//活动类别名称
                time:[],
                ActivityName:'',//活动标题
                Speaker:[],
                MainlandTel:'',
                HongKongTel:'',
                TaiwanTel:'',
                AmericaTel:'',
                SingaporeTel:'',
                ReportLink:'',//报告链接
                ReportName:'',//报告名字
                ReportId:'',//报告id
                IsNewReport:0,//是否关联的是新报告 0否 1是
                ParticipationCode:'',//拨号密码
                Audios:[],//音频
                Poster:[],//海报
                LinkParticipants:"",//参会链接
                City:'',//城市
                Address:'',//详细地址
                LimitPeopleNum:'',//限制人数
                Permission:[],//选择的参会权限
            },
            formRules:{
                firstTypeVal:[{required: true, message: "请选择活动类型", trigger: "change"}],
                childTypeVal:[{required: true, message: "请选择活动类别", trigger: "change"}],
                time:[{required: true, message: "请选择活动时间", trigger: "change"}],

            },

            showSelectReport:false,//显示选择报告弹窗
            selectReportTtype:'',
            reportTypeList:[
               /*  {name:"双周报",val:"new_two_week"},
                {name:"月报",val:"month"},
                {name:"点评",val:"other"},
                // {name:"周报",val:"week"},
                {name:'周报',val:'new_week'},
                {name:"晨报",val:"day"}, */
            ],
            reportList:[],
            searchReportVal:'',//搜索报告的关键词

            cityArr:['上海','北京','杭州','深圳'],
            PermissionList:[],//权限数据

            preImgUrl:'',
            showPreImg:false,
        };
    },
    created() {
        this.getTypeList();
        this.getSpeakerList()
        this.getTelList()
    },
    methods: {

        // 上传音频大小控制
        handleAudioBeforeUpload(e){
            if(e.size>200*1024*1024){
                this.$message.warning('音频大小不得大于200M')
                return false
            }else{
                return true
            }
        },


        //预览图片
        handlePreImg(file){
            this.preImgList=[file.url]
            this.showPreImg=true
        },

        closePreImg(){
            this.showPreImg=false
            this.preImgList=[]
        },

        // 初始化数据
        initData(){
            let obj=JSON.parse(sessionStorage.getItem('ficcActivityDetail'))
            console.log(obj);
            this.PublishStatus=obj.PublishStatus
            this.formData.firstTypeVal=obj.FirstActivityTypeId
            this.typeList.forEach((item) => {
                if (item.ActivityTypeId == this.formData.firstTypeVal) {
                    this.childTypeList = item.ChildList;
                }
            });

            this.formData.childTypeVal=obj.ActivityTypeId
            this.formData.ActivityTypeName=obj.ActivityTypeName
            this.formData.time=[moment(obj.StartTime).format('YYYY-MM-DD HH:mm:ss'),moment(obj.EndTime).format('YYYY-MM-DD HH:mm:ss')]
            this.formData.ActivityName=obj.ActivityName
            this.formData.Speaker=obj.Speaker.split(',')
            this.formData.MainlandTel=obj.MainlandTel
            this.formData.HongKongTel=obj.HongKongTel
            this.formData.TaiwanTel=obj.TaiwanTel
            this.formData.AmericaTel=obj.AmericaTel
            this.formData.SingaporeTel=obj.SingaporeTel
            this.formData.ReportLink=obj.ReportLink
            this.formData.ReportName=obj.ReportName
            this.formData.ReportId=obj.ReportId
            this.formData.IsNewReport=Number(obj.IsNewReport)
            this.formData.ParticipationCode=obj.ParticipationCode
            this.formData.Audios=obj.VoiceList&&obj.VoiceList.map(item=>{
                return {name:item.VoiceName,PlaySeconds:item.VoicePlaySeconds,url:item.VoiceUrl}
            })||[]
            this.formData.Poster=obj.PosterList&&obj.PosterList.map(item=>{
                return {name:item.Name,url:item.Url}
            })||[]
            this.formData.LinkParticipants=obj.LinkParticipants
            this.formData.City=obj.City
            this.formData.Address=obj.Address
            this.formData.LimitPeopleNum=obj.LimitPeopleNum
            this.formData.Permission=obj.PermissionList&&obj.PermissionList.map(item=>item.PermissionId)
        },
        
        //获取活动类型
        async getTypeList() {
            const res = await ficcManageInterface.activityTypeList();
            if (res.Ret === 200) {
                this.typeList = res.Data || [];
                this.initData()
                if(this.formData.firstTypeVal==3){
                    this.getPermissionList()
                }
            }
        },

        // 点击弹出选择报告
        handleShowSelectReport(){
            this.showSelectReport=true
            this.getReportList()
        },

        // 报告类别切换
        handleReportTypeChange(e){
            this.searchReportVal=''
            this.selectReportTtype=e
            this.getReportList()
        },

        // 关键词搜索报告
        handleSearchReportList(){
            this.getReportList()
        },

        // 获取报告列表
        async getReportList(){
          let reportType='',telClassifyId=0
          //如果是其他电话会,拆分ReportType和ClassifyId
          if(this.selectReportTtype.includes('_')){
            const arr = this.selectReportTtype.split('_')
            reportType = arr[0]
            telClassifyId = Number(arr[1])
          }
          const res=await ficcManageInterface.activityReportList({
              Keyword:this.searchReportVal,
              ReportType:reportType.length?reportType:this.selectReportTtype,
              ClassifyId:reportType.length?telClassifyId:0,
              CurrentIndex: 1,
              PageSize: 5,
          })
          if(res.Ret===200){
              this.reportList=res.Data.List
          }
        },

        // 保存选择的报告
        handleSaveSelectReport(){
            this.reportList.forEach(item=>{
                if(item.ResearchReportId==this.formData.ReportId){
                    this.formData.ReportName=item.ResearchReportName
                    this.formData.ReportLink=item.LinkUrl
                    // 是否是新后台的报告
                    if(this.selectReportTtype=='day'){
                        this.formData.IsNewReport=0
                    }else{
                        this.formData.IsNewReport=1
                    }
                }
            })
            this.showSelectReport=false
        },

        // 获取主讲人列表
        async getSpeakerList(){
            const res=await ficcManageInterface.activitySpeakerList({
                PageSize:10000,
                CurrentIndex:1,
            })
            if(res.Ret===200){
                this.speakerList=res.Data.List||[]
            }
        },

        // 获取基本权限列表
        async getPermissionList(){
            const res=await customInterence.authList({CompanyType:'ficc'})
            if(res.Ret===200){
                let newArr = [];
				res.Data.List.length&&res.Data.List.forEach(item => {
					let obj = {
						checkAll:false,
						isIndeterminate:false,
						...item,
                        CheckList:[]
					}
                    if(this.formData.Permission&&this.formData.Permission.length>0){
                        obj.Items.forEach((e) => {
                            let flag = this.formData.Permission.indexOf(e.ChartPermissionId);
                            if (flag != -1) {
                                obj.CheckList.push(e.ChartPermissionId);
                            }
                        });
                        if (obj.CheckList.length === obj.Items.length) {
                            obj.checkAll = true;
                        } else {
                            if(obj.CheckList.length>0){
                                obj.isIndeterminate=true
                            }
                            obj.checkAll = false;
                        }
                    }
                    
					newArr.push(obj)
				})
				this.PermissionList = newArr;
            }
        },
        /* 选择全选或取消全选 */
		handleCheckAll(item) {
			// 取到所有的子菜单id
			let ids = item.Items.map(item =>{
				return item.ChartPermissionId
			})
			item.CheckList = item.checkAll ? ids : [];	
        	item.isIndeterminate = false;
		},
		/* 复选框組选中时 */
		handleChecked(item) {
			let len = item.CheckList.length;
			item.checkAll = len === item.Items.length;
			item.isIndeterminate = len > 0 && len < item.Items.length;
		},

        // 海报上传成功回调
        handleUploadPosterSuccess(response, file, fileList){
            let arr=[]
            fileList.forEach(item=>{
                if(typeof item.response === 'string'){
                    item.response=this.$parseData(item.response)
                }
                if(item.response){
                    if(item.response.Ret===200){
                        arr.push({
                            name:item.response.Data.ResourceName,
                            url:item.response.Data.ResourceUrl
                        })
                    }
                }else{
                    arr.push({...item})
                }
            })
            this.formData.Poster=arr
        },
        // 删除上传的海报
        handlePosterRemove(file,fileList){
            this.formData.Poster=fileList
        },
        // 音频上传成功回调
        handleUploadAudioSuccess(response, file, fileList){
            let arr=[]
            fileList.forEach(item=>{
                if(typeof item.response === 'string'){
                    item.response=this.$parseData(item.response)
                }
                if(item.response){
                    if(item.response.Ret===200){
                        arr.push({
                            name:item.response.Data.ResourceName,
                            PlaySeconds:item.response.Data.PlaySeconds,
                            url:item.response.Data.ResourceUrl
                        })
                    }
                }else{
                    arr.push({...item})
                }
            })
            this.formData.Audios=arr
        },
        
        // 删除上传的音频
        handleAudioRemove(file,fileList){
            this.formData.Audios=fileList
        },

        // 提交
        handleSubmit(e){
            if(e==='cancel'){
                this.$router.go(-1)
                return
            }
            this.$refs.form.validate(async (valid)=>{
                if(valid){

                    let params={
                        ActivityId:Number(this.$route.query.id),
                        ActivityName:this.formData.ActivityName,
                        ActivityTypeId:this.formData.childTypeVal,
                        ActivityTypeName:this.formData.ActivityTypeName,
                        Address:this.formData.Address,
                        AmericaTel:this.formData.AmericaTel,
                        City:this.formData.City,
                        EndTime:this.formData.time[1],
                        HongKongTel:this.formData.HongKongTel,
                        IsLimitPeople:this.formData.LimitPeopleNum?1:0,//是否限制人数 1是，0否
                        LimitPeopleNum:Number(this.formData.LimitPeopleNum),
                        LinkParticipants:this.formData.LinkParticipants,
                        MainlandTel:this.formData.MainlandTel,
                        ParticipationCode:this.formData.ParticipationCode,
                        PermissionIdList:[],//选择的权限
                        PosterList:[],//海报数据
                        PublishStatus:e==='save'?0:1,//不发布（保存）：0； 发布：1
                        Remarks:'',
                        ReportLink:this.formData.ReportLink,//报告链接
                        ReportName:this.formData.ReportName,//报告标题
                        ReportId:this.formData.ReportId||0,//报告id
                        IsNewReport:this.formData.IsNewReport,
                        SingaporeTel:this.formData.SingaporeTel,
                        Speaker:this.formData.Speaker.join(','),
                        SpeakerBackgroundPic:'',
                        SpeakerHeadPic:'',
                        StartTime:this.formData.time[0],
                        TaiwanTel:this.formData.TaiwanTel,
                        VoiceList:[],//音频数据
                    }

                    if(this.showSelectSpeaker){//如果是选择的主讲人 则找出对应的背景图和头像
                        let SpeakerBackgroundPicArr=[]
                        let SpeakerHeadPicArr=[]
                        this.formData.Speaker.forEach(item=>{
                            this.speakerList.forEach(_item=>{
                                if(_item.SpeakerName===item){
                                    SpeakerBackgroundPicArr.push(_item.SpeakerBackgroundPic)
                                    SpeakerHeadPicArr.push(_item.SpeakerHeadPic)
                                }
                            })
                        })
                        params.SpeakerBackgroundPic=SpeakerBackgroundPicArr.join(',')
                        params.SpeakerHeadPic=SpeakerHeadPicArr.join(',')
                        // this.speakerList.forEach(item=>{
                        //     if(item.SpeakerName===params.Speaker){
                        //         params.SpeakerBackgroundPic=item.SpeakerBackgroundPic
                        //         params.SpeakerHeadPic=item.SpeakerHeadPic
                        //     }
                        // })
                    }

                    if(this.showPermission){// 选择的权限
                        this.PermissionList.forEach(item=>{
                            params.PermissionIdList.push(...item.CheckList)
                        })
                    }

                    if(this.showUploadPoster){//上传的海报
                        params.PosterList=this.formData.Poster.map(item=>{
                            return {Name:item.name,Url:item.url}
                        })
                    }

                    if(!this.showActivityTypeName){//不是手动输入的活动类别
                        this.childTypeList.forEach(item=>{
                            if(item.ActivityTypeId==params.ActivityTypeId){
                                params.ActivityTypeName=item.ActivityTypeName
                            }
                        })
                    }

                    // 处理音频
                    params.VoiceList=this.formData.Audios.map(item=>{
                        return {
                                Name:item.name,
                                PlaySeconds:item.PlaySeconds.toString(),
                                Url:item.url
                            }
                    })

                    if(!params.StartTime||!params.EndTime){
                        this.$message.warning('请选择活动时间')
                        return
                    }
                    if(!params.ActivityName){
                        this.$message.warning('请填写活动标题')
                        return
                    }
                    if(!params.Speaker){
                        if(this.showSelectSpeaker){
                            this.$message.warning('请选择主讲人')
                        }else{
                            if(this.formData.firstTypeVal==2||this.formData.firstTypeVal==4){
                                this.$message.warning('请填写主讲嘉宾')
                            }else{
                                this.$message.warning('请填写主讲人')
                            }
                        }
                        return
                    }
                    // 校验时间
                    if((new Date(params.EndTime).getTime()-new Date(params.StartTime).getTime())<1000*60*30){
                        this.$message.warning('活动时长不得小于半小时')
                        return 
                    }
                    if(this.showUploadPoster&&params.PublishStatus==1){
                        if(params.PosterList.length==0){
                            this.$message.warning('请上传活动海报')
                            return
                        }
                    }
                    if(this.showPermission&&params.PermissionIdList.length<=0){
                        this.$message.warning('请选择参会权限')
                        return 
                    }

                    console.log(params);
                    const res=await ficcManageInterface.activityEdit(params)
                    if(res.Ret===200){
                        if(e==='save'){
                            this.$message.success('保存成功')
                        }else{
                            this.$message.success('发布成功')
                        }
                        setTimeout(() => {
                            this.$router.go(-1)
                        }, 1000);
                        
                    }


                }else{
                    this.$message.warning('请完善表单项')
                }
            })
        },
        async getTelList(){
          const res = await classifyTelList()
          if(res.Ret===200){
            const data = res.Data||[]
            //其他电话会报告
            this.reportTypeList = data.map(item=>{
              return {name:item.ClassifyName,val:'tel_'+item.Id}
            })
            //晨报和周报
            this.reportTypeList = this.reportTypeList.concat([{name:'晨报',val:'day'},{name:'周报',val:'week'}])
            this.selectReportTtype = this.reportTypeList[0].val
          }
        },
    },
};
</script>


<style lang="scss">
.ficc-upload-wrap{
    display: flex;
    .el-upload-list{
        margin-left: 30px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        flex: 1;
        .el-upload-list__item{
            min-width: 200px;
            max-width: 300px;
            margin-right: 10px;
            &:first-child{
                margin-top: 5px;
            }
        }
    }
}
</style>
<style lang="scss" scoped>
.ficc-add-activity-wrap {
    div {
        box-sizing: border-box;
    }
    min-height: 80vh;
    background: #ffffff;
    border: 1px solid #ececec;
    box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    padding: 30px;
    .menu_lists {
		padding: 40px 18px;
		border: 1px dashed #AAB4CC;
		border-radius: 4px;
		.menu_item {
			display: flex;
			// align-items: center;
			margin-bottom: 40px;
			&:last-child {
				margin-bottom: 0;
			}
			.list_item {
				margin-right: 30px;
				&:last-child {
					margin-right: 0;
				}
			}
		}
	}
}
.ficc-activity-selectreport-wrap{
    display: flex;
    .left-btn-box{
        .el-button{
            background-color:#ECF5FF;
            border: 1px solid #B3D8FF;
            color:#409EFF;
            display: block;
            margin-left: 0;
            margin-bottom: 20px;
            width: 90px;
            white-space: normal;
            padding: 12px 16px;
        }
        .el-button--primary{
            background-color:#409EFF;
            border:none;
            color: #FFFFFF;
        }
    }
    .right-box{
        flex: 1;
        margin-left: 30px;
        .el-radio{
            display: flex;
        }
    }
}
</style>
