
<style lang="scss" scoped>
.orderDetail{
    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{
    width: 320px;
    height: 180px;
}
.imgBox{
    width: 100%;
    height: 180px;
}
.marterialInfo{
    
    p{margin-bottom: 0;}
    ul,li{
        margin: 0;
        padding: 0;
    }
    .info-item{
        margin-bottom: 20px;
        display: flex;
        // justify-content: center;
        align-items: center;
        span{
            display: inline-block;
            width: 70px;
            text-align: left;
        }
        .ant-tag{
            width: auto;
            min-width: 50px;
            text-align: center;
        }
    }
    .info{
        ul{
            display: flex;
            justify-content: space-between;
            flex-wrap: wrap;
        }
        li{
            width: 33.3%;
            margin-bottom: 20px;
        }
        margin-bottom: 0;
    }
    .bottom-btn{
        width: 100%;
        text-align: center;
        position: absolute;
        bottom: 20px;
        left: 0;

    }
}
</style>

<style lang="less">
    .orderDetail{
        .ant-timeline-item-head{
            background: rgb(240,242,245);
        }
        .muen{
            cursor: pointer;
        }
        .muen:hover{
            color: #1890ff;
        }
    }   
    
</style>
<template>
    <div class="orderDetail ">
        
        <div class="section">
             <p class="breadcrumb">
                <a-breadcrumb style="display:block;width:100%">
                    <a-breadcrumb-item ><span class="muen" @click="goPlantForm()">工作台</span></a-breadcrumb-item>
                    <a-breadcrumb-item>物料列表</a-breadcrumb-item>
                </a-breadcrumb>
            </p>
            <div class="sectionBody">
                <!-- <div class="tabBody">
                    <a-tabs v-model="activeKey" @change='tabChange'>
                        <a-tab-pane v-for="pane in panes" :key="pane.key" :tab="pane.title"  >
                            
                        </a-tab-pane>
                    </a-tabs>
                </div> -->
                <!-- 素材列表 -->
                <div class="section-item">
                    <div class="tabBox">
                        
                        <div class="search-item">
                            <span>名称：</span>
                            <a-input placeholder="请输入订单名称" allow-clear v-model="materialName" style="width:300px" />
                        </div>
                        <div class="search-item">
                            <span>编号：</span>
                            <a-input placeholder="请输入订单编号" allow-clear v-model="materialId" style="width:300px" />
                        </div>
                        

                        <div class="search-item">
                            <span>所属订单：</span>
                            <a-input placeholder="所属订单" allow-clear v-model="orderSponsor" style="width:300px" />
                        </div>
                        <div class="opt-item">
                            <a-button type='primary' @click="search" style="margin-right:20px">查询</a-button>
                            <a-button type='default' @click="reset">查询</a-button>
                        </div>
                    </div>
                        
                    
                    <div class="section-box">
                         <a-table
                            size="middle"
                            :columns="columns"
                            :dataSource="data"
                            id="outTable"
                            :pagination="ipagination"
                            :loading="loading"
                            @change="sort"
                            style="word-break: break-all;"
                            >
                            <div slot="materialStatus" slot-scope="text" >
                                <span class="wancheng" v-if="text==7"> </span>
                                <span class="bohui" v-else-if="text==6||text==4"> </span>
                                <span class="shenhe" v-else> </span>
                                {{text | handleMaterialStatus}}
                            </div>
                            <div slot="scriptStatus" slot-scope="text,record">
                                <div v-if="text==0||text==2">脚本未上传</div>
                                <div v-if="text==1">
                                    <a href="javascript:;" @click="scriptViewDetails(record)">预览</a>
                                    <a-divider type="vertical" />
                                    <a href="javascript:;" @click="scriptApproved(record)">通过</a>
                                    <a-divider type="vertical" />
                                    <a href="javascript:;" @click="scriptReject(record)">驳回</a>
                                </div>
                                <div v-if="text==3">
                                     <a href="javascript:;" @click="scriptViewDetails(record)">预览</a>
                                </div>
                            </div>
                            <div slot="videoStatus" slot-scope="text,record">
                                <div v-if="text==0||text==2">视频未上传</div>
                                <div v-if="text==1">
                                    <a href="javascript:;" @click="viewDetails(record)">预览</a>
                                    <a-divider type="vertical" />
                                    <a href="javascript:;" @click="approved(record)">通过</a>
                                    <a-divider type="vertical" />
                                    <a href="javascript:;" @click="reject(record)">驳回</a>
                                </div>
                                <div v-if="text==3">
                                     <a href="javascript:;" @click="viewDetails(record)">预览</a>
                                </div>
                            </div>
                           

                        </a-table>
                    </div>
                    <a-drawer
                    title="视频详情"
                    width="640"
                    :placement="placement"
                    :closable="false"
                    :visible="visible"
                    @close="onClose"
                    >
                        <div class="videoBody">
                            <div class="videoBox">
                                <video :src="currentMaterial.src" ></video>
                            </div>
                            
                            <div class="imgBox">
                                <img src="" alt="">
                                <img src="" alt="">
                            </div>
                        </div>
                        <div class="marterialInfo">
                            <div class="info-item">
                                <span>素材状态：</span>
                                <p>未审核</p>
                            </div>
                            <div class="info-item">
                                <span>生成水印：</span>
                                <a-select :defaultValue="4" v-model="size" style="width:70%;">
                                    <a-select-option :value="item.id" :key="item.id" v-for="item of sizeType">{{
                                        item.name
                                    }}</a-select-option>
                                </a-select>
                                
                            </div>
                            <div class="info-item">
                                <span>视频标签：</span>
                                <a-tag>Tag 1</a-tag>
                                <a-tag>Tag 1</a-tag>
                            </div>
                            <div class="info-item info">
                                <ul>
                                    <li><span>视频时长：</span> 17秒 </li>
                                    <li><span>视频尺寸：</span> 1080*1920 </li>
                                    <li><span>视频大小：</span> 31.42M </li>
                                    <li><span>策划：</span> 吴永前 </li>
                                    <li><span>拍摄：</span> 吴永前 </li>
                                    <li><span>剪辑：</span> 吴永前 </li>                                    
                                </ul>
                            </div>
                            <div class="info-item">
                                <span>广告语：</span>
                                <p>14354534324454354水电费水电费方式手动</p>
                            </div>
                            <div class="bottom-btn">
                                <a-button type='primary' @click="approved" style="margin-right:20px">通过审核</a-button>
                                <a-button type='default' @click="reject">驳回</a-button>
                            </div>
                        </div>
                    </a-drawer>
                    <a-drawer
                    title="脚本详情"
                    width="640"
                    :placement="placement"
                    :closable="false"
                    :visible="scriptVisible"
                    @close="scriptClose"
                    >
                        <div class="videoBody">
                            <div class="videoBox">
                                <video :src="currentMaterial.src" ></video>
                            </div>
                            
                            <div class="imgBox">
                                <img src="" alt="">
                                <img src="" alt="">
                            </div>
                        </div>
                        <div class="marterialInfo">
                            <div class="info-item">
                                <span>素材状态：</span>
                                <p>未审核</p>
                            </div>
                            <div class="info-item">
                                <span>生成水印：</span>
                                <a-select :defaultValue="4" v-model="size" style="width:70%;">
                                    <a-select-option :value="item.id" :key="item.id" v-for="item of sizeType">{{
                                        item.name
                                    }}</a-select-option>
                                </a-select>
                                
                            </div>
                            <div class="info-item">
                                <span>视频标签：</span>
                                <a-tag>Tag 1</a-tag>
                                <a-tag>Tag 1</a-tag>
                            </div>
                            <div class="info-item info">
                                <ul>
                                    <li><span>视频时长：</span> 17秒 </li>
                                    <li><span>视频尺寸：</span> 1080*1920 </li>
                                    <li><span>视频大小：</span> 31.42M </li>
                                    <li><span>策划：</span> 吴永前 </li>
                                    <li><span>拍摄：</span> 吴永前 </li>
                                    <li><span>剪辑：</span> 吴永前 </li>                                    
                                </ul>
                            </div>
                            <div class="info-item">
                                <span>广告语：</span>
                                <p>14354534324454354水电费水电费方式手动</p>
                            </div>
                            <div class="bottom-btn">
                                <a-button type='primary' @click="approved" style="margin-right:20px">通过审核</a-button>
                                <a-button type='default' @click="reject">驳回</a-button>
                            </div>
                        </div>
                    </a-drawer>
                </div>
            </div>
        </div>
    </div>

</template>

<script>
import moment from 'moment';
import { getAction, postAction, downFile, downFilePost } from '@/api/manage';
import qs from 'qs'

let columns=[
    {
        title: '物料名称',
        dataIndex: 'orderTitle',
        align: 'center',        
        key: 'orderTitle',
        scopedSlots: { customRender: 'orderTitle' }
    },
    {
        title: '物料编号',
        dataIndex: 'id',
        align: 'center',        
        key: 'tag',
        scopedSlots: { customRender: 'id' }
    },
    {
        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: 'materialFinishTime',
        align: 'center',        
        key: 'materialFinishTime',
        scopedSlots: { customRender: 'materialFinishTime' }
    },
   
]



export default {
    name:'material-list',
    data() {
        const panes = [
            { title: '脚本列表', content: '', key: 1 , },
            { title: '视频列表', content: '', key: 2 , },           
        ];
        return {
            
            userInfo:{},
            roleCode:'',

            panes,
            activeKey: 1,
            orderInfo:{ },

            columns,
            data:[],
            loading:false,
            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;
                }
            },
            // 订单进度
            materialName:'',
            materialId:'',
            orderStatus:'',
            orderParticipants:"",
            orderSponsor:'',

            visible: false,
            scriptVisible:false,
            placement: 'right',
            currentMaterial:{},


            sizeType:[],
            size: "4",
        }
    },
    methods: {
        goPlantForm(){
            if(this.$parent.role=='operator'){
                this.$parent.currentTabComponent='operatorPlatform'
            }else if(this.$parent.role=='designLeader'){
                this.$parent.currentTabComponent='designleaderPlatform'
            }else if(this.$parent.role=='design'){
                this.$parent.currentTabComponent='operatorPlatform'
            }
        },
        tabChange(key){
            console.log(key)
           
            this.tableHttp(key)
        },
        handleChange(value) {
            console.log(`selected ${value}`);
        },
        
        filterOption(input, option) {
            return (
                option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
            );
        },

        // 查看详情
        viewDetails(record){
            console.log(record)
           this.visible=true;
        },
        // 查看详情
        scriptViewDetails(record){
            console.log(record)
            this.scriptVisible=true;
            // this.$router.push(`/workBench/orderDetail?orderId=${record.id}`)
        },
        
        
        // 撤回订单
        withdrawOrder(){

        },
        // 更多操作
        handleMenuClick(e) {
            console.log('click', e);
        },

        

        // 验收
        checkAccept(record){
            console.log(record)
        },
        onClose() {
            this.visible = false;
        },
        scriptClose() {
            this.scriptVisible = false;
        },
        // 上传素材
        uploadMaterial(){

        },

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

            this.ipagination.pageSize=pagination.pageSize;
            this.materialHttp()
        },
        // 请求素材
        materialHttp(){
            // this.loading=true;           
            this.data=[];
        },

        

        

        // 视频通过审核
        approved(){

        },
        // 视频驳回
        reject(){

        },
        
        search(){

        },
        reset(){
            this.materialName='';
            this.materialId='';
            this.orderStatus='';
            this.orderParticipants="";
            this.orderSponsor='';
        },

        tableHttp(type){
            let  params=this.handlerParams(type)
            params={
                ...params,
                pageNo:this.ipagination.current,
                pageSize:this.ipagination.pageSize
            }
            console.log(params)
            getAction('/platform/designer/listByOperatorUserId',params).then(res=>{
                console.log(res);
                if(res.success){
                    this.data=res.result.records;
                    this.ipagination.total=res.result.total;

                }
            })
        },

        handlerParams(status){
            if(this.$parent.role=='operator'){
                if(status==1){
                    return {
                        materialStatus:0,
                        createBy:this.userInfo.id
                    }
                }
            }else if(this.$parent.role=='designLeader'){
                if(status==1){
                    return {
                        materialStatus:0,
                        design:this.userInfo.id
                    }
                }else if(status==2){
                    return {
                        materialStatus:1,
                        design:this.userInfo.id
                    }
                }
            }else if(this.$parent.role=='design'){
                if(status==1){
                    return {
                        materialStatus:0,
                        design:this.userInfo.id
                    }
                }else if(status==2){
                    return {
                        materialStatus:1,
                        design:this.userInfo.id
                    }
                }else if(status==3){
                    return {
                        materialStatus:3,
                        design:this.userInfo.id
                    }
                }else if(status==4){
                    return {
                        design:this.userInfo.id
                    }
                }
            }
           
        },
        
    },
    mounted(){
        
        let userInfo=localStorage.getItem('pro__Login_Userinfo');
        if(userInfo){
            this.userInfo=JSON.parse(userInfo).value
        }
        this.roleCode=localStorage.getItem('roleCode')
        console.log(this.$parent.materialStatus)
    },
    activated() {
        
        this.activeKey=this.$parent.materialStatus
        this.tableHttp(this.$parent.materialStatus)
    },
    filters:{
        handleMaterialStatus(val){
            let text
            switch (val) {
                case 0:
                    text='待指派'
                    break;
                case 1:
                    text='脚本已上传'
                    break;
                case 2:
                    text='脚本待审核'
                    break;
                case 3:
                    text='视频待上传'
                    break;
                case 4:
                    text='脚本被驳回'
                    break;
                case 5:
                    text='视频待审核'
                    break;
                case 6:
                    text='视频被驳回'
                    break;
                case 7:
                    text='物料已完成'
                    break;
                case -1:
                    text='已作废'
                    break;
            
                default:
                    text='出错'
                    break;
            }
            return text
        }
    },

}
</script>
