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

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

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

/** 删除 */
export const delSysOrganTreeApi = (treeId: string | number): Promise<IResponse> => {
  return request.postJson({ url: '/param/spi/param/SysOrganTree/SysOrganTreeDelete', data: { treeId } });
};

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

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

/** 导入 */
export const importExcelApiUrl = '/param/sui/param/SysOrganTree/SysOrganTreeImportExcel';

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