提交 63e0ab96 编写于 作者: WodahsOrez's avatar WodahsOrez

update: open-view-service

上级 9e083037
......@@ -38,6 +38,7 @@ public class AppModel extends BaseModel{
if(getApplication().getAllPSAppDataEntities()!=null)
{
getApplication().getAllPSAppDataEntities().forEach(appDataEntity ->{
if(appDataEntity.getMinorPSAppDERSs() != null){
appDataEntity.getMinorPSAppDERSs().forEach(appDERS ->{
JSONObject tempObj = new JSONObject();
......@@ -59,6 +60,41 @@ public class AppModel extends BaseModel{
}
});
}
// 初始化应用实体关系数据Set
if(getApplication().getAllPSAppDataEntities()!=null){
getApplication().getAllPSAppDataEntities().forEach(appDataEntity ->{
JSONObject tempObj = new JSONObject();
tempObj.put("appDataEntity",appDataEntity);
if(appDataEntity.getMinorPSAppDERSs() != null){
List deResLinks = new ArrayList<JSONObject>();
appDataEntity.getMinorPSAppDERSs().forEach(appDERS ->{
JSONObject deResLink = new JSONObject();
String majorCodeName = appDERS.getMajorPSAppDataEntity().getCodeName();
String minorCodeName = appDERS.getMinorPSAppDataEntity().getCodeName();
String path = String.format("%1$s/:%2$s?/%3$s/:%4$s?",Inflector.getInstance().pluralize(majorCodeName),majorCodeName,Inflector.getInstance().pluralize(minorCodeName),minorCodeName).toLowerCase();
deResLink.put("majorCodeName",majorCodeName.toLowerCase());
deResLink.put("path",path);
// 路由关系参数数组
List deResParameters = new ArrayList();
JSONObject majorResObj = new JSONObject();
majorResObj.put("pathName", Inflector.getInstance().pluralize(majorCodeName).toLowerCase());
majorResObj.put("parameterName", majorCodeName.toLowerCase());
deResParameters.add(majorResObj);
JSONObject minorResObj = new JSONObject();
minorResObj.put("pathName", Inflector.getInstance().pluralize(minorCodeName).toLowerCase());
minorResObj.put("parameterName", minorCodeName.toLowerCase());
deResParameters.add(minorResObj);
deResLink.put("deResParameters", deResParameters);
deResLinks.add(deResLink);
});
tempObj.put("deResLinks", deResLinks);
}else{
tempObj.put("path",String.format("%1$s/:%2$s?",Inflector.getInstance().pluralize(appDataEntity.getCodeName()),appDataEntity.getCodeName()).toLowerCase());
}
appDeResSet.add(tempObj);
});
}
}
......@@ -109,6 +145,11 @@ public class AppModel extends BaseModel{
*/
private Map<String, JSONObject> appEntityResourceMap =new LinkedHashMap<>();
/**
* 应用实体关系对象Set
*/
private Set<JSONObject> appDeResSet =new HashSet<>();
/**
* 获取应用实体资源数据
* @return
......
export * from './control-service'
export * from './entity'
export * from './singleton'
\ No newline at end of file
/**
* 单例基类
*
* @export
* @class Singleton
*/
export class Singleton{
/**
* 唯一实例
*
* @private
* @static
* @memberof Singleton
*/
private static readonly instance = new Singleton();
/**
* 获取唯一实例
*
* @static
* @return {*} {Singleton}
* @memberof Singleton
*/
public static getInstance(): Singleton {
return Singleton.instance;
}
}
\ No newline at end of file
export * from './util';
export * from './view-util';
export * from './view-tool';
export { Http } from './net/http';
\ No newline at end of file
......@@ -20,6 +20,16 @@ export function isExist(arg: any): boolean{
return arg !== undefined && arg !== null && arg === arg;
}
/**
* @description 除undefined,null,NaN,空字符串以外都为true
* @export
* @param {*} arg
* @return {*} {boolean}
*/
export function notEmpty(arg: any): boolean{
return isExist(arg) && arg != '';
}
/**
* @description 是否拥有某个方法
* @param {*} arg 校验对象
......
import { deepCopy, IParam, Singleton, RouteTool } from "@ibiz-core";
import { useRouter } from "vue-router";
const allViews= require('./views.json')
interface View extends IParam{
codeName: string,
openMode ?: string,
}
interface Params extends IParam{
context: any,
viewParams: any,
}
/**
* 视图打开服务
* @export
* @class OpenViewService
*/
export class OpenViewService extends Singleton{
/**
* 打开视图
*
* @param view 视图信息
* @param params 相关参数
*/
public openView(view: View, params: Params){
// 获取详细视图信息
let _view: any = allViews[view.codeName];
if(!_view){
console.error(`应用中不存在${view.codeName}视图`);
return
}
// 拷贝防污染,view的openMode覆盖配置的
_view = deepCopy(_view);
if(view.openMode){
_view.openMode = view.openMode;
}
// 重定向视图走重定向逻辑,其他根据openMode打开
if(_view.redirectView){
this.openRedirectView(_view, params);
}else{
this.openByOpenMode(_view, params)
}
}
/**
* 根据打开方式打开视图
*
* @param view 视图信息
* @param params 相关参数
*/
public openByOpenMode(view: any, params: Params){
const { openMode } = view;
const { viewParams, context } = params
// 路由打开视图
if(openMode == 'INDEXVIEWTAB' || openMode == 'POPUPAPP'){
// TODO 视图关系参数处理
const router = useRouter();
const routePath = RouteTool.buildUpRoutePath(view, context,viewParams);
if(openMode == 'INDEXVIEWTAB'){
router.push(routePath);
}else{
window.open('./#' + routePath, '_blank');
}
}else if(openMode == 'POPUPMODAL'){
}else if(openMode.indexOf('DRAWER') !== -1){
// TODO PMS上面抽屉DRAWER_TOP
}else if(openMode == 'POPOVER'){
// TODO 打开气泡卡片
}else{
console.error(`未支持${openMode}打开方式`);
}
}
/**
* 重定向视图处理
*
* @param view 视图信息
* @param params 相关参数
*/
public openRedirectView(view: any, params: Params){
// TODO 重定向视图处理
}
}
\ No newline at end of file
{{!-- {
{{#each app.appEntityResources as |appEntityResource|}}
{{#if appEntityResource.appDataEntity.allPSAppViews}}
{{#each appEntityResource.appDataEntity.allPSAppViews as |appView|}}
"{{appView.codeName}}":{
"name": "{{appView.name}}",
"codeName": "{{appView.codeName}}",
"openMode": "{{#if appView.openMode}}{{appView.openMode}}{{else}}INDEXVIEWTAB{{/if}}",
"redirectView": {{appView.redirectView}},
"path": "{{appEntityResource.path}}/views/{{lowerCase appView.codeName}}",
{{#if appView.capPSLanguageRes}}
"captionTag": "{{appView.capPSLanguageRes.lanResTag}}",
{{/if}}
"caption": "{{appView.caption}}",
{{#if appView.psSysImage}}
"imgPath": "{{appView.psSysImage.imagePath}}",
"iconCls": "{{appView.psSysImage.cssClass}}",
{{/if}}
"viewType": "{{appView.viewType}}",
"fileDir": "@page/{{#if psAppDataEntity}}{{spinalCase psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase appView.codeName}}"
}{{#unless (and @last ../@last)}},{{/unless}}
{{/each}}
{{/if}}
{{/each}}
} --}}
{
{{#each app.appDeResSet as |appDeRes|}}
{{#if appDeRes.deResLinks}}
{{#each appDeRes.appDataEntity.allPSAppViews as |appView|}}
"{{appView.codeName}}":{
"name": "{{appView.name}}",
"codeName": "{{appView.codeName}}",
"openMode": "{{#if appView.openMode}}{{appView.openMode}}{{else}}INDEXVIEWTAB{{/if}}",
"redirectView": {{appView.redirectView}},
"deResLinks": [
{{#each appDeRes.deResLinks as |deResLink| }}
[
{{#each deResLink.deResParameters as |deResParameter| }}
{ "pathName": "{{deResParameter.pathName}}", "parameterName": "{{deResParameter.parameterName}}" }{{#unless @last}},{{/unless}}
{{/each}}
]{{#unless @last}},{{/unless}}
{{/each}}
],
"parameters": [
{{#if appDeRes.appDataEntity}}
{ "pathName": "{{pluralize appDeRes.appDataEntity.codeName}}", "parameterName": "{{appDeRes.appDataEntity.codeName}}" },
{{/if}}
{ "pathName": "views", "parameterName": "{{lowerCase appView.codeName}}" }
],
{{#if appView.capPSLanguageRes}}
"captionTag": "{{appView.capPSLanguageRes.lanResTag}}",
{{/if}}
"caption": "{{appView.caption}}",
{{#if appView.psSysImage}}
"imgPath": "{{appView.psSysImage.imagePath}}",
"iconCls": "{{appView.psSysImage.cssClass}}",
{{/if}}
"viewType": "{{appView.viewType}}",
"fileDir": "@page/{{#if psAppDataEntity}}{{spinalCase psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase appView.codeName}}"
}{{#unless (and @last ../@last)}},{{/unless}}
{{/each}}
{{/if}}
{{/each}}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册