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

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

/** 批量删除 */
export const delSysDictcodeListApi = (list: string[] | number[]): Promise<IResponse> => {
  const _list = list.map(v => {
    return {
      dicKey: v.dicKey,
      dicId: v.dicId,
    };
  });
  return request.postJson({
    url: '/param/spi/param/SysDictcode/SysDictcodeBatchDelete',
    data: {
      list: _list,
    },
  });
};

/** 删除 */
export const delSysDictcodeApi = (dicKey?: string, dicId?: string): Promise<IResponse> => {
  return request.postJson({ url: '/param/spi/param/SysDictcode/SysDictcodeDelete', data: { dicKey, dicId } });
};

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

/** 查询单条数据 */
export const querySysDictcodeApi = (dicKey?: string, dicId?: string): Promise<IResponse> => {
  return request.postJson({ url: '/param/spi/param/SysDictcode/SysDictcodeQueryOne', data: { dicKey, dicId } });
};

/** 导入 */
export const importExcelApiUrl = '/param/sui/param/SysDictcode/SysDictcodeImportExcel';

/** 导出 */
export const exportExcelApi = (params: any) => {
  return request.doExport({ url: '/param/sdi/param/SysDictcode/SysDictcodeExportXls', params });
};
/** 获取某个字典 */
export const getCsckCheckType = ({ paramName, systemCode }): Promise<IResponse> => {
  return request.postJson({
    url: '/param/spi/param/systemparam',
    data: {
      paramName: paramName,
      systemCode: systemCode,
    },
  });
};

