import request from '@/config/axios';
import type { TableData } from './types';

/** 获取表格数据 */
export const getSysMenuListApi = (data: any) => {
  return request.postJson({ url: '/system/spi/system/SysMenu/SysMenuQueryPage', data });
};

/** 批量删除 */
export const delSysMenuListApi = (list: string[] | number[]): Promise<IResponse> => {
  const _list = list.map(v => {
    return {
      id: v,
    };
  });
  return request.postJson({
    url: '/system/spi/system/SysMenu/SysMenuBatchDelete',
    data: {
      list: _list,
    },
  });
};

/** 删除 */
export const delSysMenuApi = (id: string | number): Promise<IResponse> => {
  return request.postJson({ url: '/system/spi/system/SysMenu/SysMenuDelete', data: { id } });
};

/** 保存 */
export const saveSysMenuApi = (data: Partial<TableData>): Promise<IResponse> => {
  return request.postJson({ url: '/system/spi/system/SysMenu/SysMenuSave', data });
};

/** 查询单条数据 */
export const querySysMenuApi = (id: string | number): Promise<IResponse> => {
  return request.postJson({ url: '/system/spi/system/SysMenu/SysMenuQueryOne', data: { id } });
};

/** 导入 */
export const importExcelApiUrl = '/system/sui/system/SysMenu/SysMenuImportExcel';

/** 导出 */
export const exportExcelApi = (params: any) => {
  return request.doExport({ url: '/system/sdi/system/SysMenu/SysMenuExportXls', params });
};
