MWF.xApplication.query = MWF.xApplication.query || {}; MWF.xApplication.query.Query = MWF.xApplication.query.Query || {}; MWF.require("MWF.widget.Common", null, false); MWF.require("o2.widget.Paging", null, false); MWF.require("MWF.xScript.Macro", null, false); MWF.xDesktop.requireApp("query.Query", "lp.zh-cn", null, false); MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({ Implements: [Options, Events], Extends: MWF.widget.Common, options: { "style": "default", "resizeNode": true, "paging" : "scroll", "perPageCount" : 50, "isload": "true", "export": false, "moduleEvents": ["queryLoad", "postLoad", "postLoadPageData", "postLoadPage", "selectRow", "unselectRow", "queryLoadItemRow", "postLoadItemRow", "queryLoadCategoryRow", "postLoadCategoryRow"] // "actions": { // "lookup": {"uri": "/jaxrs/view/flag/{view}/query/{application}/execute", "method":"PUT"}, // "getView": {"uri": "/jaxrs/view/flag/{view}/query/{application}"} // // }, // "actionRoot": "x_query_assemble_surface" }, initialize: function(container, json, options, app, parentMacro){ //本类有三种事件, //一种是通过 options 传进来的事件,包括 loadView、openDocument、select //一种是用户配置的 事件, 在this.options.moduleEvents 中定义的作为类事件 //还有一种也是用户配置的事件,不在this.options.moduleEvents 中定义的作为 this.node 的DOM事件 this.setOptions(options); this.path = "/x_component_query_Query/$Viewer/"; this.cssPath = "/x_component_query_Query/$Viewer/"+this.options.style+"/css.wcss"; this._loadCss(); this.lp = MWF.xApplication.query.Query.LP; this.app = app; this.container = $(container); this.json = json; this.parentMacro = parentMacro; debugger; this.originalJson = Object.clone(json); this.viewJson = null; this.filterItems = []; this.searchStatus = "none"; //none, custom, default this.items = []; this.selectedItems = []; this.hideColumns = []; this.openColumns = []; this.gridJson = null; if (this.options.isload){ this.init(function(){ this.load(); }.bind(this)); } }, loadView: function(){ if (this.viewJson){ this.reload(); }else{ this.init(function(){ this.load(); }.bind(this)); } }, init: function(callback){ if (this.json.data){ this.viewJson = JSON.decode(this.json.data); if (callback) callback(); }else{ this.getView(callback); } }, load: function(){ this.loadMacro( function () { this._loadModuleEvents(); if (this.fireEvent("queryLoad")){ this._loadUserInterface(); //this._loadStyles(); this._loadDomEvents(); } }.bind(this)) }, _loadUserInterface : function(){ this.loadLayout(); this.createActionbarNode(); this.createSearchNode(); this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null}); if (this.options.resizeNode){ this.setContentHeightFun = this.setContentHeight.bind(this); this.container.addEvent("resize", this.setContentHeightFun); this.setContentHeightFun(); } }, loadLayout: function(){ this.node = new Element("div", {"styles": this.css.node}).inject(this.container); this.actionbarAreaNode = new Element("div", {"styles": this.css.actionbarAreaNode}).inject(this.node); //if (this.options.export) this.exportAreaNode = new Element("div", {"styles": this.css.exportAreaNode}).inject(this.node); this.searchAreaNode = new Element("div", {"styles": this.css.searchAreaNode}).inject(this.node); this.viewAreaNode = new Element("div", {"styles": this.css.viewAreaNode}).inject(this.node); this.viewPageNode = new Element("div", {"styles": this.css.viewPageNode}).inject(this.node); this.viewPageAreaNode = new Element("div", {"styles": this.css.viewPageAreaNode}).inject(this.viewPageNode); }, loadMacro: function (callback) { MWF.require("MWF.xScript.Macro", function () { this.Macro = new MWF.Macro.ViewContext(this); if (callback) callback(); }.bind(this)); }, createExportNode: function(){ if (this.options.export){ MWF.require("MWF.widget.Toolbar", function(){ this.toolbar = new MWF.widget.Toolbar(this.actionbarAreaNode, {"style": "simple"}, this); //this.exportAreaNode var actionNode = new Element("div", { "id": "", "MWFnodetype": "MWFToolBarButton", "MWFButtonImage": this.path+""+this.options.style+"/icon/export.png", "title": this.lp.exportExcel, "MWFButtonAction": "exportView", "MWFButtonText": this.lp.exportExcel }).inject(this.actionbarAreaNode); //this.exportAreaNode this.toolbar.load(); }.bind(this)); //this.exportNode = new Element("button", {"text": this.lp.exportExcel}).inject(this.exportAreaNode); } }, exportView: function(){ var action = MWF.Actions.get("x_query_assemble_surface"); var filterData = this.json.filter ? this.json.filter.clone() : []; if (this.filterItems.length){ this.filterItems.each(function(filter){ filterData.push(filter.data); }.bind(this)); } action.exportViewWithQuery(this.json.viewName, this.json.application, {"filterList": filterData}, function(json){ var uri = action.action.actions.getViewExcel.uri; uri = uri.replace("{flag}", json.data.id); uri = action.action.address+uri; var a = new Element("a", {"href": uri, "target":"_blank"}); a.click(); a.destroy(); }.bind(this)); }, setContentHeight: function(){ var size = this.node.getSize(); var searchSize = this.searchAreaNode.getComputedSize(); var h = size.y-searchSize.totalHeight; //if (this.exportAreaNode){ // var exportSize = this.exportAreaNode.getComputedSize(); // h = h-exportSize.totalHeight; //} if( this.actionbarAreaNode ){ var exportSize = this.actionbarAreaNode.getComputedSize(); h = h-exportSize.totalHeight; } var pageSize = this.viewPageNode.getComputedSize(); h = h-pageSize.totalHeight; this.viewAreaNode.setStyle("height", ""+h+"px"); }, createLoadding: function(){ this.loadingAreaNode = new Element("div", {"styles": this.css.viewLoadingAreaNode}).inject(this.contentAreaNode); new Element("div", {"styles": {"height": "5px"}}).inject(this.loadingAreaNode); var loadingNode = new Element("div", {"styles": this.css.viewLoadingNode}).inject(this.loadingAreaNode); new Element("div", {"styles": this.css.viewLoadingIconNode}).inject(loadingNode); var loadingTextNode = new Element("div", {"styles": this.css.viewLoadingTextNode}).inject(loadingNode); loadingTextNode.set("text", "loading..."); }, createActionbarNode : function(){ this.actionbarAreaNode.empty(); if( typeOf( this.viewJson.actionbarHidden ) === "boolean" ){ if( this.viewJson.actionbarHidden === true || !this.viewJson.actionbarList || !this.viewJson.actionbarList.length )return; this.actionbar = new MWF.xApplication.query.Query.Viewer.Actionbar(this.actionbarAreaNode, this.viewJson.actionbarList[0], this, {}); this.actionbar.load(); }else{ //兼容以前的ExportNode this.createExportNode(); } }, createViewNode: function(data){ this.viewAreaNode.empty(); this.contentAreaNode = new Element("div", {"styles": this.css.contentAreaNode}).inject(this.viewAreaNode); this.viewTable = new Element("table", { "styles": this.css.viewTitleTableNode, "border": "0px", "cellPadding": "0", "cellSpacing": "0" }).inject(this.contentAreaNode); this.createLoadding(); if (this.json.isTitle!=="no"){ this.viewTitleLine = new Element("tr", {"styles": this.css.viewTitleLineNode}).inject(this.viewTable); //if (this.json.select==="single" || this.json.select==="multi") { this.selectTitleCell = new Element("td", { "styles": this.css.viewTitleCellNode }).inject(this.viewTitleLine); this.selectTitleCell.setStyle("width", "10px"); if (this.json.titleStyles) this.selectTitleCell.setStyles(this.json.titleStyles); //} //序号 if (this.viewJson.isSequence==="yes"){ this.sequenceTitleCell = new Element("td", { "styles": this.css.viewTitleCellNode }).inject(this.viewTitleLine); this.sequenceTitleCell.setStyle("width", "10px"); if (this.json.titleStyles) this.sequenceTitleCell.setStyles(this.json.titleStyles); } this.entries = {}; this.viewJson.selectList.each(function(column){ this.entries[column.column] = column; if (!column.hideColumn){ var viewCell = new Element("td", { "styles": this.css.viewTitleCellNode, "text": column.displayName }).inject(this.viewTitleLine); var size = MWF.getTextSize(column.displayName, this.css.viewTitleCellNode); viewCell.setStyle("min-width", ""+size.x+"px"); if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles); }else{ this.hideColumns.push(column.column); } if (column.allowOpen) this.openColumns.push(column.column); }.bind(this)); this.lookup(data); }else{ this.viewJson.selectList.each(function(column){ if (column.hideColumn) this.hideColumns.push(column.column); if (!column.allowOpen) this.openColumns.push(column.column); }.bind(this)); this.lookup(data); } }, // _loadPageCountNode: function(){ // this.viewPageContentNode.empty(); // // var size = this.viewPageAreaNode.getSize(); // var w1 = this.viewPageFirstNode.getSize().x*2; // var w2 = this.viewPageContentNode.getStyle("margin-left").toInt(); // var w = size.x-w1-w2; // // var bw = this.css.viewPageButtonNode.width.toInt()+this.css.viewPageButtonNode["margin-right"].toInt(); // var count = (w/bw).toInt()-2; // if (count>10) count = 10; // this.showPageCount = Math.min(count, this.pages); // // var tmp = this.showPageCount/2; // var n = tmp.toInt(); // var left = this.currentPage-n; // if (left<=0) left = 1; // var right = this.showPageCount + left-1; // if (right>this.pages) right = this.pages; // left = right-this.showPageCount+1; // if (left<=1) left = 1; // // this.viewPagePrevNode = new Element("div", {"styles": this.css.viewPagePrevButtonNode}).inject(this.viewPageContentNode); // this.loadPageButtonEvent(this.viewPagePrevNode, "viewPagePrevButtonNode_over", "viewPagePrevButtonNode_up", "viewPagePrevButtonNode_down", function(){ // if (this.currentPage>1) this.currentPage--; // this.loadCurrentPageData(); // }.bind(this)); // // for (i=left; i<=right; i++){ // var node = new Element("div", {"styles": this.css.viewPageButtonNode, "text": i}).inject(this.viewPageContentNode); // if (i==this.currentPage){ // node.setStyles(this.css.viewPageButtonNode_current); // }else{ // this.loadPageButtonEvent(node, "viewPageButtonNode_over", "viewPageButtonNode_up", "viewPageButtonNode_down", function(e){ // this.currentPage = e.target.get("text").toInt(); // this.loadCurrentPageData(); // }.bind(this)); // } // } // this.viewPageNextNode = new Element("div", {"styles": this.css.viewPageNextButtonNode}).inject(this.viewPageContentNode); // this.loadPageButtonEvent(this.viewPageNextNode, "viewPageNextButtonNode_over", "viewPageNextButtonNode_up", "viewPageNextButtonNode_down", function(){ // if (this.currentPage<=this.pages-1) this.currentPage++; // this.loadCurrentPageData(); // }.bind(this)); // }, // loadPageButtonEvent: function(node, over, out, down, click){ // node.addEvents({ // "mouseover": function(){node.setStyles(this.css[over])}.bind(this), // "mouseout": function(){node.setStyles(this.css[out])}.bind(this), // "mousedown": function(){node.setStyles(this.css[down])}.bind(this), // "mouseup": function(){node.setStyles(this.css[out])}.bind(this), // "click": click // }); // }, // _loadPageNode: function(){ // this.viewPageAreaNode.empty(); // this.viewPageFirstNode = new Element("div", {"styles": this.css.viewPageFirstLastNode, "text": this.lp.firstPage}).inject(this.viewPageAreaNode); // this.viewPageContentNode = new Element("div", {"styles": this.css.viewPageContentNode}).inject(this.viewPageAreaNode); // this.viewPageLastNode = new Element("div", {"styles": this.css.viewPageFirstLastNode, "text": this.lp.lastPage}).inject(this.viewPageAreaNode); // this._loadPageCountNode(); // // this.loadPageButtonEvent(this.viewPageFirstNode, "viewPageFirstLastNode_over", "viewPageFirstLastNode_up", "viewPageFirstLastNode_down", function(){ // this.currentPage = 1; // this.loadCurrentPageData(); // }.bind(this)); // this.loadPageButtonEvent(this.viewPageLastNode, "viewPageFirstLastNode_over", "viewPageFirstLastNode_up", "viewPageFirstLastNode_down", function(){ // this.currentPage = this.pages; // this.loadCurrentPageData(); // }.bind(this)); // }, _loadPageNode : function(){ debugger; this.viewPageAreaNode.empty(); this.paging = new o2.widget.Paging(this.viewPageAreaNode, { countPerPage: this.json.pageSize || this.options.perPageCount, visiblePages: this.viewJson.visiblePages ? this.viewJson.visiblePages.toInt() : 9, currentPage: this.currentPage, itemSize: this.count, pageSize: this.pages, hasNextPage: typeOf( this.viewJson.hasPreNextPage ) === "boolean" ? this.viewJson.hasPreNextPage : true, hasPrevPage: typeOf( this.viewJson.hasPreNextPage ) === "boolean" ? this.viewJson.hasPreNextPage : true, hasTruningBar: typeOf( this.viewJson.hasTruningBar ) === "boolean" ? this.viewJson.hasTruningBar : true, hasBatchTuring: typeOf( this.viewJson.hasBatchTuring ) === "boolean" ? this.viewJson.hasBatchTuring : true, hasFirstPage: typeOf( this.viewJson.hasFirstLastPage ) === "boolean" ? this.viewJson.hasFirstLastPage : true, hasLastPage: typeOf( this.viewJson.hasFirstLastPage ) === "boolean" ? this.viewJson.hasFirstLastPage : true, hasJumper: typeOf( this.viewJson.hasPageJumper ) === "boolean" ? this.viewJson.hasPageJumper : true, hiddenWithDisable: false, hiddenWithNoItem: true, text: { prePage: "", nextPage: "", firstPage: this.lp.firstPage, lastPage: this.lp.lastPage }, onJumpingPage : function( pageNum, itemNum ){ this.currentPage = pageNum; this.loadCurrentPageData(); }.bind(this), onPostLoad : function () { this.setContentHeightFun(); }.bind(this) }); this.paging.load(); }, _initPage: function(){ this.count = this.bundleItems.length; var i = this.count/this.json.pageSize; this.pages = (i.toInt()1){ this.viewTable.deleteRow(-1); } //this.createLoadding(); this.loadViewRes = this.lookupAction.loadView(this.json.name, this.json.application, d, function(json){ this.viewData = json.data; this.fireEvent("postLoadPageData"); if (this.viewJson.group.column){ this.gridJson = json.data.groupGrid; this.loadGroupData(); }else{ this.gridJson = json.data.grid; this.loadData(); } if (this.gridJson.length) this._loadPageNode(); if (this.loadingAreaNode){ this.loadingAreaNode.destroy(); this.loadingAreaNode = null; } this.fireEvent("loadView"); //options 传入的事件 this.fireEvent("postLoadPage"); if(callback)callback(); }.bind(this)); }, loadData: function(){ if (this.gridJson.length){ // if( !this.options.paging ){ this.gridJson.each(function(line, i){ this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this, line, null, i)); }.bind(this)); // }else{ // this.loadPaging(); // } }else{ if (this.viewPageAreaNode) this.viewPageAreaNode.empty(); } }, loadPaging : function(){ this.isItemsLoading = false; this.pageNumber = 0; this.isItemsLoaded = false; this.isSetedScroll = false; this.setScroll(); this.loadDataByPaging() }, setScroll : function(){ if( this.options.paging && !this.isSetedScroll ){ this.contentAreaNode.setStyle("overflow","auto"); this.scrollContainerFun = function(){ var scrollSize = this.contentAreaNode.getScrollSize(); var clientSize = this.contentAreaNode.getSize(); var scrollHeight = scrollSize.y - clientSize.y; //alert( "clientSize.y=" + clientSize.y + " scrollSize.y="+scrollSize.y + " this.contentAreaNode.scrollTop="+this.contentAreaNode.scrollTop); if (this.contentAreaNode.scrollTop + 150 > scrollHeight ) { if (!this.isItemsLoaded) this.loadDataByPaging(); } }.bind(this); this.isSetedScroll = true; this.contentAreaNode.addEvent("scroll", this.scrollContainerFun ) } }, loadDataByPaging : function(){ if( this.isItemsLoading )return; if( !this.isItemsLoaded ){ var from = Math.min( this.pageNumber * this.options.perPageCount , this.gridJson.length); var to = Math.min( ( this.pageNumber + 1 ) * this.options.perPageCount + 1 , this.gridJson.length); this.isItemsLoading = true; for( var i = from; i"+""+""); this.selectTitleCell.setStyle("cursor", "pointer"); this.selectTitleCell.addEvent("click", this.expandOrCollapseAll.bind(this)); } if (this.gridJson.length){ var i = 0; this.gridJson.each(function(data){ this.items.push(new MWF.xApplication.query.Query.Viewer.ItemCategory(this, data, i)); i += data.list.length; }.bind(this)); if (this.json.isExpand=="yes") this.expandOrCollapseAll(); }else{ if (this.viewPageAreaNode) this.viewPageAreaNode.empty(); } }, expandOrCollapseAll: function(){ var icon = this.selectTitleCell.getElement("span"); if (icon.get("html").indexOf("expand.png")===-1){ this.items.each(function(item){ item.collapse(); icon.set("html", ""); }.bind(this)); }else{ this.items.each(function(item, i){ window.setTimeout(function(){ item.expand(); }.bind(this), 10*i+5); icon.set("html", ""); }.bind(this)); } }, getView: function(callback){ this.getLookupAction(function(){ if (this.json.application){ this.getViewRes = this.lookupAction.getView(this.json.viewName, this.json.application, function(json){ this.viewJson = JSON.decode(json.data.data); this.json = Object.merge(this.json, json.data); if (callback) callback(); }.bind(this)); // this.lookupAction.invoke({"name": "getView","async": true, "parameter": {"view": this.json.viewName, "application": this.json.application},"success": function(json){ // this.viewJson = JSON.decode(json.data.data); // this.json = Object.merge(this.json, json.data); // //var viewData = JSON.decode(json.data.data); // if (callback) callback(); // }.bind(this)}); }else{ this.getViewRes = this.lookupAction.getViewById(this.json.viewId, function(json){ this.viewJson = JSON.decode(json.data.data); this.json.application = json.data.query; this.json = Object.merge(this.json, json.data); if (callback) callback(); }.bind(this)); } }.bind(this)); }, getLookupAction: function(callback){ if (!this.lookupAction){ this.lookupAction = MWF.Actions.get("x_query_assemble_surface"); if (callback) callback(); // var _self = this; // MWF.require("MWF.xDesktop.Actions.RestActions", function(){ // this.lookupAction = new MWF.xDesktop.Actions.RestActions("", this.options.actionRoot, ""); // this.lookupAction.getActions = function(actionCallback){ // this.actions = _self.options.actions; // if (actionCallback) actionCallback(); // }; // if (callback) callback(); // }.bind(this)); }else{ if (callback) callback(); } }, hide: function(){ this.node.setStyle("display", "none"); }, reload: function(){ this.node.setStyle("display", "block"); if (this.loadingAreaNode) this.loadingAreaNode.setStyle("display", "block"); this.filterItems.each(function(filter){ filter.destroy(); }.bind(this)); this.filterItems = []; if (this.viewSearchInputNode) this.viewSearchInputNode.set("text", this.lp.searchKeywork); this.closeCustomSearch(); this.viewAreaNode.empty(); this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null}); }, getFilter: function(){ var filterData = []; if (this.searchStatus==="custom"){ if (this.filterItems.length){ this.filterItems.each(function(filter){ filterData.push(filter.data); }.bind(this)); } } if (this.searchStatus==="default"){ var key = this.viewSearchInputNode.get("value"); if (key && key!==this.lp.searchKeywork){ this.viewJson.customFilterList.each(function(entry){ if (entry.formatType==="textValue"){ var d = { "path": entry.path, "value": key, "formatType": entry.formatType, "logic": "or", "comparison": "like" }; filterData.push(d); } if (entry.formatType==="numberValue"){ var v = key.toFloat(); if (!isNaN(v)){ var d = { "path": entry.path, "value": v, "formatType": entry.formatType, "logic": "or", "comparison": "like" }; filterData.push(d); } } }.bind(this)); } } return (filterData.length) ? filterData : null; }, getData: function(){ if (this.selectedItems.length){ var arr = []; this.selectedItems.each(function(item){ arr.push(item.data); }); return arr; }else{ return []; } }, _loadModuleEvents : function(){ debugger; Object.each(this.viewJson.events, function(e, key){ if (e.code){ if (this.options.moduleEvents.indexOf(key)!==-1){ this.addEvent(key, function(event, target){ debugger; return this.Macro.fire(e.code, target || this, event); }.bind(this)); } } }.bind(this)); }, _loadDomEvents: function(){ Object.each(this.viewJson.events, function(e, key){ if (e.code){ if (this.options.moduleEvents.indexOf(key)===-1){ this.node.addEvent(key, function(event){ return this.Macro.fire(e.code, this, event); }.bind(this)); } } }.bind(this)); }, //搜索相关开始 createSearchNode: function(){ if (this.viewJson.customFilterList && this.viewJson.customFilterList.length){ this.searchStatus = "default"; this.loadFilterSearch(); }else{ this.loadSimpleSearch(); } }, loadSimpleSearch: function(){ return false; this.searchSimpleNode = new Element("div", {"styles": this.css.searchSimpleNode}).inject(this.searchAreaNode); this.searchSimpleButtonNode = new Element("div", {"styles": this.css.searchSimpleButtonNode}).inject(this.searchSimpleNode); this.searchSimpleInputNode = new Element("input", {"type":"text", "styles": this.css.searchSimpleInputNode, "value": this.lp.searchKeywork}).inject(this.searchSimpleNode); this.searchSimpleButtonNode.addEvent("click", function(){ this.search(); }.bind(this)); this.searchSimpleInputNode.addEvents({ "focus": function(){ if (this.searchSimpleInputNode.get("value")===this.lp.searchKeywork) this.searchSimpleInputNode.set("value", ""); }.bind(this), "blur": function(){if (!this.searchSimpleInputNode.get("value")) this.searchSimpleInputNode.set("value", this.lp.searchKeywork);}.bind(this), "keydown": function(e){ if (e.code===13) this.search(); }.bind(this) }); }, search: function(){ if (this.gridJson){ var key = this.searchSimpleInputNode.get("value"); var rows = this.viewTable.rows; var first = (this.json.isTitle!=="no") ? 1 : 0; for (var i = first; i1){ var worksAreaNode = this.createWorksArea(); json.data.workCompletedList.each(function(work){ this.createWorkCompletedNode(work, worksAreaNode); }.bind(this)); json.data.workList.each(function(work){ this.createWorkNode(work, worksAreaNode); }.bind(this)); this.showWorksArea(worksAreaNode, e); }else{ } }.bind(this)); }, createWorkNode: function(work, worksAreaNode){ var worksAreaContentNode = worksAreaNode.getLast(); var node = new Element("div", {"styles": this.css.workAreaNode}).inject(worksAreaContentNode); var actionNode = new Element("div", {"styles": this.css.workAreaActionNode, "text": this.view.lp.open}).inject(node); actionNode.store("workId", work.id); actionNode.addEvent("click", function(e){ this.openWork(e.target.retrieve("workId"), e); this.mask.hide(); worksAreaNode.destroy(); }.bind(this)); var areaNode = new Element("div", {"styles": this.css.workAreaLeftNode}).inject(node); var titleNode = new Element("div", {"styles": this.css.workAreaTitleNode, "text": work.title}).inject(areaNode); var contentNode = new Element("div", {"styles": this.css.workAreaContentNode}).inject(areaNode); new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.activity+": "}).inject(contentNode); new Element("div", {"styles": this.css.workAreaContentTextNode, "text": work.activityName}).inject(contentNode); var taskUsers = []; MWF.Actions.get("x_processplatform_assemble_surface").listTaskByWork(work.id, function(json){ json.data.each(function(task){ taskUsers.push(MWF.name.cn(task.person)); }.bind(this)); new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.taskPeople+": "}).inject(contentNode); new Element("div", {"styles": this.css.workAreaContentTextNode, "text": taskUsers.join(", ")}).inject(contentNode); }.bind(this)); }, createWorkCompletedNode: function(work, worksAreaNode){ var worksAreaContentNode = worksAreaNode.getLast(); var node = new Element("div", {"styles": this.css.workAreaNode}).inject(worksAreaContentNode); var actionNode = new Element("div", {"styles": this.css.workAreaActionNode, "text": this.view.lp.open}).inject(node); actionNode.store("workId", work.id); actionNode.addEvent("click", function(e){ this.mask.hide(); var id = e.target.retrieve("workId"); worksAreaNode.destroy(); this.openWorkCompleted(id, e); }.bind(this)); var areaNode = new Element("div", {"styles": this.css.workAreaLeftNode}).inject(node); var titleNode = new Element("div", {"styles": this.css.workAreaTitleNode, "text": work.title}).inject(areaNode); var contentNode = new Element("div", {"styles": this.css.workAreaContentNode}).inject(areaNode); new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.activity+": "}).inject(contentNode); new Element("div", {"styles": this.css.workAreaContentTextNode, "text": this.view.lp.processCompleted}).inject(contentNode); }, createWorksArea: function(){ var worksAreaNode = new Element("div", {"styles": this.css.worksAreaNode}); var worksAreaTitleNode = new Element("div", {"styles": this.css.worksAreaTitleNode}).inject(worksAreaNode); var worksAreaTitleCloseNode = new Element("div", {"styles": this.css.worksAreaTitleCloseNode}).inject(worksAreaTitleNode); worksAreaTitleCloseNode.addEvent("click", function(e){ this.mask.hide(); e.target.getParent().getParent().destroy(); }.bind(this)); var worksAreaContentNode = new Element("div", {"styles": this.css.worksAreaContentNode}).inject(worksAreaNode); return worksAreaNode; }, showWorksArea: function(node, e){ MWF.require("MWF.widget.Mask", null, false); this.mask = new MWF.widget.Mask({"style": "desktop", "loading": false}); this.mask.loadNode(this.view.container); node.inject(this.view.node); this.setWorksAreaPosition(node, e.target); }, setWorksAreaPosition: function(node, td){ var p = td.getPosition(this.view.container); var containerS = this.view.container.getSize(); var containerP = this.view.container.getPosition(this.view.container.getOffsetParent()); var s = node.getSize(); var offX = p.x+s.x-containerS.x; offX = (offX>0) ? offX+20 : 0; var offY = p.y+s.y-containerS.y; offY = (offY>0) ? offY+5 : 0; node.position({ "relativeTo": td, "position": "lefttop", "edge": "lefttop", "offset": { "x": 0-offX, "y": 0-offY } }); }, openWork: function(id, e){ var options = {"workId": id}; this.view.fireEvent("openDocument", [options, this]); //options 传入的事件 layout.desktop.openApplication(e, "process.Work", options); }, openWorkCompleted: function(id, e){ var options = {"workCompletedId": id}; this.view.fireEvent("openDocument", [options, this]); //options 传入的事件 layout.desktop.openApplication(e, "process.Work", options); }, setEvent: function(){ var flag = this.view.json.select || this.view.viewJson.select || "none"; if ( flag ==="single" || flag==="multi"){ this.node.addEvents({ "mouseover": function(){ if (!this.isSelected){ var iconName = "checkbox"; if (flag==="single") iconName = "radiobox"; this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/"+iconName+".png) center center no-repeat"}); } }.bind(this), "mouseout": function(){ if (!this.isSelected) this.selectTd.setStyles({"background": "transparent"}); }.bind(this), "click": function(){this.select();}.bind(this) }); } }, select: function(){ var flag = this.view.json.select || this.view.viewJson.select || "none"; if (this.isSelected){ if (flag==="single"){ this.unSelectedSingle(); }else{ this.unSelected(); } }else{ if (flag==="single"){ this.selectedSingle(); }else{ this.selected(); } } this.view.fireEvent("select"); //options 传入的事件 }, selected: function(){ this.view.selectedItems.push(this); this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/checkbox_checked.png) center center no-repeat"}); this.node.setStyles(this.css.viewContentTrNode_selected); this.isSelected = true; this.view.fireEvent("selectRow", [this]); }, unSelected: function(){ this.view.selectedItems.erase(this); this.selectTd.setStyles({"background": "transparent"}); this.node.setStyles(this.css.viewContentTrNode); this.isSelected = false; this.view.fireEvent("unselectRow", [this]); }, selectedSingle: function(){ if (this.view.currentSelectedItem) this.view.currentSelectedItem.unSelectedSingle(); this.view.selectedItems = [this]; this.view.currentSelectedItem = this; this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/radiobox_checked.png) center center no-repeat"}); this.node.setStyles(this.css.viewContentTrNode_selected); this.isSelected = true; this.view.fireEvent("selectRow", [this]); }, unSelectedSingle: function(){ this.view.selectedItems = []; this.view.currentSelectedItem = null; this.selectTd.setStyles({"background": "transparent"}); this.node.setStyles(this.css.viewContentTrNode); this.isSelected = false; this.view.fireEvent("unselectRow", [this]); } }); MWF.xApplication.query.Query.Viewer.ItemCategory = new Class({ initialize: function(view, data, i){ this.view = view; this.data = data; this.css = this.view.css; this.items = []; this.loadChild = false; this.idx = i; this.clazzType = "category"; this.load(); }, load: function(){ this.view.fireEvent("queryLoadCategoryRow", [null, this]); this.node = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.view.viewTable); //if (this.view.json.select==="single" || this.view.json.select==="multi"){ this.selectTd = new Element("td", {"styles": this.css.viewContentCategoryTdNode}).inject(this.node); if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles); //} this.categoryTd = new Element("td", { "styles": this.css.viewContentCategoryTdNode, "colspan": this.view.viewJson.selectList.length+1 }).inject(this.node); this.groupColumn = null; for (var c = 0; c "+text); if (this.view.json.itemStyles) this.categoryTd.setStyles(this.view.json.itemStyles); this.setEvent(); this.view.fireEvent("postLoadCategoryRow", [null, this]); }, setEvent: function(){ //if (this.selectTd){ this.node.addEvents({ "click": function(){this.expandOrCollapse();}.bind(this) }); //} }, expandOrCollapse: function(){ var t = this.node.getElement("span").get("html"); if (t.indexOf("expand.png")===-1){ this.collapse(); }else{ this.expand(); } }, collapse: function(){ this.items.each(function(item){ item.node.setStyle("display", "none"); }.bind(this)); this.node.getElement("span").set("html", ""); }, expand: function(){ this.items.each(function(item){ item.node.setStyle("display", "table-row"); }.bind(this)); this.node.getElement("span").set("html", ""); if (!this.loadChild){ //window.setTimeout(function(){ this.data.list.each(function(line, i){ var s = this.idx+i; this.lastItem = new MWF.xApplication.query.Query.Viewer.Item(this.view, line, (this.lastItem || this), s); this.items.push(this.lastItem); }.bind(this)); this.loadChild = true; //}.bind(this), 10); } } }); MWF.xApplication.query.Query.Viewer.Filter = new Class({ initialize: function(viewer, data, node){ this.viewer = viewer; this.data = data; this.css = this.viewer.css; this.content = node; this.load(); }, load: function(){ this.node = new Element("div", {"styles": this.css.viewSearchFilterNode}).inject(this.content); if (this.viewer.filterItems.length){ this.logicNode = new Element("div", {"styles": this.css.viewSearchFilterSelectAreaNode}).inject(this.node); this.logicSelectNode = new Element("div", { "styles": this.css.viewSearchFilterSelectNode, "text": this.viewer.lp.and, "value": "and" }).inject(this.logicNode); this.logicSelectButtonNode = new Element("div", {"styles": this.css.viewSearchFilterSelectButtonNode}).inject(this.logicNode); this.logicNode.addEvents({ "click": function(){ var v = this.logicSelectNode.get("value"); if (v==="and"){ this.logicSelectButtonNode.setStyle("float", "left"); this.logicSelectNode.setStyle("float", "right"); this.logicSelectNode.set({ "text": this.viewer.lp.or, "value": "or" }); this.data.logic = "or"; }else{ this.logicSelectButtonNode.setStyle("float", "right"); this.logicSelectNode.setStyle("float", "left"); this.logicSelectNode.set({ "text": this.viewer.lp.and, "value": "and" }); this.data.logic = "and"; } this.viewer.searchCustomView(); }.bind(this) }); } this.titleNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": this.data.title}).inject(this.node); this.comparisonTitleNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": this.data.comparisonTitle}).inject(this.node); this.valueNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": "\""+this.data.value+"\""}).inject(this.node); this.deleteNode = new Element("div", {"styles": this.css.viewSearchFilterDeleteNode}).inject(this.node); this.node.addEvents({ "mouseover": function(){ this.node.setStyles(this.css.viewSearchFilterNode_over); this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode_over); }.bind(this), "mouseout": function(){ this.node.setStyles(this.css.viewSearchFilterNode); this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode); }.bind(this) }); this.deleteNode.addEvent("click", function(){ this.viewer.searchViewRemoveFilter(this); }.bind(this)); }, destroy: function(){ this.node.destroy(); MWF.release(this); } }); MWF.xApplication.query.Query.Viewer.Actionbar = new Class({ Implements: [Events], options: { "style" : "default", "moduleEvents": ["load", "queryLoad", "postLoad", "afterLoad"] }, initialize: function(node, json, form, options){ this.node = $(node); this.node.store("module", this); this.json = json; this.form = form; this.view = form; }, hide: function(){ var dsp = this.node.getStyle("display"); if (dsp!=="none") this.node.store("mwf_display", dsp); this.node.setStyle("display", "none"); }, show: function(){ var dsp = this.node.retrieve("mwf_display", dsp); this.node.setStyle("display", dsp); }, load: function(){ this._loadModuleEvents(); if (this.fireEvent("queryLoad")){ //this._queryLoaded(); this._loadUserInterface(); this._loadStyles(); this._loadDomEvents(); //this._loadEvents(); //this._afterLoaded(); this.fireEvent("postLoad"); this.fireEvent("load"); } }, _loadStyles: function(){ if (this.json.styles) Object.each(this.json.styles, function(value, key){ if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1 || value.indexOf("x_cms_assemble_control")!=-1)){ var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface"); var host2 = MWF.Actions.getHost("x_portal_assemble_surface"); var host3 = MWF.Actions.getHost("x_cms_assemble_control"); if (value.indexOf("/x_processplatform_assemble_surface")!==-1){ value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface"); }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){ value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface"); } if (value.indexOf("/x_portal_assemble_surface")!==-1){ value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface"); }else if (value.indexOf("x_portal_assemble_surface")!==-1){ value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface"); } if (value.indexOf("/x_cms_assemble_control")!==-1){ value = value.replace("/x_cms_assemble_control", host3+"/x_cms_assemble_control"); }else if (value.indexOf("x_cms_assemble_control")!==-1){ value = value.replace("x_cms_assemble_control", host3+"/x_cms_assemble_control"); } } this.node.setStyle(key, value); }.bind(this)); // if (["x_processplatform_assemble_surface", "x_portal_assemble_surface"].indexOf(root.toLowerCase())!==-1){ // var host = MWF.Actions.getHost(root); // return (flag==="/") ? host+this.json.template : host+"/"+this.json.template // } //if (this.json.styles) this.node.setStyles(this.json.styles); }, _loadModuleEvents : function(){ Object.each(this.json.events, function(e, key){ if (e.code){ if (this.options.moduleEvents.indexOf(key)!==-1){ this.addEvent(key, function(event){ return this.form.Macro.fire(e.code, this, event); }.bind(this)); } } }.bind(this)); }, _loadDomEvents: function(){ Object.each(this.json.events, function(e, key){ if (e.code){ if (this.options.moduleEvents.indexOf(key)===-1){ this.node.addEvent(key, function(event){ return this.form.Macro.fire(e.code, this, event); }.bind(this)); } } }.bind(this)); }, _loadEvents: function(){ Object.each(this.json.events, function(e, key){ if (e.code){ if (this.options.moduleEvents.indexOf(key)!==-1){ this.addEvent(key, function(event){ return this.form.Macro.fire(e.code, this, event); }.bind(this)); }else{ this.node.addEvent(key, function(event){ return this.form.Macro.fire(e.code, this, event); }.bind(this)); } } }.bind(this)); }, addModuleEvent: function(key, fun){ if (this.options.moduleEvents.indexOf(key)!==-1){ this.addEvent(key, function(event){ return (fun) ? fun(this, event) : null; }.bind(this)); }else{ this.node.addEvent(key, function(event){ return (fun) ? fun(this, event) : null; }.bind(this)); } }, _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 ){ this.toolbarNode = new Element("div").inject( this.node ); } 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.hideSystemTools){ this.setCustomToolbars(this.json.tools, this.toolbarNode); this.toolbarWidget.load(); }else{ if (this.json.defaultTools){ this.setToolbars(this.json.defaultTools, 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 path = "/x_component_query_ViewDesigner/$View/"; 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 (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, "MWFButtonImage": path+this.options.style+"/actionbar/"+tool.img, "title": tool.title, "MWFButtonAction": tool.action, "MWFButtonText": tool.text }).inject(node); if( this.json.iconOverStyle ){ actionNode.set("MWFButtonImageOver" , path+""+this.options.style+"/actionbar/"+this.json.iconOverStyle+"/"+tool.img ); //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); }, exportView : function(){ this.form.exportView(); }, deleteWork: function(){ this.form.deleteWork(); } });