import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ScalePublishVO, ScalePublishForm, ScalePublishQuery } from '@/api/scale/scalePublish/types';

/**
 * 查询量发布列表
 * @param query
 * @returns {*}
 */

export const listScalePublish = (query?: ScalePublishQuery): AxiosPromise<ScalePublishVO[]> => {
  return request({
    url: '/scale/publish/pageList',
    method: 'get',
    params: query
  });
};

export const listPublish = (query?: ScalePublishQuery): AxiosPromise<ScalePublishVO[]> => {
  return request({
    url: '/scale/publish/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询量发布详细
 * @param batchNo
 */
export const getScalePublish = (batchNo: string | number): AxiosPromise<any> => {
  return request({
    url: '/scale/publish/' + batchNo,
    method: 'get'
  });
};

export const getExportCheck = (batchNo: string | number): AxiosPromise<any> => {
  return request({
    url: '/scale/publish/export/check',
    method: 'get',
    params: { batchNo }
  });
};

/**
 * 新增量发布
 * @param data
 */
export const addScalePublish = (data: ScalePublishForm) => {
  return request({
    url: '/scale/publish',
    method: 'post',
    data: data
  });
};

/**
 * 修改量发布
 * @param data
 */
export const updateScalePublish = (data: ScalePublishForm) => {
  return request({
    url: '/scale/publish',
    method: 'put',
    data: data
  });
};

export const endScalePublish = (data: ScalePublishForm) => {
  return request({
    url: '/scale/publish/end',
    method: 'post',
    data: data
  });
};

export const startScalePublish = (data: ScalePublishForm) => {
  return request({
    url: '/scale/publish/start',
    method: 'post',
    data: data
  });
};
/**
 * 删除量发布
 * @param batchNo
 */
export const delScalePublish = (batchNo: string | number | Array<string | number>) => {
  return request({
    url: '/scale/publish/' + batchNo,
    method: 'delete'
  });
};
