import request from '/@/utils/request';
import type { IInventoryCheckQueryParams } from './types';

// 添加
export function addInventoryOperate(params: object) {
	return request({
		url: '/inventory/operate/add',
		method: 'post',
		data: params,
	});
}
// 详情
export function getInventoryDetail(id: string) {
	return request({
		url: '/inventory/operate/item/detail/detail',
		method: 'post',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
	},
		params: {
			id
		}
	});
}
export function listDetails(code: string) {
	return request({
		url: '/inventory/operate/listDetails',
		method: 'post',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
	},
		params: {
			code
		}
	});
}
// 出入库查询记录
export function getInventoryList(params: object) {
	return request({
		url: '/inventory/operate/item/detail/queryList',
		method: 'post',
		params
	})
}
// 出入库明细查询
export function getInventoryDetailList(params: object) {
	return request({
		url: '/inventory/operate/item/detail/list',
		method: 'post',
		params
	})
}
// 退货
export function back(params: string) {
	return request({
		url: '/inventory/operate/save',
		method: 'post',
		data: params,
	});
}
// 列表
export function getInventory(params: object) {
    return request({
      url: '/inventory/operate/list',
      method: 'post',
      params
    })
}
// 列表
export function getInventoryNew(params: object) {
    return request({
      url: '/inventory/operate/queryInventoryOperate',
      method: 'post',
      data: params
    })
}

export function listOperates(params: object) {
    return request({
      url: '/inventory/operate/listOperates',
      method: 'post',
      params
    })
}
// 根据规格名称获取库存数量
export function getInventoryCount(code: string, clientCode:string) {
	return request({
		url: '/inventory/operate/getItemCountInStorage',
		method: 'post',
		params: {
			inventoryItemDetailCode: code,
			clientCode: clientCode
		}
	})
}
// 根据规格名称出库退库获取库存数量
export function listLots(code: string, clientCode:string) {
	return request({
		url: '/inventory/operate/listLots',
		method: 'post',
		params: {
			itemCode: code,
			clientCode: clientCode
		}
	})
}
// 添加库存盘点
export function addInventoryCheck(params:object) {
	return request({
		url: '/inventory/check/add',
		method: 'post',
		data: params
	})
}
// 盘点记录列表
export function getInventoryCheckList(params: object) {
	return request({
		url: '/inventory/check/list',
		method: 'post',
		params
	})
}
// 库存列表
export function getInventoryStorageList(params: object) {
	return request({
		url: '/inventory/item/detail/info/listWithStorageSum',
		method: 'post',
		params
	})
}
// 添加库存盘点
export function batchSave(params:object) {
	return request({
		url: '/inventory/check/batchSave',
		method: 'post',
		data: params
	})
}


/**
 * 一级记录2
 * @param params 
 * @returns 
 */
export function inventoryCheckQueryApi(params: IInventoryCheckQueryParams) {
	return request({
		url: '/inventory/check/inventoryCheckQuery',
		method: 'post',
		headers: {
			'Content-Type': 'application/x-www-form-urlencoded'
		},
		params
	})
}