<!-- 交易服务-出境检测-确认检测结果 -->
<template>
    <app-drawer title="确认检测结果" v-model:show="show" :loading="loading" :refresh="refresh">
        <el-form ref="formRef" class="el-form--horizontal" label-width="100px" :model="formData">
            <el-form-item label="单据编号">
                {{ selectedRow.orderidstr }}
            </el-form-item>
            <el-form-item class="el-form-item--row" label="备注" prop="Remark">
                <el-input type="textarea" maxlength="120" v-model="formData.Remark" />
            </el-form-item>
        </el-form>
        <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 { useCJJCMemberOperate } from '@/business/customs/exit'
import AppDrawer from '@pc/components/base/drawer/index.vue'

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

const { loading, formData, formSubmit } = useCJJCMemberOperate(props.selectedRow.orderidstr)
const show = shallowRef(true)
const refresh = shallowRef(false)

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

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