<template>
    <el-drawer v-model="open" :title="`维保申请清单`" :before-close="handleClose" direction="rtl" class="demo-drawer"
        modal-class="el-subscribe-drawer" size="80%">
        <div class="flex" v-loading="loading">
            <div class="flex-sub">
                <!-- <el-card shadow="never"> -->
                    <Index :form="form" :editable="false" />
                <!-- </el-card> -->
            </div>
            <div class="padding-left" style="width:30%;max-width:400px">
                <!-- <el-card shadow="never"> -->
                    <WfJobList :list="form.wfJobList" />
                <!-- </el-card> -->
            </div>
        </div>
    </el-drawer>
</template>

<script setup>
import { getMaintenanceApply } from "@/api/maintenanceApply/maintenanceApply";
import Index from "@/components/MaintenanceApply/detail/index";
import WfJobList from "@/components/WfJobList/index";


const { proxy, ctx } = getCurrentInstance();
const store = useStore();
const open = ref(false);
const loading = ref(true);

const props = defineProps({
    maintenanceApplyId: {
        type: [Number, String],
        default: null,
    },
});

const { maintenanceApplyId } = toRefs(props);
const data = reactive({
    form: {},
})

const { form } = toRefs(data);


// 显示弹框
function show() {
    open.value = true;
    loading.value = true;
    nextTick(() => {
        getData()
    })
}

// 关闭按钮
function handleClose() {
    form.value = {}
    open.value = false;
}



function getData() {
    if (maintenanceApplyId.value) {
        getMaintenanceApply(maintenanceApplyId.value).then(response => {
            form.value = response.data;
            loading.value = false;
        });
    }
}


defineExpose({
    show,
    handleClose,
});
</script>