提交 7cbf7f5f 编写于 作者: Shine-zwj's avatar Shine-zwj

update:更新应用功能

上级 63cac6ad
......@@ -4,7 +4,7 @@
itemType: "{{item.itemType}}",
expanded: {{item.expanded}},
tooltip: "{{item.tooltip}}",
funcTag: {{#if item.psAppFunc}}"{{item.psAppFunc.id}}"{{else}}''{{/if}},
funcTag: "{{item.psAppFunc.id}}",
hidden: {{#if item.hidden}}true{{else}}false{{/if}},
disableClose: {{#if item.disableClose}}true{{else}}false{{/if}},
{{#if item.counterId}}
......@@ -18,7 +18,7 @@
iconCls: "{{item.psSysImage.cssClass}}",
{{/if}}
{{#if item.psSysImage.imagePath}}
icon: "{{item.psSysImage.imagePath}}",
imgPath: "{{item.psSysImage.imagePath}}",
{{/if}}
{{/if}}
{{#if item.psNavigateContexts}}
......
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}}",
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, FuncConfig } from "@ibiz-core";
import { App } from "@service";
export class AppFuncService {
/**
* @description 唯一实例
* @private
* @static
* @memberof AppFuncService
*/
private static readonly instance = new AppFuncService();
/**
* @description 获取唯一实例
* @static
* @return {*} {AppFuncService}
* @memberof AppFuncService
*/
public static getInstance(): AppFuncService {
return AppFuncService.instance;
}
/**
* @description 执行应用功能
* @param {string} menu 菜单项
* @param {IParam} context 上下文
* @param {IParam} viewParams 视图参数
* @memberof AppFuncService
*/
executeAppFunc(menu: IParam, context: IParam, viewParams: IParam) {
const appFunc = FuncConfig.find((func: IParam)=> Object.is(func.funcTag, menu.funcTag));
if (appFunc) {
switch (appFunc.appFuncType) {
case 'APPVIEW':
return this.openAppView(appFunc, context, viewParams);
case 'OPENHTMLPAGE':
return this.openHtmlPage(appFunc, context, viewParams);
case 'PDTAPPFUNC':
return this.executePresetFunc(appFunc, context, viewParams);
case 'JAVASCRIPT':
return this.executeJavaScript(appFunc, context, viewParams);
case 'CUSTOM':
return this.executeCustomFunc(appFunc, context, viewParams);
default:
console.warn(`${appFunc.appFuncType} 类型应用功能暂未支持`);
}
} else {
console.warn(`菜单项 ${menu.caption} 未配置应用功能`);
}
}
/**
* @description 执行自定义功能
* @param {IParam} appFunc 应用功能
* @param {IParam} context 上下文
* @param {IParam} viewParams 视图参数
* @memberof AppFuncService
*/
executeCustomFunc(appFunc: IParam, context: IParam, viewParams: IParam) {
console.warn(`${appFunc.appFuncType} 类型应用功能暂未支持`);
}
/**
* @description 执行JavaScript
* @param {IParam} appFunc 应用功能
* @param {IParam} context 上下文
* @param {IParam} viewParams 视图参数
* @memberof AppFuncService
*/
executeJavaScript(appFunc: IParam, context: IParam, viewParams: IParam) {
console.warn(`${appFunc.appFuncType} 类型应用功能暂未支持`);
}
/**
* @description 执行预置应用功能
* @static
* @param {IParam} appFunc 应用功能
* @param {IParam} context 上下文
* @param {IParam} viewParams 视图参数
* @memberof AppFuncService
*/
executePresetFunc(appFunc: IParam, context: IParam, viewParams: IParam) {
console.warn(`${appFunc.appFuncType} 类型应用功能暂未支持`);
}
/**
* @description 打开HTML页面
* @param {IParam} appFunc 应用功能
* @param {IParam} context 上下文
* @param {IParam} viewParams 视图参数
* @memberof AppFuncService
*/
openHtmlPage(appFunc: IParam, context: IParam, viewParams: IParam) {
window.open(appFunc.htmlPageUrl, '_blank');
}
/**
* @description 打开应用视图
* @param {IParam} appFunc 应用功能
* @param {IParam} context 上下文
* @param {IParam} viewParams 视图参数
* @memberof AppFuncService
*/
openAppView(appFunc: IParam, context: IParam, viewParams: IParam) {
const view = {
codeName: appFunc.viewCodeName,
openMode: appFunc.openMode,
}
const params = {
context: context,
viewParams: viewParams,
}
App.openViewService.openView(view, params);
}
}
\ No newline at end of file
export * from './app-func-service';
export * from './app-func-config';
\ No newline at end of file
......@@ -2,4 +2,5 @@ export * from './interface';
export * from './modules';
export * from './runtime';
export * from './service';
export * from './utils'
\ No newline at end of file
export * from './utils';
export * from './helper';
\ No newline at end of file
import { Ref } from 'vue';
import { MenuControlProps, MenuControlState, IActionParam, ControlBase, IParam } from '@ibiz-core';
import { MenuControlProps, MenuControlState, IActionParam, ControlBase, IParam, AppFuncService, deepCopy } from '@ibiz-core';
import { App } from '@service';
/**
* @description 菜单部件
......@@ -163,7 +164,8 @@ export class MenuControl extends ControlBase {
* @memberof MenuControl
*/
public menuClick(item: IParam) {
console.log(item);
const { context, viewParams } = this.controlState;
App.appFuncService.executeAppFunc(item, deepCopy(context), deepCopy(viewParams));
}
/**
......
import { AppModal } from '@/utils';
import { Http, deepCopy } from '@ibiz-core';
import { OpenViewService } from '@service';
import { AppFuncService } from '@ibiz-core';
export class App{
export class App {
/**
* 打开视图服务
......@@ -10,6 +11,12 @@ export class App{
*/
public static openViewService: OpenViewService = OpenViewService.getInstance();
/**
* 应用功能服务
* @static
*/
public static appFuncService: AppFuncService = AppFuncService.getInstance();
/**
* 打开视图服务
* @static
......
......@@ -9,7 +9,5 @@ export const CtrlConfig = {
{{>(lookup 'MENUITEM') item=item}}
{{/each}}
],
funcs: [
],
funcs: [],
};
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册