| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904 |
- // MWF.xDesktop.requireApp("Organization", "GroupExplorer", null, false);
- // MWF.xDesktop.requireApp("Organization", "OrgExplorer", null, false);
- MWF.xDesktop.requireApp("Org", "$Explorer", null, false);
- MWF.require("MWF.widget.O2Identity", null, false);
- MWF.xApplication.Org.PersonExplorer = new Class({
- Extends: MWF.xApplication.Org.$Explorer,
- Implements: [Options, Events],
- options: {
- "style": "default"
- },
- _isActionManager: function(){
- return (MWF.AC.isOrganizationManager() || MWF.AC.isPersonManager() || MWF.AC.isUnitManager());
- },
- _listElementNext: function(lastid, count, callback){
- this.actions.listPersonNext(lastid||"(0)", count, function(json){
- if (callback) {
- callback.apply(this, [json]);
- }
- }.bind(this));
- },
- _newElement: function(data, explorer, i){
- return new MWF.xApplication.Org.PersonExplorer.Person(data, explorer, this.isEditor, i);
- },
- _listElementByKey: function(callback, failure, key){
- //this.actions.listPersonByPinyin(function(json){
- this.actions.listPersonByKey(function(json){
- if (callback) {
- callback.apply(this, [json]);
- }
- }.bind(this), failure, key);
- },
- _getAddElementData: function(){
- return {
- "genderType": "m",
- "signature": "",
- "description": "",
- "unique": "",
- "orderNumber": "",
- "superior": "",
- "officePhone": "",
- "boardDate": "",
- "birthday": "",
- "employee": "",
- "password": "",
- "display": "",
- "qq": "",
- "mail": "",
- "weixin": "",
- "weibo": "",
- "mobile": "",
- "name": "",
- "controllerList": [],
- "woPersonAttributeList":[],
- "woIdentityList": [],
- "control": {
- "allowEdit": true,
- "allowDelete": true
- }
- };
- }
- });
- MWF.xApplication.Org.PersonExplorer.Person = new Class({
- Extends: MWF.xApplication.Org.$Explorer.Item,
- showItemProperty: function(){
- this.content = new MWF.xApplication.Org.PersonExplorer.PersonContent(this);
- },
- _loadTextNode: function(){
- var html = "<div style='float:left; height:50px; overflow:hidden'>"+this.data.name+"</div>";
- html += "<div style='float: right; overflow:hidden; font-size: 12px; color: #aaaaaa;'>"+(this.data.mobile || "")+"</div>";
- this.textNode.set({"html": html});
- },
- "delete": function(success, failure){
- this.explorer.actions.deletePerson(this.data.id, function(){
- this.destroy();
- if (success) success();
- }.bind(this), function(xhr, text, error){
- var errorText = error;
- if (xhr) errorText = xhr.responseText;
- MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
- if (failure) failure();
- });
- },
- _getIcon: function(nocache){
- var url = (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "/x_component_Org/$Explorer/default/icon/man.png";
- return (nocache) ? url+"?"+(new Date().getTime()) : url;
- //return (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "/x_component_Org/$Explorer/default/icon/man.png";
- // var src = "data:image/png;base64,"+this.data.icon;
- // if (!this.data.icon){
- // if (this.data.genderType==="f"){
- // src = "/x_component_Org/$Explorer/default/icon/female24.png"
- // }else{
- // src = "/x_component_Org/$Explorer/default/icon/man24.png"
- // }
- // }
- // return src;
- }
- });
- MWF.xApplication.Org.PersonExplorer.PersonContent = new Class({
- Extends: MWF.xApplication.Org.$Explorer.ItemContent,
- _getData: function(callback){
- if (this.item.data.id){
- this.explorer.actions.getPerson(function(json){
- this.data = json.data;
- this.item.data = json.data;
- if (callback) callback();
- }.bind(this), null, this.item.data.id);
- }else{
- this.data = this.item.data;
- if (callback) callback();
- }
- },
- edit: function(){
- if (this.baseInfor) this.baseInfor.edit();
- },
- _showItemPropertyTitle: function(){
- this.titleInfor = new MWF.xApplication.Org.PersonExplorer.PersonContent.TitleInfor(this);
- //this.baseInfor = new MWF.xApplication.Org.BaseInfor(this);
- },
- _showItemPropertyBottom: function(){
- this.bottomInfor = new MWF.xApplication.Org.PersonExplorer.PersonContent.BottomInfor(this);
- },
- _loadTabs: function(){
- this.baseContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
- this.basePage = this.propertyTab.addTab(this.baseContentNode, this.explorer.app.lp.personBaseText);
- this.attributeContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
- this.attributePage = this.propertyTab.addTab(this.attributeContentNode, this.explorer.app.lp.personAttributeText);
- this.identityContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
- this.identityPage = this.propertyTab.addTab(this.identityContentNode, this.explorer.app.lp.personIdentityText);
- // this.managerContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
- // this.managerPage = this.propertyTab.addTab(this.managerContentNode, this.explorer.app.lp.controllerListText);
- },
- _loadContent: function(){
- this._listBaseInfor();
- this._listAttribute();
- this._listIdentity();
- this.loadListCount();
- //
- // this.showAttribute();
- },
- loadListCount: function(){
- if (this.data.woIdentityList){
- var identityCount = this.data.woIdentityList.length;
- if (identityCount){
- if (!this.identityCountNode){
- this.identityCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": identityCount}).inject(this.identityPage.tabNode);
- }else{
- this.identityCountNode.set("text", identityCount);
- }
- }else{
- if (this.identityCountNode) this.identityCountNode.destroy();
- }
- }
- if (this.data.woPersonAttributeList){
- var attributeCount = this.data.woPersonAttributeList.length;
- if (attributeCount){
- if (!this.attributeCountNode){
- this.attributeCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": attributeCount}).inject(this.attributePage.tabNode);
- }else{
- this.attributeCountNode.set("text", attributeCount);
- }
- }else{
- if (this.attributeCountNode) this.attributeCountNode.destroy();
- }
- }
- // var groupCount = this.data.groupList.length;
- // if (groupCount){
- // this.groupCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": groupCount}).inject(this.groupMemberPage.tabNode);
- // }
- },
- _listBaseInfor: function(){
- this.baseInfor = new MWF.xApplication.Org.PersonExplorer.PersonContent.BaseInfor(this);
- },
- _listAttribute: function(){
- this.attributeList = new MWF.xApplication.Org.List(this.attributeContentNode, this, {
- "action": this.data.control.allowEdit,
- "data": {
- "person": this.data.id,
- "name": "",
- "unique": "",
- "orderNumber": "",
- "attributeList": [],
- "description":""
- },
- "attr": ["name", {
- "get": function(){return this.attributeList.join(",")},
- "set": function(value){this.attributeList = value.split(/,\s*/g)}
- }, "description"],
- "onPostSave": function(item, id){
- if (!item.data.id){
- item.data.id = id;
- this.data.woPersonAttributeList.push(item.data);
- }
- this.loadListCount();
- // if (!item.data.id){
- // if (this.attributeCountNode){
- // var count = this.attributeCountNode.get("text").toInt()+1;
- // this.attributeCountNode.set("text", count);
- // }
- // }
- }.bind(this),
- "onPostDelete": function(delCount){
- if (this.attributeCountNode){
- var count = this.attributeCountNode.get("text").toInt()-delCount;
- this.attributeCountNode.set("text", count);
- }
- }.bind(this)
- });
- this.attributeList.load([
- {"style": "width: 20%", "text": this.explorer.app.lp.attributeName},
- {"style": "", "text": this.explorer.app.lp.attributeValue},
- {"style": "", "text": this.explorer.app.lp.description}
- ]);
- this.data.woPersonAttributeList.each(function(item){
- this.attributeList.push(item);
- }.bind(this));
- // if (this.data.id){
- // this.explorer.actions.listPersonAttribute(function(json){
- //
- // var attributeCount = json.data.length;
- // if (attributeCount){
- // this.attributeCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": attributeCount}).inject(this.attributePage.tabNode);
- // }
- //
- // json.data.each(function(item){
- // //this.attributes.push(new MWF.xApplication.Org.PersonExplorer.PersonAttribute(this.attributeTabContentNode.getElement("table").getFirst(), item, this, this.explorer.css.list));
- // this.attributeList.push(item);
- // }.bind(this));
- // }.bind(this), null, this.data.id);
- // }
- },
- _listIdentity: function(){
- var _self = this;
- this.identityList = new MWF.xApplication.Org.List(this.identityContentNode, this, {
- "action": false,
- "canEdit": false,
- "saveAction": "saveIdentity",
- "data": {
- "person": this.data.id,
- "name": "",
- "attributeList": []
- },
- "attr": ["name", {
- "get": function(){ return ""; },
- "events": {
- "init": function(){
- var contentNode = this.td;
- new MWF.widget.O2Unit(this.data.woUnit, contentNode, {"style": "xform"});
- }
- }
- }, {
- "get": function(){ return this.distinguishedName; },
- "set": function(value){ this.distinguishedName = value; }
- }, {
- "get": function(){ return ""; },
- "events": {
- "init": function(){
- var contentNode = this.td;
- if (this.data.woUnitDutyList){
- this.data.woUnitDutyList.each(function(duty){
- new MWF.widget.O2Duty(duty, contentNode, {"style": "xform"});
- }.bind(this));
- }
- }
- }
- }, {
- "getHtml": function(){
- if (this.major){
- return "<div style='width:24px; height:24px; background:url(/x_component_Org/$Explorer/"+
- _self.explorer.app.options.style+"/icon/mainid.png) center center no-repeat'></div>";
- }else{
- return "<div title='"+_self.explorer.app.lp.setIdentityMain+"' style='width:24px; height:24px; cursor: pointer; background:url(/x_component_Org/$Explorer/"+
- _self.explorer.app.options.style+"/icon/select.png) center center no-repeat'></div>";
- }
- },
- "events": {
- "click": function(){
- if (!this.data.major){
- if (_self.data.control.allowEdit){_self.setMainIdentity(this.data, this.td, this.item);}
- }
- }
- }
- },{
- "getHtml": function(){
- if (_self.data.control.allowEdit){
- return "<div style='width:24px; height:24px; cursor: pointer; background:url(/x_component_Org/$Explorer/"+
- _self.explorer.app.options.style+"/icon/edit.png) center center no-repeat'></div>";
- }
- return "";
- },
- "events": {
- "click": function(){
- debugger;
- if (_self.data.control.allowEdit){_self.editIdentity(this.data, this.td, this.item);}
- }
- }
- }]
- });
- this.identityList.load([
- {"style": "width: 12%", "text": this.explorer.app.lp.IdentityName},
- {"style": "width: 12%", "text": this.explorer.app.lp.IdentityInUnit},
- {"style": "width: 44%", "text": this.explorer.app.lp.personUnique},
- {"style": "width: 20%", "text": this.explorer.app.lp.IdentityDuty},
- {"style": "width: 10%", "text": this.explorer.app.lp.IdentityMain},
- {"style": "width: 30px", "text": ""}
- ]);
- this.data.woIdentityList.each(function(item){
- this.identityList.push(item);
- }.bind(this));
- },
- setMainIdentity: function(data, node, item){
- data.major = true;
- this.explorer.actions.saveIdentity(data, function(json){
- this.explorer.actions.getPerson(function(iJson){
- // data = iJson.data;
- // item.reload(iJson.data);
- this.data.woIdentityList = iJson.data.woIdentityList;
- this.identityList.clear();
- this.data.woIdentityList.each(function(item){
- this.identityList.push(item);
- }.bind(this));
- }.bind(this), null, this.data.id);
- }.bind(this));
- },
- editIdentity: function(data, node, item){
- var _self = this;
- var position = node.getPosition(this.explorer.app.content);
- var width = 700;
- var height = 170;
- 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<20) y = 20;
- MWF.require("MWF.xDesktop.Dialog", function() {
- var dlg = new MWF.xDesktop.Dialog({
- "title": this.explorer.app.lp.modifyIdentity,
- "style": "org",
- "top": y - 20,
- "left": x,
- "fromTop": position.y - 20,
- "fromLeft": position.x,
- "width": width,
- "height": height,
- "html": "<div></div>",
- "maskNode": this.explorer.app.content,
- "container": this.explorer.app.content,
- "buttonList": [
- {
- "text": MWF.LP.process.button.ok,
- "action": function () {
- _self.saveIdentity(dlg, data, item);
- this.close();
- }
- },
- {
- "text": MWF.LP.process.button.cancel,
- "action": function () {
- this.close();
- }
- }
- ]
- });
- dlg.show();
- var node = dlg.content.getFirst();
- var html = "<table width='90%' cellpadding='0px' cellspacing='5px' align='center' style='margin-top:10px'>" +
- "<tr><th width='30%'>"+this.explorer.app.lp.IdentityName+"</th><th>"+this.explorer.app.lp.personUnique+"</th><th>"+this.explorer.app.lp.IdentityMain+"</th></tr>" +
- "<tr><td style='text-align: center'><input value='' type='type' style='padding: 0px 3px; width: 95%; border: 1px solid #cccccc; height: 24px; border-radius: 3px; line-height: 24px;'/></td>" +
- "<td style='text-align: center'><input value='' type='type' style='padding: 0px 3px; width: 95%; border: 1px solid #cccccc; height: 24px; border-radius: 3px; line-height: 24px;'/></td>" +
- "<td style='text-align: center'><input value='yes' type='checkbox' "+((data.major) ? "checked" : "")+"/></td></tr></table>";
- node.set("html", html);
- var inputs = node.getElements("input");
- if (inputs[0]) inputs[0].set("value", data.name);
- if (inputs[1]) inputs[1].set("value", data.unique);
- //if (inputs[2]) inputs[2].set("value", data.major)
- }.bind(this));
- },
- saveIdentity: function(dlg, data, item){
- var node = dlg.content.getFirst();
- var inputs = node.getElements("input");
- var name = inputs[0].get("value");
- var unique = inputs[1].get("value");
- var major = (inputs[2].checked);
- if (data.name!==name || data.unique!==unique){
- if (name) data.name = name;
- data.unique=unique;
- data.major = major;
- this.explorer.actions.saveIdentity(data, function(json){
- this.explorer.actions.getPerson(function(iJson){
- // data = iJson.data;
- // item.reload(iJson.data);
- this.data.woIdentityList = iJson.data.woIdentityList;
- this.identityList.clear();
- this.data.woIdentityList.each(function(item){
- this.identityList.push(item);
- }.bind(this));
- }.bind(this), null, this.data.id);
- }.bind(this));
- }
- }
- });
- MWF.xApplication.Org.PersonExplorer.PersonContent.TitleInfor = new Class({
- Extends: MWF.xApplication.Org.$Explorer.ItemContent.TitleInfor,
- loadAction: function(){
- //this.explorer.app.lp.edit
- this.nameNode.setStyle("margin-right", "80px");
- if (MWF.AC.isOrganizationManager() || MWF.AC.isPersonManager()){
- this.resetPasswordAction = new Element("div", {"styles": this.style.titleInforResetPasswordNode, "text": this.item.explorer.app.lp.resetPassword}).inject(this.nameNode, "before");
- this.resetPasswordAction.addEvent("click", function(e){this.resetPassword(e);}.bind(this));
- }
- if (this.data.control.allowEdit){
- this.iconNode.setStyle("cursor", "pointer");
- this.iconNode.addEvent("click", function(){this.changePersonIcon();}.bind(this));
- }
- },
- resetPassword: function(e){
- var _self = this;
- var text = this.item.explorer.app.lp.resetPasswordText;
- text = text.replace("{name}", this.data.name);
- this.item.explorer.app.confirm("info", e, this.item.explorer.app.lp.resetPasswordTitle, text, "360", "120", function(){
- _self.doResetPassword();
- this.close();
- }, function(){
- this.close();
- });
- },
- doResetPassword: function(){
- var action = MWF.Actions.get("x_organization_assemble_control");
- action.resetPassword(this.data.id, function(){
- var text = this.item.explorer.app.lp.resetPasswordSuccess;
- text = text.replace("{name}", this.data.name);
- this.item.explorer.app.notice(text, "success");
- }.bind(this));
- },
- 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": "<div></div>",
- "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" : this._getIcon(true),
- "resetEnable" : false
- });
- this.image.load();
- }.bind(this));
- }.bind(this))
- },
- uploadPersonIcon: function(){
- if (this.image){
- if( this.image.getResizedImage() ){
- this.explorer.actions.changePersonIcon(this.data.id, this.image.getFormData(), this.image.getResizedImage(), function(){
- this.iconNode.set("src", "");
- if (this.item.iconNode) this.item.iconNode.getElement("img").set("src", "");
- window.setTimeout(function(){
- this.iconNode.set("src", this._getIcon(true));
- if (this.item.iconNode) this.item.iconNode.getElement("img").set("src", this.item._getIcon(true));
- }.bind(this), 100);
- }.bind(this), null);
- }
- }
- }
- });
- MWF.xApplication.Org.PersonExplorer.PersonContent.BottomInfor = new Class({
- Extends: MWF.xApplication.Org.$Explorer.ItemContent.BottomInfor,
- addInforList: function(){
- var text = this.explorer.app.lp.personReadDn.replace(/{dn}/g, (this.data.distinguishedName || " "));
- this.addInfor(text);
- text = this.explorer.app.lp.personReadCreate.replace(/{date}/g, (this.data.createTime || " "));
- text = text.replace(/{date2}/g, (this.data.updateTime || " "));
- this.addInfor(text);
- text = this.explorer.app.lp.personReadLogin.replace(/{date}/g, (this.data.lastLoginTime || " "));
- text = text.replace(/{ip}/g, (this.data.lastLoginAddress || " "));
- text = text.replace(/{client}/g, (this.data.lastLoginClient || " "));
- this.addInfor(text);
- text = this.explorer.app.lp.personReadPassword.replace(/{date}/g, (this.data.passwordExpiredTime || " "));
- text = text.replace(/{date2}/g, (this.data.changePasswordTime || " "));
- this.addInfor(text);
- }
- });
- MWF.xApplication.Org.PersonExplorer.PersonContent.BaseInfor = new Class({
- initialize: function(content){
- this.content = content;
- this.item = content.item;
- this.data = this.content.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.node = new Element("div", {"styles": this.style.baseContentNode}).inject(this.contentNode);
- this.editContentNode = new Element("div", {"styles": this.style.baseEditNode}).inject(this.node);
- this.editContentNode.set("html", this.getContentHtml());
- var n = this.editContentNode.getElement(".infor_name");
- if (n) n.set("text", this.data.name || "");
- var n = this.editContentNode.getElement(".infor_employee");
- if (n) n.set("text", this.data.employee || "");
- var n = this.editContentNode.getElement(".infor_mobile");
- if (n) n.set("text", this.data.mobile || "");
- var n = this.editContentNode.getElement(".infor_unique");
- if (n) n.set("text", this.data.unique || "");
- var n = this.editContentNode.getElement(".infor_gender");
- if (n) n.set("text", this.getGenderType());
- var n = this.editContentNode.getElement(".infor_mail");
- if (n) n.set("text", this.data.mail || "");
- var n = this.editContentNode.getElement(".infor_weixin");
- if (n) n.set("text", this.data.weixin || "");
- var n = this.editContentNode.getElement(".infor_qq");
- if (n) n.set("text", this.data.qq || "");
- var n = this.editContentNode.getElement(".infor_officePhone");
- if (n) n.set("text", this.data.officePhone || "");
- var n = this.editContentNode.getElement(".infor_boardDate");
- if (n) n.set("text", this.data.boardDate || "");
- var n = this.editContentNode.getElement(".infor_birthday");
- if (n) n.set("text", this.data.birthday || "");
- this.editContentNode.getElements("td.inforTitle").setStyles(this.style.baseInforTitleNode);
- this.editContentNode.getElements("td.inforContent").setStyles(this.style.baseInforContentNode);
- this.editContentNode.getElements("td.inforAction").setStyles(this.style.baseInforActionNode);
- var tdContents = this.editContentNode.getElements("td.inforContent");
- if (this.data.superior) new MWF.widget.O2Person({"name": this.data.superior}, tdContents[5], {"style": "xform"});
- this.loadAction();
- },
- getContentHtml: function(){
- var html = "<table width='100%' cellpadding='3px' cellspacing='5px'>";
- html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personName+":</td><td class='inforContent infor_name'>"+(this.data.name || "")+"</td>" +
- "<td class='inforTitle'>"+this.explorer.app.lp.personEmployee+":</td><td class='inforContent infor_employee'>"+(this.data.employee || "")+"</td></tr>";
- html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personMobile+":</td><td class='inforContent infor_mobile'>"+(this.data.mobile || "")+"</td>" +
- "<td class='inforTitle'>"+this.explorer.app.lp.personUnique+":</td><td class='inforContent infor_unique'>"+(this.data.unique || "")+"</td></tr>";
- html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personGender+":</td><td class='inforContent infor_gender'>"+this.getGenderType()+"</td>" +
- "<td class='inforTitle'>"+this.explorer.app.lp.personSuperior+":</td><td class='inforContent'>"+"</td></tr>";
- html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personMail+":</td><td class='inforContent infor_mail'>"+(this.data.mail || "")+"</td>" +
- "<td class='inforTitle'>"+this.explorer.app.lp.personWeixin+":</td><td class='inforContent infor_weixin'>"+(this.data.weixin || "")+"</td></tr>";
- html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personQQ+":</td><td class='inforContent infor_qq'>"+(this.data.qq || "")+"</td>" +
- "<td class='inforTitle'>"+this.explorer.app.lp.personOfficePhone+":</td><td class='inforContent infor_officePhone'>"+(this.data.officePhone || "")+"</td></tr>";
- html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personBoardDate+":</td><td class='inforContent infor_boardDate'>"+(this.data.boardDate || "")+"</td>" +
- "<td class='inforTitle'>"+this.explorer.app.lp.personBirthday+":</td><td class='inforContent infor_birthday'>"+(this.data.birthday || "")+"</td></tr>";
- html += "<tr><td colspan='4' class='inforAction'></td></tr>";
- //this.baseInforRightNode.set("html", html);
- return html;
- },
- loadAction: function(){
- //this.explorer.app.lp.edit
- var actionAreas = this.editContentNode.getElements("td");
- var actionArea = actionAreas[actionAreas.length-1];
- if (this.data.control.allowEdit){
- this.baseInforEditActionAreaNode = new Element("div", {"styles": this.style.baseInforEditActionAreaNode}).inject(actionArea);
- this.editNode = new Element("div", {"styles": this.style.actionEditNode, "text": this.explorer.app.lp.editPerson}).inject(this.baseInforEditActionAreaNode);
- this.saveNode = new Element("div", {"styles": this.style.actionSaveNode, "text": this.explorer.app.lp.savePerson}).inject(this.baseInforEditActionAreaNode);
- 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));
- }else{
- }
- },
- edit: function(){
- var tdContents = this.editContentNode.getElements("td.inforContent");
- tdContents[0].setStyles(this.style.baseInforContentNode_edit).empty();
- this.nameInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[0]);
- this.nameInputNode.set("value", (this.data.name));
- tdContents[1].setStyles(this.style.baseInforContentNode_edit).empty();
- this.employeeInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[1]);
- this.employeeInputNode.set("value", (this.data.employee));
- tdContents[2].setStyles(this.style.baseInforContentNode_edit).empty();
- this.mobileInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[2]);
- this.mobileInputNode.set("value", (this.data.mobile));
- tdContents[3].setStyles(this.style.baseInforContentNode_edit).empty();
- this.uniqueInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[3]);
- this.uniqueInputNode.set("value", (this.data.unique));
- tdContents[4].setStyles(this.style.baseInforContentNode_edit).empty();
- var html = "<input name=\"personGenderRadioNode\" value=\"m\" type=\"radio\" "+((this.data.genderType==="m") ? "checked" : "")+"/>"+this.explorer.app.lp.man;
- html += "<input name=\"personGenderRadioNode\" value=\"f\" type=\"radio\" "+((this.data.genderType==="f") ? "checked" : "")+"/>"+this.explorer.app.lp.female;
- html += "<input name=\"personGenderRadioNode\" value=\"o\" type=\"radio\" "+((this.data.genderType==="d") ? "checked" : "")+"/>"+this.explorer.app.lp.other;
- tdContents[4].set("html", html);
- tdContents[5].setStyles(this.style.baseInforContentNode_edit).empty();
- this.superiorInputNode = new Element("div", {"styles": this.style.inputNode_person}).inject(tdContents[5]);
- //this.superiorInputNode.set("value", (this.data.superior));
- if (this.data.superior) new MWF.widget.O2Person({"name": this.data.superior}, this.superiorInputNode, {"style": "xform"});
- this.superiorInputNode.addEvent("click", function(){
- MWF.xDesktop.requireApp("Selector", "package", function(){
- var options = {
- "type": "person",
- "values": (this.data.superior) ? [this.data.superior] : [],
- "count": 1,
- "onComplete": function(items){
- this.data.superior = items[0].data.distinguishedName;
- this.superiorInputNode.empty();
- new MWF.widget.O2Person(items[0].data, this.superiorInputNode, {"style": "xform"});
- }.bind(this)
- };
- var selector = new MWF.O2Selector(this.explorer.app.content, options);
- }.bind(this));
- }.bind(this));
- tdContents[6].setStyles(this.style.baseInforContentNode_edit).empty();
- this.mailInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[6]);
- this.mailInputNode.set("value", (this.data.mail));
- tdContents[7].setStyles(this.style.baseInforContentNode_edit).empty();
- this.weixinInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[7]);
- this.weixinInputNode.set("value", (this.data.weixin));
- tdContents[8].setStyles(this.style.baseInforContentNode_edit).empty();
- this.qqInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[8]);
- this.qqInputNode.set("value", (this.data.qq));
- tdContents[9].setStyles(this.style.baseInforContentNode_edit).empty();
- this.officePhoneInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[9]);
- this.officePhoneInputNode.set("value", (this.data.officePhone));
- tdContents[10].setStyles(this.style.baseInforContentNode_edit).empty();
- this.boardDateInputNode = new Element("input", {"styles": this.style.inputNode_calendar, "readonly": true}).inject(tdContents[10]);
- this.boardDateInputNode.set("value", (this.data.boardDate));
- MWF.require("MWF.widget.Calendar", function(){
- var boardDateCalendar = new MWF.widget.Calendar(this.boardDateInputNode, {
- "style": "xform",
- "isTime": false,
- "target": this.explorer.app.content,
- "format": "%Y-%m-%d"
- });
- }.bind(this));
- tdContents[11].setStyles(this.style.baseInforContentNode_edit).empty();
- this.birthdayInputNode = new Element("input", {"styles": this.style.inputNode_calendar, "readonly": true}).inject(tdContents[11]);
- this.birthdayInputNode.set("value", (this.data.birthday));
- MWF.require("MWF.widget.Calendar", function(){
- var birthdayCalendar = new MWF.widget.Calendar(this.birthdayInputNode, {
- "style": "xform",
- "isTime": false,
- "target": this.explorer.app.content,
- "format": "%Y-%m-%d"
- });
- }.bind(this));
- var _self = this;
- this.editContentNode.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.mode = "edit";
- this.editNode.setStyle("display", "none");
- this.saveNode.setStyle("display", "block");
- this.cancelNode.setStyle("display", "block");
- },
- save: function(){
- var tdContents = this.editContentNode.getElements("td.inforContent");
- var gender = "";
- var radios = tdContents[4].getElements("input");
- for (var i=0; i<radios.length; i++){
- if (radios[i].checked){
- gender = radios[i].value;
- break;
- }
- }
- //if (!this.nameInputNode.get("value") || !this.employeeInputNode.get("value") || !this.mobileInputNode.get("value") || !gender){
- if (!this.nameInputNode.get("value") || !this.mobileInputNode.get("value") || !gender){
- this.explorer.app.notice(this.explorer.app.lp.inputPersonInfor, "error", this.explorer.propertyContentNode);
- return false;
- }
- //this.data.genderType = gender;
- if (!this.uniqueInputNode.get("value")) this.data.unique = this.employeeInputNode.get("value");
- this.content.propertyContentScrollNode.mask({
- "style": {
- "opacity": 0.7,
- "background-color": "#999"
- }
- });
- this.savePerson(function(){
- this.cancel();
- this.content.propertyContentScrollNode.unmask();
- }.bind(this), function(xhr, text, error){
- var errorText = error;
- if (xhr){
- var json = JSON.decode(xhr.responseText);
- if (json){
- errorText = json.message.trim() || "request json error";
- }else{
- errorText = "request json error: "+xhr.responseText;
- }
- }
- MWF.xDesktop.notice("error", {x: "right", y:"top"}, errorText);
- this.content.propertyContentScrollNode.unmask();
- }.bind(this));
- },
- savePerson: function(callback, cancel){
- var data = Object.clone(this.data);
- data.name = this.nameInputNode.get("value");
- data.employee = this.employeeInputNode.get("value");
- data.mobile = this.mobileInputNode.get("value");
- data.unique = this.uniqueInputNode.get("value");
- //data.superior = this.superiorInputNode.get("value");
- data.mail = this.mailInputNode.get("value");
- data.weixin = this.weixinInputNode.get("value");
- data.qq = this.qqInputNode.get("value");
- data.officePhone = this.officePhoneInputNode.get("value");
- data.boardDate = this.boardDateInputNode.get("value");
- data.birthday = this.birthdayInputNode.get("value");
- var tdContents = this.editContentNode.getElements("td.inforContent");
- var radios = tdContents[4].getElements("input");
- for (var i=0; i<radios.length; i++){
- if (radios[i].checked){
- data.genderType = radios[i].value;
- break;
- }
- }
- this.explorer.actions.savePerson(data, function(json){
- Object.merge(this.data, data);
- if (this.data.id){
- this.data.id = json.data.id;
- this.item.refresh();
- if (callback) callback();
- }else{
- this.explorer.actions.getPerson(function(json){
- this.data = Object.merge(this.data, json.data);
- this.item.data = this.data;
- this.item.refresh();
- if (callback) callback();
- }.bind(this), null, json.data.id);
- }
- }.bind(this), function(xhr, text, error){
- if (cancel) cancel(xhr, text, error);
- }.bind(this));
- // }.bind(this), function(xhr, text, error){
- // if (cancel) cancel(xhr, text, error);
- // }.bind(this));
- },
- cancel: function(){
- if (this.data.id){
- var tdContents = this.editContentNode.getElements("td.inforContent");
- tdContents[0].setStyles(this.style.baseInforContentNode).set("text", this.data.name || "");
- tdContents[1].setStyles(this.style.baseInforContentNode).set("text", this.data.employee || "");
- tdContents[2].setStyles(this.style.baseInforContentNode).set("text", this.data.mobile || "");
- tdContents[3].setStyles(this.style.baseInforContentNode).set("text", this.data.unique || "");
- tdContents[4].setStyles(this.style.baseInforContentNode).set("text", this.getGenderType());
- tdContents[5].setStyles(this.style.baseInforContentNode).set("text", "");
- if (this.data.superior) new MWF.widget.O2Person({"name": this.data.superior}, tdContents[5], {"style": "xform"});
- tdContents[6].setStyles(this.style.baseInforContentNode).set("text", this.data.mail || "");
- tdContents[7].setStyles(this.style.baseInforContentNode).set("text", this.data.weixin || "");
- tdContents[8].setStyles(this.style.baseInforContentNode).set("text", this.data.qq || "");
- tdContents[9].setStyles(this.style.baseInforContentNode).set("text", this.data.officePhone || "");
- tdContents[10].setStyles(this.style.baseInforContentNode).set("text", this.data.boardDate || "");
- tdContents[11].setStyles(this.style.baseInforContentNode).set("text", this.data.birthday || "");
- this.mode = "read";
- this.editNode.setStyle("display", "block");
- this.saveNode.setStyle("display", "none");
- this.cancelNode.setStyle("display", "none");
- }else{
- this.item.destroy();
- }
- },
- getGenderType: function(){
- var text = "";
- if (this.data.genderType){
- switch (this.data.genderType) {
- case "m":
- text = this.explorer.app.lp.man;
- break;
- case "f":
- text = this.explorer.app.lp.female;
- break;
- default:
- text = this.explorer.app.lp.other;
- }
- }
- return text;
- },
- destroy: function(){
- this.node.empty();
- this.node.destroy();
- MWF.release(this);
- },
- _getIcon: function(nocache){
- var url = (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "/x_component_Org/$Explorer/default/icon/man.png";
- return (nocache) ? url+"?"+(new Date().getTime()) : url;
- //return (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "/x_component_Org/$Explorer/default/icon/man.png";
- // var src = "data:image/png;base64,"+this.data.icon;
- // if (!this.data.icon){
- // if (this.data.genderType==="f"){
- // src = "/x_component_Org/$Explorer/default/icon/female.png"
- // }else{
- // src = "/x_component_Org/$Explorer/default/icon/man.png"
- // }
- // }
- // return src;
- }
- });
|