提交 1bf03e3f 编写于 作者: WodahsOrez's avatar WodahsOrez

add: 关系路径

上级 7669dc2f
package cn.ibizlab.codegen.model; package cn.ibizlab.codegen.model;
import cn.ibizlab.codegen.utils.Inflector;
import cn.ibizlab.codegen.utils.StringAdvUtils; import cn.ibizlab.codegen.utils.StringAdvUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
...@@ -23,6 +26,49 @@ public class AppEntityModel extends BaseModel{ ...@@ -23,6 +26,49 @@ public class AppEntityModel extends BaseModel{
this.setName(appDataEntity.getName()); this.setName(appDataEntity.getName());
this.setId(String.format("%1$s-%2$s",app.getCodeName(),appDataEntity.getCodeName())); this.setId(String.format("%1$s-%2$s",app.getCodeName(),appDataEntity.getCodeName()));
// 初始化应用实体资源数据
if(getAppDataEntity().getMinorPSAppDERSs() != null){
// 遍历多个主从关系
getAppDataEntity().getMinorPSAppDERSs().forEach(appDERS ->{
JSONObject appEntityResource = 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();
appEntityResource.put("majorCodeName",majorCodeName.toLowerCase());
appEntityResource.put("curCodeName",minorCodeName.toLowerCase());
appEntityResource.put("path",path);
// 实体关系路径集合
List deResPaths = new JSONArray();
// 主关系路径节点
JSONObject majorResNode = new JSONObject();
majorResNode.put("pathName", Inflector.getInstance().pluralize(majorCodeName).toLowerCase());
majorResNode.put("parameterName", majorCodeName.toLowerCase());
deResPaths.add(majorResNode);
// 从关系路径节点
JSONObject minorResNode = new JSONObject();
minorResNode.put("pathName", Inflector.getInstance().pluralize(minorCodeName).toLowerCase());
minorResNode.put("parameterName", minorCodeName.toLowerCase());
deResPaths.add(minorResNode);
appEntityResource.put("deResPaths", deResPaths);
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);
}
} }
public IPSAppDataEntity getAppDataEntity() public IPSAppDataEntity getAppDataEntity()
...@@ -64,4 +110,10 @@ public class AppEntityModel extends BaseModel{ ...@@ -64,4 +110,10 @@ public class AppEntityModel extends BaseModel{
return ctrlsMap.values(); return ctrlsMap.values();
} }
/**
* 应用实体资源数据
*/
private List<JSONObject> appEntityResources =new ArrayList<>();
} }
...@@ -61,40 +61,6 @@ public class AppModel extends BaseModel{ ...@@ -61,40 +61,6 @@ 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);
});
}
} }
...@@ -145,11 +111,6 @@ public class AppModel extends BaseModel{ ...@@ -145,11 +111,6 @@ public class AppModel extends BaseModel{
*/ */
private Map<String, JSONObject> appEntityResourceMap =new LinkedHashMap<>(); private Map<String, JSONObject> appEntityResourceMap =new LinkedHashMap<>();
/**
* 应用实体关系对象Set
*/
private Set<JSONObject> appDeResSet =new HashSet<>();
/** /**
* 获取应用实体资源数据 * 获取应用实体资源数据
* @return * @return
......
{{!-- {
{{#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|}} {{#each app.pages as |appView|}}
{{#if appDeRes.deResLinks}}
{{#each appDeRes.appDataEntity.allPSAppViews as |appView|}}
"{{appView.codeName}}":{ "{{appView.codeName}}":{
"name": "{{appView.name}}", "name": "{{appView.name}}",
"codeName": "{{appView.codeName}}", "codeName": "{{appView.codeName}}",
"openMode": "{{#if appView.openMode}}{{appView.openMode}}{{else}}INDEXVIEWTAB{{/if}}", "openMode": "{{#if appView.openMode}}{{appView.openMode}}{{else}}INDEXVIEWTAB{{/if}}",
"redirectView": {{appView.redirectView}}, "redirectView": {{appView.redirectView}},
"deResLinks": [ "deResPaths": [
{{#each appDeRes.deResLinks as |deResLink| }} {{#each appView.appEntity.appEntityResources as |appEntityResource| }}
[ {{appEntityResource.deResPaths}}{{#unless @last}},{{/unless}}
{{#each deResLink.deResParameters as |deResParameter| }}
{ "pathName": "{{deResParameter.pathName}}", "parameterName": "{{deResParameter.parameterName}}" }{{#unless @last}},{{/unless}}
{{/each}}
]{{#unless @last}},{{/unless}}
{{/each}} {{/each}}
], ],
"parameters": [ "parameters": [
{{#if appDeRes.appDataEntity}}
{ "pathName": "{{pluralize appDeRes.appDataEntity.codeName}}", "parameterName": "{{appDeRes.appDataEntity.codeName}}" },
{{/if}}
{ "pathName": "views", "parameterName": "{{lowerCase appView.codeName}}" } { "pathName": "views", "parameterName": "{{lowerCase appView.codeName}}" }
], ],
{{#if appView.capPSLanguageRes}} {{#if appView.capPSLanguageRes}}
...@@ -58,7 +24,5 @@ ...@@ -58,7 +24,5 @@
"viewType": "{{appView.viewType}}", "viewType": "{{appView.viewType}}",
"fileDir": "@page/{{#if psAppDataEntity}}{{spinalCase psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase appView.codeName}}" "fileDir": "@page/{{#if psAppDataEntity}}{{spinalCase psAppDataEntity.codeName}}{{else}}default{{/if}}/{{spinalCase appView.codeName}}"
}{{#unless (and @last ../@last)}},{{/unless}} }{{#unless (and @last ../@last)}},{{/unless}}
{{/each}}
{{/if}}
{{/each}} {{/each}}
} }
<script setup lang="ts"> <script setup lang="ts">
// This starter template is using Vue 3 <script setup> SFCs // This starter template is using Vue 3 <script setup> SFCs
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup // Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup
import {App} from '@service'
onMounted(async ()=>{
await App.init();
// App.openViewService.openView({codeName: 'ExampleEditorEditView'},{context: {},viewParams:{}})
})
</script> </script>
<template> <template>
......
export * from './control-service' export * from './control-service'
export * from './entity' 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 './util';
export * from './view-util'; export * from './view-util';
export * from './route-tool';
export { Http } from './net/http'; export { Http } from './net/http';
\ No newline at end of file
import { useRoute } from 'vue-router';
import { notEmpty } from '@ibiz-core'; import { notEmpty } from '@ibiz-core';
import qs from 'qs'; import qs from 'qs';
...@@ -9,14 +8,13 @@ import qs from 'qs'; ...@@ -9,14 +8,13 @@ import qs from 'qs';
* @class RouteTool * @class RouteTool
*/ */
export class RouteTool { export class RouteTool {
/** /**
* 处理路由路径 * 处理路由路径
* *
* @static * @static
* @param {Route} route 路由 * @param {Route} route 路由
* @param {*} [viewParam={}] * @param {*} [viewParam={}]
* @param {any[]} deResParameters 关系实体参数对象 * @param {any[]} deResPaths 关系实体参数对象
* @param {any[]} parameters 当前应用视图参数对象 * @param {any[]} parameters 当前应用视图参数对象
* @param {any[]} args 多项数据 * @param {any[]} args 多项数据
* @param {*} data 行为参数 * @param {*} data 行为参数
...@@ -31,12 +29,10 @@ export class RouteTool { ...@@ -31,12 +29,10 @@ export class RouteTool {
* @param viewParams 视图参数 * @param viewParams 视图参数
* @return {*} * @return {*}
*/ */
public static buildUpRoutePath(view: any, context: any, viewParams: any): string { public static buildUpRoutePath(view: any, context: any, viewParams: any, route: any): string {
const route = useRoute() const { deResPaths, parameters } = view;
const { deResLinks, parameters } = view;
const deResParameters = deResLinks[0];
const indexRoutePath = this.getIndexRoutePath(route); const indexRoutePath = this.getIndexRoutePath(route);
const deResRoutePath = this.getDeResRoutePath(context, deResParameters); const deResRoutePath = this.getDeResRoutePath(context, deResPaths);
const deRoutePath = this.getActiveRoutePath(parameters, context, viewParams); const deRoutePath = this.getActiveRoutePath(parameters, context, viewParams);
return `${indexRoutePath}${deResRoutePath}${deRoutePath}`; return `${indexRoutePath}${deResRoutePath}${deRoutePath}`;
} }
...@@ -50,13 +46,12 @@ export class RouteTool { ...@@ -50,13 +46,12 @@ export class RouteTool {
* @memberof RouteTool * @memberof RouteTool
*/ */
public static getIndexRoutePath(route: any): string { public static getIndexRoutePath(route: any): string {
const { parameters: _parameters }: { parameters: any[] } = route.meta; const parameterName = route.meta?.parameters?.[0] || "apps";
const { pathName: _pathName, parameterName: _parameterName }: { pathName: string, parameterName: string } = _parameters[0]; const param = route.params[parameterName];
const param = route.params[_parameterName];
if (notEmpty(param)) { if (notEmpty(param)) {
return `/${_parameterName}/${param}`; return `/${parameterName}/${param}`;
} }
return `/${_parameterName}`; return `/${parameterName}`;
} }
/** /**
...@@ -64,21 +59,48 @@ export class RouteTool { ...@@ -64,21 +59,48 @@ export class RouteTool {
* *
* @static * @static
* @param {*} [viewParam={}] 视图上下文 * @param {*} [viewParam={}] 视图上下文
* @param {any[]} deResParameters 关系实体参数对象数组 * @param {any[]} deResPaths 关系实体参数对象数组
* @returns {string} * @returns {string}
* @memberof RouteTool * @memberof RouteTool
*/ */
public static getDeResRoutePath(context: any = {}, deResParameters: any[]): string { public static getDeResRoutePath(context: any = {}, deResPaths: any[]): string {
let routePath: string = ''; let routePath: string = '';
if (deResParameters && deResParameters.length > 0) { // 首先给deResPaths排序,关系多的排前面。
deResParameters.forEach(({ pathName, parameterName }: { pathName: string, parameterName: string }) => { deResPaths.sort((a: any[], b: any[]) => a.length - b.length);
let value: any = null;
if (context[parameterName] && !Object.is(context[parameterName], '') && !Object.is(context[parameterName], 'null')) { // 最多匹配路径节点数
value = context[parameterName]; let maxMatch: number = 0;
// 开始匹配,先遍历关系路径,在遍历关系路径的每个节点
deResPaths.some((deResPath: any[]) => {
// 如果节点个数小于最大匹配,则后面都无需在计算了。
if (maxMatch > deResPath.length) {
return true;
}
// 当前匹配路径节点数
let curMatch: number = 0;
let curRoutPath: string = '';
deResPath.some((deResNode: any, index: number) => {
let value: any = context[deResNode.parameterName];
if (notEmpty(value)) {
curMatch++;
curRoutPath += `/${deResNode.pathName}/${value}`;
} else if (curMatch != 0 || index == deResPath.length) {
// 如果前面一个路径节点已经匹配则前一段路径作废,继续匹配后面的。
// 如果最后一个节点也没值,则整个路径作废。
curMatch = 0;
curRoutPath = '';
} }
routePath = `${routePath}/${pathName}` + (notEmpty(value) ? `/${value}` : '');
}); });
// 当前匹配个数大于最大匹配时,修改最大匹配和最终结果
if (curMatch > maxMatch) {
maxMatch = curMatch;
routePath = curRoutPath;
} }
});
return routePath; return routePath;
} }
...@@ -93,25 +115,11 @@ export class RouteTool { ...@@ -93,25 +115,11 @@ export class RouteTool {
*/ */
public static getActiveRoutePath(parameters: any[], context: any, viewParams: any = {}): string { public static getActiveRoutePath(parameters: any[], context: any, viewParams: any = {}): string {
let routePath: string = ''; let routePath: string = '';
if (parameters && parameters.length > 0) {
// 不存在应用实体
if (parameters.length === 1) {
const [{ parameterName }] = parameters; const [{ parameterName }] = parameters;
routePath = `/views/${parameterName}`; routePath = `/views/${parameterName}`;
if (Object.keys(viewParams).length > 0) { if (Object.keys(viewParams).length > 0) {
routePath = `${routePath}?${qs.stringify(viewParams, { delimiter: ';' })}`; routePath = `${routePath}?${qs.stringify(viewParams, { delimiter: ';' })}`;
} }
} else if (parameters.length === 2) {
let [arg] = args;
arg = arg ? arg : {};
const [{ pathName: _pathName, parameterName: _parameterName }, { pathName: _pathName2, parameterName: _parameterName2 }] = parameters;
const _value: any = context[_parameterName] || null;
routePath = `/${_pathName}${notEmpty(_value) ? `/${_value}` : ''}/views/${_parameterName2}`;
if (Object.keys(viewParams).length > 0) {
routePath = `${routePath}?${qs.stringify(viewParams, { delimiter: ';' })}`;
}
}
}
return routePath; return routePath;
} }
...@@ -136,13 +144,13 @@ export class RouteTool { ...@@ -136,13 +144,13 @@ export class RouteTool {
Object.assign(context, { [key]: param }); Object.assign(context, { [key]: param });
} }
}); });
if (route && route.fullPath && route.fullPath.indexOf("?") > -1) { if (route && route.fullPath && route.fullPath.indexOf('?') > -1) {
const _viewparams: any = route.fullPath.slice(route.fullPath.indexOf("?") + 1); const _viewparams: any = route.fullPath.slice(route.fullPath.indexOf('?') + 1);
const _viewparamArray: Array<string> = decodeURIComponent(_viewparams).split(";") const _viewparamArray: Array<string> = decodeURIComponent(_viewparams).split(';');
if (_viewparamArray.length > 0) { if (_viewparamArray.length > 0) {
_viewparamArray.forEach((item: any) => { _viewparamArray.forEach((item: any) => {
Object.assign(viewparams, qs.parse(item)); Object.assign(viewparams, qs.parse(item));
}) });
} }
} }
} }
...@@ -165,7 +173,7 @@ export class RouteTool { ...@@ -165,7 +173,7 @@ export class RouteTool {
* @memberof RouteTool * @memberof RouteTool
*/ */
public static setIndexParameters(parameters: any[]): void { public static setIndexParameters(parameters: any[]): void {
this.indexParameters = [...parameters] this.indexParameters = [...parameters];
} }
/** /**
...@@ -221,8 +229,7 @@ export class RouteTool { ...@@ -221,8 +229,7 @@ export class RouteTool {
*/ */
public static calcActionItemAuthState(data: any, ActionModel: any, UIService: any) { public static calcActionItemAuthState(data: any, ActionModel: any, UIService: any) {
let result: any[] = []; let result: any[] = [];
if (!UIService) if (!UIService) return;
return;
for (const key in ActionModel) { for (const key in ActionModel) {
if (!ActionModel.hasOwnProperty(key)) { if (!ActionModel.hasOwnProperty(key)) {
return result; return result;
...@@ -230,7 +237,7 @@ export class RouteTool { ...@@ -230,7 +237,7 @@ export class RouteTool {
const _item = ActionModel[key]; const _item = ActionModel[key];
let dataActionResult: any; let dataActionResult: any;
if (_item && _item['dataAccessAction']) { if (_item && _item['dataAccessAction']) {
if (Object.is(_item['actionTarget'], "NONE") || Object.is(_item['actionTarget'], "")) { if (Object.is(_item['actionTarget'], 'NONE') || Object.is(_item['actionTarget'], '')) {
dataActionResult = UIService.getAllOPPrivs(undefined, _item['dataAccessAction']); dataActionResult = UIService.getAllOPPrivs(undefined, _item['dataAccessAction']);
} else { } else {
if (data && Object.keys(data).length > 0) { if (data && Object.keys(data).length > 0) {
...@@ -246,7 +253,7 @@ export class RouteTool { ...@@ -246,7 +253,7 @@ export class RouteTool {
if (_item.getNoPrivDisplayMode === 1) { if (_item.getNoPrivDisplayMode === 1) {
_item.disabled = true; _item.disabled = true;
} }
if ((_item.getNoPrivDisplayMode === 2) || (_item.getNoPrivDisplayMode === 6)) { if (_item.getNoPrivDisplayMode === 2 || _item.getNoPrivDisplayMode === 6) {
_item.visabled = false; _item.visabled = false;
} else { } else {
_item.visabled = true; _item.visabled = true;
...@@ -274,15 +281,14 @@ export class RouteTool { ...@@ -274,15 +281,14 @@ export class RouteTool {
*/ */
public static calcTreeActionItemAuthState(data: any, ActionModel: any, UIService: any) { public static calcTreeActionItemAuthState(data: any, ActionModel: any, UIService: any) {
let result: any[] = []; let result: any[] = [];
if (!UIService) if (!UIService) return;
return;
for (const key in ActionModel) { for (const key in ActionModel) {
if (!ActionModel.hasOwnProperty(key)) { if (!ActionModel.hasOwnProperty(key)) {
return result; return result;
} }
const _item = ActionModel[key]; const _item = ActionModel[key];
let dataActionResult: any; let dataActionResult: any;
if (Object.is(_item['actiontarget'], "NONE") || Object.is(_item['actiontarget'], "")) { if (Object.is(_item['actiontarget'], 'NONE') || Object.is(_item['actiontarget'], '')) {
dataActionResult = UIService.getAllOPPrivs(undefined, _item['dataaccaction']); dataActionResult = UIService.getAllOPPrivs(undefined, _item['dataaccaction']);
} else { } else {
if (_item && _item['dataaccaction'] && UIService.isEnableDEMainState) { if (_item && _item['dataaccaction'] && UIService.isEnableDEMainState) {
...@@ -297,7 +303,7 @@ export class RouteTool { ...@@ -297,7 +303,7 @@ export class RouteTool {
if (_item.noprivdisplaymode === 1) { if (_item.noprivdisplaymode === 1) {
_item.disabled = true; _item.disabled = true;
} }
if ((_item.noprivdisplaymode === 2) || (_item.noprivdisplaymode === 6)) { if (_item.noprivdisplaymode === 2 || _item.noprivdisplaymode === 6) {
_item.visabled = false; _item.visabled = false;
} else { } else {
_item.visabled = true; _item.visabled = true;
...@@ -324,7 +330,11 @@ export class RouteTool { ...@@ -324,7 +330,11 @@ export class RouteTool {
* @memberof RouteTool * @memberof RouteTool
*/ */
public static async calcRedirectContext(tempContext: any, data: any, redirectAppEntity: any) { public static async calcRedirectContext(tempContext: any, data: any, redirectAppEntity: any) {
if (redirectAppEntity && redirectAppEntity.getMinorPSAppDERSs() && ((redirectAppEntity.getMinorPSAppDERSs() as []).length > 0)) { if (
redirectAppEntity &&
redirectAppEntity.getMinorPSAppDERSs() &&
(redirectAppEntity.getMinorPSAppDERSs() as []).length > 0
) {
for (const item of redirectAppEntity.getMinorPSAppDERSs()) { for (const item of redirectAppEntity.getMinorPSAppDERSs()) {
const parentPSAppDEFieldCodeName: string = item.M.getParentPSAppDEField?.codeName; const parentPSAppDEFieldCodeName: string = item.M.getParentPSAppDEField?.codeName;
if (parentPSAppDEFieldCodeName) { if (parentPSAppDEFieldCodeName) {
...@@ -333,12 +343,13 @@ export class RouteTool { ...@@ -333,12 +343,13 @@ export class RouteTool {
const majorAppEntity: any = item.getMajorPSAppDataEntity(); const majorAppEntity: any = item.getMajorPSAppDataEntity();
await majorAppEntity.fill(); await majorAppEntity.fill();
if (!tempContext[majorAppEntity.codeName.toLowerCase()]) { if (!tempContext[majorAppEntity.codeName.toLowerCase()]) {
Object.assign(tempContext, { [majorAppEntity.codeName.toLowerCase()]: curData[parentPSAppDEFieldCodeName.toLowerCase()] }); Object.assign(tempContext, {
[majorAppEntity.codeName.toLowerCase()]: curData[parentPSAppDEFieldCodeName.toLowerCase()],
});
} }
} }
} }
} }
} }
} }
} }
import { AppModal } from '@/utils';
import { Http, deepCopy } from '@ibiz-core';
import { OpenViewService } from '@service';
export class App{
/**
* 打开视图服务
* @static
*/
public static openViewService: OpenViewService = OpenViewService.getInstance();
/**
* 打开视图服务
* @static
*/
public static modalService: AppModal = AppModal.getInstance();
/**
* 所有视图信息
*
* @static
*/
public static allViewInfos: any;
/**
* 获取视图信息
*
* @static
* @param codeName 视图codeName
* @return {*}
*/
public static getViewInfo(codeName: string){
return App.allViewInfos[codeName] ? deepCopy(App.allViewInfos[codeName]) : undefined;
}
/**
* 初始化
*
* @static
*/
public static async init(){
const response = await Http.getInstance().get('./assets/json/views.json')
App.allViewInfos = response.data;
}
}
\ No newline at end of file
export * from './open-view/open-view-service';
export * from './app/app';
\ No newline at end of file
import { deepCopy, IParam, Singleton, RouteTool } from "@ibiz-core"; import { deepCopy, IParam, RouteTool } from '@ibiz-core';
import { useRouter } from "vue-router"; import { App } from '@service';
const allViews= require('./views.json') import router from '@/router';
interface View extends IParam{ interface View extends IParam {
codeName: string, codeName: string;
openMode ?: string, openMode?: string;
} }
interface Params extends IParam{ interface Params extends IParam {
context: any, context: any;
viewParams: any, viewParams: any;
} }
/** /**
...@@ -17,7 +17,26 @@ interface Params extends IParam{ ...@@ -17,7 +17,26 @@ interface Params extends IParam{
* @export * @export
* @class OpenViewService * @class OpenViewService
*/ */
export class OpenViewService extends Singleton{ export class OpenViewService {
/**
* 唯一实例
*
* @private
* @static
* @memberof OpenViewService
*/
private static readonly instance = new OpenViewService();
/**
* 获取唯一实例
*
* @static
* @return {*} {OpenViewService}
* @memberof OpenViewService
*/
public static getInstance(): OpenViewService {
return OpenViewService.instance;
}
/** /**
* 打开视图 * 打开视图
...@@ -25,26 +44,24 @@ interface Params extends IParam{ ...@@ -25,26 +44,24 @@ interface Params extends IParam{
* @param view 视图信息 * @param view 视图信息
* @param params 相关参数 * @param params 相关参数
*/ */
public openView(view: View, params: Params){ public openView(view: View, params: Params) {
// 获取详细视图信息 // 获取详细视图信息
let _view: any = allViews[view.codeName]; let _view: any = App.getViewInfo(view.codeName);
if(!_view){ if (!_view) {
console.error(`应用中不存在${view.codeName}视图`); console.error(`应用中不存在${view.codeName}视图`);
return return;
} }
// 拷贝防污染,view的openMode覆盖配置的 // view的openMode覆盖配置的
_view = deepCopy(_view); if (view.openMode) {
if(view.openMode){
_view.openMode = view.openMode; _view.openMode = view.openMode;
} }
// 重定向视图走重定向逻辑,其他根据openMode打开 // 重定向视图走重定向逻辑,其他根据openMode打开
if(_view.redirectView){ if (_view.redirectView) {
this.openRedirectView(_view, params); this.openRedirectView(_view, params);
}else{ } else {
this.openByOpenMode(_view, params) this.openByOpenMode(_view, params);
} }
} }
/** /**
...@@ -53,30 +70,26 @@ interface Params extends IParam{ ...@@ -53,30 +70,26 @@ interface Params extends IParam{
* @param view 视图信息 * @param view 视图信息
* @param params 相关参数 * @param params 相关参数
*/ */
public openByOpenMode(view: any, params: Params){ public openByOpenMode(view: any, params: Params) {
const { openMode } = view; const { openMode } = view;
const { viewParams, context } = params const { viewParams, context } = params;
// 路由打开视图 // 路由打开视图
if(openMode == 'INDEXVIEWTAB' || openMode == 'POPUPAPP'){ if (openMode == 'INDEXVIEWTAB' || openMode == 'POPUPAPP') {
// TODO 视图关系参数处理 // TODO 视图关系参数处理
const router = useRouter(); const routePath = RouteTool.buildUpRoutePath(view, context, viewParams, router.currentRoute.value);
const routePath = RouteTool.buildUpRoutePath(view, context,viewParams); if (openMode == 'INDEXVIEWTAB') {
if(openMode == 'INDEXVIEWTAB'){
router.push(routePath); router.push(routePath);
}else{ } else {
window.open('./#' + routePath, '_blank'); window.open('./#' + routePath, '_blank');
} }
}else if(openMode == 'POPUPMODAL'){ } else if (openMode == 'POPUPMODAL') {
} else if (openMode.indexOf('DRAWER') !== -1) {
}else if(openMode.indexOf('DRAWER') !== -1){
// TODO PMS上面抽屉DRAWER_TOP // TODO PMS上面抽屉DRAWER_TOP
} else if (openMode == 'POPOVER') {
}else if(openMode == 'POPOVER'){
// TODO 打开气泡卡片 // TODO 打开气泡卡片
}else{ } else {
console.error(`未支持${openMode}打开方式`); console.error(`未支持${openMode}打开方式`);
} }
} }
/** /**
...@@ -85,7 +98,7 @@ interface Params extends IParam{ ...@@ -85,7 +98,7 @@ interface Params extends IParam{
* @param view 视图信息 * @param view 视图信息
* @param params 相关参数 * @param params 相关参数
*/ */
public openRedirectView(view: any, params: Params){ public openRedirectView(view: any, params: Params) {
// TODO 重定向视图处理 // TODO 重定向视图处理
} }
} }
...@@ -4,7 +4,6 @@ import Antd from 'ant-design-vue'; ...@@ -4,7 +4,6 @@ import Antd from 'ant-design-vue';
// import { AppServiceBase, LogUtil } from 'ibiz-core'; // import { AppServiceBase, LogUtil } from 'ibiz-core';
import AppModalComponent from "./app-modal.vue"; import AppModalComponent from "./app-modal.vue";
import IbizLoading from '@components/render/IbizLoading.vue'; import IbizLoading from '@components/render/IbizLoading.vue';
import './app-modal.scss';
export class AppModal { export class AppModal {
......
...@@ -234,7 +234,3 @@ const handleShowState = ($event: any) => { ...@@ -234,7 +234,3 @@ const handleShowState = ($event: any) => {
></component> ></component>
</a-modal> </a-modal>
</template> </template>
<style lang="scss" scoped>
@import './app-modal.scss';
</style>
\ No newline at end of file
...@@ -56,10 +56,10 @@ export class ControlVO extends ControlVOBase { ...@@ -56,10 +56,10 @@ export class ControlVO extends ControlVOBase {
{{/neq}} {{/neq}}
{{/each}} {{/each}}
// 表单里没有映射实体属性的字段 // 表单里没有映射实体属性的字段(srfuf除外)
{{#each ctrl.psDEFormItems as | formItem | }} {{#each ctrl.psDEFormItems as | formItem | }}
{{#eq formItem.psAppDEField null }} {{#if (and (eq formItem.psAppDEField null) (neq formItem.id "srfuf" )) }}
{{lowerCase formItem.id}}: any; {{lowerCase formItem.id}}: any;
{{/eq}} {{/if}}
{{/each}} {{/each}}
} }
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册