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

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

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

/** 删除 */
export const delDataurgeQueryApi = (pkid?: string): Promise<IResponse> => {
  return request.postJson({ url: '/DataurgeQuery/spi/DataurgeQuery/DataurgeQuery/DataurgeQueryDelete', data: { pkid } });
};

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

/** 查询单条数据 */
export const queryDataurgeQueryApi = (pkid?: string): Promise<IResponse> => {
  return request.postJson({ url: '/DataurgeQuery/spi/DataurgeQuery/DataurgeQuery/DataurgeQueryQueryOne', data: { pkid } });
};

/** 同步导入 */
export const importExcelApiUrl = '/DataurgeQuery/sui/DataurgeQuery/DataurgeQuery/DataurgeQueryImportExcel';

/** 异步导入 */
export const importExcelAsyncApiUrl = '/DataurgeQuery/sui/DataurgeQuery/DataurgeQuery/DataurgeQueryImportAsyncExcel';

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

/** 获取某个字典 */
export const getCsckCheckType = ({ paramName, systemCode }): Promise<IResponse> => {
  return request.postJson({
    url: '/param/spi/param/systemparam',
    data: {
      paramName: paramName,
      systemCode: systemCode,
    },
  });
};

