import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WarnRecordVO, WarnRecordForm, WarnRecordQuery } from '@/api/archive/warnRecord/types';

/**
 * 查询预警记录列表
 * @param query
 * @returns {*}
 */

export const listWarnRecord = (query?: WarnRecordQuery): AxiosPromise<WarnRecordVO[]> => {
  return request({
    url: '/scale/warn/pageList',
    method: 'get',
    params: query
  });
};

/**
 * 查询预警记录详细
 * @param warnId
 */
export const getWarnRecord = (warnId: string | number): AxiosPromise<WarnRecordVO> => {
  return request({
    url: '/scale/warn/' + warnId,
    method: 'get'
  });
};

export const getEvaluationRecordList = (warnId: string | number): AxiosPromise<WarnRecordVO> => {
  return request({
    url: '/scale/warn/evaluation/record',
    method: 'get',
    params: { warnId }
  });
};

export const listConfig = (): AxiosPromise<any> => {
  return request({
    url: '/scale/warn/config/list',
    method: 'get'
  });
};

export const editConfig = (id: string | number | Array<string | number>) => {
  return request({
    url: '/scale/warn/config/' + id,
    method: 'put'
  });
};

export const getEvaluationList = (query: any): AxiosPromise<WarnRecordVO> => {
  return request({
    url: '/scale/evaluation/conclusion/list',
    method: 'get',
    params: query
  });
};

/**
 * 新增预警记录
 * @param data
 */
export const addWarnRecord = (data: WarnRecordForm) => {
  return request({
    url: '/scale/warn',
    method: 'post',
    data: data
  });
};

/**
 * 修改预警记录
 * @param data
 */
export const updateWarnRecord = (data: WarnRecordForm) => {
  return request({
    url: '/scale/warn',
    method: 'put',
    data: data
  });
};

/**
 * 删除预警记录
 * @param warnId
 */
export const delWarnRecord = (warnId: string | number | Array<string | number>) => {
  return request({
    url: '/scale/warn/' + warnId,
    method: 'delete'
  });
};
