import request from '@/utils/request'

/**
 * 获取采购订单列表
 * @param params
 * @returns
 */
export function getOrderList(params : Record<string, any>) {
	return request.get(`erp/purchase/order`, params);
}

/**
 * 获取采购订单详情
 * @param id 采购订单id
 * @returns
 */
export function getOrderInfo(id : number) {
	return request.get(`erp/purchase/order/${id}`);
}

/**
 * 获取采购订单状态
 * @param params
 * @returns
 */
export function getOrderStatus() {
	return request.get(`erp/purchase/order/getStatus`);
}
/**
 * 添加采购订单
 * @param params
 * @returns
 */
export function addOrder(params : Record<string, any>) {
	return request.post("erp/purchase/order", params, {
		showErrorMessage: true,
		showSuccessMessage: true,
	});
}

/**
 * 获取入库列表
 * @param params
 * @returns
 */
export function getStorageList(params : Record<string, any>) {
	return request.get(`erp/purchase/storage`, params);
}

/**
 * 获取入库单状态
 * @param params
 * @returns
 */
export function getStorageStatus() {
	return request.get(`erp/purchase/storage/getStatus`);
}

/**
 * 获取入库详情
 * @param id 入库id
 * @returns
 */
export function getStorageInfo(id : number) {
	return request.get(`erp/purchase/storage/${id}`);
}


/**
 * 获取退货列表
 * @param params
 * @returns
 */
export function getRetireList(params : Record<string, any>) {
	return request.get(`erp/purchase/retire`, params);
}
/**
 * 修改
 * @param params
 * @returns
 */
export function updateRetire(id : number,params : Record<string, any>) {
	return request.post(`erp/purchase/retire/${id}`, params,{
		showErrorMessage: true,
		showSuccessMessage: true,
	});
}

/**
 * 获取退货单状态
 * @param params
 * @returns
 */
export function getRetireStatus() {
	return request.get(`erp/purchase/retire/getStatus`);
}

/**
 * 获取退货详情
 * @param id 退货id
 * @returns
 */
export function getRetireInfo(id : number) {
	return request.get(`erp/purchase/retire/${id}`);
}

/**
 * 添加退货
 * @param params
 * @returns
 */
export function addRetire(params : Record<string, any>) {
	return request.post("erp/purchase/retire", params, {
		showErrorMessage: true,
		showSuccessMessage: true,
	});
}

/**
 * 删除退货
 * @param id
 * @returns
 */
export function deleteRetire(id : number) {
	return request.delete(`erp/purchase/retire/${id}`, {
		showErrorMessage: true,
		showSuccessMessage: true,
	});
}

/*-------------------------------------new-----------------------------------------*/
/**
 * 入库列表
 * @param params
 * @returns
 */
export function getManualList(params: Record<string, any>) {
  return request.get(`erp/inbound/manual`,params);
}
/**
 * 添加入库
 * @param params
 * @returns
 */
export function addManual(params : Record<string, any>) {
	 return request.post("erp/inbound/manual", params, {
	    showErrorMessage: true,
	    showSuccessMessage: true,
	  });
}
/**
 * 获取入库单状态
 * @param params
 * @returns
 */
export function getManualStatus(params: Record<string, any>) {
  return request.get(`erp/inbound/manual/getStatus`, params);
}
/**
 * 手工单入库
 * @param id
 * @returns
 */
export function putInStorage(id: any) {
  return request.put(
    `erp/inbound/manual/putInStorage/${id}`,
    {},
    {
      showErrorMessage: true,
      showSuccessMessage: true,
    }
  );
}
/**
 * 获取入库单详情
 * @param id 入库单id
 * @returns
 */
export function getManualInfo(id: number) {
  return request.get(`erp/inbound/manual/${id}`);
}
/**
 * 获取退货列表
 * @param params
 * @returns
 */
export function getReturnList(params: Record<string, any>) {
    return request.get(`erp/inventory/return`,params)
}

export function getReturnStatus() {
    return request.get(`erp/inventory/return/getStatus`)
}

/**
 * 获取退货详情
 * @param id 退货id
 * @returns
 */
export function getReturnInfo(id: number) {
    return request.get(`erp/inventory/return/${id}`)
}

/**
 * 添加退货
 * @param params
 * @returns
 */
export function addReturn(params: Record<string, any>) {
    return request.post('erp/inventory/return', params, {
        showErrorMessage: true,
        showSuccessMessage: true
    })
}


/**
 * 审核退货订单
 * @param id
 * @returns
 */
export function updateReturnStatus(params: Record<string, any>) {
    return request.post(`erp/inventory/return/updateStatus/${params.id}`, params, {
        showErrorMessage: true,
        showSuccessMessage: true
    })
}

/**
 * 确认退货
 * @param id
 * @returns
 */
export function confirmReturned(params: Record<string, any>) {
    return request.post(`erp/inventory/return/confirm/${params.id}`, params, {
        showErrorMessage: true,
        showSuccessMessage: true
    })
}
/**
 * 反审核退货订单
 * @param id
 * @returns
 */
export function antiReturnStatus(id: number) {
    return request.post(
        `erp/inventory/return/anti/${id}`,
        {},
        {
            showErrorMessage: true,
            showSuccessMessage: true
        }
    )
}
