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

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

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

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

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

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

/** 导入 */
export const importExcelApiUrl = '/irisquery/sui/irisquery/TCdLedgerData/TCdLedgerDataImpFileLoop';

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