PersonExplorer.js 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219
  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.xDesktop.requireApp("Template", "MTooltips", null, false);
  5. MWF.require("MWF.widget.O2Identity", null, false);
  6. MWF.xApplication.Org.PersonExplorer = new Class({
  7. Extends: MWF.xApplication.Org.$Explorer,
  8. Implements: [Options, Events],
  9. options: {
  10. "style": "default"
  11. },
  12. _isActionManager: function(){
  13. return (MWF.AC.isOrganizationManager() || MWF.AC.isPersonManager() || MWF.AC.isUnitManager());
  14. },
  15. _listElementNext: function(lastid, count, callback){
  16. this.actions.listPersonNext(lastid||"(0)", count, function(json){
  17. if (callback) {
  18. callback.apply(this, [json]);
  19. }
  20. }.bind(this));
  21. },
  22. _newElement: function(data, explorer, i){
  23. return new MWF.xApplication.Org.PersonExplorer.Person(data, explorer, this.isEditor, i);
  24. },
  25. _listElementByKey: function(callback, failure, key){
  26. //this.actions.listPersonByPinyin(function(json){
  27. this.actions.listPersonByKey(function(json){
  28. if (callback) {
  29. callback.apply(this, [json]);
  30. }
  31. }.bind(this), failure, key);
  32. },
  33. _getAddElementData: function(){
  34. return {
  35. "genderType": "m",
  36. "signature": "",
  37. "description": "",
  38. "unique": "",
  39. "orderNumber": "",
  40. "superior": "",
  41. "officePhone": "",
  42. "boardDate": "",
  43. "birthday": "",
  44. "employee": "",
  45. "password": "",
  46. "display": "",
  47. "qq": "",
  48. "mail": "",
  49. "weixin": "",
  50. "weibo": "",
  51. "mobile": "",
  52. "name": "",
  53. "ipAddress" : "",
  54. "controllerList": [],
  55. "woPersonAttributeList":[],
  56. "woIdentityList": [],
  57. "control": {
  58. "allowEdit": true,
  59. "allowDelete": true
  60. }
  61. };
  62. }
  63. });
  64. MWF.xApplication.Org.PersonExplorer.Person = new Class({
  65. Extends: MWF.xApplication.Org.$Explorer.Item,
  66. showItemProperty: function(){
  67. this.content = new MWF.xApplication.Org.PersonExplorer.PersonContent(this);
  68. },
  69. _loadTextNode: function(){
  70. var html = "<div style='float:left; height:50px; overflow:hidden'>"+this.data.name+"</div>";
  71. html += "<div style='float: right; overflow:hidden; font-size: 12px; color: #aaaaaa;'>"+(this.data.mobile || "")+"</div>";
  72. this.textNode.set({"html": html});
  73. },
  74. "delete": function(success, failure){
  75. this.explorer.actions.deletePerson(this.data.id, function(){
  76. this.destroy();
  77. if (success) success();
  78. }.bind(this), function(xhr, text, error){
  79. var errorText = error;
  80. if (xhr) errorText = xhr.responseText;
  81. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  82. if (failure) failure();
  83. });
  84. },
  85. _getIcon: function(nocache){
  86. var url = (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "../x_component_Org/$Explorer/default/icon/man.png";
  87. return (nocache) ? url+"?"+(new Date().getTime()) : url;
  88. //return (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "../x_component_Org/$Explorer/default/icon/man.png";
  89. // var src = "data:image/png;base64,"+this.data.icon;
  90. // if (!this.data.icon){
  91. // if (this.data.genderType==="f"){
  92. // src = "../x_component_Org/$Explorer/default/icon/female24.png"
  93. // }else{
  94. // src = "../x_component_Org/$Explorer/default/icon/man24.png"
  95. // }
  96. // }
  97. // return src;
  98. }
  99. });
  100. MWF.xApplication.Org.PersonExplorer.PersonContent = new Class({
  101. Extends: MWF.xApplication.Org.$Explorer.ItemContent,
  102. _getData: function(callback){
  103. if (this.item.data.id){
  104. this.explorer.actions.getPerson(function(json){
  105. this.data = json.data;
  106. this.item.data = json.data;
  107. if (callback) callback();
  108. }.bind(this), null, this.item.data.id);
  109. }else{
  110. this.data = this.item.data;
  111. if (callback) callback();
  112. }
  113. },
  114. edit: function(){
  115. if (this.baseInfor) this.baseInfor.edit();
  116. },
  117. _showItemPropertyTitle: function(){
  118. this.titleInfor = new MWF.xApplication.Org.PersonExplorer.PersonContent.TitleInfor(this);
  119. //this.baseInfor = new MWF.xApplication.Org.BaseInfor(this);
  120. },
  121. _showItemPropertyBottom: function(){
  122. this.bottomInfor = new MWF.xApplication.Org.PersonExplorer.PersonContent.BottomInfor(this);
  123. },
  124. loadItemPropertyTab: function(callback){
  125. this.propertyTabContainerNode = new Element("div", {"styles": this.item.style.tabTitleNode}).inject(this.propertyContentNode, "top");
  126. MWF.require("MWF.widget.Tab", function(){
  127. this.propertyTab = new MWF.widget.Tab(this.propertyContentNode, {"style": "unit", "useMainColor":true});
  128. this.propertyTab.load();
  129. this.propertyTab.tabNodeContainer.inject(this.propertyTabContainerNode);
  130. this.propertyTab.tabNodeContainer.setStyle("width","480px");
  131. if (callback) callback();
  132. }.bind(this));
  133. },
  134. _loadTabs: function(){
  135. this.baseContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  136. this.basePage = this.propertyTab.addTab(this.baseContentNode, this.explorer.app.lp.personBaseText);
  137. this.attributeContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  138. this.attributePage = this.propertyTab.addTab(this.attributeContentNode, this.explorer.app.lp.personAttributeText);
  139. this.identityContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  140. this.identityPage = this.propertyTab.addTab(this.identityContentNode, this.explorer.app.lp.personIdentityText);
  141. this.roleContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  142. this.rolePage = this.propertyTab.addTab(this.roleContentNode, this.explorer.app.lp.personRoleText);
  143. // this.managerContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  144. // this.managerPage = this.propertyTab.addTab(this.managerContentNode, this.explorer.app.lp.controllerListText);
  145. },
  146. _loadContent: function(){
  147. this._listBaseInfor();
  148. if( this.data && this.data.id ){
  149. this._listAttribute();
  150. this._listIdentity();
  151. this._listRole();
  152. this.loadListCount();
  153. }
  154. //
  155. // this.showAttribute();
  156. },
  157. loadList : function(){
  158. this._listAttribute();
  159. this._listIdentity();
  160. this._listRole();
  161. this.loadListCount();
  162. },
  163. loadListCount: function(){
  164. if (this.data.woIdentityList){
  165. var identityCount = this.data.woIdentityList.length;
  166. if (identityCount){
  167. if (!this.identityCountNode){
  168. this.identityCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": identityCount}).inject(this.identityPage.tabNode);
  169. }else{
  170. this.identityCountNode.set("text", identityCount);
  171. }
  172. }else{
  173. if (this.identityCountNode) this.identityCountNode.destroy();
  174. }
  175. }
  176. if (this.data.woPersonAttributeList){
  177. var attributeCount = this.data.woPersonAttributeList.length;
  178. if (attributeCount){
  179. if (!this.attributeCountNode){
  180. this.attributeCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": attributeCount}).inject(this.attributePage.tabNode);
  181. }else{
  182. this.attributeCountNode.set("text", attributeCount);
  183. }
  184. }else{
  185. if (this.attributeCountNode) this.attributeCountNode.destroy();
  186. }
  187. }
  188. if( this.roleDataList ){
  189. var roleCount = this.roleDataList.length;
  190. if (roleCount){
  191. if (!this.roleCountNode){
  192. this.roleCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": roleCount}).inject(this.rolePage.tabNode);
  193. }else{
  194. this.roleCountNode.set("text", roleCount);
  195. }
  196. }else{
  197. if (this.roleCountNode) this.roleCountNode.destroy();
  198. }
  199. }
  200. // var groupCount = this.data.groupList.length;
  201. // if (groupCount){
  202. // this.groupCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": groupCount}).inject(this.groupMemberPage.tabNode);
  203. // }
  204. },
  205. _listBaseInfor: function(){
  206. this.baseInfor = new MWF.xApplication.Org.PersonExplorer.PersonContent.BaseInfor(this);
  207. },
  208. _listAttribute: function(){
  209. this.attributeList = new MWF.xApplication.Org.List(this.attributeContentNode, this, {
  210. "action": this.data.control.allowEdit,
  211. "data": {
  212. "person": this.data.id,
  213. "name": "",
  214. "unique": "",
  215. "orderNumber": "",
  216. "attributeList": [],
  217. "description":""
  218. },
  219. "attr": ["name", {
  220. "get": function(){return this.attributeList.join(",")},
  221. "set": function(value){ this.attributeList = value.split(/,\s*/g)}
  222. }, "description"],
  223. "onPostSave": function(item, id){
  224. if (!item.data.id){
  225. item.data.id = id;
  226. this.data.woPersonAttributeList.push(item.data);
  227. }
  228. this.loadListCount();
  229. // if (!item.data.id){
  230. // if (this.attributeCountNode){
  231. // var count = this.attributeCountNode.get("text").toInt()+1;
  232. // this.attributeCountNode.set("text", count);
  233. // }
  234. // }
  235. }.bind(this),
  236. "onPostDelete": function(delCount){
  237. if (this.attributeCountNode){
  238. var count = this.attributeCountNode.get("text").toInt()-delCount;
  239. this.attributeCountNode.set("text", count);
  240. }
  241. }.bind(this)
  242. });
  243. this.attributeList.load([
  244. {"style": "width: 20%", "text": this.explorer.app.lp.attributeName},
  245. {"style": "", "text": this.explorer.app.lp.attributeValue},
  246. {"style": "", "text": this.explorer.app.lp.description}
  247. ]);
  248. this.data.woPersonAttributeList.each(function(item){
  249. this.attributeList.push(item);
  250. }.bind(this));
  251. // if (this.data.id){
  252. // this.explorer.actions.listPersonAttribute(function(json){
  253. //
  254. // var attributeCount = json.data.length;
  255. // if (attributeCount){
  256. // this.attributeCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": attributeCount}).inject(this.attributePage.tabNode);
  257. // }
  258. //
  259. // json.data.each(function(item){
  260. // //this.attributes.push(new MWF.xApplication.Org.PersonExplorer.PersonAttribute(this.attributeTabContentNode.getElement("table").getFirst(), item, this, this.explorer.css.list));
  261. // this.attributeList.push(item);
  262. // }.bind(this));
  263. // }.bind(this), null, this.data.id);
  264. // }
  265. },
  266. _listIdentity: function(){
  267. var _self = this;
  268. this.identityList = new MWF.xApplication.Org.List(this.identityContentNode, this, {
  269. "action": false,
  270. "canEdit": false,
  271. "saveAction": "saveIdentity",
  272. "data": {
  273. "person": this.data.id,
  274. "name": "",
  275. "attributeList": []
  276. },
  277. "attr": ["name", {
  278. "get": function(){ return ""; },
  279. "events": {
  280. "init": function(){
  281. var contentNode = this.td;
  282. new MWF.widget.O2Unit(this.data.woUnit, contentNode, {"style": "xform"});
  283. }
  284. }
  285. }, {
  286. "get": function(){ return this.distinguishedName; },
  287. "set": function(value){ this.distinguishedName = value; }
  288. }, {
  289. "get": function(){ return ""; },
  290. "events": {
  291. "init": function(){
  292. var contentNode = this.td;
  293. if (this.data.woUnitDutyList){
  294. this.data.woUnitDutyList.each(function(duty){
  295. new MWF.widget.O2Duty(duty, contentNode, {"style": "xform"});
  296. }.bind(this));
  297. }
  298. }
  299. }
  300. }, {
  301. "getHtml": function(){
  302. if (this.major){
  303. return "<div style='width:24px; height:24px; background:url(../x_component_Org/$Explorer/"+
  304. _self.explorer.app.options.style+"/icon/mainid.png) center center no-repeat'></div>";
  305. }else{
  306. return "<div title='"+_self.explorer.app.lp.setIdentityMain+"' style='width:24px; height:24px; cursor: pointer; background:url(../x_component_Org/$Explorer/"+
  307. _self.explorer.app.options.style+"/icon/select.png) center center no-repeat'></div>";
  308. }
  309. },
  310. "events": {
  311. "click": function(){
  312. if (!this.data.major){
  313. if (_self.data.control.allowEdit){_self.setMainIdentity(this.data, this.td, this.item);}
  314. }
  315. }
  316. }
  317. },{
  318. "getHtml": function(){
  319. if (_self.data.control.allowEdit){
  320. return "<div style='width:24px; height:24px; cursor: pointer; background:url(../x_component_Org/$Explorer/"+
  321. _self.explorer.app.options.style+"/icon/edit.png) center center no-repeat'></div>";
  322. }
  323. return "";
  324. },
  325. "events": {
  326. "click": function(){
  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. _self.explorer.openRole(this.data, this.td);
  460. }
  461. }
  462. }]
  463. });
  464. this.roleList.load([
  465. {"style": "width: 15%", "text": this.explorer.app.lp.roleName},
  466. {"style": "width: 30%", "text": this.explorer.app.lp.roleFullName},
  467. {"style": "", "text": this.explorer.app.lp.description},
  468. {"style": "width: 30px", "text": ""}
  469. ]);
  470. if( this.data.id ){
  471. // o2.Actions.load("x_organization_assemble_control").RoleAction.listWithPerson(this.data.id, function (json) {
  472. // this.roleDataList = json.data;
  473. // json.data.each( function ( item ) {
  474. // this.roleList.push(item);
  475. // }.bind(this))
  476. // }.bind(this), null, false);
  477. if( this.data.woRoleList && this.data.woRoleList.length ){
  478. this.roleDataList = this.data.woRoleList;
  479. this.data.woRoleList.each( function ( item ) {
  480. this.roleList.push(item);
  481. }.bind(this))
  482. }
  483. }
  484. // this.data.woPersonAttributeList.each(function(item){
  485. // this.roleList.push(item);
  486. // }.bind(this));
  487. }
  488. });
  489. MWF.xApplication.Org.PersonExplorer.PersonContent.TitleInfor = new Class({
  490. Extends: MWF.xApplication.Org.$Explorer.ItemContent.TitleInfor,
  491. getActionPermission: function(){
  492. if(MWF.AC.isManager())return true;
  493. if(MWF.AC.isSecurityManager())return true;
  494. if(MWF.AC.isSystemManager())return false;
  495. if(MWF.AC.isOrganizationManager())return true;
  496. if(MWF.AC.isPersonManager())return true;
  497. return false;
  498. },
  499. loadAction: function(){
  500. //this.explorer.app.lp.edit
  501. this.nameNode.setStyle("margin-right", "80px");
  502. if (this.getActionPermission()){
  503. this.resetPasswordAction = new Element("div", {"styles": this.style.titleInforResetPasswordNode, "text": this.item.explorer.app.lp.resetPassword}).inject(this.nameNode, "before");
  504. this.resetPasswordAction.addEvent("click", function(e){this.resetPassword(e);}.bind(this));
  505. this.expiredTimeAction = new Element("div", {"styles": this.style.titleInforUnlockPersonNode, "text": this.item.explorer.app.lp.expiredTime}).inject(this.nameNode, "before");
  506. this.expiredTimeAction.addEvent("click", function(e){this.setPasswordExpiredTime(e);}.bind(this));
  507. this.unlockPersonAction = new Element("div", {"styles": this.style.titleInforUnlockPersonNode, "text": this.item.explorer.app.lp.unlockPerson}).inject(this.nameNode, "before");
  508. this.unlockPersonAction.addEvent("click", function(e){this.unlockPerson(e);}.bind(this));
  509. }
  510. if (this.data.control.allowEdit){
  511. this.iconNode.setStyle("cursor", "pointer");
  512. this.iconNode.addEvent("click", function(){this.changePersonIcon();}.bind(this));
  513. }
  514. },
  515. resetPassword: function(e){
  516. var _self = this;
  517. var text = this.item.explorer.app.lp.resetPasswordText;
  518. text = text.replace("{name}", this.data.name);
  519. this.item.explorer.app.confirm("info", e, this.item.explorer.app.lp.resetPasswordTitle, text, "360", "120", function(){
  520. _self.doResetPassword();
  521. this.close();
  522. }, function(){
  523. this.close();
  524. });
  525. },
  526. doResetPassword: function(){
  527. var action = MWF.Actions.get("x_organization_assemble_control");
  528. action.resetPassword(this.data.id, function(){
  529. var text = this.item.explorer.app.lp.resetPasswordSuccess;
  530. text = text.replace("{name}", this.data.name);
  531. this.item.explorer.app.notice(text, "success");
  532. }.bind(this));
  533. },
  534. unlockPerson : function(e){
  535. var _self = this;
  536. var text = this.item.explorer.app.lp.unlockPersonText;
  537. text = text.replace("{name}", this.data.name);
  538. this.item.explorer.app.confirm("info", e, this.item.explorer.app.lp.unlockPersonTitle, text, "360", "120", function(){
  539. _self.doUnlockPerson();
  540. this.close();
  541. }, function(){
  542. this.close();
  543. });
  544. },
  545. doUnlockPerson: function(){
  546. MWF.Actions.load("x_organization_assemble_control").PersonAction.unlockPerson(this.data.id, function(){
  547. var text = this.item.explorer.app.lp.unlockPersonSuccess;
  548. text = text.replace("{name}", this.data.name);
  549. this.item.explorer.app.notice(text, "success");
  550. }.bind(this));
  551. },
  552. setPasswordExpiredTime: function(){
  553. var form = new MWF.xApplication.Org.PersonExplorer.PasswordExpiredTimeForm(this.explorer, {}, {
  554. expiredTime : this.data.expiredTime || "",
  555. onPostOk : function( expiredTime ){
  556. o2.Actions.load("x_organization_assemble_control").PersonAction.setPasswordExpiredTime(this.data.id, expiredTime, function(){
  557. this.content.bottomInfor.setPasswordExpiredTime(expiredTime);
  558. this.explorer.app.notice( this.explorer.app.lp.expiredTimeSuccess );
  559. }.bind(this))
  560. }.bind(this)
  561. });
  562. form.create();
  563. },
  564. changePersonIcon: function(){
  565. var options = {};
  566. var width = "668";
  567. var height = "510";
  568. width = width.toInt();
  569. height = height.toInt();
  570. var size = this.explorer.app.content.getSize();
  571. var x = (size.x-width)/2;
  572. var y = (size.y-height)/2;
  573. if (x<0) x = 0;
  574. if (y<0) y = 0;
  575. if (layout.mobile){
  576. x = 20;
  577. y = 0;
  578. }
  579. var _self = this;
  580. MWF.require("MWF.xDesktop.Dialog", function() {
  581. MWF.require("MWF.widget.ImageClipper", function(){
  582. var dlg = new MWF.xDesktop.Dialog({
  583. "title": this.explorer.app.lp.changePersonIcon,
  584. "style": "image",
  585. "top": y,
  586. "left": x - 20,
  587. "fromTop": y,
  588. "fromLeft": x - 20,
  589. "width": width,
  590. "height": height,
  591. "html": "<div></div>",
  592. "maskNode": this.explorer.app.content,
  593. "container": this.explorer.app.content,
  594. "buttonList": [
  595. {
  596. "text": MWF.LP.process.button.ok,
  597. "action": function () {
  598. _self.uploadPersonIcon();
  599. this.close();
  600. }
  601. },
  602. {
  603. "text": MWF.LP.process.button.cancel,
  604. "action": function () {
  605. _self.image = null;
  606. this.close();
  607. }
  608. }
  609. ]
  610. });
  611. dlg.show();
  612. this.image = new MWF.widget.ImageClipper(dlg.content.getFirst(), {
  613. "aspectRatio": 1,
  614. "description" : "",
  615. "imageUrl" : this._getIcon(true),
  616. "resetEnable" : false
  617. });
  618. this.image.load();
  619. }.bind(this));
  620. }.bind(this))
  621. },
  622. uploadPersonIcon: function(){
  623. if (this.image){
  624. if( this.image.getResizedImage() ){
  625. this.explorer.actions.changePersonIcon(this.data.id, this.image.getFormData(), this.image.getResizedImage(), function(){
  626. this.iconNode.set("src", "");
  627. if (this.item.iconNode) this.item.iconNode.getElement("img").set("src", "");
  628. window.setTimeout(function(){
  629. this.iconNode.set("src", this._getIcon(true));
  630. if (this.item.iconNode) this.item.iconNode.getElement("img").set("src", this.item._getIcon(true));
  631. }.bind(this), 100);
  632. }.bind(this), null);
  633. }
  634. }
  635. }
  636. });
  637. MWF.xApplication.Org.PersonExplorer.PersonContent.BottomInfor = new Class({
  638. Extends: MWF.xApplication.Org.$Explorer.ItemContent.BottomInfor,
  639. addInforList: function(){
  640. var text = this.explorer.app.lp.personReadDn.replace(/{dn}/g, (this.data.distinguishedName || " "));
  641. this.addInfor(text);
  642. text = this.explorer.app.lp.personReadCreate.replace(/{date}/g, (this.data.createTime || " "));
  643. text = text.replace(/{date2}/g, (this.data.updateTime || " "));
  644. this.addInfor(text);
  645. text = this.explorer.app.lp.personReadLogin.replace(/{date}/g, (this.data.lastLoginTime || " "));
  646. text = text.replace(/{ip}/g, (this.data.lastLoginAddress || " "));
  647. text = text.replace(/{client}/g, (this.data.lastLoginClient || " "));
  648. this.addInfor(text);
  649. text = this.explorer.app.lp.personReadPassword.replace(/{date}/g, (this.data.passwordExpiredTime || " "));
  650. text = text.replace(/{date2}/g, (this.data.changePasswordTime || " "));
  651. this.passwordExpiredTimeNode = this.addInfor(text);
  652. },
  653. setPasswordExpiredTime: function ( passwordExpiredTime ) {
  654. var text = this.explorer.app.lp.personReadPassword.replace(/{date}/g, (passwordExpiredTime || " "));
  655. text = text.replace(/{date2}/g, (this.data.changePasswordTime || " "));
  656. this.passwordExpiredTimeNode.set("text", text);
  657. }
  658. });
  659. MWF.xApplication.Org.PersonExplorer.PersonContent.BaseInfor = new Class({
  660. initialize: function(content){
  661. this.content = content;
  662. this.item = content.item;
  663. this.data = this.content.data;
  664. this.explorer = this.item.explorer;
  665. this.contentNode = this.content.baseContentNode;
  666. this.style = this.item.style.person;
  667. this.attributes = [];
  668. this.mode = "read";
  669. this.load();
  670. },
  671. load: function(){
  672. this.node = new Element("div", {"styles": this.style.baseContentNode}).inject(this.contentNode);
  673. this.editContentNode = new Element("div", {"styles": this.style.baseEditNode}).inject(this.node);
  674. this.editContentNode.set("html", this.getContentHtml());
  675. var n = this.editContentNode.getElement(".infor_name");
  676. if (n) n.set("text", this.data.name || "");
  677. var n = this.editContentNode.getElement(".infor_employee");
  678. if (n) n.set("text", this.data.employee || "");
  679. var n = this.editContentNode.getElement(".infor_mobile");
  680. if (n) n.set("text", this.data.mobile || "");
  681. var n = this.editContentNode.getElement(".infor_unique");
  682. if (n) n.set("text", this.data.unique || "");
  683. var n = this.editContentNode.getElement(".infor_gender");
  684. if (n) n.set("text", this.getGenderType());
  685. var n = this.editContentNode.getElement(".infor_mail");
  686. if (n) n.set("text", this.data.mail || "");
  687. var n = this.editContentNode.getElement(".infor_weixin");
  688. if (n) n.set("text", this.data.weixin || "");
  689. var n = this.editContentNode.getElement(".infor_qq");
  690. if (n) n.set("text", this.data.qq || "");
  691. var n = this.editContentNode.getElement(".infor_officePhone");
  692. if (n) n.set("text", this.data.officePhone || "");
  693. var n = this.editContentNode.getElement(".infor_boardDate");
  694. if (n) n.set("text", this.data.boardDate || "");
  695. var n = this.editContentNode.getElement(".infor_birthday");
  696. if (n) n.set("text", this.data.birthday || "");
  697. var n = this.editContentNode.getElement(".infor_ipAddress");
  698. if (n) n.set("text", this.data.ipAddress || "");
  699. var n = this.editContentNode.getElement(".infor_description");
  700. if (n) n.set("text", this.data.description || "");
  701. this.editContentNode.getElements("td.inforTitle").setStyles(this.style.baseInforTitleNode);
  702. this.editContentNode.getElements("td.inforContent").setStyles(this.style.baseInforContentNode);
  703. this.editContentNode.getElements("td.inforAction").setStyles(this.style.baseInforActionNode);
  704. var tdContents = this.editContentNode.getElements("td.inforContent");
  705. if (this.data.superior) new MWF.widget.O2Person({"name": this.data.superior}, tdContents[5], {"style": "xform"});
  706. this.loadAction();
  707. },
  708. getContentHtml: function(){
  709. var html = "<table width='100%' cellpadding='3px' cellspacing='5px'>";
  710. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personName+":</td><td class='inforContent infor_name'>"+(this.data.name || "")+"</td>" +
  711. "<td class='inforTitle'>"+this.explorer.app.lp.personUnique+":</td><td class='inforContent infor_unique'>"+(this.data.unique || "")+"</td></tr>";
  712. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personMobile+":</td><td class='inforContent infor_mobile'>"+(this.data.mobile || "")+"</td>" +
  713. "<td class='inforTitle'>"+this.explorer.app.lp.personEmployee+":</td><td class='inforContent infor_employee'>"+(this.data.employee || "")+"</td></tr>";
  714. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personGender+":</td><td class='inforContent infor_gender'>"+this.getGenderType()+"</td>" +
  715. "<td class='inforTitle'>"+this.explorer.app.lp.personSuperior+":</td><td class='inforContent'>"+"</td></tr>";
  716. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personMail+":</td><td class='inforContent infor_mail'>"+(this.data.mail || "")+"</td>" +
  717. "<td class='inforTitle'>"+this.explorer.app.lp.personWeixin+":</td><td class='inforContent infor_weixin'>"+(this.data.weixin || "")+"</td></tr>";
  718. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personQQ+":</td><td class='inforContent infor_qq'>"+(this.data.qq || "")+"</td>" +
  719. "<td class='inforTitle'>"+this.explorer.app.lp.personOfficePhone+":</td><td class='inforContent infor_officePhone'>"+(this.data.officePhone || "")+"</td></tr>";
  720. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personBoardDate+":</td><td class='inforContent infor_boardDate'>"+(this.data.boardDate || "")+"</td>" +
  721. "<td class='inforTitle'>"+this.explorer.app.lp.personBirthday+":</td><td class='inforContent infor_birthday'>"+(this.data.birthday || "")+"</td></tr>";
  722. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.ipAddress+":</td><td class='inforContent infor_ipAddress'>"+(this.data.ipAddress || "")+"</td>" +
  723. "<td class='inforTitle'>"+this.explorer.app.lp.description+":</td><td class='inforContent infor_description'>"+(this.data.description || "")+"</td></tr>";
  724. html += "<tr><td colspan='4' class='inforAction'></td></tr>";
  725. //this.baseInforRightNode.set("html", html);
  726. return html;
  727. },
  728. loadAction: function(){
  729. //this.explorer.app.lp.edit
  730. var actionAreas = this.editContentNode.getElements("td");
  731. var actionArea = actionAreas[actionAreas.length-1];
  732. if (this.data.control.allowEdit){
  733. this.baseInforEditActionAreaNode = new Element("div", {"styles": this.style.baseInforEditActionAreaNode}).inject(actionArea);
  734. this.editNode = new Element("div", {"styles": this.style.actionEditNode, "text": this.explorer.app.lp.editPerson}).inject(this.baseInforEditActionAreaNode);
  735. this.saveNode = new Element("div", {"styles": this.style.actionSaveNode, "text": this.explorer.app.lp.savePerson}).inject(this.baseInforEditActionAreaNode);
  736. this.saveNode.addClass("mainColor_bg");
  737. this.cancelNode = new Element("div", {"styles": this.style.actionCancelNode, "text": this.explorer.app.lp.cancel}).inject(this.baseInforEditActionAreaNode);
  738. this.editNode.setStyle("display", "block");
  739. this.editNode.addEvent("click", this.edit.bind(this));
  740. this.saveNode.addEvent("click", this.save.bind(this));
  741. this.cancelNode.addEvent("click", this.cancel.bind(this));
  742. }else{
  743. }
  744. },
  745. edit: function(){
  746. var tdContents = this.editContentNode.getElements("td.inforContent");
  747. tdContents[0].setStyles(this.style.baseInforContentNode_edit).empty();
  748. this.nameInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[0]);
  749. this.nameInputNode.set("value", (this.data.name));
  750. tdContents[1].setStyles(this.style.baseInforContentNode_edit).empty();
  751. this.uniqueInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[1]);
  752. this.uniqueInputNode.set("value", (this.data.unique));
  753. if( this.data.id ){
  754. this.tooltip = new MWF.xApplication.Org.PersonExplorer.PersonContent.UniqueTooltip(this.explorer.app.content, tdContents[1], this.explorer.app, {}, {
  755. axis : "y",
  756. position : {
  757. x : "right"
  758. },
  759. hiddenDelay : 300,
  760. displayDelay : 300
  761. });
  762. }
  763. tdContents[2].setStyles(this.style.baseInforContentNode_edit).empty();
  764. this.mobileInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[2]);
  765. this.mobileInputNode.set("value", (this.data.mobile));
  766. tdContents[3].setStyles(this.style.baseInforContentNode_edit).empty();
  767. this.employeeInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[3]);
  768. this.employeeInputNode.set("value", (this.data.employee));
  769. tdContents[4].setStyles(this.style.baseInforContentNode_edit).empty();
  770. var html = "<input name=\"personGenderRadioNode\" value=\"m\" type=\"radio\" "+((this.data.genderType==="m") ? "checked" : "")+"/>"+this.explorer.app.lp.man;
  771. html += "<input name=\"personGenderRadioNode\" value=\"f\" type=\"radio\" "+((this.data.genderType==="f") ? "checked" : "")+"/>"+this.explorer.app.lp.female;
  772. html += "<input name=\"personGenderRadioNode\" value=\"d\" type=\"radio\" "+((this.data.genderType==="d") ? "checked" : "")+"/>"+this.explorer.app.lp.other;
  773. tdContents[4].set("html", html);
  774. tdContents[5].setStyles(this.style.baseInforContentNode_edit).empty();
  775. this.superiorInputNode = new Element("div", {"styles": this.style.inputNode_person}).inject(tdContents[5]);
  776. //this.superiorInputNode.set("value", (this.data.superior));
  777. if (this.data.superior) new MWF.widget.O2Person({"name": this.data.superior}, this.superiorInputNode, {"style": "xform"});
  778. this.superiorInputNode.addEvent("click", function(){
  779. MWF.xDesktop.requireApp("Selector", "package", function(){
  780. var options = {
  781. "type": "person",
  782. "values": (this.data.superior) ? [this.data.superior] : [],
  783. "count": 1,
  784. "onComplete": function(items){
  785. this.superiorInputNode.empty();
  786. if (items.length){
  787. this.data.superior = items[0].data.distinguishedName;
  788. new MWF.widget.O2Person(items[0].data, this.superiorInputNode, {"style": "xform"});
  789. }else{
  790. this.data.superior = "";
  791. }
  792. }.bind(this)
  793. };
  794. var selector = new MWF.O2Selector(this.explorer.app.content, options);
  795. }.bind(this));
  796. }.bind(this));
  797. tdContents[6].setStyles(this.style.baseInforContentNode_edit).empty();
  798. this.mailInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[6]);
  799. this.mailInputNode.set("value", (this.data.mail));
  800. tdContents[7].setStyles(this.style.baseInforContentNode_edit).empty();
  801. this.weixinInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[7]);
  802. this.weixinInputNode.set("value", (this.data.weixin));
  803. tdContents[8].setStyles(this.style.baseInforContentNode_edit).empty();
  804. this.qqInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[8]);
  805. this.qqInputNode.set("value", (this.data.qq));
  806. tdContents[9].setStyles(this.style.baseInforContentNode_edit).empty();
  807. this.officePhoneInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[9]);
  808. this.officePhoneInputNode.set("value", (this.data.officePhone));
  809. tdContents[10].setStyles(this.style.baseInforContentNode_edit).empty();
  810. this.boardDateInputNode = new Element("input", {"styles": this.style.inputNode_calendar, "readonly": true}).inject(tdContents[10]);
  811. this.boardDateInputNode.set("value", (this.data.boardDate));
  812. MWF.require("MWF.widget.Calendar", function(){
  813. var boardDateCalendar = new MWF.widget.Calendar(this.boardDateInputNode, {
  814. "style": "xform",
  815. "isTime": false,
  816. "target": this.explorer.app.content,
  817. "format": "%Y-%m-%d"
  818. });
  819. }.bind(this));
  820. tdContents[11].setStyles(this.style.baseInforContentNode_edit).empty();
  821. this.birthdayInputNode = new Element("input", {"styles": this.style.inputNode_calendar, "readonly": true}).inject(tdContents[11]);
  822. this.birthdayInputNode.set("value", (this.data.birthday));
  823. MWF.require("MWF.widget.Calendar", function(){
  824. var birthdayCalendar = new MWF.widget.Calendar(this.birthdayInputNode, {
  825. "style": "xform",
  826. "isTime": false,
  827. "target": this.explorer.app.content,
  828. "format": "%Y-%m-%d"
  829. });
  830. }.bind(this));
  831. tdContents[12].setStyles(this.style.baseInforContentNode_edit).empty();
  832. this.ipAddressInputNode = new Element("input", {
  833. "styles": this.style.inputNode,
  834. "placeHolder": this.explorer.app.lp.ipAddressPlaceHolder,
  835. "autocomplete": "off"
  836. }).inject(tdContents[12]);
  837. this.ipAddressInputNode.set("value", (this.data.ipAddress));
  838. tdContents[13].setStyles(this.style.baseInforContentNode_edit).empty();
  839. this.descriptionInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[13]);
  840. this.descriptionInputNode.set("value", (this.data.description));
  841. var _self = this;
  842. this.editContentNode.getElements("input").addEvents({
  843. "focus": function(){if (this.get("type").toLowerCase()==="text"){this.setStyles(_self.style.inputNode_focus);}},
  844. "blur": function(){if (this.get("type").toLowerCase()==="text"){this.setStyles(_self.style.inputNode_blur);}}
  845. });
  846. this.mode = "edit";
  847. this.editNode.setStyle("display", "none");
  848. this.saveNode.setStyle("display", "block");
  849. this.cancelNode.setStyle("display", "block");
  850. },
  851. save: function(){
  852. var tdContents = this.editContentNode.getElements("td.inforContent");
  853. var gender = "";
  854. var radios = tdContents[4].getElements("input");
  855. for (var i=0; i<radios.length; i++){
  856. if (radios[i].checked){
  857. gender = radios[i].value;
  858. break;
  859. }
  860. }
  861. //if (!this.nameInputNode.get("value") || !this.employeeInputNode.get("value") || !this.mobileInputNode.get("value") || !gender){
  862. if (!this.nameInputNode.get("value") || !this.mobileInputNode.get("value") || !this.uniqueInputNode.get("value") || !gender){
  863. this.explorer.app.notice(this.explorer.app.lp.inputPersonInfor, "error", this.explorer.propertyContentNode);
  864. return false;
  865. }
  866. // var array = [];
  867. // var ipAddress = this.ipAddressInputNode.get("value") || "";
  868. // 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]?)$/;
  869. // 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*$/;
  870. // if( ipAddress.trim() ){
  871. // ipAddress.split(",").each( function(ip){
  872. // if(!ip.match(ipV4Format) && !ip.match(ipV6Format))array.push( ip );
  873. // })
  874. // }
  875. // if( array.length > 0 ){
  876. // this.explorer.app.notice( this.explorer.app.lp.ipAddressIncorrectNotice + array.join(","), "error", this.explorer.propertyContentNode);
  877. // return false;
  878. // }
  879. //this.data.genderType = gender;
  880. if (!this.uniqueInputNode.get("value")) this.data.unique = this.employeeInputNode.get("value");
  881. this.content.propertyContentScrollNode.mask({
  882. "style": {
  883. "opacity": 0.7,
  884. "background-color": "#999"
  885. }
  886. });
  887. this.savePerson(function(){
  888. this.cancel();
  889. this.content.propertyContentScrollNode.unmask();
  890. }.bind(this), function(xhr, text, error){
  891. var errorText = error;
  892. if (xhr){
  893. var json = JSON.decode(xhr.responseText);
  894. if (json){
  895. errorText = json.message.trim() || "request json error";
  896. }else{
  897. errorText = "request json error: "+xhr.responseText;
  898. }
  899. }
  900. MWF.xDesktop.notice("error", {x: "right", y:"top"}, errorText);
  901. this.content.propertyContentScrollNode.unmask();
  902. }.bind(this));
  903. },
  904. savePerson: function(callback, cancel){
  905. var data = Object.clone(this.data);
  906. data.name = this.nameInputNode.get("value");
  907. data.employee = this.employeeInputNode.get("value");
  908. data.mobile = this.mobileInputNode.get("value");
  909. data.unique = this.uniqueInputNode.get("value");
  910. //data.superior = this.superiorInputNode.get("value");
  911. data.mail = this.mailInputNode.get("value");
  912. data.weixin = this.weixinInputNode.get("value");
  913. data.qq = this.qqInputNode.get("value");
  914. data.officePhone = this.officePhoneInputNode.get("value");
  915. data.boardDate = this.boardDateInputNode.get("value");
  916. data.birthday = this.birthdayInputNode.get("value");
  917. data.ipAddress = this.ipAddressInputNode.get("value");
  918. data.description = this.descriptionInputNode.get("value");
  919. var tdContents = this.editContentNode.getElements("td.inforContent");
  920. var radios = tdContents[4].getElements("input");
  921. for (var i=0; i<radios.length; i++){
  922. if (radios[i].checked){
  923. data.genderType = radios[i].value;
  924. break;
  925. }
  926. }
  927. this.explorer.actions.savePerson(data, function(json){
  928. Object.merge(this.data, data);
  929. if (this.data.id){
  930. this.data.id = json.data.id;
  931. this.item.refresh();
  932. if (callback) callback();
  933. }else{
  934. this.explorer.actions.getPerson(function(json){
  935. this.data = Object.merge(this.data, json.data);
  936. this.item.data = this.data;
  937. this.item.refresh();
  938. this.content.loadList();
  939. if (callback) callback();
  940. }.bind(this), null, json.data.id);
  941. }
  942. }.bind(this), function(xhr, text, error){
  943. if (cancel) cancel(xhr, text, error);
  944. }.bind(this));
  945. // }.bind(this), function(xhr, text, error){
  946. // if (cancel) cancel(xhr, text, error);
  947. // }.bind(this));
  948. },
  949. cancel: function(){
  950. if (this.data.id){
  951. var tdContents = this.editContentNode.getElements("td.inforContent");
  952. tdContents[0].setStyles(this.style.baseInforContentNode).set("text", this.data.name || "");
  953. tdContents[1].setStyles(this.style.baseInforContentNode).set("text", this.data.unique || "");
  954. tdContents[2].setStyles(this.style.baseInforContentNode).set("text", this.data.mobile || "");
  955. tdContents[3].setStyles(this.style.baseInforContentNode).set("text", this.data.employee || "");
  956. tdContents[4].setStyles(this.style.baseInforContentNode).set("text", this.getGenderType());
  957. tdContents[5].setStyles(this.style.baseInforContentNode).set("text", "");
  958. if (this.data.superior) new MWF.widget.O2Person({"name": this.data.superior}, tdContents[5], {"style": "xform"});
  959. tdContents[6].setStyles(this.style.baseInforContentNode).set("text", this.data.mail || "");
  960. tdContents[7].setStyles(this.style.baseInforContentNode).set("text", this.data.weixin || "");
  961. tdContents[8].setStyles(this.style.baseInforContentNode).set("text", this.data.qq || "");
  962. tdContents[9].setStyles(this.style.baseInforContentNode).set("text", this.data.officePhone || "");
  963. tdContents[10].setStyles(this.style.baseInforContentNode).set("text", this.data.boardDate || "");
  964. tdContents[11].setStyles(this.style.baseInforContentNode).set("text", this.data.birthday || "");
  965. tdContents[12].setStyles(this.style.baseInforContentNode).set("text", this.data.ipAddress || "");
  966. tdContents[13].setStyles(this.style.baseInforContentNode).set("text", this.data.description || "");
  967. this.mode = "read";
  968. this.editNode.setStyle("display", "block");
  969. this.saveNode.setStyle("display", "none");
  970. this.cancelNode.setStyle("display", "none");
  971. }else{
  972. this.item.destroy();
  973. }
  974. if( this.tooltip ){
  975. this.tooltip.destroy();
  976. this.tooltip = null;
  977. }
  978. },
  979. getGenderType: function(){
  980. var text = "";
  981. if (this.data.genderType){
  982. switch (this.data.genderType) {
  983. case "m":
  984. text = this.explorer.app.lp.man;
  985. break;
  986. case "f":
  987. text = this.explorer.app.lp.female;
  988. break;
  989. default:
  990. text = this.explorer.app.lp.other;
  991. }
  992. }
  993. return text;
  994. },
  995. destroy: function(){
  996. if( this.tooltip ){
  997. this.tooltip.destroy();
  998. this.tooltip = null;
  999. }
  1000. this.node.empty();
  1001. this.node.destroy();
  1002. MWF.release(this);
  1003. },
  1004. _getIcon: function(nocache){
  1005. var url = (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "../x_component_Org/$Explorer/default/icon/man.png";
  1006. return (nocache) ? url+"?"+(new Date().getTime()) : url;
  1007. //return (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "../x_component_Org/$Explorer/default/icon/man.png";
  1008. // var src = "data:image/png;base64,"+this.data.icon;
  1009. // if (!this.data.icon){
  1010. // if (this.data.genderType==="f"){
  1011. // src = "../x_component_Org/$Explorer/default/icon/female.png"
  1012. // }else{
  1013. // src = "../x_component_Org/$Explorer/default/icon/man.png"
  1014. // }
  1015. // }
  1016. // return src;
  1017. }
  1018. });
  1019. MWF.xApplication.Org.PersonExplorer.PersonContent.UniqueTooltip = new Class({
  1020. Extends: MTooltips,
  1021. _getHtml : function(){
  1022. var html =
  1023. "<div item='containr' style='line-height:24px;'><div style='font-size: 14px;color:red;float:left; '>"+ this.lp.personUniqueModifyNote +"</div></div>";
  1024. return html;
  1025. }
  1026. });
  1027. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  1028. MWF.xApplication.Org.PersonExplorer.PasswordExpiredTimeForm = new Class({
  1029. Extends: MPopupForm,
  1030. Implements: [Options, Events],
  1031. options: {
  1032. "style": "cms_xform",
  1033. "width": "580",
  1034. "height": "220",
  1035. "hasTop": true,
  1036. "hasIcon": false,
  1037. "hasTopIcon" : false,
  1038. "hasTopContent" : true,
  1039. "hasBottom": true,
  1040. "title": MWF.xApplication.Org.LP.expiredTimeTitle,
  1041. "draggable": true,
  1042. "closeAction": true,
  1043. "publishTime": ""
  1044. },
  1045. _createTableContent: function () {
  1046. this.formTopTextNode.addClass("mainColor_color");
  1047. this.formAreaNode.setStyle("z-index", 1002);
  1048. this.formMaskNode.setStyle("z-index", 1002);
  1049. this.formTableContainer.setStyles({
  1050. "margin":"40px 40px 0px 40px"
  1051. });
  1052. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1053. "<tr>" +
  1054. " <td styles='formTableValue' item='expiredTime'></td>" +
  1055. "</tr>"+
  1056. "</table>";
  1057. this.formTableArea.set("html", html);
  1058. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1059. this.form = new MForm(this.formTableArea, this.data, {
  1060. style: "meeting",
  1061. isEdited: true,
  1062. itemTemplate: {
  1063. expiredTime: {
  1064. tType: "date",
  1065. notEmpty: true,
  1066. value: this.options.expiredTime || "",
  1067. attr: {
  1068. "readonly":true
  1069. },
  1070. calendarOptions : {
  1071. "secondEnable": false,
  1072. "format": "%Y-%m-%d",
  1073. "onShow": function () {
  1074. this.container.setStyle("z-index", 1003 );
  1075. }
  1076. }
  1077. }
  1078. }
  1079. }, this.app, this.css);
  1080. this.form.load();
  1081. }.bind(this), true);
  1082. },
  1083. _createBottomContent: function () {
  1084. this.closeActionNode = new Element("div.formCancelActionNode", {
  1085. "styles": this.css.formCancelActionNode,
  1086. "text": this.lp.cancel
  1087. }).inject(this.formBottomNode);
  1088. this.closeActionNode.addEvent("click", function (e) {
  1089. this.cancel(e);
  1090. }.bind(this));
  1091. this.okActionNode = new Element("div.formOkActionNode", {
  1092. "styles": this.css.formOkActionNode,
  1093. "text": this.lp.ok
  1094. }).inject(this.formBottomNode);
  1095. this.okActionNode.addClass("mainColor_bg");
  1096. this.okActionNode.addEvent("click", function (e) {
  1097. this.ok(e);
  1098. }.bind(this));
  1099. },
  1100. ok: function (e) {
  1101. this.fireEvent("queryOk");
  1102. var result = this.form.getResult(true, null);
  1103. if( !result ){
  1104. this.app.notice(this.lp.inputExpiredTime, "error");
  1105. return;
  1106. }
  1107. (this.formMaskNode || this.formMarkNode).destroy();
  1108. this.formAreaNode.destroy();
  1109. this.fireEvent("postOk", result.expiredTime);
  1110. }
  1111. });