import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RelationMaterialVO, RelationMaterialForm, RelationMaterialQuery } from '@/api/oa/base/relationMaterial/types';

/**
 * 查询关联销售物料信息列表
 * @param query
 * @returns {*}
 */

export const listRelationMaterial = (query?: RelationMaterialQuery): AxiosPromise<RelationMaterialVO[]> => {
  return request({
    url: '/oa/base/relationMaterial/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询关联销售物料信息详细
 * @param relationMaterialId
 */
export const getRelationMaterial = (relationMaterialId: string | number): AxiosPromise<RelationMaterialVO> => {
  return request({
    url: '/oa/base/relationMaterial/' + relationMaterialId,
    method: 'get'
  });
};

/**
 * 新增关联销售物料信息
 * @param data
 */
export const addRelationMaterial = (data: RelationMaterialForm) => {
  return request({
    url: '/oa/base/relationMaterial',
    method: 'post',
    data: data
  });
};

/**
 * 修改关联销售物料信息
 * @param data
 */
export const updateRelationMaterial = (data: RelationMaterialForm) => {
  return request({
    url: '/oa/base/relationMaterial',
    method: 'put',
    data: data
  });
};

/**
 * 删除关联销售物料信息
 * @param relationMaterialId
 */
export const delRelationMaterial = (relationMaterialId: string | number | Array<string | number>) => {
  return request({
    url: '/oa/base/relationMaterial/' + relationMaterialId,
    method: 'delete'
  });
};

/**
 * 下拉框查询关联销售物料信息列表
 * @param query
 * @returns {*}
 */
export function getBaseRelationMaterialList (query) {
    return request({
        url: '/oa/base/relationMaterial/getBaseRelationMaterialList',
        method: 'get',
        params: query
    });
};
