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

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

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

/** 删除 */
export const delSysOrganApi = (id: string | number): Promise<IResponse> => {
  return request.postJson({ url: '/param/spi/param/SysOrgan/SysOrganDelete', data: { id } });
};

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

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

/** 导入 */
export const importExcelApiUrl = '/param/sui/param/SysOrgan/SysOrganImportExcel';

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

/** 机构类型 */
export const getSysOrgType = (): Promise<IResponse> => {
  return request.postJson({
    url: '/param/spi/param/systemparam',
    data: {
      paramName: 'OrganTypeParam_param',
      systemCode: 'system',
    },
  });
};
