
<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"  >
                            <!-- {{ pane.content }}{{pane.role+'-'+roleCode}} -->
                        </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="orderTitle" style="width:200px" />
                        </div>
                        <div class="search-item">
                            <span>订单编号：</span>
                            <a-input placeholder="请输入订单编号" allow-clear v-model="id" style="width:200px" />
                        </div>
                        

                        <div class="search-item">
                            <span>发起的人：</span>
                            <a-input placeholder="请输入订单发起人" allow-clear v-model="createByName" style="width:200px" />
                        </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"
                            :pagination="ipagination"
                            :loading="loading"
                            @change="sort"
                            style="word-break: break-all;"
                            >
                            <div slot="orderStatus" slot-scope="text" >
                                <span class="wancheng" v-if="text==3"> </span>
                                <span class="bohui" v-else-if="text==2||text==-1"> </span>
                                <span class="shenhe" v-else> </span>
                                {{text | handleOrderStatus}}
                            </div>
                            <span slot="options" slot-scope="text,record">
                                <a href="javascript:;" @click="viewDetails(record)">详情</a>                                                           
                            </span>
                            <span slot="updateTime" slot-scope="text">
                                {{text||'-'}}                                                    
                            </span>

                        </a-table>
                    </div>
                    
                </div>
            </div>
        </div>
    </div>
</template>

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


let listColumns=[
    {
        title: '订单名称',
        dataIndex: 'orderTitle',
        align: 'center',        
        key: 'orderTitle',
        scopedSlots: { customRender: 'orderTitle' }
    },
    {
        title: '订单编号',
        dataIndex: 'id',
        align: 'center',        
        key: 'tag',
        scopedSlots: { customRender: 'id' }
    },
    {
        title: '订单发起人',
        dataIndex: 'createByName',
        align: 'center',        
        key: 'createByName',
        scopedSlots: { customRender: 'createByName' }
    },
    {
        title: '订单状态',
        dataIndex: 'orderStatus',
        align: 'center',        
        key: 'orderStatus',
        scopedSlots: { customRender: 'orderStatus' }
    },
    {
        title: '更新时间',
        dataIndex: 'updateTime',
        align: 'center',        
        key: 'updateTime',
        scopedSlots: { customRender: 'updateTime' }
    },
    {
        title: '操作',
        dataIndex: 'options',
        align: 'center',        
        key: 'options',
        width:250,
        scopedSlots: { customRender: 'options' }
    },
]


export default {
    name:'order-list',
    data() {
        const operatorPanes = [
            { title: '我发起的', content: '', key: 1 , },           
            { title: '已完成的', content: '', key: 2 ,},
            { title: '被驳回的', content: '', key: 3 , },

        ];
        const designLeaderPanes=[
            { title: '全部订单', content: '', key: 4 , },
            { title: '待确定的', content: '', key: 1 , },
            { title: '已完成的', content: '', key: 3 ,},
            
        ]
        return {
            orderTitle:'',
            createByName:'',
            id:'',
            loadingElse:false,
            videoRejectVisiable:false,
            scriptRejectVisiable:false,

            operatorPanes,
            designLeaderPanes,
            userInfo:{},
            roleCode:'',

            panes:[],
            activeKey: '4',
            orderInfo:{ },

            columns:[...listColumns],
            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;
                }
            },
            // 订单进度
            orderName:'',
            orderId:'',
            orderStatus:'',
            orderParticipants:"",
            orderSponsor:'',

            visible: 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='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.$router.push(`/workBench/orderDetail?orderId=${record.id}`)
            this.$parent.currentTabComponent='orderDetail';
            this.$parent.orderId=record.id
        },
        
        
        // 撤回订单
        withdrawOrder(){

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

        // 催一下
        hurryUp(record){
            console.log(record)
        },

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

        },

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

            this.ipagination.pageSize=pagination.pageSize;
            this.tableHttp(this.activeKey)
        },

       
        search(){
            this.tableHttp(this.activeKey)
        },
        reset(){
            this.orderTitle='';
            this.id='';
            this.createByName='';
            
        },

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

                }
            })
        },

        handlerParams(status){
            if(this.$parent.role=='operator'){
                if(status==1){
                    return {
                        
                        createBy:this.userInfo.id
                    }
                }else if(status==2){
                    return {
                        orderStatus:3,
                        createBy:this.userInfo.id
                    }
                }else if(status==3){
                    return {
                        orderStatus:2,
                        createBy:this.userInfo.id
                    }
                } 
            }else if(this.$parent.role=='designLeader'){
                if(status==1){
                    return {
                        orderStatus:0,
                        design:this.userInfo.id
                    }
                }else if(status==2){
                    return {
                        orderStatus:1,
                        design:this.userInfo.id
                    }
                }else if(status==3){
                    return {
                        orderStatus:3,
                        design:this.userInfo.id
                    }
                }else if(status==4){
                    return {
                        design:this.userInfo.id
                    }
                }
            }
           
        },
        handlerParamsRole(role){
            if(this.$parent.role=='operator'){
                this.panes=this.operatorPanes
            }else if(this.$parent.role=='designLeader'){
                this.panes=this.designLeaderPanes
            }
        }
    },
    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.orderStatus)
        if(this.$parent.role=='operator'){
            this.panes=this.operatorPanes
        }else if(this.$parent.role=='designLeader'){
            this.panes=this.designLeaderPanes
        }
        this.activeKey=this.$parent.orderStatus
        this.tableHttp(this.$parent.orderStatus)

    },
    filters:{
        handleOrderStatus(val){
            let text
            switch (val) {
                case 0:
                    text='待接单'
                    break;
                case 1:
                    text='制作中'
                    break;
                case 2:
                    text='已驳回'
                    break;
                case 3:
                    text='已完成'
                    break;
                case -1:
                    text='已撤回'
                    break;
            
                default:
                    text='出错'
                    break;
            }
            return text
        }
    },
    activated() {
        if(this.$parent.role=='operator'){
            this.panes=this.operatorPanes
        }else if(this.$parent.role=='designLeader'){
            this.panes=this.designLeaderPanes
        }
        this.activeKey=this.$parent.orderStatus
        this.tableHttp(this.$parent.orderStatus)
    },
}
</script>
