<template>
    <el-drawer v-model="open" :title="`出入库清单`" :before-close="handleClose" direction="rtl"
        modal-class="el-subscribe-drawer" size="80%">
        <div v-loading="loading">
            <Index :form="form" :editable="false" />
        </div>
    </el-drawer>
</template>

<script setup>
import { getWarehouseAccess } from "@/api/warehouseAccess/warehouseAccess";
import Index from "@/components/WarehouseAccess/detail/index";


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

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

const { warehouseAccessId } = 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 (warehouseAccessId.value) {
        getWarehouseAccess(warehouseAccessId.value).then(response => {
            form.value = response.data;
            loading.value = false;
        });
    }
}


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