import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BaseRouteVO, BaseRouteForm, BaseRouteQuery } from '@/api/mes/baseRoute/types';

/**
 * 查询工艺路线列表
 * @param query
 * @returns {*}
 */

export const listBaseRoute = (query?: BaseRouteQuery): AxiosPromise<BaseRouteVO[]> => {
  return request({
    url: '/mes/baseRoute/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询工艺路线详细
 * @param routeId
 */
export const getBaseRoute = (routeId: string | number): AxiosPromise<BaseRouteVO> => {
  return request({
    url: '/mes/baseRoute/' + routeId,
    method: 'get'
  });
};

/**
 * 新增工艺路线
 * @param data
 */
export const addBaseRoute = (data: BaseRouteForm) => {
  return request({
    url: '/mes/baseRoute',
    method: 'post',
    data: data
  });
};

/**
 * 修改工艺路线
 * @param data
 */
export const updateBaseRoute = (data: BaseRouteForm) => {
  return request({
    url: '/mes/baseRoute',
    method: 'put',
    data: data
  });
};

/**
 * 删除工艺路线
 * @param routeId
 */
export const delBaseRoute = (routeId: string | number | Array<string | number>) => {
  return request({
    url: '/mes/baseRoute/' + routeId,
    method: 'delete'
  });
};


/**
 * 下拉框查询工艺路线列表
 * @param query
 * @returns {*}
 */
export function getBaseRouteList(query) {
  return request({
    url: '/mes/baseRoute/getProdBaseRouteList',
    method: 'get',
    params: query
  });
};
