提交 3e9e958a 编写于 作者: tony001's avatar tony001

update:更新前端结构

上级 dc15f466
package cn.ibizlab.codegen.model; package cn.ibizlab.codegen.model;
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;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import net.ibizsys.model.app.view.IPSAppView; import net.ibizsys.model.app.view.IPSAppView;
import org.springframework.util.StringUtils; import net.ibizsys.model.control.toolbar.IPSDETBUIActionItem;
import net.ibizsys.model.control.toolbar.IPSDEToolbar;
import net.ibizsys.model.view.IPSUIAction;
import java.util.*; import java.util.*;
...@@ -42,6 +46,67 @@ public class PageModel extends BaseModel{ ...@@ -42,6 +46,67 @@ public class PageModel extends BaseModel{
} }
}); });
} }
// 初始化工具栏数据
if(appView.getPSControls() != null)
{
appView.getPSControls().forEach(item->{
if("TOOLBAR".equals(item.getControlType())){
JSONObject viewToolBar = new JSONObject();
viewToolBar.put("codeName",item.getCodeName());
viewToolBar.put("controlType",item.getControlType());
viewToolBar.put("logicName",item.getLogicName());
if(((IPSDEToolbar)item).getPSDEToolbarItems() != null){
JSONArray items = new JSONArray();
((IPSDEToolbar)item).getPSDEToolbarItems().forEach(singleItam ->{
JSONObject toolbarItem = new JSONObject();
toolbarItem.put("caption",singleItam.getCaption());
if(singleItam.getCapPSLanguageRes() != null && singleItam.getCapPSLanguageRes().getLanResTag() != null){
toolbarItem.put("capPSLanguageRes",singleItam.getCapPSLanguageRes().getLanResTag());
}
toolbarItem.put("tooltip",singleItam.getTooltip());
if(singleItam.getTooltipPSLanguageRes() != null && singleItam.getTooltipPSLanguageRes().getLanResTag() != null){
toolbarItem.put("tooltipPSLanguageRes",singleItam.getTooltipPSLanguageRes().getLanResTag());
}
toolbarItem.put("itemType",singleItam.getItemType());
toolbarItem.put("name",singleItam.getName());
toolbarItem.put("showCaption",singleItam.isShowCaption());
toolbarItem.put("showIcon",singleItam.isShowIcon());
if(singleItam.getPSSysImage() != null && singleItam.getPSSysImage().getCssClass() != null){
toolbarItem.put("iconClass",singleItam.getPSSysImage().getCssClass());
}
if(singleItam.getPSSysImage() != null && singleItam.getPSSysImage().getImagePath() != null){
toolbarItem.put("imgPath",singleItam.getPSSysImage().getImagePath());
}
if("DEUIACTION".equals(singleItam.getItemType())){
IPSDETBUIActionItem actionItem = (IPSDETBUIActionItem)singleItam;
toolbarItem.put("groupExtractMode",actionItem.getNoPrivDisplayMode());
toolbarItem.put("noPrivDisplayMode",actionItem.getNoPrivDisplayMode());
toolbarItem.put("id",actionItem.getPSAppViewUIAction().getId());
toolbarItem.put("xDataControlName",actionItem.getPSAppViewUIAction().getXDataControlName());
if(actionItem.getPSAppViewUIAction().getPSUIAction() != null){
IPSUIAction UIAction = actionItem.getPSAppViewUIAction().getPSUIAction();
JSONObject appUIAction = new JSONObject();
appUIAction.put("caption",UIAction.getCaption());
if(UIAction.getCapPSLanguageRes() != null && UIAction.getCapPSLanguageRes().getLanResTag() != null){
appUIAction.put("capPSLanguageRes",UIAction.getCapPSLanguageRes().getLanResTag());
}
appUIAction.put("codeName",UIAction.getCodeName());
appUIAction.put("fullCodeName",UIAction.getFullCodeName());
appUIAction.put("name",UIAction.getName());
appUIAction.put("uIActionMode",UIAction.getUIActionMode());
appUIAction.put("uIActionTag",UIAction.getUIActionTag());
appUIAction.put("uIActionType",UIAction.getUIActionType());
toolbarItem.put("uIAction",appUIAction);
}
}
items.add(toolbarItem);
});
viewToolBar.put("items",items);
}
toolBarItems.add(viewToolBar);
}
});
}
} }
...@@ -69,5 +134,10 @@ public class PageModel extends BaseModel{ ...@@ -69,5 +134,10 @@ public class PageModel extends BaseModel{
return ctrlsMap.values(); return ctrlsMap.values();
} }
private Collection<JSONObject> toolBarItems = new ArrayList<>();
public Collection<JSONObject> getViewToolBarItems(){
return toolBarItems;
}
} }
...@@ -11,13 +11,12 @@ ...@@ -11,13 +11,12 @@
viewType: '{{page.viewType}}', viewType: '{{page.viewType}}',
viewStyle: '{{page.viewStyle}}', viewStyle: '{{page.viewStyle}}',
showCaptionBar: '{{page.viewStyle}}', showCaptionBar: '{{page.viewStyle}}',
xDataControlName:'{{page.xDataControlName}}',
viewToolbarModel: [ viewToolbarModel: [
{{#page.ctrls}} {{#page.viewToolBarItems}}
{{#eq controlType "TOOLBAR"}} {{#items}}
{{#psDEToolbarItems}} { id:'{{id}}',name:'{{name}}',caption:'{{caption}}',groupExtractMode:'{{groupExtractMode}}',itemType:'{{itemType}}',noPrivDisplayMode:'{{noPrivDisplayMode}}',showIcon:{{showIcon}},showCaption:{{showCaption}},tooltip:'{{tooltip}}',disabled: false, visible: true, imgPath: '{{imgPath}}',iconClass: '{{iconClass}}',xDataControlName:'{{xDataControlName}}',{{#if uIAction}}uIAction:{codeName:'{{uIAction.codeName}}',fullCodeName:'{{uIAction.fullCodeName}}',uIActionMode:'{{uIAction.uIActionMode}}',uIActionTag:'{{uIAction.uIActionTag}}',uIActionType:'{{uIAction.uIActionType}}'}{{/if}} },
{ name:'{{name}}',caption:'{{caption}}',groupExtractMode:'{{groupExtractMode}}',itemType:'{{itemType}}',noPrivDisplayMode:'{{noPrivDisplayMode}}',showIcon:{{showIcon}},showCaption:{{showCaption}},tooltip:'{{tooltip}}',disabled: false, visible: true,{{#if psUIAction.psSysImage}}{{#if psUIAction.psSysImage.imagePath}} imgPath: "{{psUIAction.psSysImage.imagePath}}",{{/if}}{{#if psUIAction.psSysImage.cssClass}} iconClass: "{{psUIAction.psSysImage.cssClass}}",{{/if}}{{/if}} }, {{/items}}
{{/psDEToolbarItems}} {{/page.viewToolBarItems}}
{{/eq}}
{{/page.ctrls}}
], ],
{{> @macro/front-end/view/common/controlAction.hbs}} {{> @macro/front-end/view/common/controlAction.hbs}}
\ No newline at end of file
<script setup lang="ts"> <script setup lang="ts">
// This starter template is using Vue 3 <script setup> SFCs import { App } from './app';
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup onMounted(()=>{
import {App} from '@service' (window as any).App = App.getInstance();
onMounted(async ()=>{
await App.init();
// App.openViewService.openView({codeName: 'ExampleEditorEditView'},{context: {},viewParams:{}})
}) })
</script> </script>
<template> <template>
<router-view /> <router-view />
</template> </template>
......
export const AppFuncConfig = [
{{#each app.allPSAppFuncs as | func |}}
{
name: "{{func.name}}",
funcTag: "{{func.codeName}}",
appFuncType: "{{func.appFuncType}}",
{{#if (eq func.appFuncType 'OPENHTMLPAGE')}}
htmlPageUrl: "{{func.htmlPageUrl}}",
{{/if}}
{{#if (eq func.appFuncType 'APPVIEW')}}
openMode: "{{func.openMode}}",
viewName: "{{func.psAppView.name}}",
viewCodeName: "{{func.psAppView.codeName}}",
{{/if}}
navParam: {
{{#if func.psNavigateParams}}
{{#each func.psNavigateParams as | param |}}
{{lowerCase param.key}}: "{{#if param.rawValue}}{{param.value}}{{else}}%{{lowerCase param.value}}%{{/if}}",
{{/each}}
{{/if}}
},
navContext: {
{{#if func.psNavigateContexts}}
{{#each func.psNavigateContexts as | context |}}
{{lowerCase context.key}}: "{{#if context.rawValue}}{{context.value}}{{else}}%{{lowerCase context.value}}%{{/if}}",
{{/each}}
{{/if}}
},
},
{{/each}}
]
\ No newline at end of file
{ import { IParam } from "@ibiz-core";
{{#each app.pages as |appView|}}
export const AppViewConfig:IParam = {
{{#each app.pages as |appView|}}
"{{appView.codeName}}":{ "{{appView.codeName}}":{
"name": "{{appView.name}}", "name": "{{appView.name}}",
"codeName": "{{appView.codeName}}", "codeName": "{{appView.codeName}}",
...@@ -25,4 +27,4 @@ ...@@ -25,4 +27,4 @@
"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 @last}},{{/unless}} }{{#unless @last}},{{/unless}}
{{/each}} {{/each}}
} }
\ No newline at end of file
import { OpenViewService } from "@/utils";
import { AppBase, IParam, ViewDetail, IApp, IOpenViewService, deepCopy } from "@ibiz-core";
import { AppFuncConfig } from './app-func-config';
import { AppViewConfig } from './app-view-config';
export class App extends AppBase implements IApp {
/**
* 唯一实例
*
* @private
* @static
* @memberof App
*/
private static readonly instance = new App();
/**
* 获取唯一实例
*
* @static
* @return {*} {App}
* @memberof App
*/
public static getInstance(): App {
return App.instance;
}
/**
* 获取所有应用功能
*
* @return {*} {IParam[]}
* @memberof App
*/
public getAllFuncs(): IParam[] {
return AppFuncConfig;
}
/**
* 获取打开视图服务
*
* @return {*} {IOpenViewService}
* @memberof App
*/
public getOpenViewService(): IOpenViewService {
return OpenViewService.getInstance();
}
/**
* 获取视图信息
*
* @static
* @param codeName 视图codeName
* @return {*}
*/
public getViewInfo(codeName: string): ViewDetail | undefined {
return AppViewConfig[codeName] ? (deepCopy(AppViewConfig[codeName]) as ViewDetail) : undefined;;
}
}
\ No newline at end of file
export const FuncConfig = [
{{#each app.allPSAppFuncs as | func |}}
{
name: "{{func.name}}",
funcTag: "{{func.codeName}}",
appFuncType: "{{func.appFuncType}}",
{{#if (eq func.appFuncType 'OPENHTMLPAGE')}}
htmlPageUrl: "{{func.htmlPageUrl}}",
{{/if}}
{{#if (eq func.appFuncType 'APPVIEW')}}
openMode: "{{func.openMode}}",
viewName: "{{func.psAppView.name}}",
viewCodeName: "{{func.psAppView.codeName}}",
{{/if}}
navParam: {
{{#if func.psNavigateParams}}
{{#each func.psNavigateParams as | param |}}
{{lowerCase param.key}}: "{{#if param.rawValue}}{{param.value}}{{else}}%{{lowerCase param.value}}%{{/if}}",
{{/each}}
{{/if}}
},
navContext: {
{{#if func.psNavigateContexts}}
{{#each func.psNavigateContexts as | context |}}
{{lowerCase context.key}}: "{{#if context.rawValue}}{{context.value}}{{else}}%{{lowerCase context.value}}%{{/if}}",
{{/each}}
{{/if}}
},
},
{{/each}}
]
\ No newline at end of file
export * from './app-func-service';
export * from './app-func-config';
\ No newline at end of file
export * from './interface'; export * from './interface';
export * from './logic';
export * from './modules'; export * from './modules';
export * from './runtime'; export * from './runtime';
export * from './service'; export * from './service';
export * from './utils'; export * from './utils';
export * from './helper'; \ No newline at end of file
\ No newline at end of file
/**
* @description 界面行为对象
* @export
* @interface IUIAction
*/
export interface IUIAction {
/**
* 界面行为模式
* @description 值模式 [云实体界面行为类型] {SYS:系统预定义、 FRONT:前台调用、 BACKEND:后台调用、 WFFRONT:工作流前台调用、 WFBACKEND:工作流后台调用 }
* @type {( string | 'SYS' | 'FRONT' | 'BACKEND' | 'WFFRONT' | 'WFBACKEND')}
*/
uIActionMode: string | 'SYS' | 'FRONT' | 'BACKEND' | 'WFFRONT' | 'WFBACKEND';
/**
* 界面行为标记
* @type {string}
*/
uIActionTag: string;
}
\ No newline at end of file
import { IParam, ViewDetail } from "../common";
import { IAppFuncService, IOpenViewService } from "../logic";
/**
* 应用接口
*
* @export
* @interface IApp
*/
export interface IApp {
/**
* 获取应用所有功能
*
* @return {*} {IParam[]}
* @memberof IApp
*/
getAllFuncs(): IParam[];
/**
* 获取应用功能服务
*
* @return {*} {AppFuncService}
* @memberof IApp
*/
getAppFuncService(): IAppFuncService;
/**
* 获取打开视图服务
*
* @return {*} {IParam}
* @memberof IApp
*/
getOpenViewService(): IOpenViewService;
/**
* 获取指定视图信息
*
* @param {string} codeName
* @return {*} {(ViewDetail | undefined)}
* @memberof IApp
*/
getViewInfo(codeName: string): ViewDetail | undefined
}
\ No newline at end of file
...@@ -7,20 +7,20 @@ ...@@ -7,20 +7,20 @@
export interface ViewDetail { export interface ViewDetail {
/** /**
* 视图名称 * 代码名称
* *
* @type {string} * @type {string}
* @memberof ViewDetail * @memberof ViewDetail
*/ */
name: string; codeName: string;
/** /**
* 代码名称 * 视图名称
* *
* @type {string} * @type {string}
* @memberof ViewDetail * @memberof ViewDetail
*/ */
codeName: string; name?: string;
/** /**
* 视图宽度 * 视图宽度
...@@ -60,7 +60,7 @@ export interface ViewDetail { ...@@ -60,7 +60,7 @@ export interface ViewDetail {
* @type {boolean} * @type {boolean}
* @memberof ViewDetail * @memberof ViewDetail
*/ */
redirectView?: boolean; redirectView?: boolean;
/** /**
* 关系路径 * 关系路径
......
export * from './common' export * from './app';
export * from './app-logic' export * from './common';
\ No newline at end of file export * from './logic';
\ No newline at end of file
import { IContext, IParam } from "@ibiz-core";
/**
* @description 应用功能服务
* @export
* @interface IAppFuncService
*/
export interface IAppFuncService {
/**
* @description 执行应用功能
* @param {IParam} menu 菜单项
* @param {IParam} context 上下文
* @param {IParam} viewParams 视图参数
* @return {*} {*}
* @memberof IAppFuncService
*/
executeAppFunc(menu: IParam, context: IContext, viewParams: IParam): any;
}
\ No newline at end of file
import { IParam, ViewDetail } from "@ibiz-core";
/**
* @description 打开视图服务接口
* @export
* @interface IOpenViewService
*/
export interface IOpenViewService {
/**
* @description 打开视图
* @param {ViewDetail} view 视图对象参数
* @param {IParam} params 打开视图参数
* @return {*} {*}
* @memberof IOpenViewService
*/
openView(view: ViewDetail, params: IParam): any;
}
\ No newline at end of file
export * from './i-app-func-service';
export * from './i-open-view-service';
\ No newline at end of file
import { IParam, FuncConfig, IContext } from "@ibiz-core"; import { IAppFuncService, IParam } from "@ibiz-core";
import { App } from "@service";
export class AppFuncService { export class AppFuncService implements IAppFuncService{
/** /**
* @description 唯一实例 * @description 唯一实例
...@@ -28,8 +27,8 @@ export class AppFuncService { ...@@ -28,8 +27,8 @@ export class AppFuncService {
* @param {IParam} viewParams 视图参数 * @param {IParam} viewParams 视图参数
* @memberof AppFuncService * @memberof AppFuncService
*/ */
executeAppFunc(menu: IParam, context: IContext, viewParams: IParam) { executeAppFunc(menu: IParam, context: IParam, viewParams: IParam) {
const appFunc = FuncConfig.find((func: IParam)=> Object.is(func.funcTag, menu.funcTag)); const appFunc = App.getAllFuncs().find((func: IParam)=> Object.is(func.funcTag, menu.funcTag));
if (appFunc) { if (appFunc) {
switch (appFunc.appFuncType) { switch (appFunc.appFuncType) {
case 'APPVIEW': case 'APPVIEW':
...@@ -57,7 +56,7 @@ export class AppFuncService { ...@@ -57,7 +56,7 @@ export class AppFuncService {
* @param {IParam} viewParams 视图参数 * @param {IParam} viewParams 视图参数
* @memberof AppFuncService * @memberof AppFuncService
*/ */
private executeCustomFunc(appFunc: IParam, context: IContext, viewParams: IParam) { executeCustomFunc(appFunc: IParam, context: IParam, viewParams: IParam) {
console.warn(`${appFunc.appFuncType} 类型应用功能暂未支持`); console.warn(`${appFunc.appFuncType} 类型应用功能暂未支持`);
} }
...@@ -68,7 +67,7 @@ export class AppFuncService { ...@@ -68,7 +67,7 @@ export class AppFuncService {
* @param {IParam} viewParams 视图参数 * @param {IParam} viewParams 视图参数
* @memberof AppFuncService * @memberof AppFuncService
*/ */
private executeJavaScript(appFunc: IParam, context: IContext, viewParams: IParam) { executeJavaScript(appFunc: IParam, context: IParam, viewParams: IParam) {
console.warn(`${appFunc.appFuncType} 类型应用功能暂未支持`); console.warn(`${appFunc.appFuncType} 类型应用功能暂未支持`);
} }
...@@ -80,7 +79,7 @@ export class AppFuncService { ...@@ -80,7 +79,7 @@ export class AppFuncService {
* @param {IParam} viewParams 视图参数 * @param {IParam} viewParams 视图参数
* @memberof AppFuncService * @memberof AppFuncService
*/ */
private executePresetFunc(appFunc: IParam, context: IContext, viewParams: IParam) { executePresetFunc(appFunc: IParam, context: IParam, viewParams: IParam) {
console.warn(`${appFunc.appFuncType} 类型应用功能暂未支持`); console.warn(`${appFunc.appFuncType} 类型应用功能暂未支持`);
} }
...@@ -91,7 +90,7 @@ export class AppFuncService { ...@@ -91,7 +90,7 @@ export class AppFuncService {
* @param {IParam} viewParams 视图参数 * @param {IParam} viewParams 视图参数
* @memberof AppFuncService * @memberof AppFuncService
*/ */
private openHtmlPage(appFunc: IParam, context: IContext, viewParams: IParam) { openHtmlPage(appFunc: IParam, context: IParam, viewParams: IParam) {
window.open(appFunc.htmlPageUrl, '_blank'); window.open(appFunc.htmlPageUrl, '_blank');
} }
...@@ -102,9 +101,8 @@ export class AppFuncService { ...@@ -102,9 +101,8 @@ export class AppFuncService {
* @param {IParam} viewParams 视图参数 * @param {IParam} viewParams 视图参数
* @memberof AppFuncService * @memberof AppFuncService
*/ */
private openAppView(appFunc: IParam, context: IContext, viewParams: IParam) { openAppView(appFunc: IParam, context: IParam, viewParams: IParam) {
const view = { const view = {
name: appFunc.viewName,
codeName: appFunc.viewCodeName, codeName: appFunc.viewCodeName,
openMode: appFunc.openMode, openMode: appFunc.openMode,
} }
...@@ -112,6 +110,6 @@ export class AppFuncService { ...@@ -112,6 +110,6 @@ export class AppFuncService {
context: context, context: context,
viewParams: viewParams, viewParams: viewParams,
} }
App.openViewService.openView(view, params); App.getOpenViewService().openView(view, params);
} }
} }
\ No newline at end of file
import { IContext, IParam } from "@ibiz-core";
/**
* 后台界面行为
*
* @export
* @class AppBackendAction
*/
export class AppBackendAction {
/**
* 执行后台界面行为
*
* @static
* @param {IParam} uiAction 界面行为对象
* @param {context: IContext, viewParams: IParam, data: IParam, event: MouseEvent, actionEnvironment:IParam} params { context: 上下文对象, viewParams: 视图参数, data: 当前激活数据, event: 事件源对象, actionEnvironment:操作环境}
* @memberof AppBackendAction
*/
public static async execute(uiAction: IParam, params: { context: IContext, viewParams: IParam, data: IParam, event: MouseEvent, actionEnvironment:IParam}) {
// TODO 执行后台界面行为
console.log(uiAction,params);
}
}
import { IContext, IParam } from "@ibiz-core";
/**
* 前台界面行为
*
* @export
* @class AppFrontAction
*/
export class AppFrontAction {
/**
* 执行前台界面行为
*
* @static
* @param {IParam} uiAction 界面行为对象
* @param { context: IContext, viewParams: IParam, data: IParam, event: MouseEvent, actionEnvironment:IParam} params { context: 上下文对象, viewParams: 视图参数, data: 当前激活数据, event: 事件源对象, actionEnvironment:操作环境}
* @memberof AppBackendAction
*/
public static async execute(uiAction: IParam, params: { context: IContext, viewParams: IParam, data: IParam, event: MouseEvent, actionEnvironment: IParam }) {
// TODO 前台界面行为
console.log(uiAction,params);
}
}
import { IContext, IParam } from "@ibiz-core";
/**
* 系统预置界面行为
*
* @export
* @class AppSysAction
*/
export class AppSysAction {
/**
* 执行预置界面行为
*
* @static
* @param {IParam} uiAction 界面行为对象
* @param { context: IContext, viewParams: IParam, data: IParam, event: MouseEvent, actionEnvironment:IParam} params { context: 上下文对象, viewParams: 视图参数, data: 当前激活数据, event: 事件源对象, actionEnvironment:操作环境}
* @memberof AppBackendAction
*/
public static async execute(uiAction: IParam, params: { context: IContext, viewParams: IParam, data: IParam, event: MouseEvent, actionEnvironment: IParam }) {
// TODO 预置界面行为
console.log(uiAction,params);
}
}
import { IContext, IParam } from '@ibiz-core';
import { AppBackendAction } from './app-backend-action'; import { AppBackendAction } from './app-backend-action';
import { AppFrontAction } from './app-front-action'; import { AppFrontAction } from './app-front-action';
import { IUIAction } from "@ibiz-core";
import { AppSysAction } from './app-sys-action'; import { AppSysAction } from './app-sys-action';
/** /**
...@@ -14,9 +14,9 @@ export class AppUIAction { ...@@ -14,9 +14,9 @@ export class AppUIAction {
* 执行界面行为 * 执行界面行为
* *
* @param uiAction 界面行为信息 * @param uiAction 界面行为信息
* @param params 运行参数 * @param params 运行参数 { context: 上下文对象, viewParams: 视图参数, data: 当前激活数据, event: 事件源对象, actionEnvironment:操作环境}
*/ */
public static executeUIAction(uiAction: IUIAction, params: any){ public static execute(uiAction: IParam, params: { context: IContext, viewParams: IParam, data: IParam, event: MouseEvent, actionEnvironment: IParam }){
if(uiAction.uIActionMode == 'FRONT'){ if(uiAction.uIActionMode == 'FRONT'){
AppFrontAction.execute(uiAction, params); AppFrontAction.execute(uiAction, params);
}else if(uiAction.uIActionMode == 'BACKEND'){ }else if(uiAction.uIActionMode == 'BACKEND'){
...@@ -24,7 +24,7 @@ export class AppUIAction { ...@@ -24,7 +24,7 @@ export class AppUIAction {
}else if(uiAction.uIActionMode == 'SYS'){ }else if(uiAction.uIActionMode == 'SYS'){
AppSysAction.execute(uiAction, params); AppSysAction.execute(uiAction, params);
}else{ }else{
// TODO 工作流界面行为 console.warn("非(前台界面行为、后台界面行为、系统预置界面行为)暂未支持");
} }
} }
} }
export * from './app-logic';
export * from './app-ui-action';
\ No newline at end of file
import { IUIAction } from '@ibiz-core';
/**
* 界面行为参数
* @interface UIActionParams
*/
interface UIActionParams{
args: any[],
context: any,
params: any,
$event?: any,
xData?: any,
actionContext?: any,
srfParentDeName?: string,
deUIService?: any,
}
export class AppBackendAction {
/**
* 执行界面行为
*
* @param args
* @param context
* @param params
* @param $event
* @param xData
* @param actionContext
* @param srfParentDeName
*
* @memberof AppBackendAction
*/
public static async execute(uiAction:IUIAction, params: any) {
// TODO 后台调用
}
}
import { IUIAction } from '@ibiz-core';
/**
* 界面行为参数
* @interface UIActionParams
*/
interface UIActionParams{
args: any[],
context: any,
params: any,
$event?: any,
xData?: any,
actionContext?: any,
srfParentDeName?: string,
deUIService?: any,
}
export class AppFrontAction {
/**
* 执行界面行为
*
* @param args
* @param context
* @param params
* @param $event
* @param xData
* @param actionContext
* @param srfParentDeName
*
* @memberof AppFrontAction
*/
public static async execute(uiAction:IUIAction, params: any) {
// TODO 前台调用
}
}
import { IUIAction } from '@ibiz-core';
/**
* 界面行为参数
* @interface UIActionParams
*/
interface UIActionParams{
args: any[],
context: any,
params: any,
$event?: any,
xData?: any,
actionContext?: any,
srfParentDeName?: string,
deUIService?: any,
}
export class AppSysAction {
/**
* 执行界面行为
*
* @param args
* @param context
* @param params
* @param $event
* @param xData
* @param actionContext
* @param srfParentDeName
*
* @memberof AppSysAction
*/
public static async execute(uiAction:IUIAction, params: any) {
// TODO 系统预置调用
}
}
import { AppFuncService, IApp, IAppFuncService, IOpenViewService, ViewDetail } from "@ibiz-core";
import { IParam } from "@ibiz-core/interface";
/**
* 应用基类
*
* @export
* @class AppBase
*/
export abstract class AppBase implements IApp {
/**
* 应用功能服务
*
* @private
* @type {AppFuncService}
* @memberof AppBase
*/
private appFuncService: AppFuncService = AppFuncService.getInstance();
/**
* 获取应用功能服务
*
* @return {IAppFuncService}
* @memberof AppBase
*/
public getAppFuncService(): IAppFuncService {
return this.appFuncService;
}
/**
* 获取打开视图服务
*
* @return {*} {IOpenViewService}
* @memberof AppBase
*/
public getOpenViewService(): IOpenViewService {
throw new Error("Method not implemented.");
}
/**
* 获取所有应用功能
*
* @return {*} {IParam[]}
* @memberof AppBase
*/
public getAllFuncs(): IParam[] {
return [];
}
/**
* 获取视图信息
*
* @param codeName 视图codeName
*/
public getViewInfo(codeName: string): ViewDetail | undefined {
return undefined;
}
}
\ No newline at end of file
import { computedNavData, ControlPropsBase, ControlStateBase, IParam, toOneWayRef, useContextParams } from '@ibiz-core'; import { toRefs } from 'vue';
import { RouteLocationNormalizedLoaded, Router, useRoute, useRouter } from 'vue-router'; import { UIUtil, IParam, useContextParams } from '@ibiz-core';
/** /**
* @description 部件基类 * @description 部件基类
* @export * @export
...@@ -22,11 +21,11 @@ export class EditorBase { ...@@ -22,11 +21,11 @@ export class EditorBase {
navViewParam: viewParams.value, navViewParam: viewParams.value,
} }
if (localContext && Object.keys(localContext).length > 0) { if (localContext && Object.keys(localContext).length > 0) {
const _context = computedNavData(data, navParams.navContext, navParams.navViewParam, localContext); const _context = UIUtil.computedNavData(data, navParams.navContext, navParams.navViewParam, localContext);
Object.assign(navParams.navContext, _context); Object.assign(navParams.navContext, _context);
} }
if (localParam && Object.keys(localParam).length > 0) { if (localParam && Object.keys(localParam).length > 0) {
const _param = computedNavData(data, navParams.navContext, navParams.navViewParam, localParam); const _param = UIUtil.computedNavData(data, navParams.navContext, navParams.navViewParam, localParam);
Object.assign(navParams.navViewParam, _param); Object.assign(navParams.navViewParam, _param);
} }
return navParams; return navParams;
......
export * from './common' export * from './common'
export * from './app'
export * from './views' export * from './views'
export * from './widgets' export * from './widgets'
export * from './editor' export * from './editor'
export * from './app-logic'
\ No newline at end of file
import { ViewBase, MainViewProps, MainViewState, IActionParam } from '@ibiz-core'; import { ViewBase, MainViewProps, MainViewState, IActionParam, IParam, AppUIAction } from '@ibiz-core';
/** /**
* 实体部件 * 实体部件
...@@ -7,17 +7,25 @@ import { ViewBase, MainViewProps, MainViewState, IActionParam } from '@ibiz-core ...@@ -7,17 +7,25 @@ import { ViewBase, MainViewProps, MainViewState, IActionParam } from '@ibiz-core
*/ */
export class MainView extends ViewBase { export class MainView extends ViewBase {
/** /**
* 部件状态 * 视图状态数据
*/ */
public declare viewState: MainViewState; public declare viewState: MainViewState;
/**
* 当前视图具有数据能力部件
*
* @type {IParam}
* @memberof MainView
*/
public declare xDataControl: IParam;
/** /**
* 根据props调整设置部件state * 根据props调整设置部件state
* @param props 传入的Props * @param props 传入的Props
*/ */
public setState(props: MainViewProps) { public setState(props: MainViewProps) {
super.setState(props); super.setState(props);
// 只读属性处理:把props的属性的Ref赋给state,以维持响应性。 this.xDataControl = ref(null);
} }
/** /**
...@@ -25,23 +33,41 @@ export class MainView extends ViewBase { ...@@ -25,23 +33,41 @@ export class MainView extends ViewBase {
* @todo * @todo
* @param props * @param props
*/ */
public useOpenData(props: MainViewProps) {} public useOpenData(props: MainViewProps) { }
/** /**
* 打开新建视图功能模块 * 打开新建视图功能模块
* @todo * @todo
* @param props * @param props
*/ */
public useNewData(props: MainViewProps) {} public useNewData(props: MainViewProps) { }
/** /**
* @description 处理工具栏事件 * @description 处理工具栏事件
* @param {IActionParam} actionParam * @param {IActionParam} actionParam
* @memberof MainView * @memberof MainView
*/ */
public handleToolbarEvent(actionParam: IActionParam) { public handleToolbarEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam; const { tag, action, data } = actionParam;
//todo if (!tag || !action || !data) {
console.warn("工具栏执行参数不足");
return;
}
const { xDataControlName, uIAction } = data;
if (!xDataControlName || !uIAction) {
console.warn("工具栏执行参数不足");
return;
}
// 准备参数
const inputParam = {
context: this.viewState.context,
viewParams: this.viewState.viewParams,
data: this.xDataControl?.value?.data,
event: data.event,
actionEnvironment: this
};
// 执行行为
AppUIAction.execute(uIAction, inputParam);
} }
public handleCtrlEvent(actionParam: IActionParam) { public handleCtrlEvent(actionParam: IActionParam) {
...@@ -64,6 +90,7 @@ export class MainView extends ViewBase { ...@@ -64,6 +90,7 @@ export class MainView extends ViewBase {
return { return {
...superParams, ...superParams,
state: this.viewState, state: this.viewState,
xDataControl: this.xDataControl,
handleToolbarEvent: this.handleToolbarEvent.bind(this), handleToolbarEvent: this.handleToolbarEvent.bind(this),
handleCtrlEvent: this.handleCtrlEvent.bind(this), handleCtrlEvent: this.handleCtrlEvent.bind(this),
}; };
......
import { Subject } from "rxjs"; import { Subject } from "rxjs";
import { IActionParam, IParam, IContext } from "@ibiz-core"; import { IActionParam, IParam } from "@ibiz-core";
/** /**
* @description 视图props的基类 * @description 视图props的基类
...@@ -13,7 +13,7 @@ export interface ViewPropsBase { ...@@ -13,7 +13,7 @@ export interface ViewPropsBase {
* @type {IParam} * @type {IParam}
* @memberof ViewPropsBase * @memberof ViewPropsBase
*/ */
context?: IContext; context?: IParam;
/** /**
* @description 视图参数(外部传入) * @description 视图参数(外部传入)
......
import { Subject } from "rxjs"; import { Subject } from "rxjs";
import { IActionParam, IParam, IContext } from '@ibiz-core'; import { IActionParam, IParam } from '@ibiz-core';
/** /**
* @description 视图基类状态 * @description 视图基类状态
...@@ -24,10 +24,10 @@ export interface ViewStateBase { ...@@ -24,10 +24,10 @@ export interface ViewStateBase {
/** /**
* @description 上下文参数 * @description 上下文参数
* @type {IContext} * @type {IParam}
* @memberof ViewStateBase * @memberof ViewStateBase
*/ */
context: IContext; context: IParam;
/** /**
* @description 视图参数 * @description 视图参数
......
import { Subject } from "rxjs"; import { Subject } from "rxjs";
import { IActionParam, IParam, IContext } from "@ibiz-core"; import { IActionParam, IParam } from "@ibiz-core";
/** /**
* @description 部件props的基类 * @description 部件props的基类
...@@ -10,10 +10,10 @@ export interface ControlPropsBase { ...@@ -10,10 +10,10 @@ export interface ControlPropsBase {
/** /**
* @description 上下文参数(外部传入) * @description 上下文参数(外部传入)
* @type {IContext} * @type {IParam}
* @memberof ControlPropsBase * @memberof ControlPropsBase
*/ */
context?: IContext; context?: IParam;
/** /**
* @description 视图参数(外部传入) * @description 视图参数(外部传入)
......
import { IActionParam, IParam, IContext } from "@ibiz-core"; import { IActionParam, IParam } from "@ibiz-core";
import { Subject } from "rxjs"; import { Subject } from "rxjs";
/** /**
...@@ -27,7 +27,7 @@ export interface ControlStateBase { ...@@ -27,7 +27,7 @@ export interface ControlStateBase {
* @type {IParam} * @type {IParam}
* @memberof ControlStateBase * @memberof ControlStateBase
*/ */
context: IContext; context: IParam;
/** /**
* @description 视图参数 * @description 视图参数
......
...@@ -13,7 +13,7 @@ export interface GridControlState extends MainControlState { ...@@ -13,7 +13,7 @@ export interface GridControlState extends MainControlState {
* @type {IParam[]} * @type {IParam[]}
* @memberof GridControlState * @memberof GridControlState
*/ */
data: IParam[]; items: IParam[];
/** /**
* @description 表格列模型 * @description 表格列模型
...@@ -34,7 +34,7 @@ export interface GridControlState extends MainControlState { ...@@ -34,7 +34,7 @@ export interface GridControlState extends MainControlState {
* @type {IParam} * @type {IParam}
* @memberof GridControlState * @memberof GridControlState
*/ */
rules: IParam[]; rules: IParam;
/** /**
* @description 是否多选 * @description 是否多选
...@@ -79,31 +79,93 @@ export interface GridControlState extends MainControlState { ...@@ -79,31 +79,93 @@ export interface GridControlState extends MainControlState {
selectFirstDefault: boolean; selectFirstDefault: boolean;
/** /**
* @description 表格聚合 * @description 当前页
* @type {IParam} * @type {number}
* @memberof GridControlState * @memberof GridControlState
*/ */
gridAgg: IParam; current: number;
/** /**
* @description 表格分组 * @description 分页大小
* @type {IParam} * @type {number}
* @memberof GridControlState * @memberof GridControlState
*/ */
gridGroup: IParam; pageSize: number;
/** /**
* @description 表格排序 * @description 是否启用分页
* @type {IParam} * @type {boolean}
* @memberof GridControlState * @memberof GridControlState
*/ */
gridSort: IParam; enablePagingBar: boolean;
/** /**
* @description 表格分页 * @description 数据聚合
* @type {IParam} * @type {IParam}
* @memberof GridControlState * @memberof GridControlState
*/ */
gridPaging: IParam dataAgg: string[];
/**
* @description 聚合模式
* @type {string}
* @memberof GridControlState
*/
aggMode: string;
/**
* @description 聚合实体
* @type {string}
* @memberof GridControlState
*/
aggEntity: string,
/**
* @description 聚合数据集
* @type {string}
* @memberof GridControlState
*/
aggDataSet: string,
/**
* @description 分组模式
* @type {string}
* @memberof GridControlState
*/
groupMode: string;
/**
* @description 分组属性
* @type {string}
* @memberof GridControlState
*/
groupField: string;
/**
* @description 分组代码表
* @type {*}
* @memberof GridControlState
*/
groupCodeList: any;
/**
* @description 禁用排序
* @type {boolean}
* @memberof GridControlState
*/
noSort: boolean;
/**
* @description 排序方向
* @type {string}
* @memberof GridControlState
*/
minorSortDir: string;
/**
* @description 排序属性
* @type {string}
* @memberof GridControlState
*/
minorSortPSDEF: string;
} }
...@@ -35,11 +35,4 @@ export interface MainControlState extends ControlStateBase { ...@@ -35,11 +35,4 @@ export interface MainControlState extends ControlStateBase {
* @memberof MainControlState * @memberof MainControlState
*/ */
UIService: IParam; UIService: IParam;
/**
* @description 应用实体codeName
* @type {string}
* @memberof MainControlState
*/
appDeCodeName: string;
} }
\ No newline at end of file
import { Ref } from 'vue'; import { Ref } from 'vue';
import { MenuControlProps, MenuControlState, IActionParam, ControlBase, IParam, AppFuncService, deepCopy } from '@ibiz-core'; import { MenuControlProps, MenuControlState, IActionParam, ControlBase, IParam, AppFuncService, deepCopy } from '@ibiz-core';
import { App } from '@service';
/** /**
* @description 菜单部件 * @description 菜单部件
...@@ -165,7 +164,7 @@ export class MenuControl extends ControlBase { ...@@ -165,7 +164,7 @@ export class MenuControl extends ControlBase {
*/ */
public menuClick(item: IParam) { public menuClick(item: IParam) {
const { context, viewParams } = this.controlState; const { context, viewParams } = this.controlState;
App.appFuncService.executeAppFunc(item, deepCopy(context), deepCopy(viewParams)); App.getAppFuncService().executeAppFunc(item, deepCopy(context), deepCopy(viewParams));
} }
/** /**
......
...@@ -13,7 +13,7 @@ export class GridService<T extends ControlVOBase> extends ControlServiceBase<T> ...@@ -13,7 +13,7 @@ export class GridService<T extends ControlVOBase> extends ControlServiceBase<T>
* @description 加载草稿 * @description 加载草稿
* @param {IParam} context 上下文 * @param {IParam} context 上下文
* @param {IParam} data 行为数据 * @param {IParam} data 行为数据
* @param \{{ action: string; isLoading?: boolean }} opts 行为参数 * @param { action: string; isLoading?: boolean } opts 行为参数
* @return {*} {Promise<any>} * @return {*} {Promise<any>}
* @memberof GridService * @memberof GridService
*/ */
...@@ -33,14 +33,14 @@ export class GridService<T extends ControlVOBase> extends ControlServiceBase<T> ...@@ -33,14 +33,14 @@ export class GridService<T extends ControlVOBase> extends ControlServiceBase<T>
* @description 加载数据 * @description 加载数据
* @param {IParam} context 上下文 * @param {IParam} context 上下文
* @param {IParam} data 行为数据 * @param {IParam} data 行为数据
* @param \{{ action: string; isLoading?: boolean }} opts 行为参数 * @param { action: string; isLoading?: boolean } opts 行为参数
* @return {*} {Promise<any>} * @return {*} {Promise<any>}
* @memberof GridService * @memberof GridService
*/ */
public async get(context: IParam, data: IParam, opts: { action: string; isLoading?: boolean }): Promise<any> { public async get(context: IParam, data: IParam, opts: { action: string; isLoading?: boolean }): Promise<any> {
let _entityService: any = this.entityService; let _entityService: any = this.entityService;
const { context: Context, data: Data } = this.handleRequestData(context, data, opts); const { context: Context, data: Data } = this.handleRequestData(context, data, opts);
const action = hasFunction(_entityService, opts.action) ? opts.action : 'FetchDefault'; const action = hasFunction(_entityService, opts.action) ? opts.action : 'GET';
const response = await _entityService[action](Context, Data, opts.isLoading); const response = await _entityService[action](Context, Data, opts.isLoading);
//this.setCopynativeData(response.data); //this.setCopynativeData(response.data);
response.data?.forEach((item: IParam) =>{ response.data?.forEach((item: IParam) =>{
...@@ -53,7 +53,7 @@ export class GridService<T extends ControlVOBase> extends ControlServiceBase<T> ...@@ -53,7 +53,7 @@ export class GridService<T extends ControlVOBase> extends ControlServiceBase<T>
* @description 新建数据 * @description 新建数据
* @param {IParam} context 上下文 * @param {IParam} context 上下文
* @param {IParam} data 行为数据 * @param {IParam} data 行为数据
* @param \{{ action: string; isLoading?: boolean }} opts 行为参数 * @param { action: string; isLoading?: boolean } opts 行为参数
* @return {*} {Promise<any>} * @return {*} {Promise<any>}
* @memberof GridService * @memberof GridService
*/ */
...@@ -70,7 +70,7 @@ export class GridService<T extends ControlVOBase> extends ControlServiceBase<T> ...@@ -70,7 +70,7 @@ export class GridService<T extends ControlVOBase> extends ControlServiceBase<T>
* @description 删除数据 * @description 删除数据
* @param {IParam} context 上下文 * @param {IParam} context 上下文
* @param {IParam} data 行为数据 * @param {IParam} data 行为数据
* @param \{{ action: string; isLoading?: boolean }} opts 行为参数 * @param { action: string; isLoading?: boolean } opts 行为参数
* @return {*} {Promise<any>} * @return {*} {Promise<any>}
* @memberof GridService * @memberof GridService
*/ */
...@@ -87,7 +87,7 @@ export class GridService<T extends ControlVOBase> extends ControlServiceBase<T> ...@@ -87,7 +87,7 @@ export class GridService<T extends ControlVOBase> extends ControlServiceBase<T>
* @description 更新 * @description 更新
* @param {*} context 上下文 * @param {*} context 上下文
* @param {*} data 行为数据 * @param {*} data 行为数据
* @param \{{ action: string; isLoading?: boolean }} opts 行为参数 * @param { action: string; isLoading?: boolean } opts 行为参数
* @return {*} {Promise<any>} * @return {*} {Promise<any>}
* @memberof GridService * @memberof GridService
*/ */
......
import { Http, RouteTool } from '@ibiz-core'; import { Http, RouteUtil } from '@ibiz-core';
/** /**
* 实体服务基类 * 实体服务基类
* @export * @export
...@@ -30,7 +30,7 @@ export class EntityService{ ...@@ -30,7 +30,7 @@ export class EntityService{
* @param isSelfAppend 是否拼接实体自身的主键值。 * @param isSelfAppend 是否拼接实体自身的主键值。
*/ */
protected buildDeResPath(context: any, isSelfAppend: boolean){ protected buildDeResPath(context: any, isSelfAppend: boolean){
let deResPath = RouteTool.buildDeResRequestPath(context,this.deResPaths); let deResPath = RouteUtil.buildDeResRequestPath(context,this.deResPaths);
// 不需要自身的主键值的删除末尾/xxxx // 不需要自身的主键值的删除末尾/xxxx
if(!isSelfAppend){ if(!isSelfAppend){
deResPath = deResPath.substring(0,deResPath.lastIndexOf("/")) deResPath = deResPath.substring(0,deResPath.lastIndexOf("/"))
......
export * from './util'; export * from './util';
export * from './view-util'; export * from './ui';
export * from './route-tool'; export * from './net';
export { Http } from './net/http'; \ No newline at end of file
\ No newline at end of file
export { RouteUtil } from './route-util';
export { UIUtil } from './ui-util';
\ No newline at end of file
...@@ -5,9 +5,9 @@ import qs from 'qs'; ...@@ -5,9 +5,9 @@ import qs from 'qs';
* 路由相关处理逻辑工具类 * 路由相关处理逻辑工具类
* *
* @export * @export
* @class RouteTool * @class RouteUtil
*/ */
export class RouteTool { export class RouteUtil {
/** /**
* 处理路由路径 * 处理路由路径
...@@ -31,7 +31,7 @@ export class RouteTool { ...@@ -31,7 +31,7 @@ export class RouteTool {
* @static * @static
* @param {Route} route 路由对象 * @param {Route} route 路由对象
* @returns {string} * @returns {string}
* @memberof RouteTool * @memberof RouteUtil
*/ */
public static getIndexRoutePath(route: any): string { public static getIndexRoutePath(route: any): string {
const parameter = route.meta?.parameters?.[0] || { pathName: "apps", parameterName: "app" }; const parameter = route.meta?.parameters?.[0] || { pathName: "apps", parameterName: "app" };
...@@ -54,7 +54,7 @@ export class RouteTool { ...@@ -54,7 +54,7 @@ export class RouteTool {
* @param {*} [viewParam={}] 视图上下文 * @param {*} [viewParam={}] 视图上下文
* @param {any[]} deResPaths 关系实体参数对象数组 * @param {any[]} deResPaths 关系实体参数对象数组
* @returns {string} * @returns {string}
* @memberof RouteTool * @memberof RouteUtil
*/ */
public static getDeResRoutePath(context: any = {}, deResPaths: any[]): string { public static getDeResRoutePath(context: any = {}, deResPaths: any[]): string {
let routePath: string = ''; let routePath: string = '';
...@@ -113,7 +113,7 @@ export class RouteTool { ...@@ -113,7 +113,7 @@ export class RouteTool {
* @param {*} [viewParam={}] 视图上下文 * @param {*} [viewParam={}] 视图上下文
* @param {any[]} deResPaths 关系实体参数对象数组 * @param {any[]} deResPaths 关系实体参数对象数组
* @returns {string} * @returns {string}
* @memberof RouteTool * @memberof RouteUtil
*/ */
public static buildDeResRequestPath(context: any = {}, deResPaths: any[]): string { public static buildDeResRequestPath(context: any = {}, deResPaths: any[]): string {
let routePath: string = ''; let routePath: string = '';
...@@ -186,7 +186,7 @@ export class RouteTool { ...@@ -186,7 +186,7 @@ export class RouteTool {
* @static * @static
* @param {*} params * @param {*} params
* @returns {*} * @returns {*}
* @memberof RouteTool * @memberof RouteUtil
*/ */
public static formatRouteParams(params: any, route: any, context: any, viewparams: any): void { public static formatRouteParams(params: any, route: any, context: any, viewparams: any): void {
Object.keys(params).forEach((key: string, index: number) => { Object.keys(params).forEach((key: string, index: number) => {
...@@ -218,7 +218,7 @@ export class RouteTool { ...@@ -218,7 +218,7 @@ export class RouteTool {
* @private * @private
* @static * @static
* @type {any[]} * @type {any[]}
* @memberof RouteTool * @memberof RouteUtil
*/ */
private static indexParameters: any[] = []; private static indexParameters: any[] = [];
...@@ -227,7 +227,7 @@ export class RouteTool { ...@@ -227,7 +227,7 @@ export class RouteTool {
* *
* @static * @static
* @param {any[]} parameters * @param {any[]} parameters
* @memberof RouteTool * @memberof RouteUtil
*/ */
public static setIndexParameters(parameters: any[]): void { public static setIndexParameters(parameters: any[]): void {
this.indexParameters = [...parameters]; this.indexParameters = [...parameters];
...@@ -238,7 +238,7 @@ export class RouteTool { ...@@ -238,7 +238,7 @@ export class RouteTool {
* *
* @static * @static
* @returns {any[]} * @returns {any[]}
* @memberof RouteTool * @memberof RouteUtil
*/ */
public static getIndexParameters(): any[] { public static getIndexParameters(): any[] {
return this.indexParameters; return this.indexParameters;
...@@ -249,7 +249,7 @@ export class RouteTool { ...@@ -249,7 +249,7 @@ export class RouteTool {
* *
* @static * @static
* @type {*} * @type {*}
* @memberof RouteTool * @memberof RouteUtil
*/ */
public static indexViewParam: any = {}; public static indexViewParam: any = {};
...@@ -258,7 +258,7 @@ export class RouteTool { ...@@ -258,7 +258,7 @@ export class RouteTool {
* *
* @static * @static
* @param {*} [viewParam={}] * @param {*} [viewParam={}]
* @memberof RouteTool * @memberof RouteUtil
*/ */
public static setIndexViewParam(viewParam: any = {}): void { public static setIndexViewParam(viewParam: any = {}): void {
Object.assign(this.indexViewParam, viewParam); Object.assign(this.indexViewParam, viewParam);
...@@ -269,7 +269,7 @@ export class RouteTool { ...@@ -269,7 +269,7 @@ export class RouteTool {
* *
* @static * @static
* @returns {*} * @returns {*}
* @memberof RouteTool * @memberof RouteUtil
*/ */
public static getIndexViewParam(): any { public static getIndexViewParam(): any {
return this.indexViewParam; return this.indexViewParam;
...@@ -282,7 +282,7 @@ export class RouteTool { ...@@ -282,7 +282,7 @@ export class RouteTool {
* @param {*} [data] 传入数据 * @param {*} [data] 传入数据
* @param {*} [ActionModel] 界面行为模型 * @param {*} [ActionModel] 界面行为模型
* @param {*} [UIService] 界面行为服务 * @param {*} [UIService] 界面行为服务
* @memberof RouteTool * @memberof RouteUtil
*/ */
public static calcActionItemAuthState(data: any, ActionModel: any, UIService: any) { public static calcActionItemAuthState(data: any, ActionModel: any, UIService: any) {
let result: any[] = []; let result: any[] = [];
...@@ -334,7 +334,7 @@ export class RouteTool { ...@@ -334,7 +334,7 @@ export class RouteTool {
* @param {*} [data] 传入数据 * @param {*} [data] 传入数据
* @param {*} [ActionModel] 界面行为模型 * @param {*} [ActionModel] 界面行为模型
* @param {*} [UIService] 界面行为服务 * @param {*} [UIService] 界面行为服务
* @memberof RouteTool * @memberof RouteUtil
*/ */
public static calcTreeActionItemAuthState(data: any, ActionModel: any, UIService: any) { public static calcTreeActionItemAuthState(data: any, ActionModel: any, UIService: any) {
let result: any[] = []; let result: any[] = [];
...@@ -384,7 +384,7 @@ export class RouteTool { ...@@ -384,7 +384,7 @@ export class RouteTool {
* @param {*} [tempContext] 上下文 * @param {*} [tempContext] 上下文
* @param {*} [data] 传入数据 * @param {*} [data] 传入数据
* @param {*} [redirectAppEntity] 应用实体对象 * @param {*} [redirectAppEntity] 应用实体对象
* @memberof RouteTool * @memberof RouteUtil
*/ */
public static async calcRedirectContext(tempContext: any, data: any, redirectAppEntity: any) { public static async calcRedirectContext(tempContext: any, data: any, redirectAppEntity: any) {
if ( if (
......
import { IParam } from "@ibiz-core";
/**
* 视图相关处理逻辑工具类
*
* @export
* @class UIUtil
*/
export class UIUtil {
/**
* @description 计算界面行为项权限状态
* @export
* @param {IParam} data 传入数据
* @param {IParam} actionModel 界面行为模型
* @param {*} UIService 界面行为服务
* @return {*}
*/
public static calcActionItemAuthState(data: IParam, actionModel: IParam, UIService: any) {
const result: any[] = [];
if (!UIService) return;
for (const key in actionModel) {
if (!actionModel.hasOwnProperty(key)) {
return result;
}
const item = actionModel[key];
let dataActionResult: any;
if (item && item['dataAccessAction']) {
if (Object.is(item['actionTarget'], 'NONE') || Object.is(item['actionTarget'], '')) {
dataActionResult = UIService.getAllOPPrivs({}, item['dataAccessAction']);
} else {
if (data && Object.keys(data).length > 0) {
dataActionResult = UIService.getAllOPPrivs(data, item['dataAccessAction']);
}
}
} else {
dataActionResult = 1;
}
// 无权限:0;有权限:1
if (dataActionResult === 0) {
// 禁用:1;隐藏:2;隐藏且默认隐藏:6
if (item.getNoPrivDisplayMode === 1) {
item.disabled = true;
}
if (item.getNoPrivDisplayMode === 2 || item.getNoPrivDisplayMode === 6) {
item.visabled = false;
} else {
item.visabled = true;
}
}
if (dataActionResult === 1) {
item.visabled = true;
item.disabled = false;
}
// 返回权限验证的结果
item.dataActionResult = dataActionResult;
result.push(dataActionResult);
}
return result;
}
/**
* @description 计算导航数据
* 先从当前数据目标计算,然后再从当前上下文计算,最后从当前视图参数计算,没有则为null
* @export
* @param {*} data 当前数据目标
* @param {*} parentContext 当前上下文
* @param {*} parentParam 当前视图参数
* @param {*} params 导航参数
* @return {*}
*/
public static computedNavData(data: any, parentContext: any, parentParam: any, params: any): any {
const _data: any = {};
if (params && Object.keys(params).length > 0) {
Object.keys(params).forEach((name: string) => {
if (!name) {
return;
}
let value: string | null = params[name];
if (value && value.toString().startsWith('%') && value.toString().endsWith('%')) {
const key = value.substring(1, value.length - 1).toLowerCase();
if (data && data.hasOwnProperty(key)) {
value = data[key];
} else if (parentContext && parentContext[key]) {
value = parentContext[key];
} else if (parentParam && parentParam[key]) {
value = parentParam[key];
} else {
value = null;
}
}
Object.assign(_data, { [name.toLowerCase()]: value });
});
}
return _data;
}
}
import { IParam } from "@ibiz-core";
/**
* @description 计算界面行为项权限状态
* @export
* @param {IParam} data 传入数据
* @param {IParam} actionModel 界面行为模型
* @param {*} UIService 界面行为服务
* @return {*}
*/
export function calcActionItemAuthState(data: IParam, actionModel: IParam, UIService: any) {
const result: any[] = [];
if (!UIService) return;
for (const key in actionModel) {
if (!actionModel.hasOwnProperty(key)) {
return result;
}
const item = actionModel[key];
let dataActionResult: any;
if (item && item['dataAccessAction']) {
if (Object.is(item['actionTarget'], 'NONE') || Object.is(item['actionTarget'], '')) {
dataActionResult = UIService.getAllOPPrivs({}, item['dataAccessAction']);
} else {
if (data && Object.keys(data).length > 0) {
dataActionResult = UIService.getAllOPPrivs(data, item['dataAccessAction']);
}
}
} else {
dataActionResult = 1;
}
// 无权限:0;有权限:1
if (dataActionResult === 0) {
// 禁用:1;隐藏:2;隐藏且默认隐藏:6
if (item.getNoPrivDisplayMode === 1) {
item.disabled = true;
}
if (item.getNoPrivDisplayMode === 2 || item.getNoPrivDisplayMode === 6) {
item.visabled = false;
} else {
item.visabled = true;
}
}
if (dataActionResult === 1) {
item.visabled = true;
item.disabled = false;
}
// 返回权限验证的结果
item.dataActionResult = dataActionResult;
result.push(dataActionResult);
}
return result;
}
/**
* @description 计算导航数据
* 先从当前数据目标计算,然后再从当前上下文计算,最后从当前视图参数计算,没有则为null
* @export
* @param {*} data 当前数据目标
* @param {*} parentContext 当前上下文
* @param {*} parentParam 当前视图参数
* @param {*} params 导航参数
* @return {*}
*/
export function computedNavData(data: any, parentContext: any, parentParam: any, params: any): any {
const _data: any = {};
if (params && Object.keys(params).length > 0) {
Object.keys(params).forEach((name: string) => {
if (!name) {
return;
}
let value: string | null = params[name];
if (value && value.toString().startsWith('%') && value.toString().endsWith('%')) {
const key = value.substring(1, value.length - 1).toLowerCase();
if (data && data.hasOwnProperty(key)) {
value = data[key];
} else if (parentContext && parentContext[key]) {
value = parentContext[key];
} else if (parentParam && parentParam[key]) {
value = parentParam[key];
} else {
value = null;
}
}
Object.assign(_data, { [name.toLowerCase()]: value });
});
}
return _data;
}
\ No newline at end of file
import { IApp } from "@ibiz-core";
declare global {
const App:IApp
}
\ No newline at end of file
...@@ -29,7 +29,7 @@ interface ViewEmit { ...@@ -29,7 +29,7 @@ interface ViewEmit {
const emit = defineEmits<ViewEmit>(); const emit = defineEmits<ViewEmit>();
// 安装功能模块,提供状态和能力方法 // 安装功能模块,提供状态和能力方法
const { state, handleCtrlEvent } = new GridView(ViewConfig).moduleInstall(props, emit); const { state, handleCtrlEvent, handleToolbarEvent } = new GridView(ViewConfig).moduleInstall(props, emit);
</script> </script>
......
import { AppModal } from '@/utils';
import { Http, deepCopy, ViewDetail } from '@ibiz-core';
import { OpenViewService } from '@service';
import { AppFuncService } from '@ibiz-core';
export class App {
/**
* 打开视图服务
* @static
*/
public static openViewService: OpenViewService = OpenViewService.getInstance();
/**
* 应用功能服务
* @static
*/
public static appFuncService: AppFuncService = AppFuncService.getInstance();
/**
* 打开视图服务
* @static
*/
public static modalService: AppModal = AppModal.getInstance();
/**
* 所有视图信息
*
* @static
*/
public static allViewInfos: any;
/**
* 获取视图信息
*
* @static
* @param codeName 视图codeName
* @return {*}
*/
public static getViewInfo(codeName: string): ViewDetail | undefined {
return App.allViewInfos[codeName] ? (deepCopy(App.allViewInfos[codeName]) as ViewDetail) : 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
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
@use './views'; @use './views';
@use './var'; @use './var';
@use './theme'; @use './theme';
@use '../custom/style' @use './user';
export { AppModal } from './app-modal/app-modal'; export { AppModal } from './app-modal/app-modal';
export { OpenViewService } from './open-view/open-view-service';
import { IParam, RouteTool, ViewDetail } from '@ibiz-core'; import { IContext, IOpenViewService, IParam, RouteUtil, ViewDetail } from '@ibiz-core';
import { App } from '@service';
import router from '@/router'; import router from '@/router';
import { AppModal } from '@/utils'; import { AppModal } from '@/utils';
interface Params extends IParam { interface Params extends IParam {
context: any; context: IContext;
viewParams: any; viewParams: IParam;
} }
/** /**
...@@ -14,7 +13,7 @@ interface Params extends IParam { ...@@ -14,7 +13,7 @@ interface Params extends IParam {
* @export * @export
* @class OpenViewService * @class OpenViewService
*/ */
export class OpenViewService { export class OpenViewService implements IOpenViewService{
/** /**
* 唯一实例 * 唯一实例
* *
...@@ -73,7 +72,7 @@ export class OpenViewService { ...@@ -73,7 +72,7 @@ export class OpenViewService {
// 路由打开视图 // 路由打开视图
if (openMode == 'INDEXVIEWTAB' || openMode == 'POPUPAPP') { if (openMode == 'INDEXVIEWTAB' || openMode == 'POPUPAPP') {
// TODO 视图关系参数处理 // TODO 视图关系参数处理
const routePath = RouteTool.buildUpRoutePath(view, context, viewParams, router.currentRoute.value); const routePath = RouteUtil.buildUpRoutePath(view, context, viewParams, router.currentRoute.value);
if (openMode == 'INDEXVIEWTAB') { if (openMode == 'INDEXVIEWTAB') {
router.push(routePath); router.push(routePath);
} else { } else {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册