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

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

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

/** 删除 */
export const delTableApi = (dscode: string): Promise<IResponse> => {
  return request.postJson({
    url: '/system/spi/system/RepDataSource/RepDataSourceDelete',
    data: { dscode },
  });
};

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

/** 查询单条数据 */
export const queryTableApi = (dscode: string): Promise<IResponse> => {
  return request.postJson({ url: '/system/spi/system/SysRoleQueryOne', data: { dscode } });
};

/** 导入 */
export const importExcelApiUrl = '/system/sui/system/RepDataSource/RepDataSourceImpFileLoop';

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