<!-- 会员中心-我的发票 -->
<template>
    <app-view>
        <app-table :data="dataList" v-model:columns="columns" :loading="loading">
            <template #header>
                <app-auth-operation :menus="['add']" @closed="getUserInvoiceList" />
            </template>
            <!-- 发票类型 -->
            <template #receipttype="{ value }">
                {{ getReceiptTypeName(value) }}
            </template>
            <template #operate="{ row }">
                <app-auth-operation :menus="['edit', 'delete']" :options="{ selectedRow: row }"
                    @closed="getUserInvoiceList" />
            </template>
            <template #footer>
                <app-pagination :total="total" v-model:page-size="pageSize" v-model:page-index="pageIndex"
                    @change="getUserInvoiceList" />
            </template>
        </app-table>
    </app-view>
</template>

<script lang="ts" setup>
import { ElMessage } from 'element-plus'
import { useInvoice } from '@/business/user'
import { getReceiptTypeName } from '@/constants/receipt'
import AppAuthOperation from '@pc/components/modules/auth-operation/index.vue'
import AppTable from '@pc/components/base/table/index.vue'
import AppPagination from '@pc/components/base/pagination/index.vue'

const { loading, dataList, columns, total, pageIndex, pageSize, getUserInvoiceList } = useInvoice()

getUserInvoiceList().catch((err) => ElMessage.error(err))
</script>