<template>
    <Modal v-model="modals"  scrollable title="订单记录" width="700" class="order_box" footer-hide>
        <Card :bordered="false" dis-hover>
            <Table :columns="columns" border  :data="recordData" :loading="loading" no-data-text="暂无数据"
                   highlight-row   no-filtered-data-text="暂无筛选结果">

                <template slot-scope="{ row, index }" slot="type">
                    <span v-if="row.type == 0">用户</span>
                    <span v-if="row.type == 1">管理员({{ row.admin_name}})</span>
                </template>
            </Table>
            <div class="acea-row row-right page">
                <Page :total="page.count" show-elevator show-total @on-change="pageChange"
                      :page-size="page.pageSize"/>
            </div>
        </Card>
    </Modal>
</template>

<script>
    import {SystemShowTemplateOrderLog} from "../../../../api/system/order";

    export default {
        name: 'ShowTemplateOrderRecord',
        data () {
            return {
                modals: false,
                loading: false,
                recordData: [],
                page: {
                    total: 0, // 总条数
                    pageNum: 1, // 当前页
                    pageSize: 10 // 每页显示条数
                },
                columns: [
                    {
                        title: '订单ID',
                        key: 'o_id',
                        align: 'center',
                        minWidth: 60
                    },
                    {
                        title: '类型',
                        slot: 'type',
                        align: 'center',
                        width: 100
                    },
                    {
                        title: '操作记录',
                        key: 'mono',
                        align: 'center',
                        minWidth: 280
                    },
                    {
                        title: '操作时间',
                        key: 'time',
                        align: 'center',
                        minWidth: 120
                    }
                ]
            }
        },
        methods: {
            pageChange (index) {
                this.page.pageNum = index
                this.getList();
            },
            getList (id) {
                let data = {
                    o_id: id,
                    page: this.page
                }
                this.loading = true;
                SystemShowTemplateOrderLog(data)
                    .then(res => {
                        this.loading = false;
                        this.recordData = res.data.list;
                        this.page.pageSize = res.data.pageSize;
                        this.page.count = res.data.pageCount;
                    })
                    .catch(res => {
                        this.loading = false;
                        this.$Message.error(res.msg);
                    });
            }
        }
    }
</script>

<style scoped lang="stylus">
 .order_box >>> .ivu-table th{background: #f8f8f9 !important;}
</style>
