import request from '/@/utils/request';

// 库位查询参数
export interface LocationQueryParams {
	keyword?: string;
	warehouseId?: string;
	zoneId?: string;
	zoneIds?: string[];
	status?: string;
	pageNum?: number;
	pageSize?: number;
}

// 库位数据接口
export interface LocationData {
	id?: string;
	locationName: string;
	locationCode?: string;
	locationType?: string;
	warehouseId?: string;
	zoneId: string;
	maxCapacity?: number;
	capacityUnit?: string;
	capacityUnitType: string;
	status?: string;
	remark?: string;
}

// 获取库位列表
export function listLocations(params?: LocationQueryParams) {
	return request({
		url: '/assets/location/listLocations',
		method: 'get',
		params,
	});
}

// 获取库位详情
export function getLocation(id: string) {
	return request({
		url: '/assets/location/getLocation',
		method: 'get',
		params: { id },
	});
}

// 创建库位
export function createLocation(data: LocationData) {
	return request({
		url: '/assets/location/createLocation',
		method: 'post',
		data,
	});
}

// 更新库位
export function updateLocation(data: LocationData) {
	return request({
		url: '/assets/location/updateLocation',
		method: 'put',
		data,
	});
}

// 删除库位
export function deleteLocation(id: string) {
	return request({
		url: '/assets/location/deleteLocation',
		method: 'delete',
		params: { id },
	});
}

// 更新库位状态
export function updateLocationStatus(data: { id: string; status: string }) {
	return request({
		url: '/assets/location/updateLocationStatus',
		method: 'put',
		data,
	});
}

// 获取容量单位类型
export function getCapacityUnitType() {
	return request({
		url: '/assets/location/getCapacityUnitType',
		method: 'get',
	});
}
