<template>
    <div class="box card">
        <img class="box-bg" src="@/assets/images/welcome.png" alt="welcome" />
    </div>
</template>

<script setup lang="ts" name="home">
//登录请求接口
import { getWarehousesListApi } from "@/api/modules/global";
import { useRoute, useRouter } from "vue-router";
//用户信息存储
import { useUserStore } from "@/stores/modules/user";
const userStore = useUserStore();
//路由;
const $route = useRoute();
const $router = useRouter();
// //获取组织
// const getOrgs = async () => {
//     const result = await getOrgsApi();
//     if (result?.code === 0) {
//         const { data } = result;
//         if (data?.length) {
//             let options: any = [];
//             data.forEach((item: any) => {
//                 options.push({
//                     id: item.id,
//                     value: item.org_number,
//                     label: item.org_name
//                 });
//             });
//             userStore.setOrgIdArr(options);
//         }
//     }
// };
// getOrgs();
const getWarehousesList = async () => {
    const result = await getWarehousesListApi();
    if (result?.code === 0) {
        const { data } = result;
        if (data?.length) {
            let options: any = [];
            data.forEach((item: any) => {
                options.push({
                    id: item.id,
                    value: item.warehouse_number,
                    label: item.warehouse_name
                });
            });
            userStore.setWarehouse(options);
        }
    }
};
getWarehousesList();

const init = () => {
    let redirect_path: any = $route.query.redirect_path;
    if (redirect_path) {
        setTimeout(() => {
            $router.push({ path: redirect_path });
        }, 500);
    }
};
init();
</script>

<style scoped lang="scss">
@use "./index.scss";
</style>
