<!-- 市场运行管理-监控管理-做市会员风险监控-持仓汇总-持仓单查询 -->
<template>
    <app-drawer :title="t('marketrun.monitor.marketer.positionsumm.details.title')" width="1200" v-model:show="show">
        <app-table :data="dataList" :columns="tableColumns">
            <template #headerLeft>
                <span>{{ t('marketrun.monitor.marketer.positionsumm.details.accountid1') }}{{ 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: 'marketrun.monitor.marketer.positionsumm.details.tradeid' },
    { field: 'tradedate', label: 'marketrun.monitor.marketer.positionsumm.details.tradedate' },
    { field: 'accountNameId', label: 'marketrun.monitor.marketer.positionsumm.details.accountNameId' },
    { field: 'marketname', label: 'marketrun.monitor.marketer.positionsumm.details.marketname' },
    { field: 'goodsCodeName', label: 'marketrun.monitor.marketer.positionsumm.details.goodsCodeName' },
    { field: 'buyorsell', label: 'marketrun.monitor.marketer.positionsumm.details.buyorsell' },
    { field: 'holderqty', label: 'marketrun.monitor.marketer.positionsumm.details.holderqty' },
    { field: 'holderprice', label: 'marketrun.monitor.marketer.positionsumm.details.holderprice' },
    { field: 'holderamount', label: 'marketrun.monitor.marketer.positionsumm.details.holderamount' },
    { field: 'tradetime', label: 'marketrun.monitor.marketer.positionsumm.details.tradetime' },
])

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