<!-- 市场运行管理-监控管理-做市会员风险监控-持仓汇总-持仓单查询 -->
<template>
    <app-drawer title="持仓单查询" width="1200" v-model:show="show">
        <app-table :data="dataList" :columns="tableColumns">
            <template #headerLeft>
                <span>资金账户：{{ record.accountid }}</span>
            </template>
        </app-table>
        <template #footer>
            <el-button @click="onCancel">{{ t('operation.close') }}</el-button>
        </template>
    </app-drawer>
</template>

<script lang="ts" setup>
import { shallowRef, PropType } from 'vue'
import { ElMessage } from 'element-plus'
import { useRequest } from '@/hooks/request'
import { queryHolderDetailMonitor } from '@/services/api/market'
import AppDrawer from '@pc/components/base/drawer/index.vue'
import AppTable from '@pc/components/base/table/index.vue'
import { i18n } from '@/stores'

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

const { global: { t } } = i18n

const show = shallowRef(true)

const { dataList } = useRequest(queryHolderDetailMonitor, {
    params: {
        accountid: props.record.accountid,
        goodsid: props.record.goodsid
    },
    onError: (err) => {
        ElMessage.error(err)
    }
})

const tableColumns = shallowRef<Model.TableColumn[]>([
    { field: 'tradeid', label: '成交单号' },
    { field: 'tradedate', label: '交易日' },
    { field: 'accountNameId', label: '账户' },
    { field: 'marketname', label: '市场' },
    { field: 'goodsCodeName', label: '商品' },
    { field: 'buyorsell', label: '方向' },
    { field: 'holderqty', label: '持仓数量' },
    { field: 'holderprice', label: '持仓价格' },
    { field: 'holderamount', label: '持仓金额' },
    { field: 'tradetime', label: '交易时间' },
])

const onCancel = () => {
    show.value = false
}
</script>