MWF.xDesktop.requireApp("Template", "MForm", null, false); MWF.xApplication.Attendance.WeekendSetting = new Class({ Extends: MWF.widget.Common, options:{ style : "default" }, initialize: function(app, actions, options){ this.setOptions(options); this.app = app; this.path = "/x_component_Attendance/$WeekendSetting/"; this.cssPath = "/x_component_Attendance/$WeekendSetting/"+this.options.style+"/css.wcss"; this._loadCss(); this.actions = actions; this.load(); }, load: function(){ this.app.restActions.listSetting(function(json){ if( json.data && json.data.length>0){ this.data = json.data; } }.bind(this),null,false); if( !this.data ){ this.data = []; } }, decodeData : function( data ){ //{ // 'configCode':'APPEALABLE', // 'configName':'申诉功能启用状态', // 'configValue':'false', // 'ordernumber':1 //} var json = {}; this.dataJson = {}; data.each( function(d){ json[d.configCode] = d.configValue; this.dataJson[d.configCode] = d; }.bind(this)); //alert(JSON.stringify(json)) return json; }, encodeData : function( orgData, data ){ var arr = []; for( var d in data ){ if( this.itemTemplate[d] ){ var flag = false; for( var i=0; i周末设置" + ""+ " "+ ""; html = html+""+this.dataJson.ATTENDANCE_WEEKEND.description+"" this.createTableArea.set("html",html); this.itemTemplate = { ATTENDANCE_WEEKEND : { text : "周末选择", type : "select", value : d.ATTENDANCE_WEEKEND , selectValue :this.dataJson.ATTENDANCE_WEEKEND.selectContent.split("|") ,//["周六","周日"] /*event : { change : function( item, ev ){ this.createTableArea.getElement("[item='valueArea']").setStyle( "display" , (item.getValue() == "汇报对象") ? "none" : "" ); }.bind(this) }*/ } }; this.document = new MForm( this.createTableArea, this.data, { style : "popup", isEdited : this.isEdited || this.isNew, itemTemplate : this.itemTemplate }, this.app,this.css); this.document.load(); this.cancelActionNode = new Element("div", { "styles": this.css.createCancelActionNode, "text": "取消" }).inject(this.createFormNode); this.cancelActionNode.addEvent("click", function(e){ this.cancelCreate(e); }.bind(this)); if( this.isNew || this.isEdited ){ this.createOkActionNode = new Element("div", { "styles": this.css.createOkActionNode, "text": "确定" }).inject(this.createFormNode); this.createOkActionNode.addEvent("click", function(e){ this.okCreate(e); }.bind(this)); } }, setCreateNodeSize: function(){ var size = this.app.node.getSize(); var allSize = this.app.content.getSize(); var height = "270"; var width = "600"; this.createAreaNode.setStyles({ "width": ""+size.x+"px", "height": ""+size.y+"px" }); var hY = height; var mY = (size.y-height)/2; this.createNode.setStyles({ "height": ""+hY+"px", "margin-top": ""+mY+"px", "width" : ""+width+"px" }); this.createContainerNode.setStyles({ "height": ""+hY+"px" }); var iconSize = this.createIconNode ? this.createIconNode.getSize() : {x:0,y:0}; var formMargin = hY-iconSize.y-60; this.createFormNode.setStyles({ "height": ""+formMargin+"px", "margin-top": ""+60+"px" }); }, cancelCreate: function(e){ this.createMarkNode.destroy(); this.createAreaNode.destroy(); delete this; }, okCreate: function(e){ var data = this.document.getResult(true,",",true,false,false); if(data){ var arr = this.encodeData( this.data, data ); this.save( arr ); } }, save: function( arr ){ var flag = true; arr.each( function( d ){ this.app.restActions.saveSetting( d, function(json){ if( json.type == "ERROR" ){ this.app.notice( json.message , "error"); flag = false; } }.bind(this), null, false); }.bind(this)); if( flag ){ this.createMarkNode.destroy(); this.createAreaNode.destroy(); this.app.notice( "保存成功" , "success"); } } });