import {httpApi} from "../../request/httpApi";
import {useAppStore} from "~src/store";
const useAppState = useAppStore();

export default {
    //列表数据 tree
    async deptList() {
        return httpApi({
            url: '/api/blade-system/dept/tree',
            method: 'get',
            params: {
                tenantId: useAppState.tenantId,
            }
        }, false);
    },

    //列表数据(用户部门)
    async treeUserdept() {
        return httpApi({
            url: '/api/blade-system/dept/tree-userdept-info',
            method: 'get',
            params: {
                tenantId: useAppState.tenantId,
            }
        }, false);
    },

    //列表数据(用户部门通过 depttype)
    async treeUserdeptByDeptType() {
        return httpApi({
            url: '/api/blade-system/dept/tree-userdept-info',
            method: 'get',
            params: {
                tenantId: useAppState.tenantId,
                deptType: 2
            }
        }, false);
    },

    //删除
    async remove(ids) {
        return httpApi({
            url: '/api/blade-system/dept/remove',
            method: 'post',
            params: {
                ids,
            }
        }, false);
    },
    //提交
    async submit(form) {
        return httpApi({
            url: '/api/blade-system/dept/submit',
            method: 'post',
            data: form
        }, false);
    },
    //获取相关数据
    async getList(form) {
        return httpApi({
            url: '/api/blade-system/dept/list',
            method: 'get',
            params: form
        }, false);
    },
    //获取相关数据
    async getMenuKeys(id) {
        return httpApi({
            url: '/api/blade-system/menu/role-tree-keys',
            method: 'get',
            params: {
                roleIds: id
            }
        }, false);
    },
    //获取相关数据
    async setMenuGrant(id, ids = []) {
        return httpApi({
            url: '/api/blade-system/role/grant',
            method: 'post',
            data: {
                roleIds: [id],
                menuHacIds: ids
            }
        }, false);
    },
}
