<!-- 挂牌大厅-我的摘牌 -->
<template>
    <app-view>
        <template #header>
            <app-filter v-bind="{ selectList, inputList, buttonList }" :loading="loading">
                <template #after>
                    <el-date-picker type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
                        value-format="YYYYMMDD" v-model="filterDate" />
                </template>
            </app-filter>
        </template>
        <!-- 表格数据 -->
        <app-table :data="dataList" v-model:columns="columns" :loading="loading">
            <!-- 类型 -->
            <template #buyorsell>
                {{ getBuyOrSellName(buyOrSell) }}
            </template>
            <!-- 价格 -->
            <template #price="{ row }">
                {{ row.zscurrencytypedisplayunit + formatDecimal(row.price) }}
            </template>
            <!-- 成交价格 -->
            <template #tradeprice="{ row }">
                {{ row.zscurrencytypedisplayunit + formatDecimal(row.tradeprice) }}
            </template>
            <!-- 操作 -->
            <template #operate="{ row }">
                <app-auth-operation :menus="['details']" :options="{ selectedRow: row, buyorsell: buyOrSell }"
                    @closed="getDelistingOrderList" />
            </template>
            <template #footer>
                <app-pagination :total="total" v-model:page-size="pageSize" v-model:page-index="pageIndex"
                    @change="getDelistingOrderList" />
            </template>
        </app-table>
    </app-view>
</template>

<script lang="ts" setup>
import { useRoute } from 'vue-router'
import { ElMessage } from 'element-plus'
import { formatDecimal } from '@/filters'
import { getBuyOrSellName } from '@/constants/order'
import { useDelistingOrder } from '@/business/trade/list'
import AppTable from '@pc/components/base/table/index.vue'
import AppPagination from '@pc/components/base/pagination/index.vue'
import AppAuthOperation from '@pc/components/modules/auth-operation/index.vue'
import AppFilter from '@pc/components/base/table-filter/index.vue'

const { params } = useRoute()

const buyorsell = (() => {
    const result = Number(params.buyorsell)
    return isNaN(result) ? undefined : result
})()

const { loading, dataList, total, pageIndex, pageSize, buyOrSell, columns, filterDate, selectList, inputList, buttonList, getDelistingOrderList } = useDelistingOrder(buyorsell)

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