<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 { getOrgsApi, getWarehousesListApi } from "@/api/modules/global";

//用户信息存储
import { useUserStore } from "@/stores/modules/user";
const userStore = useUserStore();
//获取组织
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();
</script>

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