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

/** 获取表格数据 */
export const getTCdTableDataListApi = (data: any) => {
  return request.postJson({ url: '/irisquery/spi/irisquery/TCdTableData/TCdTableDataQueryPage', data });
};

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

/** 删除 */
export const delTCdTableDataApi = (id: string | number): Promise<IResponse> => {
  return request.postJson({ url: '/irisquery/spi/irisquery/TCdTableData/TCdTableDataDelete', data: { id } });
};

/** 保存 */
export const saveTCdTableDataApi = (data: Partial<TableData>): Promise<IResponse> => {
  return request.postJson({ url: '/irisquery/spi/irisquery/TCdTableData/TCdTableDataSave', data });
};

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

/** 导入 */
export const importExcelApiUrl = '/irisquery/sui/irisquery/TCdTableData/TCdTableDataImpFileLoop';

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