import {Result} from "../types/result";
import {User} from "../types/user";

let user: User = {
    'userId': '1992',
    'username': 'admin',
}

const menus = [
    {
        id: "/home/index",
        icon: "layui-icon-home",
        title: "首页",
    },
    {
        id: "/day_evaluation",
        icon: "layui-icon-home",
        title: "日常考评",
        children: [
            {
                id: "/day_evaluation/index",
                icon: "layui-icon-util",
                title: "加减分管理"
            },
            {
                id: "/day_evaluation/examine",
                icon: "layui-icon-util",
                title: "加减分审核"
            }
        ]
    },
    {
        id: "/month_evaluation",
        icon: "layui-icon-home",
        title: "月度考评",
        children: [
            {
                id: "/month_evaluation/index",
                icon: "layui-icon-util",
                title: "月度考评填报"
            },
            {
                id: "/month_evaluation/examine",
                icon: "layui-icon-util",
                title: "月度考评管理"
            }
        ]
    }, {
        id: "/season_evaluation",
        icon: "layui-icon-home",
        title: "季度考评",
        children: [
            {
                id: "/season_evaluation/index",
                icon: "layui-icon-util",
                title: "季度考评"
            },
            {
                id: "/season_evaluation/examine",
                icon: "layui-icon-util",
                title: "季度考评管理"
            }
        ]
    }, {
        id: "/outside_evaluation",
        icon: "layui-icon-home",
        title: "院外考评",
        children: [
            {
                id: "/outside_evaluation/index",
                icon: "layui-icon-util",
                title: "我的院外考评"
            },
            {
                id: "/outside_evaluation/examine",
                icon: "layui-icon-util",
                title: "院外考评管理"
            }
        ]
    }, {
        id: "/year_evaluation",
        icon: "layui-icon-home",
        title: "年度考评",
        children: [
            {
                id: "/year_evaluation/index",
                icon: "layui-icon-util",
                title: "年度考评"
            },
            {
                id: "/year_evaluation/examine",
                icon: "layui-icon-util",
                title: "年度考评管理"
            }
        ]
    }, {
        id: "/file_bag",
        icon: "layui-icon-home",
        title: "医德医风档案",
        children: [
            {
                id: "/file_bag/index",
                icon: "layui-icon-util",
                title: "我的档案"
            },
            {
                id: "/file_bag/examine",
                icon: "layui-icon-util",
                title: "员工档案"
            }
        ]
    }, {
        id: "/census",
        icon: "layui-icon-home",
        title: "统计报表分析",
        children: [
            {
                id: "/census/index",
                icon: "layui-icon-util",
                title: "拒收红包报表统计"
            },
            {
                id: "/census/day",
                icon: "layui-icon-util",
                title: "日常考评报表统计"
            },
            {
                id: "/census/month",
                icon: "layui-icon-util",
                title: "月度考评报表统计"
            },
            {
                id: "/census/season",
                icon: "layui-icon-util",
                title: "季度考评报表统计"
            },
            {
                id: "/census/year",
                icon: "layui-icon-util",
                title: "年度考评报表统计"
            }
        ]
    }, {
        id: "/configuration",
        icon: "layui-icon-home",
        title: "规则配置中心",
        children: [
            {
                id: "/configuration/index",
                icon: "layui-icon-util",
                title: "登陆日志管理"
            },
            {
                id: "/configuration/foundation",
                icon: "layui-icon-util",
                title: "基础评分项管理"
            },
            {
                id: "/configuration/add",
                icon: "layui-icon-util",
                title: "加减分项管理"
            },
            {
                id: "/configuration/time",
                icon: "layui-icon-util",
                title: "考评时间管理"
            },
            {
                id: "/configuration/level",
                icon: "layui-icon-util",
                title: "考评级别管理"
            },
            {
                id: "/configuration/opinion",
                icon: "layui-icon-util",
                title: "医德征求意见管理"
            },
            {
                id: "/configuration/year",
                icon: "layui-icon-util",
                title: "字典管理"
            }
        ]
    }, {
        id: "/complaint/index",
        icon: "layui-icon-home",
        title: "投诉管理",
    }, {
        id: "/packet/index",
        icon: "layui-icon-home",
        title: "拒收红包",
    }, {
        id: "/system",
        icon: "layui-icon-home",
        title: "系统管理",
        children: [
            {
                id: "/system/index",
                icon: "layui-icon-util",
                title: "人员管理"
            },
            {
                id: "/system/department",
                icon: "layui-icon-util",
                title: "部门管理"
            },
            {
                id: "/system/party",
                icon: "layui-icon-util",
                title: "党支部管理"
            },
            {
                id: "/system/permission",
                icon: "layui-icon-util",
                title: "权限管理"
            },
            {
                id: "/system/menu",
                icon: "layui-icon-util",
                title: "菜单管理"
            }
        ]
    },
]

const getInfo = (req: any, res: any) => {
    let item = JSON.parse(req.body);
    let token = item ? item.token : null;
    let result: Result = {
        code: 200,
        msg: "操作成功",
        data: user,
        success: true
    }
    if (item || token) {
        result.code = 99998;
        result.msg = "请重新登录";
        result.success = false;
    }
    return result;
}

const getPermission = (req: any, res: any) => {
    let item = JSON.parse(req.body);
    let token = item ? item.token : null;
    let result: Result = {
        code: 200,
        msg: "操作成功",
        data: ['sys:user:add', 'sys:user:edit', 'sys:user:delete', 'sys:user:import', 'sys:user:export'],
        success: true
    }
    if (item || token) {
        result.code = 99998;
        result.msg = "请重新登录";
        result.success = false;
    }
    return result;
}

const getMenu = (req: any, res: any) => {
    let item = JSON.parse(req.body);
    let token = item ? item.token : null;
    let result: Result = {
        code: 200,
        msg: "操作成功",
        data: menus,
        success: true
    }
    if (item || token) {
        result.code = 99998;
        result.msg = "请重新登录";
        result.success = false;
    }
    return result;
}

const getLogin = (req: any, res: any) => {
    let item = JSON.parse(req.body);
    let account = item.account;
    let password = item.password;
    if (account === 'admin' && password === '123456') {
        return {
            'code': 200,
            'msg': '登陆成功',
            'data': {
                'userId': '35002',
                'token': 'eyJhbGciOiJIUzUxMiJ9.eyJ1c2VySWQiOiJhZG1pbiIsInVzZXJOYW1lIjoiYWRtaW4iLCJvcmdDb2RlIjoiMzUwMDAiLCJkZXB0Q29kZSI6IjM1MDAwIiwiYXVkIjoiYWRtaW4iLCJpc3MiOiJhZG1pbiIsImV4cCI6MTU5MzUzNTU5OH0.0pJAojRtT5lx6PS2gH_Q9BmBxeNlgBL37ABX22HyDlebbr66cCjVYZ0v0zbLO_9241FX9-FZpCkEqE98MQOyWw',
            }
        }
    } else {
        return {
            'code': 500,
            'msg': '登陆失败,账号密码不正确'
        }
    }
}

const getUpload = (req: any, res: any) => {
    return {
        'code': 200,
        'msg': '上传成功',
        'success': true
    }
}

export default {
    getInfo, getMenu, getLogin, getPermission, getUpload,menus
}
