import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DmsFaultComponentsPartsVO, DmsFaultComponentsPartsForm, DmsFaultComponentsPartsQuery } from '@/api/dms/dmsFaultComponentsParts/types';

/**
 * 查询故障报修零部件更换记录列表
 * @param query
 * @returns {*}
 */

export const listDmsFaultComponentsParts = (query?: DmsFaultComponentsPartsQuery): AxiosPromise<DmsFaultComponentsPartsVO[]> => {
  return request({
    url: '/dms/dmsFaultComponentsParts/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询故障报修零部件更换记录详细
 * @param componentsPartsId
 */
export const getDmsFaultComponentsParts = (componentsPartsId: string | number): AxiosPromise<DmsFaultComponentsPartsVO> => {
  return request({
    url: '/dms/dmsFaultComponentsParts/' + componentsPartsId,
    method: 'get'
  });
};

/**
 * 新增故障报修零部件更换记录
 * @param data
 */
export const addDmsFaultComponentsParts = (data: DmsFaultComponentsPartsForm) => {
  return request({
    url: '/dms/dmsFaultComponentsParts',
    method: 'post',
    data: data
  });
};

/**
 * 修改故障报修零部件更换记录
 * @param data
 */
export const updateDmsFaultComponentsParts = (data: DmsFaultComponentsPartsForm) => {
  return request({
    url: '/dms/dmsFaultComponentsParts',
    method: 'put',
    data: data
  });
};

/**
 * 删除故障报修零部件更换记录
 * @param componentsPartsId
 */
export const delDmsFaultComponentsParts = (componentsPartsId: string | number | Array<string | number>) => {
  return request({
    url: '/dms/dmsFaultComponentsParts/' + componentsPartsId,
    method: 'delete'
  });
};


/**
 * 下拉框查询故障报修零部件更换记录列表
 * @param query
 * @returns {*}
 */
export function getDmsFaultComponentsPartsList (query) {
    return request({
        url: '/dms/dmsFaultComponentsParts/getDmsFaultComponentsPartsList',
        method: 'get',
        params: query
    });
};
