import {useAllUserStore} from "@/store/modules/allUser";
import {listUser} from '@/api/system/user';
import {UserQuery} from "@/api/system/user/types";
import {listDept} from "@/api/system/dept";
export const useAllUserCache = () => {

    const store = useAllUserStore()
    const queryAllUser = async (isIncludeResign, menuId: string | undefined)=>{
        const queryParams = reactive<UserQuery>({
            pageIndex: 1,
            pageSize: 10000,
            reviewTag: 1,
            scopeMenuId: menuId,
            isIncludeResign: isIncludeResign
        })
        const res = await listUser(queryParams)
        if(!menuId) {
            store.setUser(res.result.records)
        }
        return res.result
    }

    const queryAllDept = async (types, menuId)=>{
        const res = await listDept(types, menuId)
        if(!menuId) {
            store.setAllDept(res.result)
        }
        return res.result
    }
    const queryAllCompany = async (types, menuId)=>{
        const res = await listDept(types, menuId)
        store.setAllCompany(res.result)
        return res.result
    }

    return {
        queryAllUser,
        queryAllDept,
        queryAllCompany
    }
}

