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

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

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

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

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

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

/** 导入 */
export const importExcelApiUrl = '/irisquery/sui/irisquery/TKdData/TKdDataImpFileLoop';

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