import request from '/@/utils/request';
import type { DiffDetails, GetDiffDetailsParams, ListOperate2DetailsParams, ListInandOutDetailsParams, ListInandOutDetailsReponse, ListReadyRowsParams, ListOutStockGroupByPatOrItemParams } from './types';
import { AxiosPromise } from 'axios';

export function Add(params: string) {
	return request({
		url: '/inventory2/info/add',
		method: 'post',
		data: params,
	});
}
export function update(params: string) {
	return request({
		url: '/inventory2/info/update',
		method: 'post',
		data: params,
	});
}
export function deleteId(params: string) {
	return request({
		url: '/inventory2/info/delete',
		method: 'post',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
		data: params,
	});
}
export function list(params: object) {
    return request({
      url: '/inventory2/info/list',
      method: 'post',
      params
    })
}
export function listWithItem(params: object) {
  return request({
    url: '/inventory2/operate/listWithItem',
    method: 'post',
    data:params
  })
}
export function listWithStorageSum2(params: object) {
    return request({
      url: '/inventory/item/detail/info/listWithStorageSum2',
      method: 'post',
      params
    })
}
export function listWithStorageSum(params: object) {
    return request({
      url: '/inventory/item/detail/info/listWithStorageSum',
      method: 'post',
      params
    })
}
export function save(params: object) {
	return request({
		url: '/inventory2/operate/save',
		method: 'post',
		data:params,
	});
}
export function listItems(params: object) {
  return request({
    url: '/inventory2/check/listItems',
    method: 'post',
    data:params
  })
}
export function checkSave(params: object) {
  return request({
    url: '/inventory2/check/batchSave',
    method: 'post',
    data:params
  })
}
export function checkList(params: object) {
  return request({
    url: '/inventory2/check/list',
    method: 'post',
    params
  })
}
export function listWithOperateType(params: object) {
	return request({
		url: '/inventory2/operate/listWithOperateType',
		method: 'post',
	  data:params,
	});
}
export function listRefundRows(params: object) {
	return request({
		url: '/inventory2/operate/listRefundRows',
		method: 'post',
	  params,
	});
}


/**
 * 获取进销存数据列表
 * @param params 
 * @returns 
 */
export function listInandOutDetailsApi(params: ListInandOutDetailsParams) :AxiosPromise<ListInandOutDetailsReponse> {
  return request({
    url: '/inventory/item/detail/info/listInandOutDetails',
    method: 'post',
    params
  })
}


/**
 * 患者透析耗材api
 * @param params 
 * @returns 
 */
export function listReadyRowsApi(data: ListReadyRowsParams) {
  return request({
    url: '/patient/hemo/med/record/listReadyRows',
    method: 'post',
    data
  })
}


/**
 * 透析耗材统计
 * @param params 
 * @returns 
 */
export function listOutStockGroupByPatOrItemApi(params: ListOutStockGroupByPatOrItemParams) {
  return request({
    url: '/inventory2/operate/listOutStockGroupByPatOrItem',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}

/**
 * 显示库存操作明细列表
 * @param params 
 * @returns 
 */
export function listOperate2DetailsApi(params: ListOperate2DetailsParams) {
  return request({
    url: '/inventory/item/detail/info/listOperate2Details',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}


/**
 * 获取亏盈详情
 * @param params 
 * @returns 
 */
export function getDiffDetailsApi(params: GetDiffDetailsParams) :AxiosPromise<{ list: DiffDetails[], total: number; [key: string]: any;}> {
  return request({
    url: '/inventory2/check/getDiffDetails',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    params
  })
}