PersonExplorer.js 77 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720
  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.xDesktop.requireApp("Selector", "package", null, false);
  6. MWF.require("MWF.widget.O2Identity", null, false);
  7. MWF.xApplication.Org.PersonExplorer = new Class({
  8. Extends: MWF.xApplication.Org.$Explorer,
  9. Implements: [Options, Events],
  10. options: {
  11. "style": "default"
  12. },
  13. loadToolbar: function(){
  14. if (this._isActionManager()) {
  15. this.isEditor = true;
  16. this.addTopElementNode = new Element("div", {"styles": this.css.addTopGroupNode}).inject(this.toolbarNode);
  17. this.addTopElementNode.addEvent("click", function () {
  18. this.addTopElement();
  19. }.bind(this));
  20. }
  21. this.filterNode = new Element("div", {"styles": this.css.filterNode}).inject(this.toolbarNode);
  22. this.loadFilterTooltip();
  23. this.createSearchNode();
  24. this.loadPingyinArea();
  25. },
  26. loadFilterTooltip: function(){
  27. this.filterTooltip = new MWF.xApplication.Org.PersonExplorer.FilterTooltip(this.app.content, this.filterNode, null, {}, {
  28. event : "click"
  29. });
  30. this.filterTooltip.explorer = this;
  31. },
  32. _isActionManager: function(){
  33. return (MWF.AC.isOrganizationManager() || MWF.AC.isPersonManager() || MWF.AC.isUnitManager());
  34. },
  35. _listElementNext: function(lastid, count, callback, page){
  36. // this.actions.listPersonNext(lastid||"(0)", count, function(json){
  37. // if (callback) {
  38. // callback.apply(this, [json]);
  39. // }
  40. // }.bind(this));
  41. o2.Actions.load("x_organization_assemble_control").PersonAction.listFilterPaging(page, count, this.filterData || {}, function(json){
  42. if (callback) {
  43. callback.apply(this, [json]);
  44. }
  45. }.bind(this));
  46. },
  47. _newElement: function(data, explorer, i){
  48. return new MWF.xApplication.Org.PersonExplorer.Person(data, explorer, this.isEditor, i);
  49. },
  50. _listElementByKey: function(callback, failure, key){
  51. // this.actions.listPersonByKey(function(json){
  52. // if (callback) {
  53. // callback.apply(this, [json]);
  54. // }
  55. // }.bind(this), failure, key);
  56. o2.Actions.load("x_organization_assemble_control").PersonAction.listFilterPaging(1, 10000, {
  57. key: key
  58. }, function(json){
  59. if (callback) {
  60. callback.apply(this, [json]);
  61. }
  62. }.bind(this), failure)
  63. },
  64. _getAddElementData: function(){
  65. return {
  66. "genderType": "m",
  67. "signature": "",
  68. "description": "",
  69. "unique": "",
  70. "orderNumber": "",
  71. "superior": "",
  72. "officePhone": "",
  73. "boardDate": "",
  74. "birthday": "",
  75. "employee": "",
  76. "password": "",
  77. "display": "",
  78. "qq": "",
  79. "mail": "",
  80. "weixin": "",
  81. "weibo": "",
  82. "mobile": "",
  83. "name": "",
  84. "ipAddress" : "",
  85. "controllerList": [],
  86. "woPersonAttributeList":[],
  87. "woIdentityList": [],
  88. "control": {
  89. "allowEdit": true,
  90. "allowDelete": true
  91. },
  92. "subjectSecurityClearance": null
  93. };
  94. }
  95. });
  96. MWF.xApplication.Org.PersonExplorer.Person = new Class({
  97. Extends: MWF.xApplication.Org.$Explorer.Item,
  98. showItemProperty: function(){
  99. this.content = new MWF.xApplication.Org.PersonExplorer.PersonContent(this);
  100. },
  101. _loadTextNode: function(){
  102. var html = "<div style='float:left; height:50px; overflow:hidden'>"+this.data.name+"</div>";
  103. html += "<div style='float: right; overflow:hidden; font-size: 12px; color: #aaaaaa;'>"+(this.data.mobile || "")+"</div>";
  104. this.textNode.set({"html": html});
  105. },
  106. "delete": function(success, failure){
  107. this.explorer.actions.deletePerson(this.data.id, function(){
  108. this.destroy();
  109. if (success) success();
  110. }.bind(this), function(xhr, text, error){
  111. var errorText = error;
  112. if (xhr) errorText = xhr.responseText;
  113. MWF.xDesktop.notice("error", {x: "right", y:"top"}, "request json error: "+errorText);
  114. if (failure) failure();
  115. });
  116. },
  117. _getIcon: function(nocache){
  118. var url = (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "../x_component_Org/$Explorer/default/icon/man.png";
  119. return (nocache) ? url+"?"+(new Date().getTime()) : url;
  120. //return (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "../x_component_Org/$Explorer/default/icon/man.png";
  121. // var src = "data:image/png;base64,"+this.data.icon;
  122. // if (!this.data.icon){
  123. // if (this.data.genderType==="f"){
  124. // src = "../x_component_Org/$Explorer/default/icon/female24.png"
  125. // }else{
  126. // src = "../x_component_Org/$Explorer/default/icon/man24.png"
  127. // }
  128. // }
  129. // return src;
  130. }
  131. });
  132. MWF.xApplication.Org.PersonExplorer.PersonContent = new Class({
  133. Extends: MWF.xApplication.Org.$Explorer.ItemContent,
  134. _getData: function(callback){
  135. if (this.item.data.id){
  136. this.explorer.actions.getPerson(function(json){
  137. this.data = json.data;
  138. this.item.data = json.data;
  139. if (callback) callback();
  140. }.bind(this), null, this.item.data.id);
  141. }else{
  142. this.data = this.item.data;
  143. if (callback) callback();
  144. }
  145. },
  146. edit: function(){
  147. if (this.baseInfor) this.baseInfor.edit();
  148. },
  149. _showItemPropertyTitle: function(){
  150. this.titleInfor = new MWF.xApplication.Org.PersonExplorer.PersonContent.TitleInfor(this);
  151. //this.baseInfor = new MWF.xApplication.Org.BaseInfor(this);
  152. },
  153. _showItemPropertyBottom: function(){
  154. this.bottomInfor = new MWF.xApplication.Org.PersonExplorer.PersonContent.BottomInfor(this);
  155. },
  156. loadItemPropertyTab: function(callback){
  157. this.propertyTabContainerNode = new Element("div", {"styles": this.item.style.tabTitleNode}).inject(this.propertyContentNode, "top");
  158. MWF.require("MWF.widget.Tab", function(){
  159. this.propertyTab = new MWF.widget.Tab(this.propertyContentNode, {"style": "unit", "useMainColor":true});
  160. this.propertyTab.load();
  161. this.propertyTab.tabNodeContainer.inject(this.propertyTabContainerNode);
  162. this.propertyTab.tabNodeContainer.setStyle("width","480px");
  163. if (callback) callback();
  164. }.bind(this));
  165. },
  166. _loadTabs: function(){
  167. this.baseContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  168. this.basePage = this.propertyTab.addTab(this.baseContentNode, this.explorer.app.lp.personBaseText);
  169. this.attributeContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  170. this.attributePage = this.propertyTab.addTab(this.attributeContentNode, this.explorer.app.lp.personAttributeText);
  171. this.identityContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  172. this.identityPage = this.propertyTab.addTab(this.identityContentNode, this.explorer.app.lp.personIdentityText);
  173. this.roleContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  174. this.rolePage = this.propertyTab.addTab(this.roleContentNode, this.explorer.app.lp.personRoleText);
  175. // this.managerContentNode = new Element("div", {"styles": this.item.style.tabContentNode});
  176. // this.managerPage = this.propertyTab.addTab(this.managerContentNode, this.explorer.app.lp.controllerListText);
  177. },
  178. _loadContent: function(){
  179. this._listBaseInfor();
  180. if( this.data && this.data.id ){
  181. this._listAttribute();
  182. this._listIdentity();
  183. this._listRole();
  184. this.loadListCount();
  185. }
  186. //
  187. // this.showAttribute();
  188. },
  189. loadList : function(){
  190. this._listAttribute();
  191. this._listIdentity();
  192. this._listRole();
  193. this.loadListCount();
  194. },
  195. loadListCount: function(){
  196. if (this.data.woIdentityList){
  197. var identityCount = this.data.woIdentityList.length;
  198. if (identityCount){
  199. if (!this.identityCountNode){
  200. this.identityCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": identityCount}).inject(this.identityPage.tabNode);
  201. }else{
  202. this.identityCountNode.set("text", identityCount);
  203. }
  204. }else{
  205. if (this.identityCountNode) this.identityCountNode.destroy();
  206. }
  207. }
  208. if (this.data.woPersonAttributeList){
  209. var attributeCount = this.data.woPersonAttributeList.length;
  210. if (attributeCount){
  211. if (!this.attributeCountNode){
  212. this.attributeCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": attributeCount}).inject(this.attributePage.tabNode);
  213. }else{
  214. this.attributeCountNode.set("text", attributeCount);
  215. }
  216. }else{
  217. if (this.attributeCountNode) this.attributeCountNode.destroy();
  218. }
  219. }
  220. if( this.roleDataList ){
  221. var roleCount = this.roleDataList.length;
  222. if (roleCount){
  223. if (!this.roleCountNode){
  224. this.roleCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": roleCount}).inject(this.rolePage.tabNode);
  225. }else{
  226. this.roleCountNode.set("text", roleCount);
  227. }
  228. }else{
  229. if (this.roleCountNode) this.roleCountNode.destroy();
  230. }
  231. }
  232. // var groupCount = this.data.groupList.length;
  233. // if (groupCount){
  234. // this.groupCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": groupCount}).inject(this.groupMemberPage.tabNode);
  235. // }
  236. },
  237. _listBaseInfor: function(){
  238. this.baseInfor = new MWF.xApplication.Org.PersonExplorer.PersonContent.BaseInfor(this);
  239. },
  240. _listAttribute: function(){
  241. this.attributeList = new MWF.xApplication.Org.List(this.attributeContentNode, this, {
  242. "action": this.data.control.allowEdit,
  243. "data": {
  244. "person": this.data.id,
  245. "name": "",
  246. "unique": "",
  247. "orderNumber": "",
  248. "attributeList": [],
  249. "description":""
  250. },
  251. "attr": ["name", {
  252. "get": function(){return this.attributeList.join(",")},
  253. "set": function(value){ this.attributeList = value.split(/,\s*/g)}
  254. }, "description"],
  255. "onPostSave": function(item, id){
  256. if (!item.data.id){
  257. item.data.id = id;
  258. this.data.woPersonAttributeList.push(item.data);
  259. }
  260. this.loadListCount();
  261. // if (!item.data.id){
  262. // if (this.attributeCountNode){
  263. // var count = this.attributeCountNode.get("text").toInt()+1;
  264. // this.attributeCountNode.set("text", count);
  265. // }
  266. // }
  267. }.bind(this),
  268. "onPostDelete": function(delCount){
  269. if (this.attributeCountNode){
  270. var count = this.attributeCountNode.get("text").toInt()-delCount;
  271. this.attributeCountNode.set("text", count);
  272. }
  273. }.bind(this)
  274. });
  275. this.attributeList.load([
  276. {"style": "width: 20%", "text": this.explorer.app.lp.attributeName},
  277. {"style": "", "text": this.explorer.app.lp.attributeValue},
  278. {"style": "", "text": this.explorer.app.lp.description}
  279. ]);
  280. this.data.woPersonAttributeList.each(function(item){
  281. this.attributeList.push(item);
  282. }.bind(this));
  283. // if (this.data.id){
  284. // this.explorer.actions.listPersonAttribute(function(json){
  285. //
  286. // var attributeCount = json.data.length;
  287. // if (attributeCount){
  288. // this.attributeCountNode = new Element("div", {"styles": this.item.style.tabCountNode, "text": attributeCount}).inject(this.attributePage.tabNode);
  289. // }
  290. //
  291. // json.data.each(function(item){
  292. // //this.attributes.push(new MWF.xApplication.Org.PersonExplorer.PersonAttribute(this.attributeTabContentNode.getElement("table").getFirst(), item, this, this.explorer.css.list));
  293. // this.attributeList.push(item);
  294. // }.bind(this));
  295. // }.bind(this), null, this.data.id);
  296. // }
  297. },
  298. getDutyActionPermission: function(){
  299. if( MWF.AC.isSystemManager() )return false;
  300. if( MWF.AC.isOrganizationManager() )return true;
  301. if( MWF.AC.isSecurityManager() )return true;
  302. return false;
  303. },
  304. _listIdentity: function(){
  305. var _self = this;
  306. this.identityList = new MWF.xApplication.Org.List(this.identityContentNode, this, {
  307. "action": false,
  308. "canEdit": false,
  309. "saveAction": "saveIdentity",
  310. "data": {
  311. "person": this.data.id,
  312. "name": "",
  313. "attributeList": []
  314. },
  315. "attr": ["name", {
  316. "get": function(){ return ""; },
  317. "events": {
  318. "init": function(){
  319. var contentNode = this.td;
  320. new MWF.widget.O2Unit(this.data.woUnit, contentNode, {"style": "xform"});
  321. }
  322. }
  323. }, {
  324. "getHtml": function(){
  325. return "<div style='word-break: break-word;'>"+o2.txt(this.distinguishedName)+"</div>";
  326. },
  327. //"get": function(){ return this.distinguishedName; },
  328. "set": function(value){ this.distinguishedName = value; }
  329. }, {
  330. "get": function(){ return ""; },
  331. "events": {
  332. "init": function(){
  333. var contentNode = new Element("div.duty-wrap").inject(this.td);
  334. var dutyNode = new Element("div.duty-area").inject(contentNode);
  335. if (this.data.woUnitDutyList){
  336. this.data.woUnitDutyList.each(function(duty){
  337. new MWF.widget.O2Duty(duty, dutyNode, {"style": "xform", "showUnit": true});
  338. }.bind(this));
  339. }
  340. if( _self.getDutyActionPermission() ){
  341. var editDutyIcon = new Element("i.o2icon-edit2", {
  342. "title": MWF.xApplication.Org.LP.editDuty
  343. }).inject(contentNode);
  344. editDutyIcon.addClass("edit-duty-icon");
  345. editDutyIcon.addEvent("click", function () {
  346. new MWF.O2Selector(_self.explorer.app.content, {
  347. "type": "UnitDuty",
  348. "values": this.data.woUnitDutyList,
  349. "onComplete" : function( items ){
  350. var selectedList = items.map( function(item){ debugger; return item.data; });
  351. var oldIdList = this.data.woUnitDutyList.map(function (d) { return d.id; })
  352. var newIdList = selectedList.map(function (d) { return d.id; });
  353. var addList = selectedList.filter(function (d) {
  354. return !oldIdList.contains( d.id );
  355. }.bind(this));
  356. var removeList = this.data.woUnitDutyList.filter(function (d) {
  357. return !newIdList.contains( d.id );
  358. });
  359. var currentIdentityId = this.data.id;
  360. var psRemove = removeList.map(function (d) {
  361. var id = d.id;
  362. return o2.Actions.load("x_organization_assemble_control").UnitDutyAction.get(id).then(function (json) {
  363. json.data.identityList = json.data.identityList.filter(function (identity) {
  364. return identity !== currentIdentityId;
  365. })
  366. return o2.Actions.load("x_organization_assemble_control").UnitDutyAction.edit(id, json.data);
  367. }.bind(this));
  368. });
  369. var psAdd = addList.map(function (d) {
  370. var id = d.id;
  371. return o2.Actions.load("x_organization_assemble_control").UnitDutyAction.get(id).then(function (json) {
  372. json.data.identityList.push(currentIdentityId);
  373. return o2.Actions.load("x_organization_assemble_control").UnitDutyAction.edit(id, json.data);
  374. }.bind(this));
  375. });
  376. Promise.all( psRemove.concat(psAdd) ).then(function( list ){
  377. _self.explorer.app.notice(MWF.xApplication.Org.LP.modifySuccess);
  378. this.data.woUnitDutyList = selectedList;
  379. dutyNode.empty();
  380. this.data.woUnitDutyList.each(function(duty){
  381. new MWF.widget.O2Duty(duty, dutyNode, {"style": "xform", "showUnit": true});
  382. }.bind(this));
  383. }.bind(this), function () {
  384. _self.explorer.app.notice(MWF.xApplication.Org.LP.modifyFail, "error");
  385. });
  386. }.bind(this)
  387. })
  388. }.bind(this))
  389. }
  390. }
  391. }
  392. }, {
  393. "getHtml": function(){
  394. if (this.major){
  395. return "<div style='width:24px; height:24px; background:url(../x_component_Org/$Explorer/"+
  396. _self.explorer.app.options.style+"/icon/mainid.png) center center no-repeat'></div>";
  397. }else{
  398. return "<div title='"+_self.explorer.app.lp.setIdentityMain+"' style='width:24px; height:24px; cursor: pointer; background:url(../x_component_Org/$Explorer/"+
  399. _self.explorer.app.options.style+"/icon/select.png) center center no-repeat'></div>";
  400. }
  401. },
  402. "events": {
  403. "click": function(){
  404. if (!this.data.major){
  405. if (_self.data.control.allowEdit){_self.setMainIdentity(this.data, this.td, this.item);}
  406. }
  407. }
  408. }
  409. },{
  410. "getHtml": function(){
  411. if (_self.data.control.allowEdit){
  412. return "<div style='width:24px; height:24px; cursor: pointer; background:url(../x_component_Org/$Explorer/"+
  413. _self.explorer.app.options.style+"/icon/edit.png) center center no-repeat'></div>";
  414. }
  415. return "";
  416. },
  417. "events": {
  418. "click": function(){
  419. if (_self.data.control.allowEdit){_self.editIdentity(this.data, this.td, this.item);}
  420. }
  421. }
  422. }]
  423. });
  424. this.identityList.load([
  425. {"style": "width: 12%", "text": this.explorer.app.lp.IdentityName},
  426. {"style": "width: 12%", "text": this.explorer.app.lp.IdentityInUnit},
  427. {"style": "width: 30%", "text": this.explorer.app.lp.personUnique},
  428. {"style": "width: 34%", "text": this.explorer.app.lp.IdentityDuty},
  429. {"style": "width: 10%", "text": this.explorer.app.lp.IdentityMain},
  430. {"style": "width: 30px", "text": ""}
  431. ]);
  432. this.data.woIdentityList.each(function(item){
  433. this.identityList.push(item);
  434. }.bind(this));
  435. },
  436. setMainIdentity: function(data, node, item){
  437. data.major = true;
  438. this.explorer.actions.saveIdentity(data, function(json){
  439. this.explorer.actions.getPerson(function(iJson){
  440. // data = iJson.data;
  441. // item.reload(iJson.data);
  442. this.data.woIdentityList = iJson.data.woIdentityList;
  443. this.identityList.clear();
  444. this.data.woIdentityList.each(function(item){
  445. this.identityList.push(item);
  446. }.bind(this));
  447. }.bind(this), null, this.data.id);
  448. }.bind(this));
  449. },
  450. editIdentity: function(data, node, item){
  451. var _self = this;
  452. var position = node.getPosition(this.explorer.app.content);
  453. var width = 700;
  454. var height = 170;
  455. var size = this.explorer.app.content.getSize();
  456. var x = (size.x-width)/2;
  457. var y = (size.y-height)/2;
  458. if (x<0) x = 0;
  459. if (y<20) y = 20;
  460. MWF.require("MWF.xDesktop.Dialog", function() {
  461. var dlg = new MWF.xDesktop.Dialog({
  462. "title": this.explorer.app.lp.modifyIdentity,
  463. "style": "org",
  464. "top": y - 20,
  465. "left": x,
  466. "fromTop": position.y - 20,
  467. "fromLeft": position.x,
  468. "width": width,
  469. "height": height,
  470. "html": "<div></div>",
  471. "maskNode": this.explorer.app.content,
  472. "container": this.explorer.app.content,
  473. "buttonList": [
  474. {
  475. "text": MWF.LP.process.button.ok,
  476. "action": function () {
  477. _self.saveIdentity(dlg, data, item);
  478. this.close();
  479. }
  480. },
  481. {
  482. "text": MWF.LP.process.button.cancel,
  483. "action": function () {
  484. this.close();
  485. }
  486. }
  487. ]
  488. });
  489. dlg.show();
  490. var node = dlg.content.getFirst();
  491. var html = "<table width='90%' cellpadding='0px' cellspacing='5px' align='center' style='margin-top:10px'>" +
  492. "<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>" +
  493. "<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>" +
  494. "<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>" +
  495. "<td style='text-align: center'><input value='yes' type='checkbox' "+((data.major) ? "checked" : "")+"/></td></tr></table>";
  496. node.set("html", html);
  497. var inputs = node.getElements("input");
  498. if (inputs[0]) inputs[0].set("value", data.name);
  499. if (inputs[1]) inputs[1].set("value", data.unique);
  500. //if (inputs[2]) inputs[2].set("value", data.major)
  501. }.bind(this));
  502. },
  503. saveIdentity: function(dlg, data, item){
  504. var node = dlg.content.getFirst();
  505. var inputs = node.getElements("input");
  506. var name = inputs[0].get("value");
  507. var unique = inputs[1].get("value");
  508. var major = (inputs[2].checked);
  509. if (data.name!==name || data.unique!==unique){
  510. if (name) data.name = name;
  511. data.unique=unique;
  512. data.major = major;
  513. this.explorer.actions.saveIdentity(data, function(json){
  514. this.explorer.actions.getPerson(function(iJson){
  515. // data = iJson.data;
  516. // item.reload(iJson.data);
  517. this.data.woIdentityList = iJson.data.woIdentityList;
  518. this.identityList.clear();
  519. this.data.woIdentityList.each(function(item){
  520. this.identityList.push(item);
  521. }.bind(this));
  522. }.bind(this), null, this.data.id);
  523. }.bind(this));
  524. }
  525. },
  526. _listRole: function(){
  527. var _self = this;
  528. this.roleList = new MWF.xApplication.Org.List(this.roleContentNode, this, {
  529. "action": false,
  530. "canEdit": false,
  531. "data": {
  532. // "person": this.data.id,
  533. // "name": "",
  534. // "unique": "",
  535. // "orderNumber": "",
  536. // "attributeList": [],
  537. // "description":""
  538. },
  539. "attr": ["name",
  540. "distinguishedName",
  541. "description",{
  542. "getHtml": function(){
  543. if (_self.data.control.allowEdit){
  544. return "<div style='width:24px; height:24px; cursor: pointer; background:url(../x_component_Org/$Explorer/"+
  545. _self.explorer.app.options.style+"/icon/open.png) center center no-repeat'></div>";
  546. }
  547. return "";
  548. },
  549. "events": {
  550. "click": function(){
  551. _self.explorer.openRole(this.data, this.td);
  552. }
  553. }
  554. }]
  555. });
  556. this.roleList.load([
  557. {"style": "width: 15%", "text": this.explorer.app.lp.roleName},
  558. {"style": "width: 30%", "text": this.explorer.app.lp.roleFullName},
  559. {"style": "", "text": this.explorer.app.lp.description},
  560. {"style": "width: 30px", "text": ""}
  561. ]);
  562. if( this.data.id ){
  563. // o2.Actions.load("x_organization_assemble_control").RoleAction.listWithPerson(this.data.id, function (json) {
  564. // this.roleDataList = json.data;
  565. // json.data.each( function ( item ) {
  566. // this.roleList.push(item);
  567. // }.bind(this))
  568. // }.bind(this), null, false);
  569. if( this.data.woRoleList && this.data.woRoleList.length ){
  570. this.roleDataList = this.data.woRoleList;
  571. this.data.woRoleList.each( function ( item ) {
  572. this.roleList.push(item);
  573. }.bind(this))
  574. }
  575. }
  576. // this.data.woPersonAttributeList.each(function(item){
  577. // this.roleList.push(item);
  578. // }.bind(this));
  579. }
  580. });
  581. MWF.xApplication.Org.PersonExplorer.PersonContent.TitleInfor = new Class({
  582. Extends: MWF.xApplication.Org.$Explorer.ItemContent.TitleInfor,
  583. getActionPermission: function(){
  584. if(MWF.AC.isManager())return true;
  585. if(MWF.AC.isSecurityManager())return true;
  586. if(MWF.AC.isSystemManager())return false;
  587. if(MWF.AC.isOrganizationManager())return true;
  588. if(MWF.AC.isPersonManager())return true;
  589. return false;
  590. },
  591. loadAction: function(){
  592. //this.explorer.app.lp.edit
  593. this.nameNode.setStyle("margin-right", "80px");
  594. if (this.getActionPermission()){
  595. this.resetPasswordAction = new Element("div", {"styles": this.style.titleInforResetPasswordNode, "text": this.item.explorer.app.lp.resetPassword}).inject(this.nameNode, "before");
  596. this.resetPasswordAction.addEvent("click", function(e){this.resetPassword(e);}.bind(this));
  597. this.expiredTimeAction = new Element("div", {"styles": this.style.titleInforUnlockPersonNode, "text": this.item.explorer.app.lp.expiredTime}).inject(this.nameNode, "before");
  598. this.expiredTimeAction.addEvent("click", function(e){this.setPasswordExpiredTime(e);}.bind(this));
  599. this.lockPersonAction = new Element("div", {"styles": this.style.titleInforUnlockPersonNode, "text": this.item.explorer.app.lp.lockPerson}).inject(this.nameNode, "before");
  600. this.lockPersonAction.addEvent("click", function(e){this.lockPerson(e);}.bind(this));
  601. if( this.data.status === '1' )this.lockPersonAction.hide(); //data.status = 1 表示已锁定
  602. this.unlockPersonAction = new Element("div", {"styles": this.style.titleInforUnlockPersonNode, "text": this.item.explorer.app.lp.unlockPerson}).inject(this.nameNode, "before");
  603. this.unlockPersonAction.addEvent("click", function(e){this.unlockPerson(e);}.bind(this));
  604. if( this.data.status !== '1' )this.unlockPersonAction.hide();
  605. this.banPersonAction = new Element("div", {"styles": this.style.titleInforUnlockPersonNode, "text": this.item.explorer.app.lp.banPerson}).inject(this.nameNode, "before");
  606. this.banPersonAction.addEvent("click", function(e){this.banPerson(e);}.bind(this));
  607. if( this.data.status === '2' )this.banPersonAction.hide(); //data.status = 2 表示已禁用
  608. this.unbanPersonAction = new Element("div", {"styles": this.style.titleInforUnlockPersonNode, "text": this.item.explorer.app.lp.unbanPerson}).inject(this.nameNode, "before");
  609. this.unbanPersonAction.addEvent("click", function(e){this.unbanPerson(e);}.bind(this));
  610. if( this.data.status !== '2' )this.unbanPersonAction.hide();
  611. }
  612. if (this.data.control.allowEdit){
  613. this.iconNode.setStyle("cursor", "pointer");
  614. this.iconNode.addEvent("click", function(){this.changePersonIcon();}.bind(this));
  615. }
  616. },
  617. banPerson: function (){
  618. var form = new MWF.xApplication.Org.PersonExplorer.BanPersonForm(this.explorer, {}, {
  619. name : this.data.name || "",
  620. onPostOk : function( reason ){
  621. o2.Actions.load("x_organization_assemble_control").PersonAction.banPerson(this.data.id, {
  622. desc: reason
  623. }, function(){
  624. this.explorer.app.notice( this.explorer.app.lp.banPersonSuccess.replace('{name}', this.data.name) );
  625. this.unbanPersonAction.show();
  626. this.banPersonAction.hide();
  627. window.setTimeout( function (){
  628. this.explorer.currentItem.changeSelectedItem();
  629. }.bind(this), 300)
  630. }.bind(this));
  631. }.bind(this)
  632. });
  633. form.create();
  634. },
  635. unbanPerson: function(e){
  636. var _self = this;
  637. var text = this.item.explorer.app.lp.unbanPersonText.replace("{name}", this.data.name);
  638. this.item.explorer.app.confirm("info", e, this.item.explorer.app.lp.unbanPersonTitle, text, "360", "120", function(){
  639. _self.doUnbanPerson();
  640. this.close();
  641. }, function(){
  642. this.close();
  643. });
  644. },
  645. doUnbanPerson: function (e){
  646. MWF.Actions.load("x_organization_assemble_control").PersonAction.unbanPerson(this.data.id, {}, function(){
  647. var text = this.item.explorer.app.lp.unbanPersonSuccess;
  648. text = text.replace("{name}", this.data.name);
  649. this.item.explorer.app.notice(text, "success");
  650. this.unbanPersonAction.hide();
  651. this.banPersonAction.show();
  652. window.setTimeout( function (){
  653. this.explorer.currentItem.changeSelectedItem();
  654. }.bind(this), 300)
  655. }.bind(this));
  656. },
  657. resetPassword: function(e){
  658. var _self = this;
  659. var text = this.item.explorer.app.lp.resetPasswordText;
  660. text = text.replace("{name}", this.data.name);
  661. this.item.explorer.app.confirm("info", e, this.item.explorer.app.lp.resetPasswordTitle, text, "360", "120", function(){
  662. _self.doResetPassword();
  663. this.close();
  664. }, function(){
  665. this.close();
  666. });
  667. },
  668. doResetPassword: function(){
  669. var action = MWF.Actions.get("x_organization_assemble_control");
  670. action.resetPassword(this.data.id, function(){
  671. var text = this.item.explorer.app.lp.resetPasswordSuccess;
  672. text = text.replace("{name}", this.data.name);
  673. this.item.explorer.app.notice(text, "success");
  674. }.bind(this));
  675. },
  676. lockPerson: function (e){
  677. var form = new MWF.xApplication.Org.PersonExplorer.LockPersonForm(this.explorer, {}, {
  678. name : this.data.name || "",
  679. onPostOk : function( lockExpiredTime, reason ){
  680. o2.Actions.load("x_organization_assemble_control").PersonAction.lockPerson(this.data.id, {
  681. lockExpiredTime: lockExpiredTime,
  682. desc: reason
  683. }, function(){
  684. this.explorer.app.notice( this.explorer.app.lp.lockPersonSuccess.replace('{name}', this.data.name) );
  685. this.unlockPersonAction.show();
  686. this.lockPersonAction.hide();
  687. window.setTimeout( function (){
  688. this.explorer.currentItem.changeSelectedItem();
  689. }.bind(this), 300);
  690. }.bind(this));
  691. }.bind(this)
  692. });
  693. form.create();
  694. },
  695. unlockPerson : function(e){
  696. var _self = this;
  697. var text = this.item.explorer.app.lp.unlockPersonText;
  698. text = text.replace("{name}", this.data.name);
  699. this.item.explorer.app.confirm("info", e, this.item.explorer.app.lp.unlockPersonTitle, text, "360", "120", function(){
  700. _self.doUnlockPerson();
  701. this.close();
  702. }, function(){
  703. this.close();
  704. });
  705. },
  706. doUnlockPerson: function(){
  707. MWF.Actions.load("x_organization_assemble_control").PersonAction.unlockPerson(this.data.id, function(){
  708. var text = this.item.explorer.app.lp.unlockPersonSuccess;
  709. text = text.replace("{name}", this.data.name);
  710. this.item.explorer.app.notice(text, "success");
  711. this.unlockPersonAction.hide();
  712. this.lockPersonAction.show();
  713. window.setTimeout( function (){
  714. this.explorer.currentItem.changeSelectedItem();
  715. }.bind(this), 300);
  716. }.bind(this));
  717. },
  718. setPasswordExpiredTime: function(){
  719. var form = new MWF.xApplication.Org.PersonExplorer.PasswordExpiredTimeForm(this.explorer, {}, {
  720. expiredTime : this.data.expiredTime || "",
  721. onPostOk : function( expiredTime ){
  722. o2.Actions.load("x_organization_assemble_control").PersonAction.setPasswordExpiredTime(this.data.id, expiredTime, function(){
  723. this.content.bottomInfor.setPasswordExpiredTime(expiredTime);
  724. this.explorer.app.notice( this.explorer.app.lp.expiredTimeSuccess );
  725. }.bind(this))
  726. }.bind(this)
  727. });
  728. form.create();
  729. },
  730. changePersonIcon: function(){
  731. var options = {};
  732. var width = "668";
  733. var height = "510";
  734. width = width.toInt();
  735. height = height.toInt();
  736. var size = this.explorer.app.content.getSize();
  737. var x = (size.x-width)/2;
  738. var y = (size.y-height)/2;
  739. if (x<0) x = 0;
  740. if (y<0) y = 0;
  741. if (layout.mobile){
  742. x = 20;
  743. y = 0;
  744. }
  745. var _self = this;
  746. MWF.require("MWF.xDesktop.Dialog", function() {
  747. MWF.require("MWF.widget.ImageClipper", function(){
  748. var dlg = new MWF.xDesktop.Dialog({
  749. "title": this.explorer.app.lp.changePersonIcon,
  750. "style": "image",
  751. "top": y,
  752. "left": x - 20,
  753. "fromTop": y,
  754. "fromLeft": x - 20,
  755. "width": width,
  756. "height": height,
  757. "html": "<div></div>",
  758. "maskNode": this.explorer.app.content,
  759. "container": this.explorer.app.content,
  760. "buttonList": [
  761. {
  762. "text": MWF.LP.process.button.ok,
  763. "action": function () {
  764. _self.uploadPersonIcon();
  765. this.close();
  766. }
  767. },
  768. {
  769. "text": MWF.LP.process.button.cancel,
  770. "action": function () {
  771. _self.image = null;
  772. this.close();
  773. }
  774. }
  775. ]
  776. });
  777. dlg.show();
  778. this.image = new MWF.widget.ImageClipper(dlg.content.getFirst(), {
  779. "aspectRatio": 1,
  780. "description" : "",
  781. "imageUrl" : this._getIcon(true),
  782. "resetEnable" : false
  783. });
  784. this.image.load();
  785. }.bind(this));
  786. }.bind(this))
  787. },
  788. uploadPersonIcon: function(){
  789. if (this.image){
  790. if( this.image.getResizedImage() ){
  791. this.explorer.actions.changePersonIcon(this.data.id, this.image.getFormData(), this.image.getResizedImage(), function(){
  792. this.iconNode.set("src", "");
  793. if (this.item.iconNode) this.item.iconNode.getElement("img").set("src", "");
  794. window.setTimeout(function(){
  795. this.iconNode.set("src", this._getIcon(true));
  796. if (this.item.iconNode) this.item.iconNode.getElement("img").set("src", this.item._getIcon(true));
  797. }.bind(this), 100);
  798. }.bind(this), null);
  799. }
  800. }
  801. }
  802. });
  803. MWF.xApplication.Org.PersonExplorer.PersonContent.BottomInfor = new Class({
  804. Extends: MWF.xApplication.Org.$Explorer.ItemContent.BottomInfor,
  805. addInforList: function(){
  806. var text = this.explorer.app.lp.personReadDn.replace(/{dn}/g, (this.data.distinguishedName || " "));
  807. this.addInfor(text);
  808. text = this.explorer.app.lp.personReadCreate.replace(/{date}/g, (this.data.createTime || " "));
  809. text = text.replace(/{date2}/g, (this.data.updateTime || " "));
  810. this.addInfor(text);
  811. text = this.explorer.app.lp.personReadLogin.replace(/{date}/g, (this.data.lastLoginTime || " "));
  812. text = text.replace(/{ip}/g, (this.data.lastLoginAddress || " "));
  813. text = text.replace(/{client}/g, (this.data.lastLoginClient || " "));
  814. this.addInfor(text);
  815. text = this.explorer.app.lp.personReadPassword.replace(/{date}/g, (this.data.passwordExpiredTime || " "));
  816. text = text.replace(/{date2}/g, (this.data.changePasswordTime || " "));
  817. this.passwordExpiredTimeNode = this.addInfor(text);
  818. },
  819. setPasswordExpiredTime: function ( passwordExpiredTime ) {
  820. var text = this.explorer.app.lp.personReadPassword.replace(/{date}/g, (passwordExpiredTime || " "));
  821. text = text.replace(/{date2}/g, (this.data.changePasswordTime || " "));
  822. this.passwordExpiredTimeNode.set("text", text);
  823. }
  824. });
  825. MWF.xApplication.Org.PersonExplorer.PersonContent.BaseInfor = new Class({
  826. initialize: function(content){
  827. this.content = content;
  828. this.item = content.item;
  829. this.data = this.content.data;
  830. this.explorer = this.item.explorer;
  831. this.contentNode = this.content.baseContentNode;
  832. this.style = this.item.style.person;
  833. this.attributes = [];
  834. this.mode = "read";
  835. this.load();
  836. },
  837. load: function(){
  838. this.node = new Element("div", {"styles": this.style.baseContentNode}).inject(this.contentNode);
  839. this.editContentNode = new Element("div", {"styles": this.style.baseEditNode}).inject(this.node);
  840. this.editContentNode.set("html", this.getContentHtml());
  841. var n = this.editContentNode.getElement(".infor_name");
  842. if (n) n.set("text", this.data.name || "");
  843. n = this.editContentNode.getElement(".infor_employee");
  844. if (n) n.set("text", this.data.employee || "");
  845. n = this.editContentNode.getElement(".infor_mobile");
  846. if (n) n.set("text", this.data.mobile || "");
  847. n = this.editContentNode.getElement(".infor_unique");
  848. if (n) n.set("text", this.data.unique || "");
  849. n = this.editContentNode.getElement(".infor_gender");
  850. if (n) n.set("text", this.getGenderType());
  851. n = this.editContentNode.getElement(".infor_mail");
  852. if (n) n.set("text", this.data.mail || "");
  853. n = this.editContentNode.getElement(".infor_weixin");
  854. if (n) n.set("text", this.data.weixin || "");
  855. n = this.editContentNode.getElement(".infor_qq");
  856. if (n) n.set("text", this.data.qq || "");
  857. n = this.editContentNode.getElement(".infor_officePhone");
  858. if (n) n.set("text", this.data.officePhone || "");
  859. n = this.editContentNode.getElement(".infor_boardDate");
  860. if (n) n.set("text", this.data.boardDate || "");
  861. n = this.editContentNode.getElement(".infor_birthday");
  862. if (n) n.set("text", this.data.birthday || "");
  863. n = this.editContentNode.getElement(".infor_ipAddress");
  864. if (n) n.set("text", this.data.ipAddress || "");
  865. n = this.editContentNode.getElement(".infor_description");
  866. if (n) n.set("text", this.data.description || "");
  867. n = this.editContentNode.getElement(".infor_securityLabel");
  868. this.getSecurityLabelText().then(function(securityLabel){
  869. if (this.mode !== "edit") if (n) n.set("text", securityLabel || "");
  870. }.bind(this));
  871. this.editContentNode.getElements("td.inforTitle").setStyles(this.style.baseInforTitleNode);
  872. this.editContentNode.getElements("td.inforContent").setStyles(this.style.baseInforContentNode);
  873. this.editContentNode.getElements("td.inforAction").setStyles(this.style.baseInforActionNode);
  874. var tdContents = this.editContentNode.getElements("td.inforContent");
  875. if (this.data.superior) new MWF.widget.O2Person({"name": this.data.superior}, tdContents[5], {"style": "xform"});
  876. this.loadAction();
  877. },
  878. getSecurityLabelText(){
  879. return this.getSecurityLabelList().then(function(labelList){
  880. var securityLabel = "";
  881. var keys = Object.keys(labelList);
  882. for (var i=0; i<keys.length; i++){
  883. var value = this.content.securityLabelList[keys[i]];
  884. if (value === this.data.subjectSecurityClearance){
  885. securityLabel = keys[i];
  886. break;
  887. }
  888. }
  889. return securityLabel;
  890. }.bind(this));
  891. },
  892. getSecurityLabelList: function(){
  893. if (this.content.securityLabelList) return Promise.resolve(this.content.securityLabelList);
  894. return o2.Actions.load("x_general_assemble_control").SecurityClearanceAction.subject().then(function(json){
  895. this.content.securityLabelList = json.data;
  896. return this.content.securityLabelList;
  897. }.bind(this));
  898. },
  899. getContentHtml: function(){
  900. var statusText = "";
  901. this.explorer.app.lp.statusOption.each(function (opt){
  902. if( opt.value === (this.data.status || "0") )statusText = opt.text;
  903. }.bind(this));
  904. var html = "<table width='100%' cellpadding='3px' cellspacing='5px'>";
  905. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personName+":</td><td class='inforContent infor_name'>"+(this.data.name || "")+"</td>" +
  906. "<td class='inforTitle'>"+this.explorer.app.lp.personUnique+":</td><td class='inforContent infor_unique'>"+(this.data.unique || "")+"</td></tr>";
  907. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personMobile+":</td><td class='inforContent infor_mobile'>"+(this.data.mobile || "")+"</td>" +
  908. "<td class='inforTitle'>"+this.explorer.app.lp.personEmployee+":</td><td class='inforContent infor_employee'>"+(this.data.employee || "")+"</td></tr>";
  909. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personGender+":</td><td class='inforContent infor_gender'>"+this.getGenderType()+"</td>" +
  910. "<td class='inforTitle'>"+this.explorer.app.lp.personSuperior+":</td><td class='inforContent'>"+"</td></tr>";
  911. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personMail+":</td><td class='inforContent infor_mail'>"+(this.data.mail || "")+"</td>" +
  912. "<td class='inforTitle'>"+this.explorer.app.lp.personWeixin+":</td><td class='inforContent infor_weixin'>"+(this.data.weixin || "")+"</td></tr>";
  913. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personQQ+":</td><td class='inforContent infor_qq'>"+(this.data.qq || "")+"</td>" +
  914. "<td class='inforTitle'>"+this.explorer.app.lp.personOfficePhone+":</td><td class='inforContent infor_officePhone'>"+(this.data.officePhone || "")+"</td></tr>";
  915. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.personBoardDate+":</td><td class='inforContent infor_boardDate'>"+(this.data.boardDate || "")+"</td>" +
  916. "<td class='inforTitle'>"+this.explorer.app.lp.personBirthday+":</td><td class='inforContent infor_birthday'>"+(this.data.birthday || "")+"</td></tr>";
  917. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.ipAddress+":</td><td class='inforContent infor_ipAddress'>"+(this.data.ipAddress || "")+"</td>" +
  918. "<td class='inforTitle'>"+this.explorer.app.lp.description+":</td><td class='inforContent infor_description'>"+(this.data.description || "")+"</td></tr>";
  919. html += "<tr><td class='inforTitle'>"+this.explorer.app.lp.securityLabel+":</td><td class='inforContent infor_securityLabel'>"+(this.data.subjectSecurityClearance || "")+"</td>" +
  920. "<td class='inforTitle'>"+this.explorer.app.lp.status+":</td><td class='inforContent infor_status'>"+(statusText || "")+"</td></tr>";
  921. html += "<tr><td colspan='4' class='inforAction'></td></tr>";
  922. //this.baseInforRightNode.set("html", html);
  923. return html;
  924. },
  925. loadAction: function(){
  926. //this.explorer.app.lp.edit
  927. var actionAreas = this.editContentNode.getElements("td");
  928. var actionArea = actionAreas[actionAreas.length-1];
  929. if (this.data.control.allowEdit){
  930. this.baseInforEditActionAreaNode = new Element("div", {"styles": this.style.baseInforEditActionAreaNode}).inject(actionArea);
  931. this.editNode = new Element("div", {"styles": this.style.actionEditNode, "text": this.explorer.app.lp.editPerson}).inject(this.baseInforEditActionAreaNode);
  932. this.saveNode = new Element("div", {"styles": this.style.actionSaveNode, "text": this.explorer.app.lp.savePerson}).inject(this.baseInforEditActionAreaNode);
  933. this.saveNode.addClass("mainColor_bg");
  934. this.cancelNode = new Element("div", {"styles": this.style.actionCancelNode, "text": this.explorer.app.lp.cancel}).inject(this.baseInforEditActionAreaNode);
  935. this.editNode.setStyle("display", "block");
  936. this.editNode.addEvent("click", this.edit.bind(this));
  937. this.saveNode.addEvent("click", this.save.bind(this));
  938. this.cancelNode.addEvent("click", this.cancel.bind(this));
  939. }else{
  940. }
  941. },
  942. edit: function(){
  943. debugger;
  944. var tdContents = this.editContentNode.getElements("td.inforContent");
  945. tdContents[0].setStyles(this.style.baseInforContentNode_edit).empty();
  946. this.nameInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[0]);
  947. this.nameInputNode.set("value", (this.data.name));
  948. tdContents[1].setStyles(this.style.baseInforContentNode_edit).empty();
  949. this.uniqueInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[1]);
  950. this.uniqueInputNode.set("value", (this.data.unique));
  951. if( this.data.id ){
  952. this.tooltip = new MWF.xApplication.Org.PersonExplorer.PersonContent.UniqueTooltip(this.explorer.app.content, tdContents[1], this.explorer.app, {}, {
  953. axis : "y",
  954. position : {
  955. x : "right"
  956. },
  957. hiddenDelay : 300,
  958. displayDelay : 300
  959. });
  960. }
  961. tdContents[2].setStyles(this.style.baseInforContentNode_edit).empty();
  962. this.mobileInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[2]);
  963. this.mobileInputNode.set("value", (this.data.mobile));
  964. tdContents[3].setStyles(this.style.baseInforContentNode_edit).empty();
  965. this.employeeInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[3]);
  966. this.employeeInputNode.set("value", (this.data.employee));
  967. tdContents[4].setStyles(this.style.baseInforContentNode_edit).empty();
  968. var html = "<input name=\"personGenderRadioNode\" value=\"m\" type=\"radio\" "+((this.data.genderType==="m") ? "checked" : "")+"/>"+this.explorer.app.lp.man;
  969. html += "<input name=\"personGenderRadioNode\" value=\"f\" type=\"radio\" "+((this.data.genderType==="f") ? "checked" : "")+"/>"+this.explorer.app.lp.female;
  970. html += "<input name=\"personGenderRadioNode\" value=\"d\" type=\"radio\" "+((this.data.genderType==="d") ? "checked" : "")+"/>"+this.explorer.app.lp.other;
  971. tdContents[4].set("html", html);
  972. tdContents[5].setStyles(this.style.baseInforContentNode_edit).empty();
  973. this.superiorInputNode = new Element("div", {"styles": this.style.inputNode_person}).inject(tdContents[5]);
  974. //this.superiorInputNode.set("value", (this.data.superior));
  975. if (this.data.superior) new MWF.widget.O2Person({"name": this.data.superior}, this.superiorInputNode, {"style": "xform"});
  976. this.superiorInputNode.addEvent("click", function(){
  977. MWF.xDesktop.requireApp("Selector", "package", function(){
  978. var options = {
  979. "type": "person",
  980. "values": (this.data.superior) ? [this.data.superior] : [],
  981. "count": 1,
  982. "onComplete": function(items){
  983. this.superiorInputNode.empty();
  984. if (items.length){
  985. this.data.superior = items[0].data.distinguishedName;
  986. new MWF.widget.O2Person(items[0].data, this.superiorInputNode, {"style": "xform"});
  987. }else{
  988. this.data.superior = "";
  989. }
  990. }.bind(this)
  991. };
  992. var selector = new MWF.O2Selector(this.explorer.app.content, options);
  993. }.bind(this));
  994. }.bind(this));
  995. tdContents[6].setStyles(this.style.baseInforContentNode_edit).empty();
  996. this.mailInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[6]);
  997. this.mailInputNode.set("value", (this.data.mail));
  998. tdContents[7].setStyles(this.style.baseInforContentNode_edit).empty();
  999. this.weixinInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[7]);
  1000. this.weixinInputNode.set("value", (this.data.weixin));
  1001. tdContents[8].setStyles(this.style.baseInforContentNode_edit).empty();
  1002. this.qqInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[8]);
  1003. this.qqInputNode.set("value", (this.data.qq));
  1004. tdContents[9].setStyles(this.style.baseInforContentNode_edit).empty();
  1005. this.officePhoneInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[9]);
  1006. this.officePhoneInputNode.set("value", (this.data.officePhone));
  1007. tdContents[10].setStyles(this.style.baseInforContentNode_edit).empty();
  1008. this.boardDateInputNode = new Element("input", {"styles": this.style.inputNode_calendar, "readonly": true}).inject(tdContents[10]);
  1009. this.boardDateInputNode.set("value", (this.data.boardDate));
  1010. MWF.require("MWF.widget.Calendar", function(){
  1011. var boardDateCalendar = new MWF.widget.Calendar(this.boardDateInputNode, {
  1012. "style": "xform",
  1013. "isTime": false,
  1014. "target": this.explorer.app.content,
  1015. "format": "%Y-%m-%d"
  1016. });
  1017. }.bind(this));
  1018. tdContents[11].setStyles(this.style.baseInforContentNode_edit).empty();
  1019. this.birthdayInputNode = new Element("input", {"styles": this.style.inputNode_calendar, "readonly": true}).inject(tdContents[11]);
  1020. this.birthdayInputNode.set("value", (this.data.birthday));
  1021. MWF.require("MWF.widget.Calendar", function(){
  1022. var birthdayCalendar = new MWF.widget.Calendar(this.birthdayInputNode, {
  1023. "style": "xform",
  1024. "isTime": false,
  1025. "target": this.explorer.app.content,
  1026. "format": "%Y-%m-%d"
  1027. });
  1028. }.bind(this));
  1029. tdContents[12].setStyles(this.style.baseInforContentNode_edit).empty();
  1030. this.ipAddressInputNode = new Element("input", {
  1031. "styles": this.style.inputNode,
  1032. "placeHolder": this.explorer.app.lp.ipAddressPlaceHolder,
  1033. "autocomplete": "off",
  1034. "title": this.explorer.app.lp.ipAddressPlaceHolder
  1035. }).inject(tdContents[12]);
  1036. this.ipAddressInputNode.set("value", (this.data.ipAddress));
  1037. tdContents[13].setStyles(this.style.baseInforContentNode_edit).empty();
  1038. this.descriptionInputNode = new Element("input", {"styles": this.style.inputNode}).inject(tdContents[13]);
  1039. this.descriptionInputNode.set("value", (this.data.description));
  1040. tdContents[14].setStyles(this.style.baseInforContentNode_edit).empty();
  1041. var securityLabel = this.data.subjectSecurityClearance;
  1042. this.securityLabelSelectNode = new Element("select", {"styles": this.style.selectNode}).inject(tdContents[14]);
  1043. new Element("option", {value: "", text: ""}).inject(this.securityLabelSelectNode);
  1044. this.getSecurityLabelList().then(function(securityLabelList){
  1045. if (securityLabelList) Object.keys(securityLabelList).forEach(function(key){
  1046. var value = securityLabelList[key];
  1047. var option = new Element("option", {value: value, text: key}).inject(this.securityLabelSelectNode);
  1048. if (securityLabel === value){
  1049. option.selected = true;
  1050. }
  1051. }.bind(this));
  1052. }.bind(this));
  1053. // this.securityLabelSelectNode.set("value", (this.data.description));
  1054. var _self = this;
  1055. this.editContentNode.getElements("input").addEvents({
  1056. "focus": function(){if (this.get("type").toLowerCase()==="text"){this.setStyles(_self.style.inputNode_focus);}},
  1057. "blur": function(){if (this.get("type").toLowerCase()==="text"){this.setStyles(_self.style.inputNode_blur);}}
  1058. });
  1059. this.mode = "edit";
  1060. this.editNode.setStyle("display", "none");
  1061. this.saveNode.setStyle("display", "block");
  1062. this.cancelNode.setStyle("display", "block");
  1063. },
  1064. save: function(){
  1065. var tdContents = this.editContentNode.getElements("td.inforContent");
  1066. var gender = "";
  1067. var radios = tdContents[4].getElements("input");
  1068. for (var i=0; i<radios.length; i++){
  1069. if (radios[i].checked){
  1070. gender = radios[i].value;
  1071. break;
  1072. }
  1073. }
  1074. return o2.Actions.load("x_general_assemble_control").SecurityClearanceAction.enable().then(function(json){
  1075. if (json.data.enable===true){
  1076. var label = this.securityLabelSelectNode.options[this.securityLabelSelectNode.selectedIndex].value;
  1077. if (!label || !this.nameInputNode.get("value") || !this.mobileInputNode.get("value") || !this.uniqueInputNode.get("value") || !gender){
  1078. this.explorer.app.notice(this.explorer.app.lp.inputPersonInfor2, "error", this.explorer.propertyContentNode);
  1079. return false;
  1080. }
  1081. }else{
  1082. if (!this.nameInputNode.get("value") || !this.mobileInputNode.get("value") || !this.uniqueInputNode.get("value") || !gender){
  1083. this.explorer.app.notice(this.explorer.app.lp.inputPersonInfor, "error", this.explorer.propertyContentNode);
  1084. return false;
  1085. }
  1086. }
  1087. if (!this.uniqueInputNode.get("value")) this.data.unique = this.employeeInputNode.get("value");
  1088. this.content.propertyContentScrollNode.mask({
  1089. "style": {
  1090. "opacity": 0.7,
  1091. "background-color": "#999"
  1092. }
  1093. });
  1094. this.savePerson(function(){
  1095. this.cancel();
  1096. this.content.propertyContentScrollNode.unmask();
  1097. }.bind(this), function(xhr, text, error){
  1098. var errorText = error;
  1099. if (xhr){
  1100. var json = JSON.decode(xhr.responseText);
  1101. if (json){
  1102. errorText = json.message.trim() || "request json error";
  1103. }else{
  1104. errorText = "request json error: "+xhr.responseText;
  1105. }
  1106. }
  1107. MWF.xDesktop.notice("error", {x: "right", y:"top"}, errorText);
  1108. this.content.propertyContentScrollNode.unmask();
  1109. }.bind(this));
  1110. }.bind(this));
  1111. },
  1112. savePerson: function(callback, cancel){
  1113. var data = Object.clone(this.data);
  1114. data.name = this.nameInputNode.get("value");
  1115. data.employee = this.employeeInputNode.get("value");
  1116. data.mobile = this.mobileInputNode.get("value");
  1117. data.unique = this.uniqueInputNode.get("value");
  1118. //data.superior = this.superiorInputNode.get("value");
  1119. data.mail = this.mailInputNode.get("value");
  1120. data.weixin = this.weixinInputNode.get("value");
  1121. data.qq = this.qqInputNode.get("value");
  1122. data.officePhone = this.officePhoneInputNode.get("value");
  1123. data.boardDate = this.boardDateInputNode.get("value");
  1124. data.birthday = this.birthdayInputNode.get("value");
  1125. data.ipAddress = this.ipAddressInputNode.get("value");
  1126. data.description = this.descriptionInputNode.get("value");
  1127. data.description = this.descriptionInputNode.get("value");
  1128. var securityLabel = this.securityLabelSelectNode.options[this.securityLabelSelectNode.selectedIndex].value;
  1129. data.subjectSecurityClearance = (securityLabel) ? parseInt(securityLabel) : null;
  1130. var tdContents = this.editContentNode.getElements("td.inforContent");
  1131. var radios = tdContents[4].getElements("input");
  1132. for (var i=0; i<radios.length; i++){
  1133. if (radios[i].checked){
  1134. data.genderType = radios[i].value;
  1135. break;
  1136. }
  1137. }
  1138. this.explorer.actions.savePerson(data, function(json){
  1139. Object.merge(this.data, data);
  1140. if (this.data.id){
  1141. this.data.id = json.data.id;
  1142. this.item.refresh();
  1143. if (callback) callback();
  1144. }else{
  1145. this.explorer.actions.getPerson(function(json){
  1146. this.data = Object.merge(this.data, json.data);
  1147. this.item.data = this.data;
  1148. this.item.refresh();
  1149. this.content.loadList();
  1150. if (callback) callback();
  1151. }.bind(this), null, json.data.id);
  1152. }
  1153. }.bind(this), function(xhr, text, error){
  1154. if (cancel) cancel(xhr, text, error);
  1155. }.bind(this));
  1156. // }.bind(this), function(xhr, text, error){
  1157. // if (cancel) cancel(xhr, text, error);
  1158. // }.bind(this));
  1159. },
  1160. cancel: function(){
  1161. debugger;
  1162. if (this.data.id){
  1163. var tdContents = this.editContentNode.getElements("td.inforContent");
  1164. tdContents[0].setStyles(this.style.baseInforContentNode).set("text", this.data.name || "");
  1165. tdContents[1].setStyles(this.style.baseInforContentNode).set("text", this.data.unique || "");
  1166. tdContents[2].setStyles(this.style.baseInforContentNode).set("text", this.data.mobile || "");
  1167. tdContents[3].setStyles(this.style.baseInforContentNode).set("text", this.data.employee || "");
  1168. tdContents[4].setStyles(this.style.baseInforContentNode).set("text", this.getGenderType());
  1169. tdContents[5].setStyles(this.style.baseInforContentNode).set("text", "");
  1170. if (this.data.superior) new MWF.widget.O2Person({"name": this.data.superior}, tdContents[5], {"style": "xform"});
  1171. tdContents[6].setStyles(this.style.baseInforContentNode).set("text", this.data.mail || "");
  1172. tdContents[7].setStyles(this.style.baseInforContentNode).set("text", this.data.weixin || "");
  1173. tdContents[8].setStyles(this.style.baseInforContentNode).set("text", this.data.qq || "");
  1174. tdContents[9].setStyles(this.style.baseInforContentNode).set("text", this.data.officePhone || "");
  1175. tdContents[10].setStyles(this.style.baseInforContentNode).set("text", this.data.boardDate || "");
  1176. tdContents[11].setStyles(this.style.baseInforContentNode).set("text", this.data.birthday || "");
  1177. tdContents[12].setStyles(this.style.baseInforContentNode).set("text", this.data.ipAddress || "");
  1178. tdContents[13].setStyles(this.style.baseInforContentNode).set("text", this.data.description || "");
  1179. this.getSecurityLabelText().then(function(securityLabel){
  1180. tdContents[14].setStyles(this.style.baseInforContentNode).set("text", securityLabel || "");
  1181. }.bind(this));
  1182. this.mode = "read";
  1183. this.editNode.setStyle("display", "block");
  1184. this.saveNode.setStyle("display", "none");
  1185. this.cancelNode.setStyle("display", "none");
  1186. }else{
  1187. this.item.destroy();
  1188. }
  1189. if( this.tooltip ){
  1190. this.tooltip.destroy();
  1191. this.tooltip = null;
  1192. }
  1193. },
  1194. getGenderType: function(){
  1195. var text = "";
  1196. if (this.data.genderType){
  1197. switch (this.data.genderType) {
  1198. case "m":
  1199. text = this.explorer.app.lp.man;
  1200. break;
  1201. case "f":
  1202. text = this.explorer.app.lp.female;
  1203. break;
  1204. default:
  1205. text = this.explorer.app.lp.other;
  1206. }
  1207. }
  1208. return text;
  1209. },
  1210. destroy: function(){
  1211. if( this.tooltip ){
  1212. this.tooltip.destroy();
  1213. this.tooltip = null;
  1214. }
  1215. this.node.empty();
  1216. this.node.destroy();
  1217. MWF.release(this);
  1218. },
  1219. _getIcon: function(nocache){
  1220. var url = (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "../x_component_Org/$Explorer/default/icon/man.png";
  1221. return (nocache) ? url+"?"+(new Date().getTime()) : url;
  1222. //return (this.data.id) ? this.explorer.actions.getPersonIcon(this.data.id) : "../x_component_Org/$Explorer/default/icon/man.png";
  1223. // var src = "data:image/png;base64,"+this.data.icon;
  1224. // if (!this.data.icon){
  1225. // if (this.data.genderType==="f"){
  1226. // src = "../x_component_Org/$Explorer/default/icon/female.png"
  1227. // }else{
  1228. // src = "../x_component_Org/$Explorer/default/icon/man.png"
  1229. // }
  1230. // }
  1231. // return src;
  1232. }
  1233. });
  1234. MWF.xApplication.Org.PersonExplorer.PersonContent.UniqueTooltip = new Class({
  1235. Extends: MTooltips,
  1236. _getHtml : function(){
  1237. var html =
  1238. "<div item='containr' style='line-height:24px;'><div style='font-size: 14px;color:red;float:left; '>"+ this.lp.personUniqueModifyNote +"</div></div>";
  1239. return html;
  1240. }
  1241. });
  1242. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  1243. MWF.xApplication.Org.PersonExplorer.PasswordExpiredTimeForm = new Class({
  1244. Extends: MPopupForm,
  1245. Implements: [Options, Events],
  1246. options: {
  1247. "style": "cms_xform",
  1248. "width": "580",
  1249. "height": "220",
  1250. "hasTop": true,
  1251. "hasIcon": false,
  1252. "hasTopIcon" : false,
  1253. "hasTopContent" : true,
  1254. "hasBottom": true,
  1255. "title": MWF.xApplication.Org.LP.expiredTimeTitle,
  1256. "draggable": true,
  1257. "closeAction": true,
  1258. "publishTime": ""
  1259. },
  1260. _createTableContent: function () {
  1261. this.formTopTextNode.addClass("mainColor_color");
  1262. this.formAreaNode.setStyle("z-index", 1002);
  1263. this.formMaskNode.setStyle("z-index", 1002);
  1264. this.formTableContainer.setStyles({
  1265. "margin":"20px 40px 0px 40px"
  1266. });
  1267. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1268. "<tr>" +
  1269. " <td styles='formTableValue' item='expiredTime'></td>" +
  1270. "</tr>"+
  1271. "</table>";
  1272. this.formTableArea.set("html", html);
  1273. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1274. this.form = new MForm(this.formTableArea, this.data, {
  1275. style: "meeting",
  1276. isEdited: true,
  1277. itemTemplate: {
  1278. expiredTime: {
  1279. tType: "date",
  1280. notEmpty: true,
  1281. value: this.options.expiredTime || "",
  1282. attr: {
  1283. "readonly":true
  1284. },
  1285. calendarOptions : {
  1286. "secondEnable": false,
  1287. "format": "%Y-%m-%d",
  1288. "onShow": function () {
  1289. this.container.setStyle("z-index", 1003 );
  1290. }
  1291. }
  1292. }
  1293. }
  1294. }, this.app, this.css);
  1295. this.form.load();
  1296. }.bind(this), true);
  1297. },
  1298. _createBottomContent: function () {
  1299. this.closeActionNode = new Element("div.formCancelActionNode", {
  1300. "styles": this.css.formCancelActionNode,
  1301. "text": this.lp.cancel
  1302. }).inject(this.formBottomNode);
  1303. this.closeActionNode.addEvent("click", function (e) {
  1304. this.cancel(e);
  1305. }.bind(this));
  1306. this.okActionNode = new Element("div.formOkActionNode", {
  1307. "styles": this.css.formOkActionNode,
  1308. "text": this.lp.ok
  1309. }).inject(this.formBottomNode);
  1310. this.okActionNode.addClass("mainColor_bg");
  1311. this.okActionNode.addEvent("click", function (e) {
  1312. this.ok(e);
  1313. }.bind(this));
  1314. },
  1315. ok: function (e) {
  1316. this.fireEvent("queryOk");
  1317. var result = this.form.getResult(true, null);
  1318. if( !result ){
  1319. this.app.notice(this.lp.inputExpiredTime, "error");
  1320. return;
  1321. }
  1322. (this.formMaskNode || this.formMarkNode).destroy();
  1323. this.formAreaNode.destroy();
  1324. this.fireEvent("postOk", result.expiredTime);
  1325. }
  1326. });
  1327. MWF.xApplication.Org.PersonExplorer.LockPersonForm = new Class({
  1328. Extends: MPopupForm,
  1329. Implements: [Options, Events],
  1330. options: {
  1331. "style": "cms_xform",
  1332. "width": "580",
  1333. "height": "330",
  1334. "hasTop": true,
  1335. "hasIcon": false,
  1336. "hasTopIcon" : false,
  1337. "hasTopContent" : true,
  1338. "hasBottom": true,
  1339. "title": MWF.xApplication.Org.LP.lockPerson,
  1340. "draggable": true,
  1341. "closeAction": true,
  1342. "lockExpiredTime": ""
  1343. },
  1344. _createTableContent: function () {
  1345. this.formTopTextNode.addClass("mainColor_color");
  1346. this.formAreaNode.setStyle("z-index", 1002);
  1347. this.formMaskNode.setStyle("z-index", 1002);
  1348. this.formTableContainer.setStyles({
  1349. "margin":"20px 40px 0px 40px"
  1350. });
  1351. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1352. "<tr>" +
  1353. " <td styles='formTableValue' style='width:70px;'></td>" +
  1354. " <td styles='formTableValue'>"+MWF.xApplication.Org.LP.lockPersonInfo+"</td>" +
  1355. "</tr>"+
  1356. "<tr>" +
  1357. " <td styles='formTableValue' style='width:70px;' lable='lockExpiredTime'></td>" +
  1358. " <td styles='formTableValue' item='lockExpiredTime'></td>" +
  1359. "</tr>"+
  1360. "<tr>" +
  1361. " <td styles='formTableValue' style='width:70px;' lable='reason'></td>" +
  1362. " <td styles='formTableValue' item='reason'></td>" +
  1363. "</tr>"+
  1364. "</table>";
  1365. this.formTableArea.set("html", html);
  1366. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1367. this.form = new MForm(this.formTableArea, this.data, {
  1368. style: "meeting",
  1369. isEdited: true,
  1370. itemTemplate: {
  1371. lockExpiredTime: {
  1372. text: MWF.xApplication.Org.LP.lockLimitTime,
  1373. tType: "date",
  1374. notEmpty: true,
  1375. value: this.options.lockExpiredTime || "",
  1376. attr: {
  1377. "readonly":true
  1378. },
  1379. calendarOptions : {
  1380. "secondEnable": false,
  1381. "format": "%Y-%m-%d",
  1382. "onShow": function () {
  1383. this.container.setStyle("z-index", 1003 );
  1384. }
  1385. }
  1386. },
  1387. reason: {
  1388. text: MWF.xApplication.Org.LP.lockPersonReason,
  1389. type: "textarea",
  1390. notEmpty: true,
  1391. value: this.options.reason || ""
  1392. }
  1393. }
  1394. }, this.app, this.css);
  1395. this.form.load();
  1396. }.bind(this), true);
  1397. },
  1398. _createBottomContent: function () {
  1399. this.closeActionNode = new Element("div.formCancelActionNode", {
  1400. "styles": this.css.formCancelActionNode,
  1401. "text": this.lp.cancel
  1402. }).inject(this.formBottomNode);
  1403. this.closeActionNode.addEvent("click", function (e) {
  1404. this.cancel(e);
  1405. }.bind(this));
  1406. this.okActionNode = new Element("div.formOkActionNode", {
  1407. "styles": this.css.formOkActionNode,
  1408. "text": this.lp.ok
  1409. }).inject(this.formBottomNode);
  1410. this.okActionNode.addClass("mainColor_bg");
  1411. this.okActionNode.addEvent("click", function (e) {
  1412. this.ok(e);
  1413. }.bind(this));
  1414. },
  1415. ok: function (e) {
  1416. this.fireEvent("queryOk");
  1417. var result = this.form.getResult(true, null);
  1418. if( !result ){
  1419. this.app.notice(this.lp.inputLockExpiredTimeAndReason, "error");
  1420. return;
  1421. }
  1422. (this.formMaskNode || this.formMarkNode).destroy();
  1423. this.formAreaNode.destroy();
  1424. this.fireEvent("postOk", [result.lockExpiredTime, result.reason]);
  1425. }
  1426. });
  1427. MWF.xApplication.Org.PersonExplorer.BanPersonForm = new Class({
  1428. Extends: MPopupForm,
  1429. Implements: [Options, Events],
  1430. options: {
  1431. "style": "cms_xform",
  1432. "width": "580",
  1433. "height": "290",
  1434. "hasTop": true,
  1435. "hasIcon": false,
  1436. "hasTopIcon" : false,
  1437. "hasTopContent" : true,
  1438. "hasBottom": true,
  1439. "title": MWF.xApplication.Org.LP.banPerson,
  1440. "draggable": true,
  1441. "closeAction": true,
  1442. "publishTime": ""
  1443. },
  1444. _createTableContent: function () {
  1445. this.formTopTextNode.addClass("mainColor_color");
  1446. this.formAreaNode.setStyle("z-index", 1002);
  1447. this.formMaskNode.setStyle("z-index", 1002);
  1448. this.formTableContainer.setStyles({
  1449. "margin":"20px 40px 0px 40px"
  1450. });
  1451. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1452. "<tr>" +
  1453. " <td styles='formTableValue' style='width:70px;'></td>" +
  1454. " <td styles='formTableValue'>"+MWF.xApplication.Org.LP.banPersonText.replace("{name}", this.options.name)+"</td>" +
  1455. "</tr>"+
  1456. "<tr>" +
  1457. " <td styles='formTableValue' style='width:70px;' lable='reason'></td>" +
  1458. " <td styles='formTableValue' item='reason'></td>" +
  1459. "</tr>"+
  1460. "</table>";
  1461. this.formTableArea.set("html", html);
  1462. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1463. this.form = new MForm(this.formTableArea, this.data, {
  1464. style: "meeting",
  1465. isEdited: true,
  1466. itemTemplate: {
  1467. reason: {
  1468. text: MWF.xApplication.Org.LP.reason,
  1469. type: "textarea",
  1470. notEmpty: true,
  1471. value: this.options.reason || ""
  1472. }
  1473. }
  1474. }, this.app, this.css);
  1475. this.form.load();
  1476. }.bind(this), true);
  1477. },
  1478. _createBottomContent: function () {
  1479. this.closeActionNode = new Element("div.formCancelActionNode", {
  1480. "styles": this.css.formCancelActionNode,
  1481. "text": this.lp.cancel
  1482. }).inject(this.formBottomNode);
  1483. this.closeActionNode.addEvent("click", function (e) {
  1484. this.cancel(e);
  1485. }.bind(this));
  1486. this.okActionNode = new Element("div.formOkActionNode", {
  1487. "styles": this.css.formOkActionNode,
  1488. "text": this.lp.ok
  1489. }).inject(this.formBottomNode);
  1490. this.okActionNode.addClass("mainColor_bg");
  1491. this.okActionNode.addEvent("click", function (e) {
  1492. this.ok(e);
  1493. }.bind(this));
  1494. },
  1495. ok: function (e) {
  1496. this.fireEvent("queryOk");
  1497. var result = this.form.getResult(true, null);
  1498. if( !result ){
  1499. this.app.notice(this.lp.inputReason, "error");
  1500. return;
  1501. }
  1502. (this.formMaskNode || this.formMarkNode).destroy();
  1503. this.formAreaNode.destroy();
  1504. this.fireEvent("postOk", result.expiredTime);
  1505. }
  1506. });
  1507. MWF.xApplication.Org.PersonExplorer.FilterTooltip = new Class({
  1508. Extends: MTooltips,
  1509. _customNode : function(node, contentNode){
  1510. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0'>" +
  1511. "<tr>" +
  1512. " <td styles='formTableValue' style='width:30px;' lable='key'></td>" +
  1513. " <td styles='formTableValue' item='key'></td>" +
  1514. "</tr>"+
  1515. "<tr>" +
  1516. " <td styles='formTableValue' lable='status'></td>" +
  1517. " <td styles='formTableValue' item='status'></td>" +
  1518. "</tr>"+
  1519. "<tr>" +
  1520. " <td styles='formTableValue'></td>" +
  1521. " <td styles='formTableValue'><div class='mainColor_bg' item='searchAction'>"+MWF.xApplication.Org.LP.search+"</div></td>" +
  1522. "</tr>"+
  1523. "</table>";
  1524. this.contentNode.set("html", html);
  1525. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1526. this.form = new MForm(this.contentNode, {}, {
  1527. style: "execution",
  1528. isEdited: true,
  1529. itemTemplate: {
  1530. key: {
  1531. text: MWF.xApplication.Org.LP.search,
  1532. attr:{
  1533. placeholder: MWF.xApplication.Org.LP.searchText
  1534. }
  1535. },
  1536. status: {
  1537. text: MWF.xApplication.Org.LP.status,
  1538. type: "select",
  1539. selectValue: MWF.xApplication.Org.LP.statusOption.map(function (opt){
  1540. return opt.value;
  1541. }),
  1542. selectText: MWF.xApplication.Org.LP.statusOption.map(function (opt){
  1543. return opt.text;
  1544. })
  1545. }
  1546. }
  1547. });
  1548. this.form.load();
  1549. var searchAction = this.contentNode.getElement("[item='searchAction'");
  1550. searchAction.setStyles(this.explorer.css.filterSearchAction);
  1551. searchAction.addEvent("click", function (){
  1552. this.explorer.filterData = this.form.getItemsKeyValue();
  1553. this.explorer.reloadElements();
  1554. }.bind(this));
  1555. }.bind(this), true);
  1556. }
  1557. });