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

完善树节点上下文菜单权限

上级 eff84849
......@@ -26,7 +26,7 @@
:filter-node-method="filterNode"
>
<template slot-scope="{ node, data }">
<context-menu :contextMenuStyle="{width: '100%'}" :data="node" :renderContent="renderContextMenu">
<context-menu :ref='data.id' :isBlocked="true" :contextMenuStyle="{width: '100%'}" :data="node" :renderContent="renderContextMenu" @showContext="showContext(data,$event)">
<tooltip transfer style="width: 100%;" max-width="2000" placement="right">
<div class="tree-node" @dblclick="doDefaultAction(node)">
<span class="icon">
......@@ -281,6 +281,14 @@ import UIService from '@/uiservice/ui-service';
</#if>
}
/**
* 备份行为模型
*
* @type any
* @memberof MainTreeBase
*/
public copyActionModel:any;
/**
* 选中数据变更事件
*
......@@ -687,7 +695,7 @@ import UIService from '@/uiservice/ui-service';
<#list ctrl.getPSControls() as childCtrl>
<#if childCtrl.getControlType() == "CONTEXTMENU">
if (tags[0] === "${childCtrl.getOwner().getNodeType()}") {
content = this.renderContextMenu${srfclassname(childCtrl.getOwner().getNodeType()?lower_case)}('${childCtrl.getOwner().getTreeNodeType()}','${childCtrl.getPSAppDataEntity().getCodeName()?lower_case}',copyActionModel);
content = this.renderContextMenu${srfclassname(childCtrl.getOwner().getNodeType()?lower_case)}();
}
</#if>
</#list>
......@@ -702,13 +710,10 @@ import UIService from '@/uiservice/ui-service';
/**
* 绘制${childCtrl.getOwner().getNodeType()}类型右键菜单
*
* @param {*} nodeType 节点类型
* @param {*} appEntityName 应用实体名称
* @param {*} actionModelData 模型数据
* @returns
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public renderContextMenu${srfclassname(childCtrl.getOwner().getNodeType()?lower_case)}(nodeType:string,appEntityName:string,actionModelData:any) {
public renderContextMenu${srfclassname(childCtrl.getOwner().getNodeType()?lower_case)}() {
return (
<@ibizindent blank=12>
${P.getCtrlCode(childCtrl, 'CONTROL.html').code}
......@@ -719,27 +724,46 @@ ${P.getCtrlCode(childCtrl, 'CONTROL.html').code}
</#list>
</#if>
/**
* 显示上下文菜单
*
* @param data 节点数据
* @param event 事件源
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public showContext(data:any,event:any){
let _this:any = this;
this.copyActionModel = Util.deepCopy(this.actionModel);
this.computeNodeState(data,data.nodeType,data.appEntityName).then((res:any) => {
(_this.$refs[data.id] as any).showContextMenu(event.clientX, event.clientY);
});
}
/**
* 计算节点右键权限
*
* @param {*} node
* @param {*} node 节点数据
* @param {*} nodeType 节点类型
* @param {*} appEntityName 应用实体名称
* @returns
* @memberof MainTreeBase
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public computeNodeState(node: any) {
let targetData: any = this.transformData(node);
if(this.nodeModel && Object.keys(this.nodeModel).length > 0) {
Object.keys(this.nodeModel).forEach((name: any) => {
if(this.nodeModel[name] && this.nodeModel[name].uiservice && this.nodeModel[name].uiaction && this.nodeModel[name].uiaction.dataaccaction) {
this.nodeModel[name].isPower = true;
let uiservice: any = new UIService().getService(this.nodeModel[name].uiservice)
let tempUIAction:any = JSON.parse(JSON.stringify(this.nodeModel[name].uiaction));
let result: any[] = ViewTool.calcActionItemAuthState(targetData,[tempUIAction],uiservice);
this.nodeModel[name].uiaction.visabled = tempUIAction.visabled;
this.nodeModel[name].uiaction.disabled = tempUIAction.disabled;
this.nodeModel[name].isPower = result[0] === 1 ? true : false;
}
})
public computeNodeState(node:any,nodeType:string,appEntityName:string) {
if(Object.is(nodeType,"STATIC")){
return;
}
let service:any = await this.appEntityService.getService(appEntityName);
if(this.copyActionModel && Object.keys(this.copyActionModel).length > 0) {
if(service['Get'] && service['Get'] instanceof Function){
let tempContext:any = Util.deepCopy(this.context);
tempContext[appEntityName] = node.srfkey;
let targetData = await this.appEntityService.Get(tempContext,{}, false);
let uiservice:any = await new UIService().getService(appEntityName);
let result: any[] = ViewTool.calcActionItemAuthState(targetData.data,this.copyActionModel,uiservice);
return this.copyActionModel;
}else{
console.warn("获取数据异常");
}
}
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册