import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BaseStructureBomVO, BaseStructureBomForm, BaseStructureBomQuery } from '@/api/mes/baseStructureBom/types';
import {BaseMaterialTypeQuery,BaseMaterialTypeVO} from "./../baseMaterialType/types";

/**
 * 查询结构BOM信息列表
 * @param query
 * @returns {*}
 */

export const listBaseStructureBom = (query?: BaseStructureBomQuery): AxiosPromise<BaseStructureBomVO[]> => {
  return request({
    url: '/mes/baseStructureBom/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询结构BOM信息详细
 * @param structureBomId
 */
export const getBaseStructureBom = (structureBomId: string | number): AxiosPromise<BaseStructureBomVO> => {
  return request({
    url: '/mes/baseStructureBom/' + structureBomId,
    method: 'get'
  });
};

/**
 * 新增结构BOM信息
 * @param data
 */
export const addBaseStructureBom = (data: BaseStructureBomForm) => {
  return request({
    url: '/mes/baseStructureBom',
    method: 'post',
    data: data
  });
};

/**
 * 修改结构BOM信息
 * @param data
 */
export const updateBaseStructureBom = (data: BaseStructureBomForm) => {
  return request({
    url: '/mes/baseStructureBom',
    method: 'put',
    data: data
  });
};

/**
 * 删除结构BOM信息
 * @param structureBomId
 */
export const delBaseStructureBom = (structureBomId: string | number | Array<string | number>) => {
  return request({
    url: '/mes/baseStructureBom/' + structureBomId,
    method: 'delete'
  });
};


/**
 * 下拉框查询结构BOM信息列表
 * @param query
 * @returns {*}
 */
export function getBaseStructureBomList (query) {
    return request({
        url: '/mes/baseStructureBom/getBaseStructureBomList',
        method: 'get',
        params: query
    });
};


/**
 * 查询物料结构树下拉树结构
 */
export const structureBomTreeSelect = (): AxiosPromise<BaseStructureBomVO[]> => {
  return request({
    url: '/mes/baseStructureBom/structureBomTree',
    method: 'get'
  });
};


/**
 * 分页查询结构BOM信息列表
 * @param query
 * @returns {*}
 */

export const pageListBaseStructureBom = (query?: BaseStructureBomQuery): AxiosPromise<BaseStructureBomVO[]> => {
  return request({
    url: '/mes/baseStructureBom/pageList',
    method: 'get',
    params: query
  });
};


/**
 * 查询物料类型列表
 * @param query
 * @returns {*}
 */

export const getMaterialTypeList = (query?: BaseMaterialTypeQuery): AxiosPromise<BaseMaterialTypeVO[]> => {
  return request({
    url: '/mes/baseStructureBom/getMaterialTypeList',
    method: 'get',
    params: query
  });
};

