import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StockUpVO, StockUpForm, StockUpQuery } from '@/api/product/stockUp/types';

/**
 * 查询商品备货属性列表
 * @param query
 * @returns {*}
 */

export const listStockUp = (query?: StockUpQuery): AxiosPromise<StockUpVO[]> => {
  return request({
    url: '/system/stockUp/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商品备货属性详细
 * @param id
 */
export const getStockUp = (id: string | number): AxiosPromise<StockUpVO> => {
  return request({
    url: '/system/stockUp/' + id,
    method: 'get'
  });
};

/**
 * 新增商品备货属性
 * @param data
 */
export const addStockUp = (data: StockUpForm) => {
  return request({
    url: '/system/stockUp',
    method: 'post',
    data: data
  });
};

/**
 * 修改商品备货属性
 * @param data
 */
export const updateStockUp = (data: StockUpForm) => {
  return request({
    url: '/system/stockUp',
    method: 'put',
    data: data
  });
};

/**
 * 删除商品备货属性
 * @param id
 */
export const delStockUp = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/stockUp/' + id,
    method: 'delete'
  });
};

export function changeStatus(id: string | number, isShow: string) {
  const data = {
    id,
    isShow
  };
  return request({
    url: '/system/stockUp/changeStatus',
    method: 'put',
    data: data
  });
}
