<!-- 报表查询-资金账户报表-成交汇总表 -->
<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 { tradeQuery } 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(tradeQuery, {
    manual: true,
    params: props.params,
    onError: (err) => {
        ElMessage.error(err)
    }
})

const tableColumns = shallowRef<Model.TableColumn[]>([
    { field: 'goodscode', label: 'report.account.trade.goodscode' },
    { field: 'goodsname', label: 'report.account.trade.goodsname' },
    { field: 'marketname', label: 'report.account.trade.marketname' },
    { field: 'tradeqty', label: 'report.account.trade.tradeqty' },
    { field: 'openqty', label: 'report.account.trade.openqty' },
    { field: 'closeqty', label: 'report.account.trade.closeqty' },
    { field: 'tradeamount', label: 'report.account.trade.tradeamount' },
    { field: 'closepl', label: 'report.account.trade.closepl' },
    { field: 'opencharge', label: 'report.account.trade.opencharge' },
    { field: 'closecharge', label: 'report.account.trade.closecharge' },
])

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