import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ToolingTypeRelationVO, ToolingTypeRelationForm, ToolingTypeRelationQuery } from '@/api/mes/toolingTypeRelation/types';

/**
 * 查询载具工装类型关联信息列表
 * @param query
 * @returns {*}
 */

export const listToolingTypeRelation = (query?: ToolingTypeRelationQuery): AxiosPromise<ToolingTypeRelationVO[]> => {
  return request({
    url: '/mes/toolingTypeRelation/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询载具工装类型关联信息详细
 * @param relationId
 */
export const getToolingTypeRelation = (relationId: string | number): AxiosPromise<ToolingTypeRelationVO> => {
  return request({
    url: '/mes/toolingTypeRelation/' + relationId,
    method: 'get'
  });
};

/**
 * 新增载具工装类型关联信息
 * @param data
 */
export const addToolingTypeRelation = (data: ToolingTypeRelationForm) => {
  return request({
    url: '/mes/toolingTypeRelation',
    method: 'post',
    data: data
  });
};

/**
 * 修改载具工装类型关联信息
 * @param data
 */
export const updateToolingTypeRelation = (data: ToolingTypeRelationForm) => {
  return request({
    url: '/mes/toolingTypeRelation',
    method: 'put',
    data: data
  });
};

/**
 * 删除载具工装类型关联信息
 * @param relationId
 */
export const delToolingTypeRelation = (relationId: string | number | Array<string | number>) => {
  return request({
    url: '/mes/toolingTypeRelation/' + relationId,
    method: 'delete'
  });
};


/**
 * 下拉框查询载具工装类型关联信息列表
 * @param query
 * @returns {*}
 */
export function getBaseToolingTypeRelationList (query) {
    return request({
        url: '/mes/toolingTypeRelation/getBaseToolingTypeRelationList',
        method: 'get',
        params: query
    });
};
