<template>
    <app-drawer title="比例流水" :width="960" v-model:show="show">
        <app-table :data="dataList" :columns="tableColumns" :loading="loading" border>
            <!-- 变更时间 -->
            <template #updatetime="{ value }">
                {{ formatDate(value) }}
            </template>
            <template #footer>
                <app-pagination :total="total" v-model:page-size="pageSize" v-model:page-index="pageIndex" @change="run" />
            </template>
        </app-table>
    </app-drawer>
</template>

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

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

const { loading, dataList, total, pageIndex, pageSize, run } = useRequest(queryTHJInvesotrDepositLog, {
    params: {
        pagesize: 10,
        userid: props.selectedRow.userid,
        depositrate: props.selectedRow.depositrate,
    },
    onError: (err) => {
        ElMessage.error(err)
    }
})

const show = shallowRef(true)

const tableColumns = shallowRef<Model.TableColumn[]>([
    { prop: 'updatetime', label: '变更时间', width: 180 },
    { prop: 'oridepositqty', label: '变更前' },
    { prop: 'changeqty', label: '变更值' },
    { prop: 'curdepositqty', label: '变更后' },
    { prop: 'accountname', label: '采购人' },
    { prop: 'wrtradedetailid', label: '采购单号', width: 200 },
])
</script>