<template>
    <order-page
        ref="pageRef"
        :pageConfig="pageConfig"
        permissionKey="review"
        :formatterData="formatterData"
    >
        <template #toolbar>
            <el-button
                type="success"
                plain
                class="ele-btn-icon"
                :icon="DownloadOutlined"
                v-permission="'recycleOrder:review:export'"
                @click="exportData"
            >
                导出订单明细
            </el-button>
        </template>
    </order-page>
</template>

<script setup>
    import { ref, reactive } from 'vue';
    import { ElMessageBox } from 'element-plus/es';
    import { DownloadOutlined } from '@/components/icons';
    import OrderPage from '@/views/recycleOrder/components/order-page-all.vue';
    import { useRouter } from 'vue-router';

    defineOptions({ name: 'RecycleOrderReview' });

    let router = useRouter();
    /** 页面组件实例 */
    const pageRef = ref(null);
    const status = ref('');

    const pageConfig = reactive({
        pageUrl: '/order/recycleOrderReview/pagelist',
        exportUrl: '/order/recycleOrderReview/export',
        fileName: '复审订单',
        cacheKey: 'awaitReviewTable',
        where: {
            expressType: ''
        }
    });

    /** 格式化数据 */
    const formatterData = (data) => {
        data.rows.forEach((item) => {
            for (let key in item.orderInfoResult) {
                item[key] = item.orderInfoResult[key];
            }
        });
        return data;
    };

    //导出数据
    function exportData() {
        pageRef.value?.exportData('复审订单');
    }
</script>
