<!-- 报表查询-资金账户报表-持仓汇总表 -->
<template>
    <app-table :data="dataList" :columns="tableColumns">
        <template #footer>
            <app-pagination :total="total" v-model:page-size="pageSize" v-model:page-index="pageIndex" @change="run" />
        </template>
    </app-table>
</template>

<script lang="ts" setup>
import { shallowRef, PropType } from 'vue'
import { ElMessage } from 'element-plus'
import { useRequest } from '@/hooks/request'
import { holderTotalQuery } from '@/services/api/report'
import AppTable from '@pc/components/base/table/index.vue'
import AppPagination from '@pc/components/base/pagination/index.vue'

const props = defineProps({
    params: {
        type: Object as PropType<Model.TaaccountReportReq>,
        required: true
    }
})

const { dataList, total, pageSize, pageIndex, run } = useRequest(holderTotalQuery, {
    manual: true,
    params: props.params,
    onError: (err) => {
        ElMessage.error(err)
    }
})

const tableColumns = shallowRef<Model.TableColumn[]>([
    { field: 'goodscode', label: 'report.account.position.goodscode' },
    { field: 'goodsname', label: 'report.account.position.goodsname' },
    { field: 'buypositionqty', label: 'report.account.position.buypositionqty', width: 140 },
    { field: 'buyholderamount', label: 'report.account.position.buyholderamount', width: 140 },
    { field: 'buycurpositionqty', label: 'report.account.position.buycurpositionqty', width: 140 },
    { field: 'buycurholderamount', label: 'report.account.position.buycurholderamount', width: 140 },
    { field: 'sellpositionqty', label: 'report.account.position.sellpositionqty' },
    { field: 'sellholderamount', label: 'report.account.position.sellholderamount', width: 140 },
    { field: 'sellcurpositionqty', label: 'report.account.position.sellcurpositionqty', width: 140 },
    { field: 'sellcurholderamount', label: 'report.account.position.sellcurholderamount', width: 140 },
])

defineExpose({
    query: () => run()
})
</script>