<!-- 查询管理-内部订单查询-线下交收单查询-详情 -->
<template>
    <app-drawer title="详细" width="960" v-model:show="show">
        <app-table-details :data="data" :label-width="160" :cell-props="detailProps1" :column="2" />
        <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 { formatDate } from '@/filters'
import { getBuyOrSellName } from '@/constants/order'
import { useRequest } from '@/hooks/request'
import { queryOfflineDetail } from '@/services/api/order'
import { CellProp } from '@pc/components/base/table-details/types'
import AppDrawer from '@pc/components/base/drawer/index.vue'
import AppTableDetails from '@pc/components/base/table-details/index.vue'
import { i18n } from '@/stores'

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

const { t } = i18n.global
const show = shallowRef(true)

const { data } = useRequest(queryOfflineDetail, {
    params: {
        deliveryorderid: props.record.deliveryorderid
    },
    onError: (err) => {
        ElMessage.error(err)
    }
})

const detailProps1: CellProp[] = [
    { prop: 'deliveryorderid', label: '交收单号：' },
    { prop: 'username', label: '申请人：' },
    { prop: 'goodsdisplay', label: '交收商品：' },
    { prop: 'buyorsell', label: '方向：', formatValue: (val) => getBuyOrSellName(val) },
    { prop: 'deliveryqty', label: '申请交收数量：' },
    { prop: 'sucdeliveryqty', label: '实际交收数量：' },
    { prop: 'cancledeliveryqty', label: '撤销交收数量：' },
    { prop: 'deliveryprice', label: '交收价格：' },
    { prop: 'deliveryamount', label: '交收货款：' },
    { prop: 'matchname', label: '对手方：' },
    { prop: 'deliveryinfo', label: '交收信息：' },
    { prop: 'reqtime', label: '申请时间：', formatValue: (val) => formatDate(val) },
    { prop: 'orderstatusdisplay', label: '交收状态：' },
    { prop: 'remark', label: '备注：' },
    { prop: 'deliverycharge', label: '交收手续费：' },
    { prop: 'closetime', label: '完成时间：', formatValue: (val) => formatDate(val) },
]

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