提交 cac6d3a2 编写于 作者: Mosher's avatar Mosher

update:更新路由计算逻辑

上级 9c8aa3ac
...@@ -51,22 +51,21 @@ public class AppEntityModel extends BaseModel{ ...@@ -51,22 +51,21 @@ public class AppEntityModel extends BaseModel{
appEntityResource.put("deResPaths", deResPaths); appEntityResource.put("deResPaths", deResPaths);
appEntityResources.add(appEntityResource); appEntityResources.add(appEntityResource);
}); });
}else{
// 没有主从关系,路径就只有自己本身一个
JSONObject appEntityResource = new JSONObject();
appEntityResource.put("curCodeName",appDataEntity.getCodeName().toLowerCase());
appEntityResource.put("path",String.format("%1$s/:%2$s?",Inflector.getInstance().pluralize(appDataEntity.getCodeName()),appDataEntity.getCodeName()).toLowerCase());
// 路由关系路径集合
List deResPaths = new JSONArray();
// 实体本身关系路径节点
JSONObject curResNode = new JSONObject();
curResNode.put("pathName", Inflector.getInstance().pluralize(appDataEntity.getCodeName()).toLowerCase());
curResNode.put("parameterName", appDataEntity.getCodeName().toLowerCase());
deResPaths.add(curResNode);
appEntityResource.put("deResPaths", deResPaths);
appEntityResource.put("deResPathsString", deResPaths.toString());
appEntityResources.add(appEntityResource);
} }
// 本身路径
JSONObject appEntityResource = new JSONObject();
appEntityResource.put("curCodeName",appDataEntity.getCodeName().toLowerCase());
appEntityResource.put("path",String.format("%1$s/:%2$s?",Inflector.getInstance().pluralize(appDataEntity.getCodeName()),appDataEntity.getCodeName()).toLowerCase());
// 路由关系路径集合
List deResPaths = new JSONArray();
// 实体本身关系路径节点
JSONObject curResNode = new JSONObject();
curResNode.put("pathName", Inflector.getInstance().pluralize(appDataEntity.getCodeName()).toLowerCase());
curResNode.put("parameterName", appDataEntity.getCodeName().toLowerCase());
deResPaths.add(curResNode);
appEntityResource.put("deResPaths", deResPaths);
appEntityResource.put("deResPathsString", deResPaths.toString());
appEntityResources.add(appEntityResource);
// 初始化界面行为 // 初始化界面行为
try { try {
......
...@@ -54,13 +54,12 @@ public class AppModel extends BaseModel{ ...@@ -54,13 +54,12 @@ public class AppModel extends BaseModel{
tempObj.put("appDataEntity",appDataEntity); tempObj.put("appDataEntity",appDataEntity);
appEntityResourceMap.put(String.format("%1$s:%2$s",majorCodeName,minorCodeName),tempObj); appEntityResourceMap.put(String.format("%1$s:%2$s",majorCodeName,minorCodeName),tempObj);
}); });
}else{
JSONObject tempObj = new JSONObject();
tempObj.put("curCodeName",appDataEntity.getCodeName().toLowerCase());
tempObj.put("path",String.format("%1$s/:%2$s?",Inflector.getInstance().pluralize(appDataEntity.getCodeName()),appDataEntity.getCodeName()).toLowerCase());
tempObj.put("appDataEntity",appDataEntity);
appEntityResourceMap.put(appDataEntity.getCodeName(),tempObj);
} }
JSONObject tempObj = new JSONObject();
tempObj.put("curCodeName",appDataEntity.getCodeName().toLowerCase());
tempObj.put("path",String.format("%1$s/:%2$s?",Inflector.getInstance().pluralize(appDataEntity.getCodeName()),appDataEntity.getCodeName()).toLowerCase());
tempObj.put("appDataEntity",appDataEntity);
appEntityResourceMap.put(appDataEntity.getCodeName(),tempObj);
}); });
} }
......
import { ExpViewProps } from "@core"; import { ExpViewProps } from "@core";
/** /**
* @description 导航视图props * @description 分页导航视图props
* @export * @export
* @interface TabExpViewProps * @interface TabExpViewProps
* @extends {ExpViewProps} * @extends {ExpViewProps}
......
import { ExpViewState } from '@core'; import { ExpViewState } from '@core';
/** /**
* @description 导航视图状态 * @description 分页导航视图状态
* @export * @export
* @interface TabExpViewState * @interface TabExpViewState
* @extends {ExpViewState} * @extends {ExpViewState}
......
import { IParam, MainControlProps } from "@core"; import { IParam, MainControlProps } from "@core";
/** /**
* @description 搜索栏部件的props * @description 分页导航部件props
* @export * @export
* @interface TabExpPanelControlProps * @interface TabExpPanelControlProps
* @extends {MainControlProps} * @extends {MainControlProps}
...@@ -16,5 +16,5 @@ export interface TabExpPanelControlProps extends MainControlProps { ...@@ -16,5 +16,5 @@ export interface TabExpPanelControlProps extends MainControlProps {
/** /**
* 默认打开的分页name * 默认打开的分页name
*/ */
defaultActivePanel?: string; defaultActivePanel: string;
} }
\ No newline at end of file
import { IParam, MainControlState } from '@core'; import { MainControlState } from '@core';
/** /**
* @description 搜索栏部件状态 * @description 分页导航面板状态
* @export * @export
* @interface TabExpPanelControlState * @interface TabExpPanelControlState
* @extends {MainControlState} * @extends {MainControlState}
......
import { UIUtil, deepCopy, IActionParam, IParam, MainControl, TabExpPanelControlState, TabExpPanelControlProps } from '@core'; import { MainControl, TabExpPanelControlState, TabExpPanelControlProps } from '@core';
/** /**
* @description 分页导航部件 * @description 分页导航部件
...@@ -16,9 +16,17 @@ export class TabExpPanelControl extends MainControl { ...@@ -16,9 +16,17 @@ export class TabExpPanelControl extends MainControl {
public declare state: TabExpPanelControlState; public declare state: TabExpPanelControlState;
/** /**
* 分页导航部件输出参数
*
* @type {TabExpPanelControlProps}
* @memberof TabExpPanelControl * @memberof TabExpPanelControl
*/ */
public setState() { public declare props: TabExpPanelControlProps;
/**
* @memberof TabExpPanelControl
*/
public setState() {
super.setState(); super.setState();
this.state.tabPosition = toRef(this.props, 'tabPosition') as any; this.state.tabPosition = toRef(this.props, 'tabPosition') as any;
this.state.activePanel = this.props.defaultActivePanel; this.state.activePanel = this.props.defaultActivePanel;
......
...@@ -59,7 +59,7 @@ export class RouteUtil { ...@@ -59,7 +59,7 @@ export class RouteUtil {
public static getDeResRoutePath(context: any = {}, deResPaths: any[]): string { public static getDeResRoutePath(context: any = {}, deResPaths: any[]): string {
let routePath: string = ''; let routePath: string = '';
// 首先给deResPaths排序,关系多的排前面。 // 首先给deResPaths排序,关系多的排前面。
deResPaths.sort((a: any[], b: any[]) => a.length - b.length); deResPaths.sort((a: any[], b: any[]) => b.length - a.length);
// 最多匹配路径节点数 // 最多匹配路径节点数
let maxMatch: number = 0; let maxMatch: number = 0;
...@@ -118,7 +118,7 @@ export class RouteUtil { ...@@ -118,7 +118,7 @@ export class RouteUtil {
public static buildDeResRequestPath(context: any = {}, deResPaths: any[]): string { public static buildDeResRequestPath(context: any = {}, deResPaths: any[]): string {
let routePath: string = ''; let routePath: string = '';
// 首先给deResPaths排序,关系多的排前面。 // 首先给deResPaths排序,关系多的排前面。
deResPaths.sort((a: any[], b: any[]) => a.length - b.length); deResPaths.sort((a: any[], b: any[]) => b.length - a.length);
// 最多匹配路径节点数 // 最多匹配路径节点数
let maxMatch: number = 0; let maxMatch: number = 0;
...@@ -135,20 +135,22 @@ export class RouteUtil { ...@@ -135,20 +135,22 @@ export class RouteUtil {
deResPath.some((deResNode: any, index: number) => { deResPath.some((deResNode: any, index: number) => {
let value: any = context[deResNode.parameterName]; let value: any = context[deResNode.parameterName];
// 如果不是最后一条,则正常拼接,否则会一直拼接 // 存在关系
if (index !== deResPath.length - 1) { if (deResPath.length > 1) {
if (notEmpty(value)) { if (index !== deResPath.length - 1) {
if (notEmpty(value)) {
curMatch++;
curRoutPath += `/${deResNode.pathName}/${value}`;
} else {
// 只要有一个主关系节点没值,则整个路径作废。
curMatch = 0;
curRoutPath = '';
return true;
}
} else { // 该实体本身主键正常拼接
curMatch++; curMatch++;
curRoutPath += `/${deResNode.pathName}/${value}`; curRoutPath += `/${deResNode.pathName}/${notEmpty(value) ? value : 'undefined'}`;
} else {
// 只要有一个节点没值,则整个路径作废。
curMatch = 0;
curRoutPath = '';
return true
} }
} else {
curMatch++;
curRoutPath += `/${deResNode.pathName}/${notEmpty(value) ? value : 'undefined'}`;
} }
}); });
...@@ -160,9 +162,9 @@ export class RouteUtil { ...@@ -160,9 +162,9 @@ export class RouteUtil {
}); });
// 如果一个匹配的没有,即没有任何主键匹配上,关系路径为实体自身的/pathName/undefined // 如果一个匹配的没有,即没有任何主键匹配上,关系路径为实体自身的/pathName/undefined
// if(routePath == ''){ if(routePath == ''){
// routePath = "/"+deResPaths[deResPaths.length -1][0].pathName+"/undefined"; routePath = "/"+deResPaths[deResPaths.length -1][0].pathName+"/undefined";
// } }
return routePath; return routePath;
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册