| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
- //MWF.require("MWF.widget.Tree", null, false);
- //MWF.require("MWF.widget.Toolbar", null, false);
- MWF.xApplication.process.Xform.Actionbar = MWF.APPActionbar = new Class({
- Extends: MWF.APP$Module,
- options: {
- "moduleEvents": ["load", "queryLoad", "postLoad", "afterLoad"]
- },
- reload : function(){
- this._loadUserInterface();
- },
- _loadUserInterface: function(){
- // if (this.form.json.mode == "Mobile"){
- // this.node.empty();
- // }else if (COMMON.Browser.Platform.isMobile){
- // this.node.empty();
- // }else{
- this.toolbarNode = this.node.getFirst("div");
- if(!this.toolbarNode)return;
- this.toolbarNode.empty();
- MWF.require("MWF.widget.Toolbar", function(){
- this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {
- "style": this.json.style,
- "onPostLoad" : function(){
- this.fireEvent("afterLoad");
- }.bind(this)
- }, this);
- if (this.json.actionStyles) this.toolbarWidget.css = this.json.actionStyles;
- //alert(this.readonly)
- if( this.json.multiTools ){ //自定义操作和系统操作混合的情况,用 system : true 来区分系统和自定义
- var addReadActionFlag = !this.json.hideSystemTools && !this.json.hideReadedAction; //是否需要增加已阅
- this.json.multiTools.each( function (tool) {
- if( tool.system ){
- if( !this.json.hideSystemTools ){
- if( tool.id === "action_readed" )addReadActionFlag = false;
- this.setToolbars([tool], this.toolbarNode, this.readonly);
- }
- }else{
- this.setCustomToolbars([tool], this.toolbarNode);
- }
- }.bind(this));
- if( addReadActionFlag ){
- var addActions = [
- {
- "type": "MWFToolBarButton",
- "img": "read.png",
- "title": "标记为已阅",
- "action": "readedWork",
- "text": "已阅",
- "id": "action_readed",
- "control": "allowReadProcessing",
- "condition": "",
- "read": true
- }
- ];
- this.setToolbars(addActions, this.toolbarNode, this.readonly);
- }
- this.toolbarWidget.load();
- }else{
- if (this.json.hideSystemTools){
- this.setCustomToolbars(this.json.tools, this.toolbarNode);
- this.toolbarWidget.load();
- }else{
- if (this.json.defaultTools){
- var addActions = [
- {
- "type": "MWFToolBarButton",
- "img": "read.png",
- "title": "标记为已阅",
- "action": "readedWork",
- "text": "已阅",
- "id": "action_readed",
- "control": "allowReadProcessing",
- "condition": "",
- "read": true
- }
- ];
- //this.form.businessData.control.allowReflow =
- //this.json.defaultTools.push(o);
- this.setToolbars(this.json.defaultTools, this.toolbarNode, this.readonly);
- if( !this.json.hideReadedAction ){
- this.setToolbars(addActions, this.toolbarNode, this.readonly);
- }
- this.setCustomToolbars(this.json.tools, this.toolbarNode);
- this.toolbarWidget.load();
- }else{
- MWF.getJSON(this.form.path+"toolbars.json", function(json){
- this.setToolbars(json, this.toolbarNode, this.readonly, true);
- this.setCustomToolbars(this.json.tools, this.toolbarNode);
- this.toolbarWidget.load();
- }.bind(this), null);
- }
- }
- }
- }.bind(this));
- // }
- },
- setCustomToolbars: function(tools, node){
- var path = "../x_component_process_FormDesigner/Module/Actionbar/";
- var iconPath = "";
- if( this.json.customIconStyle ){
- iconPath = this.json.customIconStyle+"/";
- }
- tools.each(function(tool){
- var flag = true;
- if (this.readonly){
- flag = tool.readShow;
- }else{
- flag = tool.editShow;
- }
- if (flag){
- flag = true;
- if (tool.control){
- flag = this.form.businessData.control[tool.control]
- }
- if (tool.condition){
- var hideFlag = this.form.Macro.exec(tool.condition, this);
- flag = !hideFlag;
- }
- if (flag){
- var actionNode = new Element("div", {
- "id": tool.id,
- "MWFnodetype": tool.type,
- "MWFButtonImage": path+""+this.form.options.style+"/custom/"+iconPath+tool.img,
- "title": tool.title,
- "MWFButtonAction": "runCustomAction",
- "MWFButtonText": tool.text
- }).inject(node);
- if( this.json.customIconOverStyle ){
- actionNode.set("MWFButtonImageOver" , path+""+this.form.options.style +"/custom/"+this.json.customIconOverStyle+ "/" +tool.img );
- }
- if( tool.properties ){
- actionNode.set(tool.properties);
- }
- if (tool.actionScript){
- actionNode.store("script", tool.actionScript);
- }
- if (tool.sub){
- var subNode = node.getLast();
- this.setCustomToolbars(tool.sub, subNode);
- }
- }
- }
- }.bind(this));
- },
- setToolbarItem: function(tool, node, readonly, noCondition){
- var path = "../x_component_process_FormDesigner/Module/Actionbar/";
- var flag = true;
- if (tool.control){
- flag = this.form.businessData.control[tool.control]
- }
- if (!noCondition) if (tool.condition){
- var hideFlag = this.form.Macro.exec(tool.condition, this);
- flag = flag && (!hideFlag);
- }
- // if (tool.id == "action_processWork"){
- // if (!this.form.businessData.task){
- // flag = false;
- // }
- // }
- if (tool.id == "action_downloadAll" || tool.id == "action_print"){
- if (!this.form.businessData.work.startTime){
- flag = false;
- }
- }
- if (tool.id == "action_delete"){
- if (!this.form.businessData.work || !this.form.businessData.work.id){
- flag = false;
- }
- }
- if (tool.id == "action_rollback") tool.read = true;
- if (readonly) if (!tool.read) flag = false;
- if (flag){
- var actionNode = new Element("div", {
- "id": tool.id,
- "MWFnodetype": tool.type,
- //"MWFButtonImage": this.form.path+""+this.form.options.style+"/actionbar/"+tool.img,
- "MWFButtonImage": path+(this.options.style||"default") +"/tools/"+ (this.json.style || "default") +"/"+tool.img,
- "title": tool.title,
- "MWFButtonAction": tool.action,
- "MWFButtonText": tool.text
- }).inject(node);
- if( this.json.iconOverStyle ){
- actionNode.set("MWFButtonImageOver" , path+""+(this.options.style||"default")+"/tools/"+( this.json.iconOverStyle || "default" )+"/"+tool.img );
- }
- if( tool.properties ){
- actionNode.set(tool.properties);
- }
- if (tool.sub){
- var subNode = node.getLast();
- this.setToolbars(tool.sub, subNode, readonly, noCondition);
- }
- }
- },
- setToolbars: function(tools, node, readonly, noCondition){
- tools.each(function(tool){
- this.setToolbarItem(tool, node, readonly, noCondition);
- }.bind(this));
- },
- runCustomAction: function(bt){
- var script = bt.node.retrieve("script");
- this.form.Macro.exec(script, this);
- },
- saveWork: function(){
- this.form.saveWork();
- },
- closeWork: function(){
- this.form.closeWork();
- },
- processWork: function(){
- this.form.processWork();
- },
- resetWork: function(){
- this.form.resetWork();
- },
- retractWork: function(e, ev){
- this.form.retractWork(e, ev);
- },
- rerouteWork: function(e, ev){
- this.form.rerouteWork(e, ev);
- },
- deleteWork: function(){
- this.form.deleteWork();
- },
- printWork: function(){
- this.form.printWork();
- },
- readedWork: function(b,e){
- this.form.readedWork(e);
- },
- addSplit: function(e){
- this.form.addSplit(e);
- },
- rollback: function(e){
- this.form.rollback(e);
- },
- downloadAll: function(e){
- this.form.downloadAll(e);
- },
- pressWork: function(e){
- this.form.pressWork(e);
- }
- });
|