orderListNavigation.js 1.24 KB
export const ORDER_LIST_DETAIL_TAG_PATHS = {
	orderDetail: "/orderDetail",
	carDamageDetail: "/carDamageDetail",
	crowdfundDetail: "/crowdfundDetail",
	configUpgradationDetail: "/configUpgradationDetail",
};

/**
 * 从订单列表相关详情返回列表(保留 keep-alive 缓存,不关闭列表 Tab)
 * @param {import('vue-router').default} router
 * @param {Function} close - d2admin/page/close
 * @param {{ detailTagPath?: string }} [options]
 */
export function navigateBackToOrderList(router, close, options = {}) {
	const { detailTagPath = ORDER_LIST_DETAIL_TAG_PATHS.orderDetail } = options;
	close({ tagName: detailTagPath });
	router.push({ name: "orderList" });
}

/**
 * 从 orderDetail / carDamageDetail 返回
 * @param {import('vue-router').default} router
 * @param {Function} close
 * @param {{ fromSupplement?: boolean, detailTagPath?: string }} [options]
 */
export function navigateBackFromOrderDetail(router, close, options = {}) {
	const {
		fromSupplement = false,
		detailTagPath = ORDER_LIST_DETAIL_TAG_PATHS.orderDetail,
	} = options;

	if (fromSupplement) {
		close({ tagName: "/orderSupplement" });
		router.push({ name: "orderSupplement" });
	} else {
		router.push({ name: "orderList" });
	}
	close({ tagName: detailTagPath });
}