PersonExplorer.js 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024
  1. // MWF.xDesktop.requireApp("Organization", "GroupExplorer", null, false);
  2. // MWF.xDesktop.requireApp("Organization", "OrgExplorer", null, false);
  3. MWF.xDesktop.requireApp("Org", "$Explorer", null, false);
  4. MWF.require("MWF.widget.O2Identity", null, false);
  5. MWF.xApplication.Org.PersonExplorer = new Class({
  6. Extends: MWF.xApplication.Org.$Explorer,
  7. Implements: [Options, Events],
  8. options: {
  9. "style": "default"
  10. },
  11. _isActionManager: function(){
  12. return (MWF.AC.isOrganizationManager() || MWF.AC.isPersonManager() || MWF.AC.isUnitManager());
  13. },
  14. _listElementNext: function(lastid, count, callback){
  15. this.actions.listPersonNext(lastid||"(0)", count, function(json){
  16. if (callback) {
  17. callback.apply(this, [json]);
  18. }
  19. }.bind(this));
  20. },
  21. _newElement: function(data, explorer, i){
  22. return new MWF.xApplication.Org.PersonExplorer.Person(data, explorer, this.isEditor, i);
  23. },
  24. _listElementByKey: function(callback, failure, key){
  25. //this.actions.listPersonByPinyin(function(json){
  26. this.actions.listPersonByKey(function(json){
  27. if (callback) {
  28. callback.apply(this, [json]);
  29. }
  30. }.bind(this), failure, key);
  31. },
  32. _getAddElementData: function(){
  33. return {
  34. "genderType": "m",
  35. "signature": "",
  36. "description": "",
  37. "unique": "",
  38. "orderNumber": "",
  39. "superior": "",
  40. "officePhone": "",
  41. "boardDate": "",
  42. "birthday": "",
  43. "employee": "",
  44. "password": "",
  45. "display": "",
  46. "qq": "",
  47. "mail": "",
  48. "weixin": "",
  49. "weibo": "",
  50. "mobile": "",
  51. "name": "",
  52. "ipAddress" : "",
  53. "controllerList": [],
  54. "woPersonAttributeList":[],
  55. "woIdentityList": [],
  56. "control": {
  57. "allowEdit": true,
  58. "allowDelete": true
  59. }
  60. };
  61. }
  62. });
  63. MWF.xApplication.Org.PersonExplorer.Person = new Class({
  64. Extends: MWF.xApplication.Org.$Explorer.Item,
  65. showItemProperty: function(){
  66. this.content = new MWF.xApplication.Org.PersonExplorer.PersonContent(this);
  67. },
  68. _loadTextNode: function(){
  69. var html = "<div style='float:left; height:50px; overflow:hidden'>"+this.data.name+"</div>";
  70. html += "<div style='float: right; overflow:hidden; font-size: 12px; color: #aaaaaa;'>"+(this.data.mobile || "")+"</div>";
  71. this.textNode.set({"html": html});
  72. },
  73. "delete": function(success, failure){
  74. this.explorer.actions.deletePerson(this.data.id, function(){
  75. this.destroy();
  76. if (success) success();
  77. }.bind(this), function(xhr, text, error){
  78. var errorText = error;
  79. if (xhr) errorText = xhr.responseText;
  80. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  81. if (failure) failure();
  82. });
  83. },
  84. _getIcon: function(nocache){
  85. var url = (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "../x_component_Org/$Explorer/default/icon/man.png";
  86. return (nocache) ? url+"?"+(new Date().getTime()) : url;
  87. //return (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "../x_component_Org/$Explorer/default/icon/man.png";
  88. // var src = "data:image/png;base64,"+this.data.icon;
  89. // if (!this.data.icon){
  90. // if (this.data.genderType==="f"){
  91. // src = "../x_component_Org/$Explorer/default/icon/female24.png"
  92. // }else{
  93. // src = "../x_component_Org/$Explorer/default/icon/man24.png"
  94. // }
  95. // }
  96. // return src;
  97. }
  98. });
  99. MWF.xApplication.Org.PersonExplorer.PersonContent = new Class({
  100. Extends: MWF.xApplication.Org.$Explorer.ItemContent,
  101. _getData: function(callback){
  102. if (this.item.data.id){
  103. this.explorer.actions.getPerson(function(json){
  104. this.data = json.data;
  105. this.item.data = json.data;
  106. if (callback) callback();
  107. }.bind(this), null, this.item.data.id);
  108. }else{
  109. this.data = this.item.data;
  110. if (callback) callback();
  111. }
  112. },
  113. edit: function(){
  114. if (this.baseInfor) this.baseInfor.edit();
  115. },
  116. _showItemPropertyTitle: function(){
  117. this.titleInfor = new MWF.xApplication.Org.PersonExplorer.PersonContent.TitleInfor(this);
  118. //this.baseInfor = new MWF.xApplication.Org.BaseInfor(this);
  119. },
  120. _showItemPropertyBottom: function(){
  121. this.bottomInfor = new MWF.xApplication.Org.PersonExplorer.PersonContent.BottomInfor(this);
  122. },
  123. loadItemPropertyTab: function(callback){
  124. this.propertyTabContainerNode = new Element("div", {"styles": this.item.style.tabTitleNode}).inject(this.propertyContentNode, "top");
  125. MWF.require("MWF.widget.Tab", function(){
  126. this.propertyTab = new MWF.widget.Tab(this.propertyContentNode, {"style": "unit"});
  127. this.propertyTab.load();
  128. this.propertyTab.tabNodeContainer.inject(this.propertyTabContainerNode);
  129. this.propertyTab.tabNodeContainer.setStyle("width","480px");
  130. if (callback) callback();
  131. }.bind(this));
  132. },
  133. _loadTabs: function(){
  134. this.baseContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  135. this.basePage = this.propertyTab.addTab(this.baseContentNode, this.explorer.app.lp.personBaseText);
  136. this.attributeContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  137. this.attributePage = this.propertyTab.addTab(this.attributeContentNode, this.explorer.app.lp.personAttributeText);
  138. this.identityContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  139. this.identityPage = this.propertyTab.addTab(this.identityContentNode, this.explorer.app.lp.personIdentityText);
  140. this.roleContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  141. this.rolePage = this.propertyTab.addTab(this.roleContentNode, this.explorer.app.lp.personRoleText);
  142. // this.managerContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  143. // this.managerPage = this.propertyTab.addTab(this.managerContentNode, this.explorer.app.lp.controllerListText);
  144. },
  145. _loadContent: function(){
  146. this._listBaseInfor();
  147. if( this.data && this.data.id ){
  148. this._listAttribute();
  149. this._listIdentity();
  150. this._listRole();
  151. this.loadListCount();
  152. }
  153. //
  154. // this.showAttribute();
  155. },
  156. loadList : function(){
  157. this._listAttribute();
  158. this._listIdentity();
  159. this._listRole();
  160. this.loadListCount();
  161. },
  162. loadListCount: function(){
  163. if (this.data.woIdentityList){
  164. var identityCount = this.data.woIdentityList.length;
  165. if (identityCount){
  166. if (!this.identityCountNode){
  167. this.identityCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": identityCount}).inject(this.identityPage.tabNode);
  168. }else{
  169. this.identityCountNode.set("text", identityCount);
  170. }
  171. }else{
  172. if (this.identityCountNode) this.identityCountNode.destroy();
  173. }
  174. }
  175. if (this.data.woPersonAttributeList){
  176. var attributeCount = this.data.woPersonAttributeList.length;
  177. if (attributeCount){
  178. if (!this.attributeCountNode){
  179. this.attributeCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": attributeCount}).inject(this.attributePage.tabNode);
  180. }else{
  181. this.attributeCountNode.set("text", attributeCount);
  182. }
  183. }else{
  184. if (this.attributeCountNode) this.attributeCountNode.destroy();
  185. }
  186. }
  187. if( this.roleDataList ){
  188. var roleCount = this.roleDataList.length;
  189. if (roleCount){
  190. if (!this.roleCountNode){
  191. this.roleCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": roleCount}).inject(this.rolePage.tabNode);
  192. }else{
  193. this.roleCountNode.set("text", roleCount);
  194. }
  195. }else{
  196. if (this.roleCountNode) this.roleCountNode.destroy();
  197. }
  198. }
  199. // var groupCount = this.data.groupList.length;
  200. // if (groupCount){
  201. // this.groupCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": groupCount}).inject(this.groupMemberPage.tabNode);
  202. // }
  203. },
  204. _listBaseInfor: function(){
  205. this.baseInfor = new MWF.xApplication.Org.PersonExplorer.PersonContent.BaseInfor(this);
  206. },
  207. _listAttribute: function(){
  208. this.attributeList = new MWF.xApplication.Org.List(this.attributeContentNode, this, {
  209. "action": this.data.control.allowEdit,
  210. "data": {
  211. "person": this.data.id,
  212. "name": "",
  213. "unique": "",
  214. "orderNumber": "",
  215. "attributeList": [],
  216. "description":""
  217. },
  218. "attr": ["name", {
  219. "get": function(){return this.attributeList.join(",")},
  220. "set": function(value){ this.attributeList = value.split(/,\s*/g)}
  221. }, "description"],
  222. "onPostSave": function(item, id){
  223. if (!item.data.id){
  224. item.data.id = id;
  225. this.data.woPersonAttributeList.push(item.data);
  226. }
  227. this.loadListCount();
  228. // if (!item.data.id){
  229. // if (this.attributeCountNode){
  230. // var count = this.attributeCountNode.get("text").toInt()+1;
  231. // this.attributeCountNode.set("text", count);
  232. // }
  233. // }
  234. }.bind(this),
  235. "onPostDelete": function(delCount){
  236. if (this.attributeCountNode){
  237. var count = this.attributeCountNode.get("text").toInt()-delCount;
  238. this.attributeCountNode.set("text", count);
  239. }
  240. }.bind(this)
  241. });
  242. this.attributeList.load([
  243. {"style": "width: 20%", "text": this.explorer.app.lp.attributeName},
  244. {"style": "", "text": this.explorer.app.lp.attributeValue},
  245. {"style": "", "text": this.explorer.app.lp.description}
  246. ]);
  247. this.data.woPersonAttributeList.each(function(item){
  248. this.attributeList.push(item);
  249. }.bind(this));
  250. // if (this.data.id){
  251. // this.explorer.actions.listPersonAttribute(function(json){
  252. //
  253. // var attributeCount = json.data.length;
  254. // if (attributeCount){
  255. // this.attributeCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": attributeCount}).inject(this.attributePage.tabNode);
  256. // }
  257. //
  258. // json.data.each(function(item){
  259. // //this.attributes.push(new MWF.xApplication.Org.PersonExplorer.PersonAttribute(this.attributeTabContentNode.getElement("table").getFirst(), item, this, this.explorer.css.list));
  260. // this.attributeList.push(item);
  261. // }.bind(this));
  262. // }.bind(this), null, this.data.id);
  263. // }
  264. },
  265. _listIdentity: function(){
  266. var _self = this;
  267. this.identityList = new MWF.xApplication.Org.List(this.identityContentNode, this, {
  268. "action": false,
  269. "canEdit": false,
  270. "saveAction": "saveIdentity",
  271. "data": {
  272. "person": this.data.id,
  273. "name": "",
  274. "attributeList": []
  275. },
  276. "attr": ["name", {
  277. "get": function(){ return ""; },
  278. "events": {
  279. "init": function(){
  280. var contentNode = this.td;
  281. new MWF.widget.O2Unit(this.data.woUnit, contentNode, {"style": "xform"});
  282. }
  283. }
  284. }, {
  285. "get": function(){ return this.distinguishedName; },
  286. "set": function(value){ this.distinguishedName = value; }
  287. }, {
  288. "get": function(){ return ""; },
  289. "events": {
  290. "init": function(){
  291. var contentNode = this.td;
  292. if (this.data.woUnitDutyList){
  293. this.data.woUnitDutyList.each(function(duty){
  294. new MWF.widget.O2Duty(duty, contentNode, {"style": "xform"});
  295. }.bind(this));
  296. }
  297. }
  298. }
  299. }, {
  300. "getHtml": function(){
  301. if (this.major){
  302. return "<div style='width:24px; height:24px; background:url(../x_component_Org/$Explorer/"+
  303. _self.explorer.app.options.style+"/icon/mainid.png) center center no-repeat'></div>";
  304. }else{
  305. return "<div title='"+_self.explorer.app.lp.setIdentityMain+"' style='width:24px; height:24px; cursor: pointer; background:url(../x_component_Org/$Explorer/"+
  306. _self.explorer.app.options.style+"/icon/select.png) center center no-repeat'></div>";
  307. }
  308. },
  309. "events": {
  310. "click": function(){
  311. if (!this.data.major){
  312. if (_self.data.control.allowEdit){_self.setMainIdentity(this.data, this.td, this.item);}
  313. }
  314. }
  315. }
  316. },{
  317. "getHtml": function(){
  318. if (_self.data.control.allowEdit){
  319. return "<div style='width:24px; height:24px; cursor: pointer; background:url(../x_component_Org/$Explorer/"+
  320. _self.explorer.app.options.style+"/icon/edit.png) center center no-repeat'></div>";
  321. }
  322. return "";
  323. },
  324. "events": {
  325. "click": function(){
  326. debugger;
  327. if (_self.data.control.allowEdit){_self.editIdentity(this.data, this.td, this.item);}
  328. }
  329. }
  330. }]
  331. });
  332. this.identityList.load([
  333. {"style": "width: 12%", "text": this.explorer.app.lp.IdentityName},
  334. {"style": "width: 12%", "text": this.explorer.app.lp.IdentityInUnit},
  335. {"style": "width: 44%", "text": this.explorer.app.lp.personUnique},
  336. {"style": "width: 20%", "text": this.explorer.app.lp.IdentityDuty},
  337. {"style": "width: 10%", "text": this.explorer.app.lp.IdentityMain},
  338. {"style": "width: 30px", "text": ""}
  339. ]);
  340. this.data.woIdentityList.each(function(item){
  341. this.identityList.push(item);
  342. }.bind(this));
  343. },
  344. setMainIdentity: function(data, node, item){
  345. data.major = true;
  346. this.explorer.actions.saveIdentity(data, function(json){
  347. this.explorer.actions.getPerson(function(iJson){
  348. // data = iJson.data;
  349. // item.reload(iJson.data);
  350. this.data.woIdentityList = iJson.data.woIdentityList;
  351. this.identityList.clear();
  352. this.data.woIdentityList.each(function(item){
  353. this.identityList.push(item);
  354. }.bind(this));
  355. }.bind(this), null, this.data.id);
  356. }.bind(this));
  357. },
  358. editIdentity: function(data, node, item){
  359. var _self = this;
  360. var position = node.getPosition(this.explorer.app.content);
  361. var width = 700;
  362. var height = 170;
  363. var size = this.explorer.app.content.getSize();
  364. var x = (size.x-width)/2;
  365. var y = (size.y-height)/2;
  366. if (x<0) x = 0;
  367. if (y<20) y = 20;
  368. MWF.require("MWF.xDesktop.Dialog", function() {
  369. var dlg = new MWF.xDesktop.Dialog({
  370. "title": this.explorer.app.lp.modifyIdentity,
  371. "style": "org",
  372. "top": y - 20,
  373. "left": x,
  374. "fromTop": position.y - 20,
  375. "fromLeft": position.x,
  376. "width": width,
  377. "height": height,
  378. "html": "<div></div>",
  379. "maskNode": this.explorer.app.content,
  380. "container": this.explorer.app.content,
  381. "buttonList": [
  382. {
  383. "text": MWF.LP.process.button.ok,
  384. "action": function () {
  385. _self.saveIdentity(dlg, data, item);
  386. this.close();
  387. }
  388. },
  389. {
  390. "text": MWF.LP.process.button.cancel,
  391. "action": function () {
  392. this.close();
  393. }
  394. }
  395. ]
  396. });
  397. dlg.show();
  398. var node = dlg.content.getFirst();
  399. var html = "<table width='90%' cellpadding='0px' cellspacing='5px' align='center' style='margin-top:10px'>" +
  400. "<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>" +
  401. "<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>" +
  402. "<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>" +
  403. "<td style='text-align: center'><input value='yes' type='checkbox' "+((data.major) ? "checked" : "")+"/></td></tr></table>";
  404. node.set("html", html);
  405. var inputs = node.getElements("input");
  406. if (inputs[0]) inputs[0].set("value", data.name);
  407. if (inputs[1]) inputs[1].set("value", data.unique);
  408. //if (inputs[2]) inputs[2].set("value", data.major)
  409. }.bind(this));
  410. },
  411. saveIdentity: function(dlg, data, item){
  412. var node = dlg.content.getFirst();
  413. var inputs = node.getElements("input");
  414. var name = inputs[0].get("value");
  415. var unique = inputs[1].get("value");
  416. var major = (inputs[2].checked);
  417. if (data.name!==name || data.unique!==unique){
  418. if (name) data.name = name;
  419. data.unique=unique;
  420. data.major = major;
  421. this.explorer.actions.saveIdentity(data, function(json){
  422. this.explorer.actions.getPerson(function(iJson){
  423. // data = iJson.data;
  424. // item.reload(iJson.data);
  425. this.data.woIdentityList = iJson.data.woIdentityList;
  426. this.identityList.clear();
  427. this.data.woIdentityList.each(function(item){
  428. this.identityList.push(item);
  429. }.bind(this));
  430. }.bind(this), null, this.data.id);
  431. }.bind(this));
  432. }
  433. },
  434. _listRole: function(){
  435. var _self = this;
  436. this.roleList = new MWF.xApplication.Org.List(this.roleContentNode, this, {
  437. "action": false,
  438. "canEdit": false,
  439. "data": {
  440. // "person": this.data.id,
  441. // "name": "",
  442. // "unique": "",
  443. // "orderNumber": "",
  444. // "attributeList": [],
  445. // "description":""
  446. },
  447. "attr": ["name",
  448. "distinguishedName",
  449. "description",{
  450. "getHtml": function(){
  451. if (_self.data.control.allowEdit){
  452. return "<div style='width:24px; height:24px; cursor: pointer; background:url(../x_component_Org/$Explorer/"+
  453. _self.explorer.app.options.style+"/icon/open.png) center center no-repeat'></div>";
  454. }
  455. return "";
  456. },
  457. "events": {
  458. "click": function(){
  459. debugger;
  460. _self.explorer.openRole(this.data, this.td);
  461. }
  462. }
  463. }]
  464. });
  465. this.roleList.load([
  466. {"style": "width: 15%", "text": this.explorer.app.lp.roleName},
  467. {"style": "width: 30%", "text": this.explorer.app.lp.roleFullName},
  468. {"style": "", "text": this.explorer.app.lp.description},
  469. {"style": "width: 30px", "text": ""}
  470. ]);
  471. if( this.data.id ){
  472. o2.Actions.load("x_organization_assemble_control").RoleAction.listWithPerson(this.data.id, function (json) {
  473. this.roleDataList = json.data;
  474. json.data.each( function ( item ) {
  475. this.roleList.push(item);
  476. }.bind(this))
  477. }.bind(this), null, false);
  478. }
  479. // this.data.woPersonAttributeList.each(function(item){
  480. // this.roleList.push(item);
  481. // }.bind(this));
  482. }
  483. });
  484. MWF.xApplication.Org.PersonExplorer.PersonContent.TitleInfor = new Class({
  485. Extends: MWF.xApplication.Org.$Explorer.ItemContent.TitleInfor,
  486. loadAction: function(){
  487. //this.explorer.app.lp.edit
  488. this.nameNode.setStyle("margin-right", "80px");
  489. if (MWF.AC.isOrganizationManager() || MWF.AC.isPersonManager()){
  490. this.resetPasswordAction = new Element("div", {"styles": this.style.titleInforResetPasswordNode, "text": this.item.explorer.app.lp.resetPassword}).inject(this.nameNode, "before");
  491. this.resetPasswordAction.addEvent("click", function(e){this.resetPassword(e);}.bind(this));
  492. }
  493. if (this.data.control.allowEdit){
  494. this.iconNode.setStyle("cursor", "pointer");
  495. this.iconNode.addEvent("click", function(){this.changePersonIcon();}.bind(this));
  496. }
  497. },
  498. resetPassword: function(e){
  499. var _self = this;
  500. var text = this.item.explorer.app.lp.resetPasswordText;
  501. text = text.replace("{name}", this.data.name);
  502. this.item.explorer.app.confirm("info", e, this.item.explorer.app.lp.resetPasswordTitle, text, "360", "120", function(){
  503. _self.doResetPassword();
  504. this.close();
  505. }, function(){
  506. this.close();
  507. });
  508. },
  509. doResetPassword: function(){
  510. var action = MWF.Actions.get("x_organization_assemble_control");
  511. action.resetPassword(this.data.id, function(){
  512. var text = this.item.explorer.app.lp.resetPasswordSuccess;
  513. text = text.replace("{name}", this.data.name);
  514. this.item.explorer.app.notice(text, "success");
  515. }.bind(this));
  516. },
  517. changePersonIcon: function(){
  518. var options = {};
  519. var width = "668";
  520. var height = "510";
  521. width = width.toInt();
  522. height = height.toInt();
  523. var size = this.explorer.app.content.getSize();
  524. var x = (size.x-width)/2;
  525. var y = (size.y-height)/2;
  526. if (x<0) x = 0;
  527. if (y<0) y = 0;
  528. if (layout.mobile){
  529. x = 20;
  530. y = 0;
  531. }
  532. var _self = this;
  533. MWF.require("MWF.xDesktop.Dialog", function() {
  534. MWF.require("MWF.widget.ImageClipper", function(){
  535. var dlg = new MWF.xDesktop.Dialog({
  536. "title": this.explorer.app.lp.changePersonIcon,
  537. "style": "image",
  538. "top": y,
  539. "left": x - 20,
  540. "fromTop": y,
  541. "fromLeft": x - 20,
  542. "width": width,
  543. "height": height,
  544. "html": "<div></div>",
  545. "maskNode": this.explorer.app.content,
  546. "container": this.explorer.app.content,
  547. "buttonList": [
  548. {
  549. "text": MWF.LP.process.button.ok,
  550. "action": function () {
  551. _self.uploadPersonIcon();
  552. this.close();
  553. }
  554. },
  555. {
  556. "text": MWF.LP.process.button.cancel,
  557. "action": function () {
  558. _self.image = null;
  559. this.close();
  560. }
  561. }
  562. ]
  563. });
  564. dlg.show();
  565. this.image = new MWF.widget.ImageClipper(dlg.content.getFirst(), {
  566. "aspectRatio": 1,
  567. "description" : "",
  568. "imageUrl" : this._getIcon(true),
  569. "resetEnable" : false
  570. });
  571. this.image.load();
  572. }.bind(this));
  573. }.bind(this))
  574. },
  575. uploadPersonIcon: function(){
  576. if (this.image){
  577. if( this.image.getResizedImage() ){
  578. this.explorer.actions.changePersonIcon(this.data.id, this.image.getFormData(), this.image.getResizedImage(), function(){
  579. this.iconNode.set("src", "");
  580. if (this.item.iconNode) this.item.iconNode.getElement("img").set("src", "");
  581. window.setTimeout(function(){
  582. this.iconNode.set("src", this._getIcon(true));
  583. if (this.item.iconNode) this.item.iconNode.getElement("img").set("src", this.item._getIcon(true));
  584. }.bind(this), 100);
  585. }.bind(this), null);
  586. }
  587. }
  588. }
  589. });
  590. MWF.xApplication.Org.PersonExplorer.PersonContent.BottomInfor = new Class({
  591. Extends: MWF.xApplication.Org.$Explorer.ItemContent.BottomInfor,
  592. addInforList: function(){
  593. var text = this.explorer.app.lp.personReadDn.replace(/{dn}/g, (this.data.distinguishedName || " "));
  594. this.addInfor(text);
  595. text = this.explorer.app.lp.personReadCreate.replace(/{date}/g, (this.data.createTime || " "));
  596. text = text.replace(/{date2}/g, (this.data.updateTime || " "));
  597. this.addInfor(text);
  598. text = this.explorer.app.lp.personReadLogin.replace(/{date}/g, (this.data.lastLoginTime || " "));
  599. text = text.replace(/{ip}/g, (this.data.lastLoginAddress || " "));
  600. text = text.replace(/{client}/g, (this.data.lastLoginClient || " "));
  601. this.addInfor(text);
  602. text = this.explorer.app.lp.personReadPassword.replace(/{date}/g, (this.data.passwordExpiredTime || " "));
  603. text = text.replace(/{date2}/g, (this.data.changePasswordTime || " "));
  604. this.addInfor(text);
  605. }
  606. });
  607. MWF.xApplication.Org.PersonExplorer.PersonContent.BaseInfor = new Class({
  608. initialize: function(content){
  609. this.content = content;
  610. this.item = content.item;
  611. this.data = this.content.data;
  612. this.explorer = this.item.explorer;
  613. this.contentNode = this.content.baseContentNode;
  614. this.style = this.item.style.person;
  615. this.attributes = [];
  616. this.mode = "read";
  617. this.load();
  618. },
  619. load: function(){
  620. this.node = new Element("div", {"styles": this.style.baseContentNode}).inject(this.contentNode);
  621. this.editContentNode = new Element("div", {"styles": this.style.baseEditNode}).inject(this.node);
  622. this.editContentNode.set("html", this.getContentHtml());
  623. var n = this.editContentNode.getElement(".infor_name");
  624. if (n) n.set("text", this.data.name || "");
  625. var n = this.editContentNode.getElement(".infor_employee");
  626. if (n) n.set("text", this.data.employee || "");
  627. var n = this.editContentNode.getElement(".infor_mobile");
  628. if (n) n.set("text", this.data.mobile || "");
  629. var n = this.editContentNode.getElement(".infor_unique");
  630. if (n) n.set("text", this.data.unique || "");
  631. var n = this.editContentNode.getElement(".infor_gender");
  632. if (n) n.set("text", this.getGenderType());
  633. var n = this.editContentNode.getElement(".infor_mail");
  634. if (n) n.set("text", this.data.mail || "");
  635. var n = this.editContentNode.getElement(".infor_weixin");
  636. if (n) n.set("text", this.data.weixin || "");
  637. var n = this.editContentNode.getElement(".infor_qq");
  638. if (n) n.set("text", this.data.qq || "");
  639. var n = this.editContentNode.getElement(".infor_officePhone");
  640. if (n) n.set("text", this.data.officePhone || "");
  641. var n = this.editContentNode.getElement(".infor_boardDate");
  642. if (n) n.set("text", this.data.boardDate || "");
  643. var n = this.editContentNode.getElement(".infor_birthday");
  644. if (n) n.set("text", this.data.birthday || "");
  645. var n = this.editContentNode.getElement(".infor_ipAddress");
  646. if (n) n.set("text", this.data.ipAddress || "");
  647. this.editContentNode.getElements("td.inforTitle").setStyles(this.style.baseInforTitleNode);
  648. this.editContentNode.getElements("td.inforContent").setStyles(this.style.baseInforContentNode);
  649. this.editContentNode.getElements("td.inforAction").setStyles(this.style.baseInforActionNode);
  650. var tdContents = this.editContentNode.getElements("td.inforContent");
  651. if (this.data.superior) new MWF.widget.O2Person({"name": this.data.superior}, tdContents[5], {"style": "xform"});
  652. this.loadAction();
  653. },
  654. getContentHtml: function(){
  655. var html = "<table width='100%' cellpadding='3px' cellspacing='5px'>";
  656. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personName+":</td><td class='inforContent infor_name'>"+(this.data.name || "")+"</td>" +
  657. "<td class='inforTitle'>"+this.explorer.app.lp.personEmployee+":</td><td class='inforContent infor_employee'>"+(this.data.employee || "")+"</td></tr>";
  658. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personMobile+":</td><td class='inforContent infor_mobile'>"+(this.data.mobile || "")+"</td>" +
  659. "<td class='inforTitle'>"+this.explorer.app.lp.personUnique+":</td><td class='inforContent infor_unique'>"+(this.data.unique || "")+"</td></tr>";
  660. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personGender+":</td><td class='inforContent infor_gender'>"+this.getGenderType()+"</td>" +
  661. "<td class='inforTitle'>"+this.explorer.app.lp.personSuperior+":</td><td class='inforContent'>"+"</td></tr>";
  662. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personMail+":</td><td class='inforContent infor_mail'>"+(this.data.mail || "")+"</td>" +
  663. "<td class='inforTitle'>"+this.explorer.app.lp.personWeixin+":</td><td class='inforContent infor_weixin'>"+(this.data.weixin || "")+"</td></tr>";
  664. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personQQ+":</td><td class='inforContent infor_qq'>"+(this.data.qq || "")+"</td>" +
  665. "<td class='inforTitle'>"+this.explorer.app.lp.personOfficePhone+":</td><td class='inforContent infor_officePhone'>"+(this.data.officePhone || "")+"</td></tr>";
  666. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personBoardDate+":</td><td class='inforContent infor_boardDate'>"+(this.data.boardDate || "")+"</td>" +
  667. "<td class='inforTitle'>"+this.explorer.app.lp.personBirthday+":</td><td class='inforContent infor_birthday'>"+(this.data.birthday || "")+"</td></tr>";
  668. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.ipAddress+":</td><td class='inforContent infor_ipAddress'>"+(this.data.ipAddress || "")+"</td>" +
  669. "<td class='inforTitle'></td></tr>";
  670. html += "<tr><td colspan='4' class='inforAction'></td></tr>";
  671. //this.baseInforRightNode.set("html", html);
  672. return html;
  673. },
  674. loadAction: function(){
  675. //this.explorer.app.lp.edit
  676. var actionAreas = this.editContentNode.getElements("td");
  677. var actionArea = actionAreas[actionAreas.length-1];
  678. if (this.data.control.allowEdit){
  679. this.baseInforEditActionAreaNode = new Element("div", {"styles": this.style.baseInforEditActionAreaNode}).inject(actionArea);
  680. this.editNode = new Element("div", {"styles": this.style.actionEditNode, "text": this.explorer.app.lp.editPerson}).inject(this.baseInforEditActionAreaNode);
  681. this.saveNode = new Element("div", {"styles": this.style.actionSaveNode, "text": this.explorer.app.lp.savePerson}).inject(this.baseInforEditActionAreaNode);
  682. this.cancelNode = new Element("div", {"styles": this.style.actionCancelNode, "text": this.explorer.app.lp.cancel}).inject(this.baseInforEditActionAreaNode);
  683. this.editNode.setStyle("display", "block");
  684. this.editNode.addEvent("click", this.edit.bind(this));
  685. this.saveNode.addEvent("click", this.save.bind(this));
  686. this.cancelNode.addEvent("click", this.cancel.bind(this));
  687. }else{
  688. }
  689. },
  690. edit: function(){
  691. var tdContents = this.editContentNode.getElements("td.inforContent");
  692. tdContents[0].setStyles(this.style.baseInforContentNode_edit).empty();
  693. this.nameInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[0]);
  694. this.nameInputNode.set("value", (this.data.name));
  695. tdContents[1].setStyles(this.style.baseInforContentNode_edit).empty();
  696. this.employeeInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[1]);
  697. this.employeeInputNode.set("value", (this.data.employee));
  698. tdContents[2].setStyles(this.style.baseInforContentNode_edit).empty();
  699. this.mobileInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[2]);
  700. this.mobileInputNode.set("value", (this.data.mobile));
  701. tdContents[3].setStyles(this.style.baseInforContentNode_edit).empty();
  702. this.uniqueInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[3]);
  703. this.uniqueInputNode.set("value", (this.data.unique));
  704. tdContents[4].setStyles(this.style.baseInforContentNode_edit).empty();
  705. var html = "<input name=\"personGenderRadioNode\" value=\"m\" type=\"radio\" "+((this.data.genderType==="m") ? "checked" : "")+"/>"+this.explorer.app.lp.man;
  706. html += "<input name=\"personGenderRadioNode\" value=\"f\" type=\"radio\" "+((this.data.genderType==="f") ? "checked" : "")+"/>"+this.explorer.app.lp.female;
  707. html += "<input name=\"personGenderRadioNode\" value=\"d\" type=\"radio\" "+((this.data.genderType==="d") ? "checked" : "")+"/>"+this.explorer.app.lp.other;
  708. tdContents[4].set("html", html);
  709. tdContents[5].setStyles(this.style.baseInforContentNode_edit).empty();
  710. this.superiorInputNode = new Element("div", {"styles": this.style.inputNode_person}).inject(tdContents[5]);
  711. //this.superiorInputNode.set("value", (this.data.superior));
  712. if (this.data.superior) new MWF.widget.O2Person({"name": this.data.superior}, this.superiorInputNode, {"style": "xform"});
  713. this.superiorInputNode.addEvent("click", function(){
  714. MWF.xDesktop.requireApp("Selector", "package", function(){
  715. var options = {
  716. "type": "person",
  717. "values": (this.data.superior) ? [this.data.superior] : [],
  718. "count": 1,
  719. "onComplete": function(items){
  720. this.data.superior = items[0].data.distinguishedName;
  721. this.superiorInputNode.empty();
  722. new MWF.widget.O2Person(items[0].data, this.superiorInputNode, {"style": "xform"});
  723. }.bind(this)
  724. };
  725. var selector = new MWF.O2Selector(this.explorer.app.content, options);
  726. }.bind(this));
  727. }.bind(this));
  728. tdContents[6].setStyles(this.style.baseInforContentNode_edit).empty();
  729. this.mailInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[6]);
  730. this.mailInputNode.set("value", (this.data.mail));
  731. tdContents[7].setStyles(this.style.baseInforContentNode_edit).empty();
  732. this.weixinInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[7]);
  733. this.weixinInputNode.set("value", (this.data.weixin));
  734. tdContents[8].setStyles(this.style.baseInforContentNode_edit).empty();
  735. this.qqInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[8]);
  736. this.qqInputNode.set("value", (this.data.qq));
  737. tdContents[9].setStyles(this.style.baseInforContentNode_edit).empty();
  738. this.officePhoneInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[9]);
  739. this.officePhoneInputNode.set("value", (this.data.officePhone));
  740. tdContents[10].setStyles(this.style.baseInforContentNode_edit).empty();
  741. this.boardDateInputNode = new Element("input", {"styles": this.style.inputNode_calendar, "readonly": true}).inject(tdContents[10]);
  742. this.boardDateInputNode.set("value", (this.data.boardDate));
  743. MWF.require("MWF.widget.Calendar", function(){
  744. var boardDateCalendar = new MWF.widget.Calendar(this.boardDateInputNode, {
  745. "style": "xform",
  746. "isTime": false,
  747. "target": this.explorer.app.content,
  748. "format": "%Y-%m-%d"
  749. });
  750. }.bind(this));
  751. tdContents[11].setStyles(this.style.baseInforContentNode_edit).empty();
  752. this.birthdayInputNode = new Element("input", {"styles": this.style.inputNode_calendar, "readonly": true}).inject(tdContents[11]);
  753. this.birthdayInputNode.set("value", (this.data.birthday));
  754. MWF.require("MWF.widget.Calendar", function(){
  755. var birthdayCalendar = new MWF.widget.Calendar(this.birthdayInputNode, {
  756. "style": "xform",
  757. "isTime": false,
  758. "target": this.explorer.app.content,
  759. "format": "%Y-%m-%d"
  760. });
  761. }.bind(this));
  762. tdContents[12].setStyles(this.style.baseInforContentNode_edit).empty();
  763. this.ipAddressInputNode = new Element("input", {"styles": this.style.inputNode, "placeHolder": this.explorer.app.lp.ipAddressPlaceHolder, }).inject(tdContents[12]);
  764. this.ipAddressInputNode.set("value", (this.data.ipAddress));
  765. var _self = this;
  766. this.editContentNode.getElements("input").addEvents({
  767. "focus": function(){if (this.get("type").toLowerCase()==="text"){this.setStyles(_self.style.inputNode_focus);}},
  768. "blur": function(){if (this.get("type").toLowerCase()==="text"){this.setStyles(_self.style.inputNode_blur);}}
  769. });
  770. this.mode = "edit";
  771. this.editNode.setStyle("display", "none");
  772. this.saveNode.setStyle("display", "block");
  773. this.cancelNode.setStyle("display", "block");
  774. },
  775. save: function(){
  776. var tdContents = this.editContentNode.getElements("td.inforContent");
  777. var gender = "";
  778. var radios = tdContents[4].getElements("input");
  779. for (var i=0; i<radios.length; i++){
  780. if (radios[i].checked){
  781. gender = radios[i].value;
  782. break;
  783. }
  784. }
  785. //if (!this.nameInputNode.get("value") || !this.employeeInputNode.get("value") || !this.mobileInputNode.get("value") || !gender){
  786. if (!this.nameInputNode.get("value") || !this.mobileInputNode.get("value") || !gender){
  787. this.explorer.app.notice(this.explorer.app.lp.inputPersonInfor, "error", this.explorer.propertyContentNode);
  788. return false;
  789. }
  790. // var array = [];
  791. // var ipAddress = this.ipAddressInputNode.get("value") || "";
  792. // var ipV4Format = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
  793. // var ipV6Format = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
  794. // if( ipAddress.trim() ){
  795. // ipAddress.split(",").each( function(ip){
  796. // if(!ip.match(ipV4Format) && !ip.match(ipV6Format))array.push( ip );
  797. // })
  798. // }
  799. // if( array.length > 0 ){
  800. // this.explorer.app.notice( this.explorer.app.lp.ipAddressIncorrectNotice + array.join(","), "error", this.explorer.propertyContentNode);
  801. // return false;
  802. // }
  803. //this.data.genderType = gender;
  804. if (!this.uniqueInputNode.get("value")) this.data.unique = this.employeeInputNode.get("value");
  805. this.content.propertyContentScrollNode.mask({
  806. "style": {
  807. "opacity": 0.7,
  808. "background-color": "#999"
  809. }
  810. });
  811. this.savePerson(function(){
  812. this.cancel();
  813. this.content.propertyContentScrollNode.unmask();
  814. }.bind(this), function(xhr, text, error){
  815. var errorText = error;
  816. if (xhr){
  817. var json = JSON.decode(xhr.responseText);
  818. if (json){
  819. errorText = json.message.trim() || "request json error";
  820. }else{
  821. errorText = "request json error: "+xhr.responseText;
  822. }
  823. }
  824. MWF.xDesktop.notice("error", {x: "right", y:"top"}, errorText);
  825. this.content.propertyContentScrollNode.unmask();
  826. }.bind(this));
  827. },
  828. savePerson: function(callback, cancel){
  829. var data = Object.clone(this.data);
  830. data.name = this.nameInputNode.get("value");
  831. data.employee = this.employeeInputNode.get("value");
  832. data.mobile = this.mobileInputNode.get("value");
  833. data.unique = this.uniqueInputNode.get("value");
  834. //data.superior = this.superiorInputNode.get("value");
  835. data.mail = this.mailInputNode.get("value");
  836. data.weixin = this.weixinInputNode.get("value");
  837. data.qq = this.qqInputNode.get("value");
  838. data.officePhone = this.officePhoneInputNode.get("value");
  839. data.boardDate = this.boardDateInputNode.get("value");
  840. data.birthday = this.birthdayInputNode.get("value");
  841. data.ipAddress = this.ipAddressInputNode.get("value");
  842. var tdContents = this.editContentNode.getElements("td.inforContent");
  843. var radios = tdContents[4].getElements("input");
  844. for (var i=0; i<radios.length; i++){
  845. if (radios[i].checked){
  846. data.genderType = radios[i].value;
  847. break;
  848. }
  849. }
  850. this.explorer.actions.savePerson(data, function(json){
  851. debugger;
  852. Object.merge(this.data, data);
  853. if (this.data.id){
  854. this.data.id = json.data.id;
  855. this.item.refresh();
  856. if (callback) callback();
  857. }else{
  858. this.explorer.actions.getPerson(function(json){
  859. this.data = Object.merge(this.data, json.data);
  860. this.item.data = this.data;
  861. this.item.refresh();
  862. this.content.loadList();
  863. if (callback) callback();
  864. }.bind(this), null, json.data.id);
  865. }
  866. }.bind(this), function(xhr, text, error){
  867. if (cancel) cancel(xhr, text, error);
  868. }.bind(this));
  869. // }.bind(this), function(xhr, text, error){
  870. // if (cancel) cancel(xhr, text, error);
  871. // }.bind(this));
  872. },
  873. cancel: function(){
  874. if (this.data.id){
  875. var tdContents = this.editContentNode.getElements("td.inforContent");
  876. tdContents[0].setStyles(this.style.baseInforContentNode).set("text", this.data.name || "");
  877. tdContents[1].setStyles(this.style.baseInforContentNode).set("text", this.data.employee || "");
  878. tdContents[2].setStyles(this.style.baseInforContentNode).set("text", this.data.mobile || "");
  879. tdContents[3].setStyles(this.style.baseInforContentNode).set("text", this.data.unique || "");
  880. tdContents[4].setStyles(this.style.baseInforContentNode).set("text", this.getGenderType());
  881. tdContents[5].setStyles(this.style.baseInforContentNode).set("text", "");
  882. if (this.data.superior) new MWF.widget.O2Person({"name": this.data.superior}, tdContents[5], {"style": "xform"});
  883. tdContents[6].setStyles(this.style.baseInforContentNode).set("text", this.data.mail || "");
  884. tdContents[7].setStyles(this.style.baseInforContentNode).set("text", this.data.weixin || "");
  885. tdContents[8].setStyles(this.style.baseInforContentNode).set("text", this.data.qq || "");
  886. tdContents[9].setStyles(this.style.baseInforContentNode).set("text", this.data.officePhone || "");
  887. tdContents[10].setStyles(this.style.baseInforContentNode).set("text", this.data.boardDate || "");
  888. tdContents[11].setStyles(this.style.baseInforContentNode).set("text", this.data.birthday || "");
  889. tdContents[12].setStyles(this.style.baseInforContentNode).set("text", this.data.ipAddress || "");
  890. this.mode = "read";
  891. this.editNode.setStyle("display", "block");
  892. this.saveNode.setStyle("display", "none");
  893. this.cancelNode.setStyle("display", "none");
  894. }else{
  895. this.item.destroy();
  896. }
  897. },
  898. getGenderType: function(){
  899. var text = "";
  900. if (this.data.genderType){
  901. switch (this.data.genderType) {
  902. case "m":
  903. text = this.explorer.app.lp.man;
  904. break;
  905. case "f":
  906. text = this.explorer.app.lp.female;
  907. break;
  908. default:
  909. text = this.explorer.app.lp.other;
  910. }
  911. }
  912. return text;
  913. },
  914. destroy: function(){
  915. this.node.empty();
  916. this.node.destroy();
  917. MWF.release(this);
  918. },
  919. _getIcon: function(nocache){
  920. var url = (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "../x_component_Org/$Explorer/default/icon/man.png";
  921. return (nocache) ? url+"?"+(new Date().getTime()) : url;
  922. //return (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "../x_component_Org/$Explorer/default/icon/man.png";
  923. // var src = "data:image/png;base64,"+this.data.icon;
  924. // if (!this.data.icon){
  925. // if (this.data.genderType==="f"){
  926. // src = "../x_component_Org/$Explorer/default/icon/female.png"
  927. // }else{
  928. // src = "../x_component_Org/$Explorer/default/icon/man.png"
  929. // }
  930. // }
  931. // return src;
  932. }
  933. });