import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BaseProcessInfoVO, BaseProcessInfoForm, BaseProcessInfoQuery } from '@/api/mes/baseProcessInfo/types';

/**
 * 查询工序信息列表
 * @param query
 * @returns {*}
 */

export const listBaseProcessInfo = (query?: BaseProcessInfoQuery): AxiosPromise<BaseProcessInfoVO[]> => {
  return request({
    url: '/mes/baseProcessInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询工序信息详细
 * @param processId
 */
export const getBaseProcessInfo = (processId: string | number): AxiosPromise<BaseProcessInfoVO> => {
  return request({
    url: '/mes/baseProcessInfo/' + processId,
    method: 'get'
  });
};

/**
 * 新增工序信息
 * @param data
 */
export const addBaseProcessInfo = (data: BaseProcessInfoForm) => {
  return request({
    url: '/mes/baseProcessInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改工序信息
 * @param data
 */
export const updateBaseProcessInfo = (data: BaseProcessInfoForm) => {
  return request({
    url: '/mes/baseProcessInfo/edit',
    method: 'put',
    data: data
  });
};

/**
 * 修改工序信息关联用户
 * @param data
 */
export const updateBaseProcessInfoUser = (data: BaseProcessInfoForm) => {
  return request({
    url: '/mes/baseProcessInfo/editUser',
    method: 'put',
    data: data
  });
};

/**
 * 删除工序信息
 * @param processId
 */
export const delBaseProcessInfo = (processId: string | number | Array<string | number>) => {
  return request({
    url: '/mes/baseProcessInfo/' + processId,
    method: 'delete'
  });
};

/**
 * 查询工序信息下拉框列表
 * @param query
 * @returns {*}
 */
export function getProcessInfoList(query) {
  return request({
    url: '/mes/baseProcessInfo/getProcessInfoList',
    method: 'get',
    params: query
  });
};
