<template>
    <app-view class="order-detail g-form">
        <template #header>
            <app-navbar title="采购详情" />
        </template>
        <div v-if="detail" class="order-detail__container g-form__container">
            <CellGroup title="成交信息">
                <Cell title="商品" :value="detail.wrstandardname" />
                <Cell title="仓库" :value="detail.warehousename" />
                <Cell title="类型" :value="detail.wrtradetype === 1 ? '挂牌' : '摘牌'" />
                <Cell title="方向" :value="detail.buyorsell === 0 ? '买入' : '卖出'" />
                <Cell title="成交价格" :value="detail.tradeprice.toFixed(2)" />
                <Cell title="成交数量" :value="detail.tradeqty" />
                <Cell title="成交金额" :value="(detail.tradeprice * detail.tradeqty).toFixed(2)" />
                <Cell title="成交时间" :value="formatDate(detail.tradetime, 'YYYY/MM/DD HH:mm:ss')" />
                <Cell title="对手方" :value="detail.matchusername" />
                <Cell title="成交单号：" :value="detail.wrtradedetailid" />
            </CellGroup>
        </div>
        <div v-else>
            <Empty />
        </div>
    </app-view>
</template>

<script lang="ts" setup>

import { shallowRef } from 'vue'
import { useNavigation } from '@/hooks/navigation'
import { CellGroup, Cell, Empty } from 'vant'
import { formatDate } from "@/filters";

const { route } = useNavigation()
const item = route.params.item
const detail = shallowRef<Model.WrTradeDetailRsp>()


if (item) {
    detail.value = JSON.parse(item.toString())
}

</script>