<template>
    <div>
        <h1>订单中心</h1>
        <span style="float: right!important;">共有数据：<strong>{{list.length}}</strong> 条</span>
        <!--tabel表单-->
        <div>
            <el-table
                    ref="multipleTable"
                    stripe:true
                    stripe border fit highlight-current-row
                    :data="list"
                    height="960"
                    row-key="_id"
                    :tree-props="{children: 'shopInfo'}"
                    style="width: 100%">

                <el-table-column prop="orderNumber" label="订单编号"  width="200" align="center"></el-table-column>
                <el-table-column prop="orderUS" label="订单人姓名" width="200" align="center"></el-table-column>
                <el-table-column prop="orderTime" label="购买时的时间" width="200" align="center"></el-table-column>
                <el-table-column prop="orderPriceAll" label="订单总钱数" width="200" align="center"></el-table-column>
                <el-table-column prop="orderPrice" label="商品单价"  width="160" align="center"></el-table-column>
                <el-table-column prop="orderNum" label="商品数量" width="160" align="center"></el-table-column>
                <el-table-column prop="orderPriceTotal" label="商品总钱数" width="160" align="center"></el-table-column>

            </el-table>
            <br>
            <!--取消-->
            <el-button type="warning" @click="cancelBtnClick" round><i class="el-icon-close"></i> 返回上一级</el-button>
        </div>
    </div>
</template>

<script>
    const axios=require('axios');
    import Cookies from 'js-cookie';
    export default {
        data(){
            return{
                list:[],
                multipleTable:[],
                form:{
                    orderPriceAll:'',
                    orderName:'',
                    orderUS:'',
                    orderNum:null,
                    orderPrice:null,
                    orderPriceTotal:null,
                    orderNumber:null,
                    orderTime:'',
                }
            }
        },
        mounted() {
            this.$message.info(Cookies.get('RoleName'));
            this.tableData();
        },
        methods:{
            tableData(){//登录的时候就将登录的角色存入Cookie,通过存入的角色来判断是否显示全部信息

                if(Cookies.get('RoleObjectId')=='5f8e766ebca0471e0801adc2'){
                    axios.post('https://mz.tshe.cn/restauantCH/user/orderCenter/getInfoAll')
                        .then((res)=>{
                            this.list=res.data;
                        })
                }
                else{
                    axios.post('https://mz.tshe.cn/restauantCH/user/orderCenter/getInfoByKw',{
                        Kw:Cookies.get('username')
                    })
                        .then((res)=>{
                            this.list=res.data;
                        })
                }
            },
            cancelBtnClick(){
                this.$router.go(-1);
            },
        }
    }
</script>
