
<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{
   
    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;
            text-align: right;
        }
        .ant-tag{
            width: auto;
            min-width: 50px;
            text-align: center;
        }
    }
    .info{
        width: 100%;
        ul{
            width: 100%;
            display: flex;
            justify-content: space-between;
            flex-wrap: wrap;
            width: 100%;
        }
        li{
            width: 33.3%;
            margin-bottom: 20px;
        }
        margin-bottom: 0;
    }
    
    .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">
    .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==3"> </span>
                                <span class="shenhe" v-else> </span>
                                {{text | handlerMaterialStatus}}
                            </div>
                            <div slot="scriptStatus" slot-scope="text,record">
                                <span v-if="record.materialStatus==0">-</span>
                                <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">-</span>
                                <span v-else>
                                     <a href="javascript:;" @click="viewDetails(record)">{{record.clipName}}</a>
                                </span>
                            </div>
                            <div slot="orderTitle" slot-scope="text,record">
                               
                                <a href="javascript:;" @click="goOrderDetail(record)">{{text}}</a>
                                
                            </div>
                           

                        </a-table>
                    </div>
                    <a-drawer
                    title="视频详情"
                    width="700"
                    :placement="placement"
                    :closable="false"
                    :visible="visible"
                    @close="onClose"
                    >
                        <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" v-if="currentVideo.videoStatus==1||currentVideo.videoStatus==3">
                                    <video style="height:100%" :src="currentVideo.url" v-if="currentVideo.url" controls></video>
                                    <img :src="defaultPic" alt="" style="height:100%" v-else>
                                </div>
                            </div>
                            <div class="info-item">
                                <span>封面预览：</span>
                                <div class="imgBox" 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' @click="openBigImage(item)" :src="item">                                   
                                </div>
                                <div v-else>
                                    <span>暂无封面</span>
                                </div>
                            </div>
                            <div class="info-item" v-if="currentVideo.videoStatus==1">
                                <span>视频标签：</span>
                                <p>
                                    <a-tag v-for="(item,index) in currentVideo.tagList" :key="index" style="margin-bottom:8px">{{item}}</a-tag>
                                    <!-- {{currentVideo.tag}} -->
                                </p>
                            </div>
                            <div class="info-item info">
                                <ul>
                                   
                                    <li><span>编导：</span> {{ currentVideo.planName }} </li>
                                    <li><span>拍摄：</span> {{ currentVideo.shotName }} </li>
                                    <li><span>剪辑：</span> {{ currentVideo.clipName }} </li>                                    
                                </ul>
                            </div>
                            <div class="info-item" v-if="currentVideo.videoStatus==2">
                                <span>驳回理由：</span>
                                <p>{{ currentVideo.videoAdvise }}</p>
                            </div>
                            
                            <!-- <div class="bottom-btn">
                                <a-button type='primary' @click="approved" v-if="currentMaterial.materialStatus==5" :loading='acceptLoading' style="margin-right:20px">通过审核</a-button>                               
                                <a-button type='default' @click="()=>{videoRejectVisiable=true}" v-if="currentMaterial.materialStatus==5"  style="margin-right:20px">驳回</a-button>
                                                            
                                <a-button type='default' @click="onClose">关闭</a-button>
                            </div> -->
                            
                        
                        </div>
                        </a-spin>
                        <div
                            :style="{
                            position: 'absolute',
                            right: 0,
                            bottom: 0,
                            width: '100%',
                            borderTop: '1px solid #e9e9e9',
                            padding: '10px 16px',
                            background: '#fff',
                            textAlign: 'right',
                            zIndex: 1,
                            }"
                        >
                            <a-button type='primary' @click="approved" v-if="currentMaterial.materialStatus==5" :loading='acceptLoading' style="margin-right:20px">通过审核</a-button>                               
                                <a-button type='default' @click="()=>{videoRejectVisiable=true}" v-if="currentMaterial.materialStatus==5"  style="margin-right:20px">驳回</a-button>
                                                            
                                <a-button type='default' @click="onClose">关闭</a-button>
                        </div>   
                    </a-drawer>
                    <a-drawer
                    title="脚本详情"
                    width="600"
                    :placement="placement"
                    :closable="false"
                    :visible="scriptVisible"
                    @close="scriptClose"
                    >
                        <a-spin :spinning="visibleLoading">
                        <div class="marterialInfo">
                            <div class="info-item">
                                <span>脚本状态：</span>
                                <p>{{ currentScript.scriptStatus | handlerVideoStatus }}</p>
                            </div>
                            <div class="info-item">
                                <span>所属项目：</span>
                                <p>{{currentScript.projectName}}</p>
                                
                            </div>
                            <div class="info-item">
                                <span>所属物料：</span>
                                <p>{{currentScript.materialName}}</p>
                            </div>
                            <div class="info-item">
                                <span>编导：</span>
                                <p>{{currentScript.planName}}</p>
                            </div>
                            <div class="info-item" v-if="currentScript.scriptStatus==2">
                                <span>驳回理由：</span>
                                <p>{{currentScript.scriptAdvise}}</p>
                            </div>
                            <div class="info-item">
                                <span>脚本：</span>
                                <p v-if="currentScript.scriptStatus==0">暂无</p>
                                <p v-else><a :href="currentScript.url">{{currentScript.scriptName}}</a></p>

                            </div>
                                                       
                            <div class="scriptbottom-btn">
                                <!-- <a-button type='primary' @click="scriptApproved" v-if="currentMaterial.materialStatus==2" :loading='acceptLoading' style="margin-right:20px" >通过审核</a-button>
                               
                                <a-button type='default' v-if="currentMaterial.materialStatus==2" @click="()=>{scriptRejectVisiable=true}"  style="margin-right:20px">驳回</a-button>
                                
                                <a-button type='default' @click="scriptClose">关闭</a-button> -->
                            </div>
                        </div>
                        </a-spin>
                        <div
                            :style="{
                            position: 'absolute',
                            right: 0,
                            bottom: 0,
                            width: '100%',
                            borderTop: '1px solid #e9e9e9',
                            padding: '10px 16px',
                            background: '#fff',
                            textAlign: 'right',
                            zIndex: 1,
                            }"
                        >
                            <a-button type='primary' @click="scriptApproved" v-if="currentMaterial.materialStatus==2" :loading='acceptLoading' style="margin-right:20px" >通过审核</a-button>
                               
                                <a-button type='default' v-if="currentMaterial.materialStatus==2" @click="()=>{scriptRejectVisiable=true}"  style="margin-right:20px">驳回</a-button>
                                
                                <a-button type='default' @click="scriptClose">关闭</a-button>
                        </div>    
                    </a-drawer>

                    <!-- bohui -->
                <a-modal v-model="videoRejectVisiable" title="视频驳回"  width='600px'>
                     <template slot="footer">
                        <a-button key="back" @click="()=>{videoRejectVisiable=false}">取消</a-button>
                        <a-button type="primary"  @click="reject" :loading="loadingElse">确定驳回</a-button>
                    </template>
                    <div style="position:relative">
                        <a-textarea
                        v-model="videoAdvise"
                        placeholder="请填写驳回理由"
                        :auto-size="{ minRows: 3, maxRows: 5 }"
                        :maxLength='50'
                        />
                        <span style="position:absolute;bottom:5px;right:10px;line-height:24px"><span style="color:#1890ff">{{videoAdvise.length}}</span>/50</span> 
                    </div>
                   
                </a-modal>
                <a-modal v-model="scriptRejectVisiable" title="脚本驳回"  width='600px'>
                     <template slot="footer">
                        <a-button key="back" @click="()=>{scriptRejectVisiable=false}">取消</a-button>
                        <a-button type="primary"  @click="scriptReject" :loading="loadingElse">确定驳回</a-button>
                    </template>                   
                    <div style="position:relative">
                        <a-textarea
                            v-model="scriptAdvise"
                            placeholder="请填写驳回理由"
                            :auto-size="{ minRows: 3, maxRows: 5 }"
                            :maxLength='50'
                        />
                        <span style="position:absolute;bottom:5px;right:10px;line-height:24px"><span style="color:#1890ff">{{scriptAdvise.length}}</span>/50</span>     
                    </div>
                               
                </a-modal>
                <a-modal v-model="viewImgVisiable" title="封面预览"  width='600px' :footer=null>
                        
                        <div style="position:relative;text-align:center">
                            <img :src="viewImgUrl" alt="" width="250">
                        </div>
                    
                    </a-modal>
                </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: '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' }
    },
   
]



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

            visibleLoading:false,
            loadingElse:false,
            videoRejectVisiable:false,
            scriptRejectVisiable:false,

            acceptLoading:false,
            videoAdvise:'',
            scriptAdvise:'',
            currentScript:{},
            currentVideo:{},


            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",

            url:{
                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',
            }
        }
    },
    methods: {
        openBigImage(item){
            this.viewImgVisiable=true;
            this.viewImgUrl=item
        },
        goOrderDetail(record){
            console.log(record)
            this.$parent.currentTabComponent='orderDetail';
            this.$parent.orderId=record.orderId
        },
        
        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='designPlatform'
            }
        },
        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.currentMaterial=record
            if(record.materialStatus>=4){              
                this.currentVideo={};   
                this.visible = true;     
                this.visibleLoading=true        
                if(record.videoId){
                    getAction(this.url.videoDetail,{
                        videoId:record.videoId
                    }).then(res=>{
                        console.log(res);
                        this.visibleLoading=false
                        if(res.success){
                            if(res.result){
                                let tagList=res.result.tag?res.result.tag.split(','):[]
                                let imgList=res.result.imageUrl?res.result.imageUrl.split(','):[]
                                // console.log(tagList)
                                this.currentVideo={
                                    ...res.result,
                                    tagList,
                                    imgList
                                }
                            }
                            
                            
                        }else{
                            this.currentVideo={};
                        }
                    })
                }else{
                    this.currentVideo=record
                    this.visible = true;
                }
            }else{
                this.$message.error('请等待脚本审核通过后，上传视频')
            }
            
        },
        // 脚本查看详情
        scriptViewDetails(record){
            console.log(record)
            this.currentMaterial=record
            this.currentScript={};
            this.scriptVisible = true;
            if(record.scriptId){
                this.visibleLoading=true
                getAction(this.url.scriptDetail,{
                    scriptId:record.scriptId
                }).then(res=>{
                    console.log(res);
                    this.visibleLoading=false
                    if(res.success){
                        this.currentScript=res.result;
                        
                    }else{
                        this.currentScript={};
                    }
                })
            }else{
                this.currentScript=record
                this.scriptVisible = true;
            }
            
        },
        
        
        // 撤回订单
        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.tableHttp(this.activeKey)
        },
       
        

        

        // 脚本通过审核
        scriptApproved(){
            this.acceptLoading=true;
            getAction('/platform/material/verifyScript',{
                materialCode:this.currentMaterial.materialCode,
                scriptId:this.currentMaterial.scriptId,
            }).then(res=>{
                if(res.success){
                    postAction(this.url.scriptAccept,{
                        id:this.currentMaterial.materialId,
                        orderCode:this.currentMaterial.orderCode,
                        materialCode:this.currentMaterial.materialCode
                    }).then(res=>{
                        console.log(res);
                        this.acceptLoading=false;
                        this.scriptVisible=false;
                        if(res.success){
                            
                            this.$message.success(res.message);
                            this.tableHttp(this.$parent.materialStatus)
                        }else{
                            this.$message.error(res.message)
                        }
                    })
                }else{
                    this.acceptLoading=false;
                    this.scriptVisible=false;
                    this.tableHttp(this.$parent.materialStatus)
                    this.$message.error(res.message)
                }
            })
            
        },
        // 脚本驳回
        scriptReject(){
            this.loadingElse=true
             getAction('/platform/material/verifyScript',{
                materialCode:this.currentMaterial.materialCode,
                scriptId:this.currentMaterial.scriptId,
            }).then(res=>{
                if(res.success){
                    if(this.scriptAdvise){
                        postAction(this.url.scriptReject,{
                            id:this.currentMaterial.materialId,
                            scriptAdvise:this.scriptAdvise,
                            materialCode:this.currentMaterial.materialCode
                        }).then(res=>{
                            console.log(res);
                            this.scriptAdvise=''
                            this.scriptVisible=false;
                            this.loadingElse=false;
                            this.scriptRejectVisiable=false
                            if(res.success){
                                this.$message.success(res.message);
                                this.tableHttp(this.$parent.materialStatus)
                            }else{
                                this.$message.error(res.message)
                            }
                        })
                    }else{
                        this.loadingElse=false;
                        this.$message.error('请填写驳回理由')
                    }
                }else{
                    this.loadingElse=false;
                    this.scriptVisible=false;
                    this.tableHttp(this.$parent.materialStatus)
                    this.$message.error(res.message)
                }
            })
        },
        // 视频通过审核
        approved(){
            this.acceptLoading=true;
            getAction('/platform/material/verifyVideo',{
                materialCode:this.currentMaterial.materialCode,
                videoId:this.currentMaterial.videoId,
            }).then(res=>{
                if(res.success){
                    postAction(this.url.videoAccept,{
                        id:this.currentMaterial.materialId,
                        orderCode:this.currentMaterial.orderCode,
                        materialCode:this.currentMaterial.materialCode,
                        videoId:this.currentVideo.videoId
                    }).then(res=>{
                        console.log(res);
                        this.acceptLoading=false;
                        this.visible=false;
                        if(res.success){
                            this.$message.success(res.message);
                            this.tableHttp(this.$parent.materialStatus)
                        }else{
                            this.$message.error(res.message)
                        }
                    })
                }else{
                    this.$message.error(res.message)
                    this.acceptLoading=false
                    this.visible=false;
                    this.tableHttp(this.$parent.materialStatus)
                }
            })
            
        },
        // 视频驳回
        reject(){
            this.loadingElse=true
            getAction('/platform/material/verifyVideo',{
                materialCode:this.currentMaterial.materialCode,
                videoId:this.currentMaterial.videoId,
            }).then(res=>{
                if(res.success){
                    if(this.videoAdvise){
                        postAction(this.url.videoReject,{
                            id:this.currentMaterial.materialId,
                            videoAdvise:this.videoAdvise,
                            materialCode:this.currentMaterial.materialCode
                        }).then(res=>{
                            console.log(res);
                            this.videoAdvise='';
                            this.visible=false;
                            this.loadingElse=false;
                            this.videoRejectVisiable=false
                            if(res.success){
                                this.$message.success(res.message);
                                this.tableHttp(this.$parent.materialStatus)
                            }else{
                                this.$message.error(res.message)
                            }
                        })
                    }else{
                        this.loadingElse=false;
                        this.$message.error('请填写驳回理由')
                    }
                }else{
                    this.$message.error(res.message)
                    this.loadingElse=false
                    this.visible=false;
                    this.tableHttp(this.$parent.materialStatus)
                }
            })
        },
        
        search(){

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

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

                }
            })
        },

        handlerParams(status){
            if(this.$parent.role=='operator'){
                if(status==1){
                    return {
                        operatorUserId: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)
        this.tableHttp(this.$parent.materialStatus)
        this.activeKey=this.$parent.materialStatus
    },
    activated() {
        
       
        // this.tableHttp(this.$parent.materialStatus)
    },
    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>
