/*
 ** 轻量化报表平台接口
 ** create by ChenLong on 2022/6/24
 ** 功能路径：src\api\service\report.js
 ** 菜单参数列表：*变量名*(变量说明，数据类型，是否必填，取值范围)
 **/
import { request } from '@wisdom-utils/utils';
import * as constants from '../constants';

const BASEURL = '/PandaAssets/CityWater/ReportManager';
export const API = {
  GET_REPORT_INFO: `${BASEURL}/GetReportInfo`, // 获取报表信息
  GET_REPORT_FILTER_VALUE: `${BASEURL}/GetReportFilterValue`, // 获取过滤字段的值的枚举
  GET_REPORT_FILTER_VALUES: `${BASEURL}/GetReportFilterValues`, // 获取过滤字段的值的枚举
  GET_REPORT_CONFIG_LIST: `${BASEURL}/GetReportConfigList`, // 获取配置列表
  GET_REPORT_DETAILS_INFO: `${BASEURL}/GetReportDetailsInfo`, // 获取配置详情
  GET_TABLES: `${BASEURL}/GetTables`, // 查询表
  GET_TABLE_FIELDS: `${BASEURL}/GetTableFields`, // 查询表内的字段
  ADD_REPORT_INFO: `${BASEURL}/AddReportInfo`, // 创建报表主表、关联报表子表
  EDIT_REPORT_INFO: `${BASEURL}/AddReportInfo`,
  ADD_REPORT_DETAIL_INFO: `${BASEURL}/AddReportDetailInfo`, // 附加子表字段到主表
  DELETE_REPORT_INFO: `${BASEURL}/DeleteReportInfo`, // 删除报表
  DELETE_REPORT_DETAIL_INFO: `${BASEURL}/DeleteReportDetailInfo`, // 删除字段
  EXPORT_ACCOUNT_DATA: `${BASEURL}/ExportAccountData`, // 导出数据
  SAVE_REPORT_LIST_SORT_FIELDS: `${BASEURL}/SaveReportListSortFields`, // 保存排序
  ADD_REPORT_DETAIL_INFO_INDEX: `${BASEURL}/AddReportDetailInfoIndex`, // 变更接口顺序
  UPDATE_REPORT_DATA: `${BASEURL}/UpdateReportData`, // 更新报表数据
  GET_REPORT_DETAILS: `${BASEURL}/GetReportDetails`, // 获取报表配置
  DEL_REPORT_DATA: `${BASEURL}/DelReportData`, // 删除报表数据
  SET_REPORT_ALLOW: `${BASEURL}/SetReportAllow`, // 设置关注
  ADD_REPORT_DATA: `${BASEURL}/AddReportData`, // 添加报表数据
  EXPORT_JPG: `${BASEURL}/ExportJPGAccountData`,
  EXPORT_REPORT_CONFIG: `${BASEURL}/ExportReportConfig`,
  IMPORT_REPORT_CONFIG: `${BASEURL}/ImportReportConfig`,
  // 多数据源
  GET_DATA_SOURCES: `${BASEURL}/GetDataSources`, // 获取数据源列表
  ADD_DB_CONNECTION: `${BASEURL}/AddDbConnection`, // 新增/编辑数据源
  DELETE_DB_CONNECTION: `${BASEURL}/DeleteDbConnection`, // 删除数据源
  GET_DB_SOURCES: `${BASEURL}/GetDBSources`, // 获取数据库
  TEST_CONNECTION: `${BASEURL}/TestConnection`, // 测试链接
  DEL_REPORT_CHILD: `${BASEURL}/DelReportChlid`, // 删除挂接关系
};
const reportService = {
  getReportInfo: {
    url: API.GET_REPORT_INFO,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  getReportFilterValue: {
    url: API.GET_REPORT_FILTER_VALUE,
    method: constants.REQUEST_METHOD_GET,
    type: constants.REQUEST_METHOD_GET,
  },
  getReportFilterValues: {
    url: API.GET_REPORT_FILTER_VALUES,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  getReportConfigList: {
    url: API.GET_REPORT_CONFIG_LIST,
    method: constants.REQUEST_METHOD_GET,
    type: constants.REQUEST_METHOD_GET,
  },
  getReportDetailsInfo: {
    url: API.GET_REPORT_DETAILS_INFO,
    method: constants.REQUEST_METHOD_GET,
    type: constants.REQUEST_METHOD_GET,
  },
  getTables: {
    url: API.GET_TABLES,
    method: constants.REQUEST_METHOD_GET,
    type: constants.REQUEST_METHOD_GET,
  },
  getTableFields: {
    url: API.GET_TABLE_FIELDS,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  addReportInfo: {
    url: API.ADD_REPORT_INFO,
    method: constants.REQUEST_METHOD_POST,
    type: constants._METHOD_POST,
  },
  editReportInfo: {
    url: API.EDIT_REPORT_INFO,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  addReportDetailInfo: {
    url: API.ADD_REPORT_DETAIL_INFO,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  deleteReportInfo: {
    url: API.DELETE_REPORT_INFO,
    method: constants.REQUEST_METHOD_GET,
    type: constants.REQUEST_METHOD_GET,
  },
  deleteReportDetailInfo: {
    url: API.DELETE_REPORT_DETAIL_INFO,
    method: constants.REQUEST_METHOD_GET,
    type: constants.REQUEST_METHOD_GET,
  },
  saveReportListSortFields: {
    url: API.SAVE_REPORT_LIST_SORT_FIELDS,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  addReportDetailInfoIndex: {
    url: API.ADD_REPORT_DETAIL_INFO_INDEX,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  updateReportData: {
    url: API.UPDATE_REPORT_DATA,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  getReportDetails: {
    url: API.GET_REPORT_DETAILS,
    method: constants.REQUEST_METHOD_GET,
    type: constants.REQUEST_METHOD_GET,
  },
  delReportData: {
    url: API.DEL_REPORT_DATA,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  setReportAllow: {
    url: API.SET_REPORT_ALLOW,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  addReportData: {
    url: API.ADD_REPORT_DATA,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  exportJPG: {
    url: API.EXPORT_JPG,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  exportConfig: {
    url: API.EXPORT_REPORT_CONFIG,
    method: constants.REQUEST_METHOD_GET,
    type: constants.REQUEST_METHOD_GET,
  },
  importConfig: {
    url: API.IMPORT_REPORT_CONFIG,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  getDataSources: {
    url: API.GET_DATA_SOURCES,
    method: constants.REQUEST_METHOD_GET,
    type: constants.REQUEST_METHOD_GET,
  },
  addDbConnection: {
    url: API.ADD_DB_CONNECTION,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  deleteDbConnection: {
    url: API.DELETE_DB_CONNECTION,
    method: constants.REQUEST_METHOD_GET,
    type: constants.REQUEST_METHOD_GET,
  },
  getDbSources: {
    url: API.GET_DB_SOURCES,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  testConnection: {
    url: API.TEST_CONNECTION,
    method: constants.REQUEST_METHOD_POST,
    type: constants.REQUEST_METHOD_POST,
  },
  delReportChild: {
    url: API.DEL_REPORT_CHILD,
    method: constants.REQUEST_METHOD_GET,
    type: constants.REQUEST_METHOD_GET,
  },
};
export const submitReportData = (params, data) =>
  request({
    url: API.UPDATE_REPORT_DATA,
    method: 'post',
    params,
    data,
  });
export const exportAccountData = (options, params, data) =>
  request({
    url: API.EXPORT_ACCOUNT_DATA,
    method: 'post',
    ...options,
    params,
    data,
  });
export const exportJPG = (options, data) => {
  return request({
    url: API.EXPORT_JPG,
    method: 'post',
    ...options,
    data,
  });
};
export const addReportDetailInfoIndex = (data) =>
  request({
    url: API.ADD_REPORT_DETAIL_INFO_INDEX,
    method: 'post',
    data,
  });
export const importReportConfig = (options, params, data) =>
  request({
    url: API.IMPORT_REPORT_CONFIG,
    method: 'post',
    ...options,
    params,
    data,
  });
export const exportReportConfig = (options, params) =>
  request({
    url: API.EXPORT_REPORT_CONFIG,
    method: 'get',
    ...options,
    params,
  });
export default reportService;
