146 lines
4.2 KiB
TypeScript
146 lines
4.2 KiB
TypeScript
import type { RouteRecordRaw } from "vue-router";
|
|
import RecycleAPI from "@/api/RecycleAPI";
|
|
import { getErrorMessage } from "@/utils/error";
|
|
import { Message } from "@/utils/message";
|
|
|
|
function meta(depth = 3): RouteRecordRaw["meta"] {
|
|
return { depth, tabBarVisible: false, bodyBackground: "#F5F5F8", darkBodyBackground: "#10161f" };
|
|
}
|
|
|
|
export default [
|
|
{
|
|
path: "/product/recycle-payments",
|
|
name: "RecyclePaymentAll",
|
|
component: () => import("@/pages/recycle/RecyclePaymentList.vue"),
|
|
meta: meta()
|
|
},
|
|
{
|
|
path: "/product/recycle-exchanges",
|
|
name: "RecycleExchangeList",
|
|
redirect: to => {
|
|
const detail = typeof to.query.detail === "string" ? to.query.detail : "";
|
|
if (detail) {
|
|
return { name: "RecycleExchangeDetail", params: { id: detail } };
|
|
}
|
|
return { name: "SalesOrderList", query: { orderType: "RECYCLE", customerId: to.query.customerId } };
|
|
},
|
|
meta: meta()
|
|
},
|
|
{
|
|
path: "/product/recycle-exchanges/create",
|
|
name: "RecycleExchangeCreate",
|
|
component: () => import("@/pages/recycle/RecycleExchangeCreate.vue"),
|
|
meta: meta(4)
|
|
},
|
|
{
|
|
path: "/product/recycle-exchanges/:id/payments/create",
|
|
name: "RecyclePaymentCreate",
|
|
component: () => import("@/pages/recycle/RecyclePaymentCreate.vue"),
|
|
meta: meta(6)
|
|
},
|
|
{
|
|
path: "/product/recycle-exchanges/:id/payments/:paymentId/revoke",
|
|
name: "RecyclePaymentRevoke",
|
|
component: () => import("@/pages/recycle/RecyclePaymentRevoke.vue"),
|
|
meta: meta(7)
|
|
},
|
|
{
|
|
path: "/product/recycle-exchanges/:id/payments/:paymentId",
|
|
name: "RecyclePaymentDetail",
|
|
component: () => import("@/pages/recycle/RecyclePaymentDetail.vue"),
|
|
meta: meta(6)
|
|
},
|
|
{
|
|
path: "/product/recycle-exchanges/:id/payments",
|
|
name: "RecyclePaymentList",
|
|
component: () => import("@/pages/recycle/RecyclePaymentList.vue"),
|
|
meta: meta(5)
|
|
},
|
|
{
|
|
// 兑换单详情已并入交易订单详情,这里保留旧路径与名称,按销售订单 ID 转发
|
|
path: "/product/recycle-exchanges/:id",
|
|
name: "RecycleExchangeDetail",
|
|
beforeEnter: async to => {
|
|
const id = String(to.params.id || "");
|
|
if (id) {
|
|
try {
|
|
const result = await RecycleAPI.detail(id);
|
|
if (result.exchange?.salesOrderId) {
|
|
return { name: "SalesOrderDetail", params: { id: result.exchange.salesOrderId }, replace: true };
|
|
}
|
|
} catch (error) {
|
|
Message.error(getErrorMessage(error, "兑换单加载失败"));
|
|
}
|
|
}
|
|
return { name: "SalesOrderList", query: { orderType: "RECYCLE" }, replace: true };
|
|
},
|
|
meta: meta(4)
|
|
},
|
|
{
|
|
path: "/management/customer-recycle-accounts",
|
|
name: "CustomerRecycleList",
|
|
component: () => import("@/pages/customer/CustomerRecycleList.vue"),
|
|
meta: meta()
|
|
},
|
|
{
|
|
path: "/management/recycle-accounts",
|
|
name: "RecycleAccount",
|
|
component: () => import("@/pages/recycle/RecycleAccount.vue"),
|
|
meta: meta()
|
|
},
|
|
{
|
|
path: "/product/recycle-items",
|
|
name: "RecycleItemList",
|
|
component: () => import("@/pages/recycle/RecycleItemList.vue"),
|
|
meta: meta()
|
|
},
|
|
{
|
|
path: "/product/recycle-items/create",
|
|
name: "RecycleItemCreate",
|
|
component: () => import("@/pages/recycle/RecycleItemEdit.vue"),
|
|
meta: meta(4)
|
|
},
|
|
{
|
|
path: "/product/recycle-items/:id",
|
|
name: "RecycleItemDetail",
|
|
component: () => import("@/pages/recycle/RecycleItemDetail.vue"),
|
|
meta: meta(4)
|
|
},
|
|
{
|
|
path: "/product/recycle-items/:id/edit",
|
|
name: "RecycleItemEdit",
|
|
component: () => import("@/pages/recycle/RecycleItemEdit.vue"),
|
|
meta: meta(5)
|
|
},
|
|
{
|
|
path: "/product/recycle-rules",
|
|
name: "RecycleRuleList",
|
|
component: () => import("@/pages/recycle/RecycleRuleList.vue"),
|
|
meta: meta()
|
|
},
|
|
{
|
|
path: "/product/recycle-rules/create",
|
|
name: "RecycleRuleCreate",
|
|
component: () => import("@/pages/recycle/RecycleRuleEdit.vue"),
|
|
meta: meta(4)
|
|
},
|
|
{
|
|
path: "/product/recycle-rules/:id",
|
|
name: "RecycleRuleDetail",
|
|
component: () => import("@/pages/recycle/RecycleRuleDetail.vue"),
|
|
meta: meta(4)
|
|
},
|
|
{
|
|
path: "/product/recycle-rules/:id/edit",
|
|
name: "RecycleRuleEdit",
|
|
component: () => import("@/pages/recycle/RecycleRuleEdit.vue"),
|
|
meta: meta(5)
|
|
},
|
|
{
|
|
path: "/product/recycle-stats",
|
|
name: "RecycleStat",
|
|
component: () => import("@/pages/recycle/RecycleStat.vue"),
|
|
meta: meta()
|
|
}
|
|
] as RouteRecordRaw[];
|