| 1 |
- MWF.xApplication.Strategy=MWF.xApplication.Strategy||{};MWF.xDesktop.requireApp("Template","MDomItem",null,false);MWF.xDesktop.requireApp("Strategy","Template",null,false);MWF.require("MWF.widget.Identity",null,false);MWF.xApplication.Strategy.PriorityList=new Class({Extends:MWF.widget.Common,Implements:[Options,Events],options:{style:"default"},initialize:function(t,e,i,n){this.setOptions(n);this.app=e;this.lp=e.lp.priority;this.path="/x_component_Strategy/$PriorityList/";this.loadCss();this.actions=i;this.node=$(t)},loadCss:function(){this.cssPath=this.path+this.options.style+"/css.wcss";this._loadCss()},load:function(){if(this.options.style=="portal"){this.node.setStyles({"background-color":"#ffffff"})}this.allArrowArr=[];this.node.addEvents({click:function(){if(this.listContentDiv){$(this.listContentDiv).destroy()}if(this.allArrowArr.length>0){this.allArrowArr.each(function(t){$(t).setStyles({background:"url(/x_component_Strategy/$Template/default/icons/arrow.png) no-repeat center"})}.bind(this))}}.bind(this)});this.node.empty();this.createDepartmentNavi();this.app.addEvent("resize",function(){this.resizeContent()}.bind(this))},reload:function(t){},createDepartmentNavi:function(){this.departmentNavi=new Element("div.departmentNavi",{styles:this.css.departmentNavi}).inject(this.node);this.actions.getPriorityDepartments(function(t){if(t.type=="success"){var e=this;t.data.each(function(t){new Element("div.departmentItem",{styles:e.css.departmentItem,distinguishedName:t.distinguishedName,text:t.name}).inject(e.departmentNavi).addEvents({click:function(){e.openDepartment(this.get("distinguishedName"))},mouseover:function(){if(e.currentDistinguishedName!=this.get("distinguishedName")){this.setStyles({"background-color":"#D9EBFF",color:"#4990E2"})}},mouseout:function(){if(e.currentDistinguishedName!=this.get("distinguishedName")){this.setStyles({"background-color":"",color:""})}}})}.bind(e));this.departmentNavi.getElements(".departmentItem")[0].click()}}.bind(this))},openDepartment:function(t){if(!t)return;this.changeDepartmentSelect(t);this.createYearContent(function(){this.resizeContent()}.bind(this))},changeDepartmentSelect:function(t){if(!t)return;this.currentDistinguishedName=t;var e=this.departmentNavi.getElements(".departmentItem");e.each(function(e){e.setStyles({"background-color":"",color:""});if(t==e.get("distinguishedName")){e.setStyles({"background-color":"#D9EBFF",color:"#4990E2"})}}.bind(this))},createYearContent:function(t){if(this.rightContent)this.rightContent.destroy();this.rightContent=new Element("div.rightContent",{styles:this.css.rightContent}).inject(this.node);this.rightContent.setStyles({width:this.node.getWidth()-this.departmentNavi.getWidth()+"px"});this.yearContent=new Element("div.yearContent",{styles:this.css.yearContent}).inject(this.rightContent);this.yearContentList=new Element("div.yearContentList",{styles:this.css.yearContentList}).inject(this.yearContent);var e={keyworkunit:this.currentDistinguishedName};this.actions.getYearsByDepartment(e,function(e){if(e.type=="success"){if(e.data&&e.data.valueList){this.yearList=e.data.valueList;this.yearList.each(function(t,e){if(e<3){new Element("div.year",{styles:this.css.year,value:t,name:t,text:t}).inject(this.yearContentList).addEvents({click:function(){this.changeYearSelected(t);this.openList(t)}.bind(this)})}}.bind(this));if(this.yearList.length>3){new Element("div.yearMore",{styles:this.css.year,id:"yearMore"}).inject(this.yearContentList).setStyles({width:"30px"}).set({text:"..."}).addEvents({click:function(){this.expandYears()}.bind(this)})}if(this.currentYear){if(this.yearContentList.getElements("div[name='"+this.currentYear+"']").length>0){this.yearContentList.getElements("div[name='"+this.currentYear+"']")[0].click()}}else{if(this.yearContentList.getElements("div").length>0){this.yearContentList.getElements("div")[0].click()}}if(t)t()}}}.bind(this));this.actions.getPriorityAddAuthorize(function(t){if(t.type=="success"&&t.data&&t.data.value){this.addContent=new Element("div.addContent",{styles:this.css.addContent}).inject(this.yearContent).addEvents({click:function(){MWF.xDesktop.requireApp("Strategy","PriorityForm",function(){this.Priorityform=new MWF.xApplication.Strategy.PriorityForm(this,{},{isNew:true,onPostSave:function(){this.openDepartment(this.currentDistinguishedName)}.bind(this),width:"90%",height:"100%",maxAction:true,year:this.currentYear||"",department:this.currentDistinguishedName,container:this.app.portalContainer||this.app.content},{container:this.app.portalContainer||this.app.content});this.Priorityform.load()}.bind(this))}.bind(this)});this.addContentImg=new Element("div.addContentImg",{styles:this.css.addContentImg}).inject(this.addContent);this.addContentLabel=new Element("div.addContentLabel",{styles:this.css.addContentLabel,text:this.lp.add}).inject(this.addContent)}}.bind(this))},expandYears:function(){this.yearContentList.getElementById("yearMore").destroy();this.yearList.each(function(t,e){if(e>2){new Element("div.year",{styles:this.css.year,value:t,name:t,text:t}).inject(this.yearContentList).addEvents({click:function(){this.changeYearSelected(t);this.openList(t)}.bind(this)})}}.bind(this))},openList:function(t){this.currentYear=t;this.createSearch();this.createViewContent()},changeYearSelected:function(t){this.yearContentList.getElements("div").each(function(e){if(e.get("text")==t){e.setStyles({"background-color":"#4990E2",color:"#FFFFFF"})}else{e.setStyles({"background-color":"",color:"#666666"})}}.bind(this))},createSearch:function(){if(this.searchContent)this.searchContent.destroy();this.searchContent=new Element("div.searchContent",{styles:this.css.searchContent}).inject(this.rightContent);this.searchBar=new Element("div.searchBar",{styles:this.css.searchBar}).inject(this.searchContent);this.searchIn=new Element("input.searchIn",{styles:this.css.searchIn,placeholder:this.lp.defaultSearchIn}).inject(this.searchBar).addEvents({keydown:function(t){if(this.searchIn.get("value")!=""&&t.event.keyCode=="13"){this.searchReset.setStyles({display:""});this.createViewContent({keyworktitle:this.searchIn.get("value")})}}.bind(this)});this.searchImg=new Element("div.searchImg",{styles:this.css.searchImg}).inject(this.searchBar);this.searchImg.addEvents({click:function(){if(this.searchIn.get("value")!=""){this.searchReset.setStyles({display:""});this.createViewContent({keyworktitle:this.searchIn.get("value")})}}.bind(this)});this.searchReset=new Element("div.searchReset",{styles:this.css.searchReset}).inject(this.searchBar).addEvents({click:function(){this.searchIn.set("value","");this.searchReset.setStyles({display:"none"});this.createViewContent()}.bind(this)})},createViewContent:function(t){if(this.viewContent)this.viewContent.destroy();this.viewContent=new Element("div.viewContent",{styles:this.css.viewContent}).inject(this.rightContent);this.viewContentList=new Element("div.viewContentList",{styles:this.css.viewContentList}).inject(this.viewContent);this.filter={keyworkyear:this.currentYear,keyworkunit:this.currentDistinguishedName,ordersymbol:"ASC"};for(var e in t){if(t[e]!=this.app.lp.template.defaultSelect){this.filter[e]=t[e]}}var i=this.path+"Priority.json";this.view=new MWF.xApplication.Strategy.PriorityList.View(this.viewContentList,this.app,{explorer:this,lp:this.lp.view,css:this.css,actions:this.actions},{templateUrl:i,filterData:this.filter});this.view.load();this.resizeContent()},createPageContent:function(){if(this.pageContent)this.pageContent.destroy();this.pageContent=new Element("div.pageContent",{styles:this.css.pageContent}).inject(this.viewContent)},dragItemData:function(){var t=new Sortables("tabBody",{clone:true,opacity:.3,onStart:function(t,e){e.setStyles({position:"absolute","margin-top":160-this.viewContentList.getScrollTop()+"px",border:"1px dotted #000",width:this.viewContentList.getWidth()-10+"px",height:t.getHeight()+"px",overflow:"hidden","max-height":t.getHeight()+"px"})}.bind(this),onSort:function(t,e){}.bind(this),onComplete:function(e){var i=e.get("id");var n=t.serialize()}.bind(this)})},resizeContent:function(){var t=this.node.getSize();var e=this.departmentNavi;this.rightContent.setStyles({width:t.x-e.getWidth()+"px",height:t.y+"px"});var i=$(this.yearContent);var n=$(this.searchContent);var s=$(this.viewContent);var r=$(this.viewContentList);if(n&&s){$(s).setStyles({height:t.y-i.getHeight()-n.getHeight()+"px"})}if(r){$(r).setStyles({height:s.getHeight()-10+"px"})}},createShade:function(t,e){var i=this.node;var n=t||i;var s=e||"loading...";if(this.shadeDiv){$(this.shadeDiv).destroy()}if(this["shadeTxtDiv"])this["shadeTxtDiv"].destroy();this.shadeDiv=new Element("div.shadeDiv").inject(n);this.inforDiv=new Element("div.inforDiv",{styles:{height:"16px",width:"200px",display:"line-block",position:"relative","background-color":"#000000","border-radius":"3px",padding:"5px 10px"}}).inject(this.shadeDiv);this.loadImg=new Element("img.loadImg",{styles:{width:"16px",height:"16px",float:"left"},src:"/x_component_Strategy/$Main/default/icon/loading.gif"}).inject(this.inforDiv);this.shadeTxtSpan=new Element("span.shadeTxtSpan").inject(this.inforDiv);this.shadeTxtSpan.set("text",s);this.shadeDiv.setStyles({width:"100%",height:"100%",opacity:"0.6","background-color":"#cccccc","z-index":"999"});this.shadeTxtSpan.setStyles({color:"#ffffff","font-size":"12px",display:"inline-block","line-height":"16px","padding-left":"5px"});var r=n.getSize().x;var o=n.getSize().y;this.shadeDiv.setStyles({left:n.getLeft()-i.getLeft()+"px",top:n.getTop()-i.getTop()+"px",width:r+"px",height:o+"px"});if(n.getStyle("position")=="position"){this.shadeDiv.setStyles({left:"0px",top:"0px"})}this.inforDiv.setStyles({left:r/2+"px",top:o/2+"px"});this.inforDiv.setStyles({display:"none"})},destroyShade:function(){if(this.shadeDiv)$(this.shadeDiv).destroy()},showErrorMessage:function(t,e,i){var n=i;var s;if(t)s=t.responseText;if(s!=""){var r=JSON.parse(s);if(r.message){this.notice(r.message,"error")}else{this.notice(n,"error")}}else{this.notice(n,"error")}}});MWF.xApplication.Strategy.PriorityList.View=new Class({Extends:MWF.xApplication.Strategy.Template.view,_createDocument:function(t){return new MWF.xApplication.Strategy.PriorityList.Document(this.viewBodyNode,t,this.explorer,this)},loadScrollElementList:function(t){if(!this.isItemsLoaded){if(!this.isItemLoadding){this.isItemLoadding=true;this._getCurrentPageData(function(t){var e=this.dataCount=t.count;if(e<=this.items.length){this.isItemsLoaded=true}if(t.data&&typeOf(t.data)=="array"){t.data.each(function(t){var e=t[this.options.documentKeyWord||"id"];if(!this.documents[e]){var i=this._createDocument(t,this.items.length);this.items.push(i);this.documents[e]=i}}.bind(this))}this.isItemLoadding=false;if(this.explorer.explorer.options.style!="portal"){if(!this.explorer.explorer.filter.keyworktitle){this.explorer.explorer.dragItemData()}}if(this.loadItemQueue>0){this.loadItemQueue--;this.loadElementList()}}.bind(this),t)}else{this.loadItemQueue++}}},_getCurrentPageData:function(t,e){if(!e)e=100;var i=this.items.length?this.items[this.items.length-1].data.id:"(0)";if(i=="(0)"){debugger;this.explorer.explorer.createShade()}var n=this.options.filterData||{};this.actions.getPriorityListNext(i,e,n,function(e){if(t)t(e);this.explorer.explorer.destroyShade()}.bind(this))},_removeDocument:function(t){},_create:function(){},_openDocument:function(t){MWF.xDesktop.requireApp("Strategy","PriorityForm",function(){this.priorityForm=new MWF.xApplication.Strategy.PriorityForm(this,this.actions,{id:t.id},{isEdited:false,container:this.app.portalContainer||this.app.content});this.priorityForm.load()}.bind(this))},_queryCreateViewNode:function(){},_postCreateViewNode:function(){},_queryCreateViewHead:function(){},_postCreateViewHead:function(t){}});MWF.xApplication.Strategy.PriorityList.Document=new Class({Extends:MWF.xApplication.Strategy.Template.Document,openActionReturn:function(t){var e=false;if(t.actions&&t.actions.length==1){e=true}return e},editActionReturn:function(t){var e=false;if(t.actions&&t.actions.indexOf("EDIT")>-1)e=true;return e},deleteActionReturn:function(t){var e=false;if(t.actions&&t.actions.indexOf("DELETE")>-1)e=true;return e},action_open:function(){MWF.xDesktop.requireApp("Strategy","PriorityForm",function(){this.PriorityForm=new MWF.xApplication.Strategy.PriorityForm(this,this.actions,{id:this.data.id},{isEdited:false});this.PriorityForm.load()}.bind(this))},action_edit:function(){MWF.xDesktop.requireApp("Strategy","PriorityForm",function(){this.Priorityform=new MWF.xApplication.Strategy.PriorityForm(this,this.app.actions,{id:this.data.id,isNew:false,isEdited:true,width:1e3,height:500,year:this.data.keyworkyear,onPostSave:function(){this.explorer.explorer.openDepartment(this.explorer.explorer.currentDistinguishedName)}.bind(this)},{container:this.app.portalContainer||this.app.content});this.Priorityform.load()}.bind(this))},action_delete:function(t){var e=this;e.view.app.confirm("warn",t,e.explorer.explorer.app.lp.priority.submitWarn.title,e.explorer.explorer.app.lp.priority.submitWarn.content.deleted,300,120,function(){e.actions.deletePriority(e.data.id,function(t){if(t.type&&t.type=="success"){this.app.notice(e.explorer.explorer.app.lp.prompt.priority.deleteOK,"success");e.explorer.explorer.openDepartment(e.explorer.explorer.currentDistinguishedName)}}.bind(e));this.close()},function(){this.close()})},_postCreateDocumentNode:function(t,e){t.set("id",e.id);if(!this.openActionReturn(e)){t.getElements("[item='action_open']").destroy()}if(!this.editActionReturn(e)){t.getElements("[item='action_edit']").destroy()}if(!this.deleteActionReturn(e)){t.getElements("[item='action_delete']").destroy()}}});
|