<!-- 挂牌大厅-我的求购-撤销 -->
<template>
    <app-drawer title="提示" v-model:show="show" :loading="loading" :refresh="refresh">
        <div style="font-size:16px;text-align:center">是否撤销该求购？</div>
        <template #footer>
            <el-button @click="onCancel(false)" plain>取消</el-button>
            <el-button type="primary" @click="onSubmit">确认</el-button>
        </template>
    </app-drawer>
</template>

<script lang="ts" setup>
import { shallowRef, PropType } from 'vue'
import { ElMessage } from 'element-plus'
import { BuyOrSell } from '@/constants/order'
import { useListingCancel } from '@/business/trade/listing'
import AppDrawer from '@pc/components/base/drawer/index.vue'

const props = defineProps({
    selectedRow: {
        type: Object as PropType<Ermcp.MyBuyOrderRsp>,
        default: () => ({})
    }
})

const { loading, formSubmit } = useListingCancel(props.selectedRow.wrtradeorderid, BuyOrSell.Buy)
const show = shallowRef(true)
const refresh = shallowRef(false)

const onCancel = (isRefresh = false) => {
    show.value = false
    refresh.value = isRefresh
}

const onSubmit = () => {
    formSubmit().then(() => {
        ElMessage.success('提交成功')
        onCancel(true)
    }).catch((err) => {
        ElMessage.error('提交失败：' + err)
    })
}
</script>