/** * Created by hq_19 on 2017/5/31. */ MWF.xApplication.Org.BaseInfor = new Class({ initialize: function(content){ this.content = content; this.item = content.item; this.data = this.item.data; this.explorer = this.item.explorer; this.contentNode = this.content.baseContentNode; this.style = this.item.style.person; this.attributes = []; this.mode = "read"; this.load(); }, load: function(){ this.baseBgNode = new Element("div", {"styles": this.style.baseBgNode}).inject(this.contentNode); this.baseNode = new Element("div", {"styles": this.style.baseNode}).inject(this.baseBgNode); this.baseInforNode = new Element("div", {"styles": this.style.baseInforNode}).inject(this.baseNode); this.baseInforLeftNode = new Element("div", {"styles": this.style.baseInforLeftNode}).inject(this.baseInforNode); this.baseInforRightNode = new Element("div", {"styles": this.style.baseInforRightNode}).inject(this.baseInforNode); // this.actionEditAreaNode = new Element("div", {"styles": this.style.baseInforRightActionAreaNode}).inject(this.baseInforNode); // this.actionEditContentNode = new Element("div", {"styles": this.style.baseInforRightActionContentNode}).inject(this.actionEditAreaNode); this.actionAreaNode = new Element("div", {"styles": this.style.actionAreaNode}).inject(this.baseBgNode); this.loadLeftInfor(); this.loadRightInfor(); this.loadAction(); }, loadAction: function(){ //this.explorer.app.lp.edit if (MWF.AC.isPersonEditor({"list": this.data.controllerList})){ this.editNode = new Element("div", {"styles": this.style.actionNode, "text": this.explorer.app.lp.edit}).inject(this.actionAreaNode); var actionAreas = this.baseInforRightNode.getElements("td"); var actionArea = actionAreas[actionAreas.length-1]; this.baseInforEditActionAreaNode = new Element("div", {"styles": this.style.baseInforEditActionAreaNode}).inject(actionArea); this.saveNode = new Element("div", {"styles": this.style.actionSaveNode, "text": this.explorer.app.lp.save}).inject(this.baseInforEditActionAreaNode); this.saveNode.addClass("mainColor_bg"); this.cancelNode = new Element("div", {"styles": this.style.actionCancelNode, "text": this.explorer.app.lp.cancel}).inject(this.baseInforEditActionAreaNode); this.editNode.setStyle("display", "block"); this.editNode.addEvent("click", this.edit.bind(this)); this.saveNode.addEvent("click", this.save.bind(this)); this.cancelNode.addEvent("click", this.cancel.bind(this)); this.iconNode.setStyle("cursor", "pointer"); this.iconNode.addEvent("click", function(){this.changePersonIcon();}.bind(this)); } }, edit: function(){ this.nameNode.empty(); this.nameInputNode = new Element("input", {"styles": this.style.nameInputNode}).inject(this.nameNode); this.nameInputNode.set("value", this.data.name); this.signatureNode.empty(); this.signatureTextNode = new Element("textarea", {"styles": this.style.signatureTextNode}).inject(this.signatureNode); this.signatureTextNode.set("value", (this.data.signature)); var tdContents = this.baseInforRightNode.getElements("td.inforContent"); tdContents[0].empty(); this.uniqueInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[0]); this.uniqueInputNode.set("value", (this.data.unique)); tdContents[1].empty(); this.mobileInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[1]); this.mobileInputNode.set("value", (this.data.mobile)); tdContents[2].empty(); var html = ""+this.explorer.app.lp.man; html += ""+this.explorer.app.lp.female; html += ""+this.explorer.app.lp.other; tdContents[2].set("html", html); // this.mobileInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[2]); // this.mobileInputNode.set("value", (this.data.mobile)); tdContents[3].empty(); this.mailInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[3]); this.mailInputNode.set("value", (this.data.mail)); tdContents[4].empty(); this.employeeInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[4]); this.employeeInputNode.set("value", (this.data.employee)); tdContents[5].empty(); this.qqInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[5]); this.qqInputNode.set("value", (this.data.qq)); tdContents[6].empty(); this.displayInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[6]); this.displayInputNode.set("value", (this.data.display)); tdContents[7].empty(); this.weiboInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[7]); this.weiboInputNode.set("value", (this.data.weibo)); var _self = this; this.baseInforNode.getElements("input").addEvents({ "focus": function(){if (this.get("type").toLowerCase()==="text"){this.setStyles(_self.style.inputNode_focus);}}, "blur": function(){if (this.get("type").toLowerCase()==="text"){this.setStyles(_self.style.inputNode_blur);}} }); this.baseInforNode.getElements("textarea").addEvents({ "focus": function(){this.setStyles(_self.style.inputNode_focus);}, "blur": function(){this.setStyles(_self.style.inputNode_blur);} }); this.mode = "edit"; this.editNode.setStyle("display", "none"); this.saveNode.setStyle("display", "block"); this.cancelNode.setStyle("display", "block"); }, changePersonIcon: function(){ var options = {}; var width = "668"; var height = "510"; width = width.toInt(); height = height.toInt(); var size = this.explorer.app.content.getSize(); var x = (size.x-width)/2; var y = (size.y-height)/2; if (x<0) x = 0; if (y<0) y = 0; if (layout.mobile){ x = 20; y = 0; } var _self = this; MWF.require("MWF.xDesktop.Dialog", function() { MWF.require("MWF.widget.ImageClipper", function(){ var dlg = new MWF.xDesktop.Dialog({ "title": this.explorer.app.lp.changePersonIcon, "style": "image", "top": y, "left": x - 20, "fromTop": y, "fromLeft": x - 20, "width": width, "height": height, "html": "
", "maskNode": this.explorer.app.content, "container": this.explorer.app.content, "buttonList": [ { "text": MWF.LP.process.button.ok, "action": function () { _self.uploadPersonIcon(); this.close(); } }, { "text": MWF.LP.process.button.cancel, "action": function () { _self.image = null; this.close(); } } ] }); dlg.show(); this.image = new MWF.widget.ImageClipper(dlg.content.getFirst(), { "aspectRatio": 1, "description" : "", "imageUrl" : "", "resetEnable" : false }); this.image.load(this.data.icon); }.bind(this)); }.bind(this)) }, uploadPersonIcon: function(){ if (this.image){ if( this.image.getResizedImage() ){ this.explorer.actions.changePersonIcon(this.data.id ,function(){ this.explorer.actions.getPerson(function(json){ if (json.data){ this.data.icon = json.data.icon; if (this.data.icon){ this.iconNode.set("src", this._getIcon()); this.item.iconNode.getElement("img").set("src", this.item._getIcon()); } } }.bind(this), null, this.data.id, false) }.bind(this), null, this.image.getFormData(), this.image.resizedImage); } } }, save: function(){ var tdContents = this.baseInforRightNode.getElements("td.inforContent"); var gender = ""; var radios = tdContents[2].getElements("input"); for (var i=0; i