import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ErpConfigVO, ErpConfigForm, ErpConfigQuery } from '@/api/api/erpConfig/types';

/**
 * 查询ERP系统配置列表
 * @param query
 * @returns {*}
 */

export const listErpConfig = (query?: ErpConfigQuery): AxiosPromise<ErpConfigVO[]> => {
  return request({
    url: '/api/erpConfig/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询ERP系统配置详细
 * @param configId
 */
export const getErpConfig = (configId: string | number): AxiosPromise<ErpConfigVO> => {
  return request({
    url: '/api/erpConfig/' + configId,
    method: 'get'
  });
};

/**
 * 新增ERP系统配置
 * @param data
 */
export const addErpConfig = (data: ErpConfigForm) => {
  return request({
    url: '/api/erpConfig',
    method: 'post',
    data: data
  });
};

/**
 * 修改ERP系统配置
 * @param data
 */
export const updateErpConfig = (data: ErpConfigForm) => {
  return request({
    url: '/api/erpConfig',
    method: 'put',
    data: data
  });
};

/**
 * 删除ERP系统配置
 * @param configId
 */
export const delErpConfig = (configId: string | number | Array<string | number>) => {
  return request({
    url: '/api/erpConfig/' + configId,
    method: 'delete'
  });
};


/**
 * 下拉框查询ERP系统配置列表
 * @param query
 * @returns {*}
 */
export function getSysErpConfigList(query) {
  return request({
    url: '/api/erpConfig/getSysErpConfigList',
    method: 'get',
    params: query
  });
};
