
<style lang="scss" scoped>
.previewStrategy{
    .moduler {
         .opt {
            text-align: right;
        }
        width: 100%;
        background: #fff;
        margin-bottom: 16px;
        position: relative;
        padding: 32px 24px 48px 32px;
        // border-radius: 4px;
        // box-shadow: 0px 1px 6px 0px rgba(0, 0, 0, 0.05);
        .moduler-title {
        display: flex;
        align-items: center;
        font-size: 22px;
        margin-bottom: 20px;
        }
        .extraClass{
            .row-item {
                margin-bottom: 20px;
            }
            
        }
        .row-item {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        margin-bottom: 25px;
        }
        .row-item:last-of-type {
        margin-bottom: 0;
        }
        .row-item .hint-item {
        width: 24px;
        min-width: 24px;
        align-self: flex-start;
        line-height: 20px;
        height: 20px;
        margin-top: 9px;
        }
        .row-item .label-item {
        position: relative;
        align-items: flex-start;
        align-self: flex-start;
        line-height: 20px;
        height: 20px;
        margin-top: 10px;
        width: 80px;
        min-width: 80px;
        .text-item {
            font-size: 14px;
            width: 60px;
        }
        }
        .row-item .required-item {
        width: 4px;
        height: 4px;
        border-radius: 2px;
        background: #f45858;
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        }
        .row-item .input-item {
        min-width: 480px;
        position: relative;
        // height: 35px;
        .tip {
            font-size: 12px;
            color: tomato;
        }
        }
        .adName{
        display: flex;
        .nameList{
            width: 90%;
        }
        .item{
            display: inline-block;
            width: 30%;
            margin-left: 15px;
            margin-bottom: 10px;
        }
        }
    }
     .toolbox-automate-rules-create-body {
        margin: 16px 0 16px ;
        padding: 32px 32px 16px;
        background-color: #fff;
        border-radius: 4px;
    }
    .toolbox-automate-rules-create-content_title {
        background-color: #fff;
        display: flex;
        flex-flow: row nowrap;
        justify-content: flex-start;
        align-items: center;
        margin-bottom: 28px;
        h3 {
            font-size: 22px;
            margin: 0;
            font-weight: 400;
            height: 30px;
            line-height: 30px;
        }
    }
    .toolbox-automate-rules-create-content {
        padding-left: 28px;
    }
    ul,li{
        margin: 0;
        padding: 0;
    }
   
    width: 100%;
    .topBody{
        width: 100%;
        background: #FFFFFF;
        margin-bottom: 12px;
        padding: 20px;
        box-sizing: border-box;
        .breadcrumb{
            height: 22px;
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #000000;
            line-height: 22px;
        }
        .bottom{
            display: flex;
            position: relative;
            justify-content: space-between;
            // padding: 20px;
            .orderIcon{
                width: 28px;
                height: 28px;
                margin-right: 15px;
                img{
                    width: 100%;
                }
            }
            .tip{
                .greet{
                    width: 300px;
                    height: 28px;
                    font-size: 20px;
                    font-family: PingFangSC-Medium, PingFang SC;
                    font-weight: 500;
                    color: rgba(0, 0, 0, 0.85);
                    line-height: 28px;
                    margin-bottom: 5px;
                }
                .descPosition{
                    
                    font-size: 14px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    color: rgba(0, 0, 0, 0.45);
                    overflow: hidden;
                    margin-bottom: 0;
                    li{
                        height: 22px;
                        line-height: 22px;
                        margin-top:3px ;
                    }
                    span{
                        width: 250px;
                        display: inline-block;
                    }
                }

            }
            .optBody{
                width: 200px;
                flex-shrink:0;
                // justify-content: flex-end;
                text-align: right;
                .btnBody{
                    margin-bottom: 10px;
                }
                .orderInfo{
                    display: flex;
                    justify-content: space-between;
                    text-align: right;
                    p{
                        margin-bottom: 0;
                    }
                    
                    .markName{                        
                        height: 22px;
                        font-size: 14px;
                        font-family: PingFangSC-Regular, PingFang SC;
                        font-weight: 400;
                        color: rgba(0, 0, 0, 0.45);
                        line-height: 22px;
                    }
                    .big{                                               
                        height: 28px;
                        font-size: 20px;
                        font-family: PingFangSC-Regular, PingFang SC;
                        font-weight: 400;
                        color: rgba(0, 0, 0, 0.85);
                        line-height: 28px;
                    }
                }

            }
        }

    }
    .section{
        background: white;
        padding:20px ;
        .breadcrumb{
            height: 22px;
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #000000;
            line-height: 22px;
        }
        .sectionBody{
            
            p{
                margin-bottom: 0;
            }
            .section-item{
                background: white;
                margin-bottom: 20px;
            }
            .tabBox{
                padding: 15px 20px 0;
                display: flex;
                flex-wrap: wrap;
                position: relative;
                .search-item{
                    margin-bottom: 12px;
                    width: 30%;
                }
                .opt-item{
                    position: absolute;
                    right: 20px;
                    top: 16px;
                }
            }
            .sectionHead{
                padding: 15px 20px;
                // height: 24px;
                font-size: 16px;
                font-family: PingFangSC-Medium, PingFang SC;
                font-weight: 500;
                color: rgba(0, 0, 0, 0.85);
                line-height: 24px;
                border-bottom: 1px solid  #E9E9E9;;
                .allOrder{
                    float: right;
                }
            }
            .section-box{
                margin-top: 30px;
                padding: 20px 20px;
                border: 1px solid #E9E9E9;
                .description{
                    margin-top: 10px;
                    .time{
                        height: 32px;
                        line-height: 32px;
                    }
                }
                ul{
                    display: flex;
                    flex-wrap: wrap;
                    // justify-content: space-around;
                }
                li{
                    
                    width: 30%;
                    height: 22px;
                    font-size: 14px;
                    font-family: PingFangSC-Regular, PingFang SC;
                    font-weight: 400;
                    color: rgba(0, 0, 0, 0.85);
                    line-height: 22px;
                    text-align: left;
                    margin-bottom: 15px;
                }
                .top{
                    margin-bottom: 25px;
                }
                .bottom{
                    h4{
                        
                        font-size: 15px;
                        font-family: PingFangSC-Medium, PingFang SC;
                        font-weight: 600;
                        color: rgba(0, 0, 0, 0.85);
                        margin-bottom: 25px;
                    }
                }
                .shenhe{
                    width: 6px;
                    height: 6px;
                    display: inline-block;
                    background: #52C41A;
                    border-radius: 50%;
                    position: relative;
                    top: -2px;

                }
                .wancheng{
                    width: 6px;
                    height: 6px;
                     display: inline-block;
                    background: #1890FF;
                    border-radius: 50%;
                    // margin-right: 3px;
                    position: relative;
                    top: -2px;
                }
                .bohui{
                    width: 6px;
                    height: 6px;
                    display: inline-block;
                    background: #F5222D;
                    border-radius: 50%;
                    position: relative;
                    top: -2px;
                }
            }
            
        }
    }
}
.videoBox{
   
    height: 240px;
}
.imgBox{
    width: 90%;
}
.videomarterialInfo{
    position: relative;
    height: 800px;
}
.marterialInfo{
    overflow: auto;   
    height: 800px;
    position: relative;
    p{margin-bottom: 0;}
    ul,li{
        margin: 0;
        padding: 0;
    }
    .info-item{
        margin-bottom: 20px;
        display: flex;
        // justify-content: center;
        align-items: flex-start;
        span{
            display: inline-block;
            width: 70px;
            text-align: left;
            flex-shrink: 0;
        }
        .ant-tag{
            width: auto;
            min-width: 50px;
            text-align: center;
        }
    }
    .info{
        ul{
            width: 100%;
            display: flex;
            justify-content: space-between;
            flex-wrap: wrap;
        }
        li{
            width: 33.3%;
            margin-bottom: 20px;
        }
        margin-bottom: 0;
    }
    // .btnBody{
    //     width: 100%;
    //     height: 80px;
    //     position: relative;
    // }
    .bottom-btn{
        width: 100%; 
        text-align: center;
        position: absolute;
        bottom: 0px;
        left: 0;
        // margin-top: 20px;

    }
    .scriptbottom-btn{
        width: 100%; 
        // height: 60px;  
        line-height: 60px;   
        text-align: center;
        position: absolute;
        bottom: 0px;
        left: 0;
       
    }
}
</style>

<style lang="less">
    .previewStrategy{
        .ant-timeline-item-head{
            background: rgb(240,242,245);
        }
        .muen{
            cursor: pointer;
        }
        .muen:hover{
            color: #1890ff;
        }
    }
    
    
</style>
<template>
    <div class="previewStrategy ">   
        <a-spin :spinning="spinning">
        <div class="toolbox-automate-rules-create-body">
            <div class="toolbox-automate-rules-create-content_title"><h3>策略预览</h3></div>
            <div class="toolbox-automate-rules-create-content">
                
                    <a-table
                        size="middle"
                        :columns="columns"
                        :dataSource="data"
                        id="outTable"
                        :pagination="ipagination"
                        :loading="loading"
                        @change="sort"
                        style="word-break: break-all;"
                        :bordered='true'
                        >
                        <div slot="materialStatus" slot-scope="text" >
                            <span class="wancheng" v-if="text==7"> </span>
                            <span class="bohui" v-else-if="text==6||text==3"> </span>
                            <span class="shenhe" v-else> </span>
                            {{text | handlerMaterialStatus}}
                        </div>
                        <div slot="scriptStatus" slot-scope="text,record">
                            <span v-if="record.materialStatus==0&&role=='design'">-</span>
                            <a href="javascript:;" v-if="record.materialStatus==0&&role=='designLeader'"  @click="scriptAssign(record)">指派</a>
                            <span v-else>
                                    <a href="javascript:;" @click="scriptViewDetails(record)">{{record.planName}}</a>
                            </span>
                        </div>
                        <div slot="videoStatus" slot-scope="text,record">
                            <span v-if="record.materialStatus==0&&role=='design'">-</span>
                            <a href="javascript:;" v-if="record.materialStatus==0&&role=='designLeader'"  @click="videoAssign(record)">指派</a>
                            <span v-else>
                                    <a href="javascript:;" @click="viewDetails(record)">{{record.clipName}}</a>
                            </span>
                        </div>
                        <div slot="operator" slot-scope="text,record">                            
                            <a href="javascript:;" @click="goDetail(record)">查看详情</a>
                        </div>

                    </a-table>

                    <a-drawer
                    title="视频详情"
                    width="800"
                    :placement="placement"
                    :closable="false"
                    :visible="visible"
                    @close="onClose"
                    >
                        <a-tabs
                        default-active-key="1"
                        tab-position="top"
                        :style="{ height: '200px' }"
                        @prevClick="callback"
                        @nextClick="callback"
                        >
                            <a-tab-pane v-for="i in 30" :key="i" :tab="`Tab-${i}`">  </a-tab-pane>
                        </a-tabs>
                        <a-spin :spinning="visibleLoading">                            
                        <div class="marterialInfo videomarterialInfo">
                            <div class="info-item">
                                <span>素材类型：</span>
                                <p>{{ currentVideo.videoStatus | handlerVideoStatus }}</p>
                            </div> 
                            <div class="info-item">
                                <span>视频预览：</span>
                               <div class="videoBox">
                                    <video style="height:100%" :src="currentVideo.url" controls v-if="currentVideo.url"></video>
                                    <img :src="defaultPic" alt="" style="width:100px;margin:0 10px 8px 0" v-else>
                                </div> 
                            </div>
                            <div class="info-item">
                                <span>封面预览：</span>
                                <div class="imgBox">
                                    <div >
                                        <template v-if="currentVideo.imgList&&currentVideo.imgList.length">
                                            <img  alt="" style="width:100px;margin:0 10px 8px 0" v-for="(item,index) in currentVideo.imgList"  :key='index' :src="item"> 
                                        </template>
                                        <span v-else>暂无封面</span>
                                    </div>

                                </div>
                            </div>
                            
                            <div class="info-item" >
                                <span>创意标题：</span>
                                <p>
                                   
                                </p>
                            </div>
                            <div class="info-item" >
                                <span>广告语：</span>
                                <p>
                                   
                                </p>
                            </div>
                            <div class="info-item" >
                                <span>行动号召：</span>
                                <p>
                                   
                                </p>
                            </div>
                            <div class="info-item" >
                                <span>监测链接</span>
                                <p>
                                   
                                </p>
                            </div>
                           
                           
                            <div class="bottom-btn">
                                <a-button type='default' @click="onClose">关闭</a-button>
                            </div>
                         
                            
                        </div>
                        </a-spin>
                    </a-drawer>
            </div>
        </div>
        <div class="moduler">
                    <!-- <div class="moduler-title">计划名称</div> -->
            <div class="opt">
                <a-button type="default" style="margin-right:15px" @click="goBack">取消创建</a-button>
                <a-button type="primary"  style="margin-right:15px" @click="saveHandler" :loading="saveLoading">确认创建</a-button>
            </div>
        </div>  
    </a-spin>     
        
    </div>
</template>

<script>
import moment from 'moment';
import qs from 'qs'
import { getAction, postAction, downFile, downFilePost } from '@/api/manage';
import Vue from 'vue'
import {ACCESS_TOKEN} from "@/store/mutation-types"
import BMF from 'browser-md5-file'
import { fileCheck, fileCheckImage, fileEdit, fileEditAll,orderFileInsert} from '@/api/actor'
import uploadFile from '@/components/uploadFile.vue'
import { closeAllVideoFun, stopOtherVideo } from '@/utils/videoControl'
import UploadToAli from '@femessage/upload-to-ali'
import { mapGetters } from 'vuex'
import TrendVue from '../../../components/Trend/Trend.vue';

let listColumns=[
    {
        title: '广告组',
        dataIndex: 'materialName',
        align: 'center',        
        key: 'materialName',
        scopedSlots: { customRender: 'materialName' }
    },
    {
        title: '所属计划',
        dataIndex: 'materialId',
        align: 'center',        
        key: 'tag',
        scopedSlots: { customRender: 'materialId' }
    },
    {
        title: '优化目标',
        dataIndex: 'materialStatus',
        align: 'center',        
        key: 'materialStatus',
        scopedSlots: { customRender: 'materialStatus' }
    },
    {
        title: '出价',
        dataIndex: 'scriptStatus',
        align: 'center',        
        key: 'scriptStatus',
        scopedSlots: { customRender: 'scriptStatus' }
    },
     {
        title: '深度优化目标',
        dataIndex: 'videoStatus',
        align: 'center',        
        key: 'videoStatus',
        width:250,
        scopedSlots: { customRender: 'videoStatus' }
    },
    {
        title: '深度优化出价',
        dataIndex: 'orderTitle',
        align: 'center',        
        key: 'orderTitle',
        scopedSlots: { customRender: 'orderTitle' }
    },
    {
        title: '广告位置',
        dataIndex: 'position',
        align: 'center',        
        key: 'position',
        scopedSlots: { customRender: 'position' }
    },
    {
        title: '创意',
        dataIndex: 'operator',
        align: 'center',        
        key: 'operator',
        scopedSlots: { customRender: 'operator' }
    },
   
]


export default {
    name:'preview-strategy',
    
    data() {
        
        return {
            spinning:false,
            currentVideo:{},
            visible: false,
            visibleLoading:false,
            placement: 'right',
            loading:false,
            data:[],
            columns:[...listColumns],
            url:{
                assgin:'/platform/designer/assign',
                scriptDetail:'/platform/material/scriptDetail',
                videoDetail:'/platform/material/videoDetail',
                scriptAccept:'/platform/material/script/accept',
                scriptReject:'/platform/material/script/reject',
                videoAccept:'/platform/material/video/accept',
                videoReject:'/platform/material/video/reject',
            },     
            ipagination: {
                current: 1,
                pageSize: 10,
                //   pageSizeOptions: ['10', '20', '30'],
                showTotal: (total, range) => {
                    return range[0] + "-" + range[1] + " 共" + total + "条"
                },
                showQuickJumper: true,
                showSizeChanger:true,
                pageSizeOptions: ['10', '30', '50'],
                total: 0,
                onChange: (current, pageSize) => {
                    // 切换分页时的回调，
                    // 当在页面定义change事件时，切记要把此处的事件清除，因为这两个事件重叠了，可能到时候会导致一些莫名的bug
                    this.ipagination.current = current;
                    this.ipagination.pageSize= pageSize;
                }
            }, 
        }
    },
    methods: {
        goDetail(record){
            consoel.log(record);
            this.visible=true;
        },
        callback(val) {
            console.log(val);
        },
        onClose() {
            this.visible = false;
        },

        sort(pagination, filters, sorter, { currentDataSource }){
        
            this.ipagination.current=pagination.current;

            this.ipagination.pageSize=pagination.pageSize;
            this.materialHttp(this.activeKey)
        },
        // 请求列表
        getListHttp(type){
            this.loading=true;           
            this.data=[];
            let  params=this.handlerParams(type)
            params={
                ...params,
                pageNo:this.ipagination.current,
                pageSize:this.ipagination.pageSize
            }
            getAction('/platform/material/listByRole',params).then(res=>{
                console.log(res);
                if(res.success){
                    this.loading=false;   
                    this.data=res.result.list;
                    this.ipagination.total=res.result.total;

                }
            })
        },

        

        saveHandler(){
             this.$refs.ruleForm.validate(valid=> {
                if (valid) {
                    // this.form.rulesList=this.rulesList;
                    console.log(valid,this.form);
                    
                    this.saveLoading=true;

                        if(this.currentRuleId){
                            let ruleList=this.form.ruleList.filter(item=>{
                                return !item.groupId
                            })
                            console.log(ruleList)
                            if(ruleList.length>0){
                                postAction(this.url.createRuleGroup,{
                                    templateId:this.currentRuleId,
                                    ruleList
                                }).then(res=>{
                                    console.log(res);
                                    this.saveLoading=false;
                                    if(res.success){
                                        
                                        this.$router.push('/earlyWarningRules/index')
                                        this.$bus.$emit('remove', `/earlyWarningRules/configRules?id=${this.currentRuleId}`)
                                    }else{
                                        this.$message.error(res.message)
                                    }
                                    
                                })
                            }else{
                                this.$router.push('/earlyWarningRules/index')
                                this.$bus.$emit('remove', `/earlyWarningRules/configRules?id=${this.currentRuleId}`)
                            }
                            
                        }else{
                            postAction(this.url.creativeTemplate,this.form).then(res=>{
                                console.log(res);
                                this.saveLoading=false;
                                if(res.success){
                                    this.$router.push('/earlyWarningRules/index')
                                    this.$bus.$emit('remove', '/earlyWarningRules/configRules')
                                }else{
                                    this.$message.error(res.message)
                                }
                                    
                            
                            })
                        }
                    
                    
                    
                } else {
                    console.log('error submit!!');
                    this.$message.error('请按提示填写必填项目！')
                    return false;
                }
            });
        },

        goBack() {
             this.$router.push('/earlyWarningRules/index')
            this.$bus.$emit('remove', '/earlyWarningRules/configRules')
           
        },


    },
    mounted(){
        
    },
    activated() {
        
    },
    filters:{
        handlerMaterialStatus(val){
            let str='';
            switch(val){
                
                case 0:
                    str= '待指派'
                    break;
                case 1:
                    str= '脚本待上传'
                    break;
                case 2:
                    str= '脚本待审核'
                    break;
                case 3:
                    str= '脚本被驳回'
                    break;
                case 4:
                    str= '视频待上传'
                    break;
                case 5:
                    str= '视频待审核'
                    break;
                case 6:
                    str= '视频被驳回'
                    break;
                case 7:
                    str= '物料已完结'
                    break;
                default:
                    str='出错了'
                    break;
            }
            return str
        },
        handlerVideoStatus(val){
            let str='';
            switch(val){
                
                case 0:
                    str= '待上传'
                    break;
                case 1:
                    str= '待审核'
                    break;
                case 2:
                    str= '被驳回'
                    break;
                case 3:
                    str= '已审核'
                    break;
                default:
                    str='出错了'
                    break;
            }
            return str
        },
        
    },

}
</script>
