/*
 * @Author: cclu
 * @Date: 2021-12-13 11:01:23
 * @LastEditors: cclu
 * @LastEditTime: 2022-02-10 19:57:28
 * @FilePath: \cloud-platform\src\pages\Setting\Module\service.ts
 * @Description: 
 * 
 * Copyright (c) 2022 by cclu/杭州驿商科技, All Rights Reserved. 
 */
import request from '@/utils/request';
import { tableList, wrapTreeNode } from '@/utils/format';
import type { ModuleItem } from './data';

// 获取模块列表数据
// export async function getMenuModuleList(params?: any) {
//     const data = await request('/Platform/GetSystemModuleList', {
//         method: 'POST',
//         data: {SearchParameter : {...params},pageindex: params.current,pagesize:params.pageSize},
//     })


//     if (data.Result_Code !== 100) {
//         return {
//             data: [],
//             current: 1,
//             pageSize: 10,
//             total: 0,
//             success: false
//         }
//     }
//     //   const treeTable = wrapTreeNode(data.Result_Data.List);

//     //   return tableList({ ...data.Result_Data, List: treeTable });

//     return tableList(data.Result_Data)
// }
// 更新模块
export async function updataModule(params?: ModuleItem) {
    return request('/platform/synchroSystemModule', {
        method: 'POST',
        data: {
            ...params,
        },
        requestType: 'form'
    });
}

/* 模块列表end */


// 获取模块类别列表数据
export async function getSystemMenu(params?: any) {
    const data = await request('/FrameWork/GetSystemMenuLsit', {
        method: 'GET',
        params,
    })

    if (data.Result_Code !== 100) {
        return []
    }
    const treeTable = wrapTreeNode(data.Result_Data.List);
    return treeTable;

}

/**
 * @description: 更新菜单
 * @param {any} params
 * @return {*} 更新通知
 */
export async function updataSystemMenu(params?: any) {

    return request('/platform/synchroSystemMenu', {
        method: 'POST',
        data: {
            ...params,
        },
        requestType: 'form',
    });
}
/* 删除菜单 */
export async function deleteSystemMenu(SystemMenuId: number) {

    return request('/platform/DeleteSystemMenu', {
        method: 'GET',
        params: {
            SystemMenuId,
        }
    });
}



