Main.js 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430
  1. MWF.xApplication.Profile.options.multitask = false;
  2. MWF.xApplication.Profile.Main = new Class({
  3. Extends: MWF.xApplication.Common.Main,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "newVersion",
  7. "name": "Profile",
  8. "icon": "icon.png",
  9. "width": "1100",
  10. "height": "820",
  11. "isResize": false,
  12. "isMax": false,
  13. "mvcStyle": "style.css",
  14. "title": MWF.xApplication.Profile.LP.title
  15. },
  16. _loadCss: function(){},
  17. loadCss: function(file, callback){
  18. var path = (file && typeOf(file)==="string") ? file : "style.css";
  19. var cb = (file && typeOf(file)==="function") ? file : callback;
  20. var cssPath = this.path+this.options.style+"/"+path;
  21. this.content.loadCss(cssPath, cb);
  22. },
  23. onQueryLoad: function(){
  24. this.lp = MWF.xApplication.Profile.LP;
  25. this.action = MWF.Actions.get("x_organization_assemble_personal");
  26. MWF.xDesktop.requireApp("Profile", "Common", null, false);
  27. },
  28. loadApplication: function(callback){
  29. this.action.getPerson(function(json){
  30. this.personData = json.data;
  31. this.personData.personIcon = this.action.getPersonIcon();
  32. this.content.loadHtml(this.path+this.options.style+"/"+((this.inBrowser||layout.viewMode=="Default")? "viewBrowser": "view")+".html", {"bind": {"data": this.personData, "lp": this.lp}, "module": this}, function(){
  33. this.loadContent()
  34. }.bind(this));
  35. }.bind(this));
  36. //this.loadCss();
  37. // this.loadTitle();
  38. // this.loadContent();
  39. if (callback) callback();
  40. },
  41. loadContent: function(){
  42. debugger;
  43. var pageConfigNodes = this.content.getElements(".o2_profile_configNode");
  44. this.contentNode = this.content.getElement(".o2_profile_contentNode");
  45. MWF.require("MWF.widget.Tab", function(){
  46. this.tab = new MWF.widget.Tab(this.contentNode, {"style": "profileV2"});
  47. this.tab.load();
  48. pageConfigNodes.each(function(node){
  49. this.tab.addTab(node, node.get("title"));
  50. }.bind(this));
  51. this.contentNode.getElement("[name=MWFcontentNodeContainer]").setStyles({
  52. "height":"calc(100% - 50px)",
  53. "overflow":"auto"
  54. });
  55. this.tab.pages.map(function(stab){
  56. var tabNode = stab.tabNode;
  57. tabNode.addEvent("click",function(){
  58. this.addClass("mainColor_border");
  59. this.getChildren().addClass("mainColor_color");
  60. this.getSiblings().removeClass("mainColor_border");
  61. this.getSiblings().map(function(otabNode) {
  62. otabNode.getChildren().removeClass("mainColor_color");
  63. })
  64. }.bind(tabNode));
  65. }.bind(this));
  66. if (this.options.tab){
  67. this.tab.pages[this.options.tab].showIm();
  68. this.tab.pages[this.options.tab].tabNode.addClass("mainColor_border");
  69. this.tab.pages[this.options.tab].textNode.addClass("mainColor_color");
  70. }else{
  71. this.tab.pages[0].showIm();
  72. this.tab.pages[0].tabNode.addClass("mainColor_border");
  73. this.tab.pages[0].textNode.addClass("mainColor_color");
  74. }
  75. this.loadInforConfigActions();
  76. if (!this.inBrowser&&layout.viewMode=="Layout"){
  77. this.loadLayoutConfigActions();
  78. }else{
  79. }
  80. this.loadIdeaConfigActions();
  81. this.loadEmPowerConfigAction();
  82. this.loadPasswordConfigActions();
  83. this.loadSSOConfigAction();
  84. }.bind(this));
  85. },
  86. openFaceSet: function(){
  87. layout.openApplication(null, "FaceSet");
  88. },
  89. loadInforConfigActions: function(){
  90. this.contentImgNode = this.content.getElement(".o2_profile_inforIconContentImg");
  91. this.content.getElement(".o2_profile_inforIconChange").addClass("mainColor_color mainColor_border").addEvent("click", function(){
  92. this.changeIcon();
  93. }.bind(this));
  94. var inputs = this.tab.pages[0].contentNode.getElements("input");
  95. inputs.addEvent("focus",function(){
  96. this.addClass("mainColor_border mainColor_color");
  97. }).addEvent("blur",function(){
  98. this.removeClass("mainColor_border mainColor_color");
  99. });
  100. this.mailInputNode = inputs[0];
  101. this.mobileInputNode = inputs[1];
  102. this.officePhoneInputNode = inputs[2];
  103. this.weixinInputNode = inputs[3];
  104. this.qqInputNode = inputs[4];
  105. this.ipAddressInputNode = inputs[5];
  106. this.signatureInputNode = this.tab.pages[0].contentNode.getElement("textarea");
  107. this.signatureInputNode.addEvent("focus",function(){
  108. this.addClass("mainColor_border mainColor_color");
  109. }).addEvent("blur",function(){
  110. this.removeClass("mainColor_border mainColor_color");
  111. });
  112. this.content.getElement(".o2_profile_saveInforAction").addEvent("click", function(){
  113. this.savePersonInfor();
  114. }.bind(this));
  115. },
  116. loadLayoutConfigActions: function(){
  117. var buttons = this.tab.pages[1].contentNode.getElements(".o2_profile_layoutClearDataAction");
  118. this.clearDataAction = buttons[0];
  119. this.defaultDataAction = (buttons.length>1) ? buttons[1]: null;
  120. this.clearDefaultDataAction = (buttons.length>2) ? buttons[2]: null;
  121. this.forceDataAction = (buttons.length>3) ? buttons[3]: null;
  122. this.deleteForceDataAction = (buttons.length>4) ? buttons[4]: null;
  123. this.clearDataAction.addEvent("click", function(){
  124. MWF.require("MWF.widget.UUID", function(){
  125. MWF.UD.deleteData("layout", function(){
  126. this.notice(this.lp.clearok, "success");
  127. this.desktop.notRecordStatus = true;
  128. }.bind(this));
  129. }.bind(this));
  130. }.bind(this));
  131. if( MWF.AC.isAdministrator() ){
  132. this.defaultDataAction.addEvent("click", function(){
  133. MWF.require("MWF.widget.UUID", function(){
  134. var text = this.lp.setDefaultOk;
  135. this.close();
  136. var status = layout.desktop.getLayoutStatusData();
  137. MWF.UD.putPublicData("defaultLayout", status, function(){
  138. MWF.xDesktop.notice("success", {"x": "right", "y": "top"}, text, layout.desktop.desktopNode);
  139. }.bind(this));
  140. }.bind(this));
  141. }.bind(this));
  142. this.clearDefaultDataAction.addEvent("click", function(){
  143. MWF.require("MWF.widget.UUID", function(){
  144. MWF.UD.deletePublicData("defaultLayout", function(){
  145. this.notice(this.lp.clearok, "success");
  146. this.desktop.notRecordStatus = true;
  147. }.bind(this));
  148. }.bind(this));
  149. }.bind(this));
  150. this.forceDataAction.addEvent("click", function(){
  151. MWF.require("MWF.widget.UUID", function(){
  152. var text = this.lp.setForceOk;
  153. this.close();
  154. var status = layout.desktop.getLayoutStatusData();
  155. MWF.UD.putPublicData("forceLayout", status, function(){
  156. MWF.xDesktop.notice("success", {"x": "right", "y": "top"}, text, layout.desktop.desktopNode);
  157. }.bind(this));
  158. }.bind(this));
  159. }.bind(this));
  160. this.deleteForceDataAction.addEvent("click", function(){
  161. MWF.require("MWF.widget.UUID", function(){
  162. MWF.UD.deletePublicData("forceLayout", function(){
  163. this.notice(this.lp.clearok, "success");
  164. this.desktop.notRecordStatus = true;
  165. }.bind(this));
  166. }.bind(this));
  167. }.bind(this));
  168. }
  169. var UINode = this.tab.pages[1].contentNode.getLast();
  170. this.loadDesktopBackground(UINode);
  171. },
  172. loadIdeaConfigActions: function(){
  173. var i = (this.inBrowser||layout.viewMode=="Default")? 1 : 2;
  174. this.ideasArea = this.tab.pages[i].contentNode.setStyle("min-height","500px").getElement("textarea").addEvent("focus",function(){
  175. this.addClass("mainColor_border mainColor_color");
  176. }).addEvent("blur",function(){
  177. this.removeClass("mainColor_border mainColor_color");
  178. });
  179. this.ideasSaveAction = this.ideasArea.getNext().addEvent("mouseover",function(){
  180. this.addClass("mainColor_bg");
  181. }).addEvent("mouseout",function(){
  182. this.removeClass("mainColor_bg");
  183. });
  184. this.ideasSaveDefaultAction = this.ideasSaveAction.getNext() || null;
  185. if (MWF.AC.isAdministrator()){
  186. this.ideasSaveDefaultAction.addEvent("mouseover",function(){
  187. this.addClass("mainColor_bg");
  188. }).addEvent("mouseout",function(){
  189. this.removeClass("mainColor_bg");
  190. });
  191. this.ideasSaveDefaultAction.addEvent("click", function(){
  192. MWF.require("MWF.widget.UUID", function(){
  193. var data = {};
  194. data.ideas = this.ideasArea.get("value").split("\n");
  195. MWF.UD.putPublicData("idea", data, function(){
  196. this.notice(this.lp.ideaSaveOk, "success");
  197. }.bind(this));
  198. }.bind(this));
  199. }.bind(this))
  200. }
  201. MWF.require("MWF.widget.UUID", function(){
  202. MWF.UD.getDataJson("idea", function(json){
  203. if (json){
  204. if (json.ideas) this.ideasArea.set("value", json.ideas.join("\n"));
  205. }
  206. }.bind(this));
  207. }.bind(this));
  208. this.ideasSaveAction.addEvent("click", function(){
  209. MWF.require("MWF.widget.UUID", function(){
  210. var data = {};
  211. data.ideas = this.ideasArea.get("value").split("\n");
  212. MWF.UD.putData("idea", data, function(){
  213. this.notice(this.lp.ideaSaveOk, "success");
  214. }.bind(this));
  215. }.bind(this));
  216. }.bind(this))
  217. },
  218. loadEmPowerConfigAction: function(){
  219. var i = (this.inBrowser||layout.viewMode=="Default")? 2 : 3;
  220. this.tab.pages[i].contentNode.setStyle("overflow","auto");
  221. var tabEmpowerNodes = this.tab.pages[i].contentNode.getElements("div.o2_profile_emPower_tab");
  222. this.emPowerContentNode = this.tab.pages[i].contentNode.getElement("div.o2_profile_emPower_content");
  223. MWF.require("MWF.widget.Tab", function() {
  224. this.tabEmpower = new MWF.widget.Tab(this.emPowerContentNode, {"style": "empower"});
  225. this.tabEmpower.load();
  226. tabEmpowerNodes.each(function(node){
  227. this.tabEmpower.addTab(node, node.get("title"));
  228. }.bind(this));
  229. this.tabEmpower.pages.map(function(stab){
  230. var tabNode = stab.tabNode.setStyle("cursor","pointer");
  231. tabNode.addEvent("click",function(){
  232. this.addClass("mainColor_bg");
  233. this.getSiblings().removeClass("mainColor_bg");
  234. }.bind(tabNode));
  235. }.bind(this));
  236. if (!this.options.tabEmpower) {
  237. this.tabEmpower.pages[0].showIm();
  238. this.tabEmpower.pages[0].tabNode.addClass("mainColor_bg");
  239. } else {
  240. this.tabEmpower.pages[this.options.tab].showIm();
  241. this.tabEmpower.pages[this.options.tab].tabNode.addClass("mainColor_bg");
  242. }
  243. }.bind(this));
  244. this.loadEmpowerBtn();
  245. this.loadMyEmPower();
  246. this.loadReceiveEmPower();
  247. this.loadMyEmPowerLog();
  248. this.loadReceiveEmPowerLog();
  249. },
  250. loadEmpowerBtn: function(){
  251. var BtnImg = new Element("div.o2_profile_emPower_Btnimg");
  252. var BtnText = new Element("div.o2_profile_emPower_Btntext");
  253. var addEmPowerDiv = new Element("div.o2_profile_emPower_Add").adopt(BtnImg.cloneNode(),BtnText.cloneNode().set("text",this.lp.empower.addEmPower));
  254. var withDrawEmPowerDiv = new Element("div.o2_profile_emPower_WithDraw").adopt(BtnImg.cloneNode(),BtnText.cloneNode().set("text",this.lp.empower.withdraw));
  255. this.tabEmpower.tabNodeContainerArea.adopt(withDrawEmPowerDiv,addEmPowerDiv);
  256. this.tabEmpower.tabNodeContainerArea.getElements(".o2_profile_emPower_Add").addEvent("click",function(){
  257. var popForm = new MWF.xApplication.Profile.emPowerPopupForm(null, {}, {
  258. "style": "empower",
  259. "width": "550",
  260. "height": layout.desktop.session.user.identityList.length>1?"490":"440",
  261. "hasTop": true,
  262. "hasIcon": false,
  263. "hasTopIcon" : false,
  264. "hasTopContent" : false,
  265. "draggable": true,
  266. "maxAction" : true,
  267. "closeAction": true,
  268. "isFull" : false,
  269. "startTime" : null,
  270. "endTime" : null,
  271. "isWholeday" : false,
  272. "title" : "新建外出授权",
  273. "defaultCalendarId" : ""
  274. }, {
  275. app: this,
  276. container : this.content,
  277. lp : this.lp,
  278. actions : this.action,
  279. css : {}
  280. });
  281. if(layout.desktop.session.user.identityList.length>=1){
  282. popForm.create();
  283. }else{
  284. this.notice( this.lp.empower.alert2 ,"error");
  285. }
  286. }.bind(this));
  287. //撤回按钮
  288. this.tabEmpower.tabNodeContainerArea.getElements(".o2_profile_emPower_WithDraw").addEvent("click",function(){
  289. // var checkElement = this.emPowerTable.getElements("input[name=id]:checked");
  290. var checkElement = this.tabEmpower.showPage.contentNode.getElements("td input[name=id]:checked")
  291. var editCount = 0;
  292. checkElement.forEach(function(item){
  293. this.action.deleteEmPower(item.get("value"),function(json){
  294. if(json.type=="success"){
  295. editCount += 1;
  296. }
  297. item.getParent().getParent().getParent().destroy();
  298. }.bind(this),null,false);
  299. /*enable为false时无法再次委托相同内容,又因为目前没做授权的编辑,所以撤回直接调用delete接口
  300. var idata = this.emPowerData[item.get("value")];
  301. idata.enable = false;
  302. this.action.editEmPower(item.get("value"),idata,function(json){
  303. if(json.type=="success"){
  304. editCount += 1;
  305. }
  306. item.getParent().getParent().destroy();
  307. }.bind(this),null,false);*/
  308. }.bind(this));
  309. if(checkElement.length==0){
  310. this.notice(this.lp.empower.selectEmPower, "error");
  311. }else if(checkElement.length&&editCount==checkElement.length){
  312. this.notice(this.lp.empower.withdrawOk, "success");
  313. }else{
  314. //this.notice(this.lp.empower.withdrawOk, "success");
  315. }
  316. if(this.myEmPower.getElements("tr").length==1){
  317. this["myEmPowerNoDataDiv"].setStyle("display","");
  318. }
  319. }.bind(this));
  320. },
  321. loadMyEmPower: function(){
  322. this.myEmPower = this.tabEmpower.pages[0].contentNode;
  323. //this.myEmPowerContent = new Element("div.myEmPowerContent",{text:"hhhhhh"}).inject(this.myEmPower);
  324. this.getAction( function( ){
  325. this.action.getMyEmPower(function(json){
  326. var data = json.data;
  327. this.getEmPowerTable("myEmPower",data,this.myEmPower);
  328. }.bind(this));
  329. }.bind(this));
  330. },
  331. loadReceiveEmPower: function(){
  332. this.receiveEmPower = this.tabEmpower.pages[1].contentNode;
  333. //this.myEmPowerContent = new Element("div.myEmPowerContent",{text:"hhhhhh"}).inject(this.myEmPower);
  334. this.getAction( function( ){
  335. this.action.getReceiveEmPower(function(json){
  336. var data = json.data;
  337. this.getEmPowerTable("receiveEmPower",data,this.receiveEmPower);
  338. }.bind(this));
  339. }.bind(this) );
  340. },
  341. loadMyEmPowerLog: function(){
  342. this.myEmPowerLog = this.tabEmpower.pages[2].contentNode;
  343. this.getEmPowerLogTable("myEmPowerLog","",this.myEmPowerLog);
  344. },
  345. loadReceiveEmPowerLog: function(){
  346. this.receiveEmPowerLog = this.tabEmpower.pages[3].contentNode;
  347. this.getEmPowerLogTable("receiveEmPowerLog","",this.receiveEmPowerLog);
  348. },
  349. getEmPowerLogTable: function(type,data,content){
  350. var _this = this;
  351. new MWF.xApplication.Profile.Common.Content(content, {
  352. "title":content.get("title"),
  353. "searchItemList": [
  354. ],
  355. "columns": [
  356. {width:"30%","title": this.lp.empower.title, "field": "subject","formatter":function(data,target){
  357. new Element("a",{"text":data.title,"style":"cursor:pointer"}).inject(target).addEvent("click",function(e){
  358. var options = {"workId": data.work, "appId": "process.Work"+data.work};
  359. _this.desktop.openApplication(e, "process.Work", options);
  360. });
  361. }},
  362. type=="myEmPowerLog"?{width:"10%","title": this.lp.empower.toPerson, "field": "toPerson","formatter":function(data,target){
  363. new Element("div",{"text":data.toPerson.split("@")[0]}).inject(target);
  364. }}:{width:"10%","title": this.lp.empower.fromPerson, "field": "fromPerson","formatter":function(data,target){
  365. new Element("div",{"text":data.fromPerson.split("@")[0]}).inject(target);
  366. }},
  367. {width:"15%","title": this.lp.empower.applicationName, "field": "applicationName"},
  368. {width:"15%","title": this.lp.empower.processName, "field": "processName"},
  369. {width:"15%","title": this.lp.empower.activityName, "field": "activityName"},
  370. {width:"15%","title": this.lp.empower.createTime, "field": "updateTime"}
  371. ],
  372. "opButtonList": [
  373. ],
  374. "onBeforeLoadData": function () {
  375. _this.getAction( function( ){
  376. if( type=="myEmPowerLog"){
  377. _this.action.listWithCurrentPersonPaging(this.options.page,this.options.pageSize,"",function(json){
  378. this.dataList = json.data;
  379. this.total = json.count;
  380. }.bind(this),null,false);
  381. }else{
  382. _this.action.listToCurrentPersonPaging(this.options.page,this.options.pageSize,"",function(json){
  383. this.dataList = json.data;
  384. this.total = json.count;
  385. }.bind(this),null,false);
  386. }
  387. }.bind(this) );
  388. }
  389. }).load();
  390. if(!this[type+"NoDataDiv"]){
  391. this[type+"NoDataDiv"] = new Element("div.o2_profile_emPower_noData").adopt(
  392. new Element("img",{src:"../x_component_Profile/$Main/newVersion/icon_wuweituo.png"}),
  393. new Element("div",{text:"无待办"})
  394. ).inject(content.getElement(".profile_common_tableDiv"));
  395. }
  396. if(content.getElements("tr").length==1){
  397. this[type+"NoDataDiv"].setStyle("display","");
  398. }else{
  399. if(this[type+"NoDataDiv"]){
  400. this[type+"NoDataDiv"].setStyle("display","none");
  401. }
  402. }
  403. },
  404. getEmPowerTable: function(type,data,content){
  405. //var table = content.getElement("table.emPowerTable");
  406. this.emPowerTable = content.getElement("table.emPowerTable");
  407. if(!this.emPowerTable){
  408. this.emPowerTable = new Element("table.emPowerTable",{
  409. width:"100%",
  410. border:"0",
  411. cellpadding:"0",
  412. cellspacing:"0"
  413. }).inject(content);
  414. }
  415. this.userName = layout.desktop.session.user.distinguishedName;
  416. var th = new Element("tr.first");
  417. if(type=="myEmPower"){
  418. var BtnImg = new Element("div.o2_profile_emPower_Btnimg");
  419. var BtnText = new Element("div.o2_profile_emPower_Btntext");
  420. this.emPowerData={};
  421. var cblabel = new Element("label.o2_profile_empower_checkbox").adopt(new Element("input",{
  422. name:"allEmpower",
  423. id:"allEmpower",
  424. type:"checkbox"
  425. })).setStyle("float","left").addEvent("click",function(){
  426. if(this.getElement("input").get("checked")){
  427. this.getParent().getParent().getParent().getElements("input[type=checkbox]").set("checked",true);
  428. this.getParent().getParent().getParent().getElements("label").addClass("o2_profile_empower_checkbox__checked o2_profile_empower_checkbox_checked");
  429. this.getParent().getParent().getParent().getElements("tr").addClass("selected");
  430. }else{
  431. this.getParent().getParent().getParent().getElements("input[type=checkbox]").set("checked",false);
  432. this.getParent().getParent().getParent().getElements("label").removeClass("o2_profile_empower_checkbox__checked o2_profile_empower_checkbox_checked");
  433. this.getParent().getParent().getParent().getElements("tr").removeClass("selected");
  434. }
  435. });
  436. th.adopt(new Element("th",{width:"16%"}).adopt(cblabel,new Element("div",{text:this.lp.empower.toPerson}).setStyle("float","left")));
  437. }else{
  438. th.adopt(new Element("th",{width:"16%"}).adopt(new Element("div",{text:this.lp.empower.fromPerson})));
  439. }
  440. th.adopt(new Element("th",{width:"7%"}).adopt(new Element("div",{text:this.lp.empower.type})));
  441. th.adopt(new Element("th",{width:"16%"}).adopt(new Element("div",{text:this.lp.empower.applicationName+"/"+this.lp.empower.processName})));
  442. th.adopt(new Element("th",{width:"18%"}).adopt(new Element("div",{text:this.lp.empower.startTime})));
  443. th.adopt(new Element("th",{width:"18%"}).adopt(new Element("div",{text:this.lp.empower.completedTime})));
  444. if(type=="myEmPower"){
  445. th.adopt(new Element("th",{width:"25%"}).adopt(new Element("div",{text:"操作"})));
  446. }
  447. this.emPowerTable.adopt(th);
  448. data.forEach(function(item){
  449. if(true||item.enable==true){
  450. var tr = new Element("tr"+(item.enable?"":".disabled"));
  451. var td = new Element("td");
  452. var cblabel = new Element("label.o2_profile_empower_checkbox").adopt(new Element("input",{
  453. name:"id",
  454. value:item.id,
  455. type:"checkbox"
  456. })).setStyle("float","left").addEvent("click",function(){
  457. if(this.getElement("input").get("checked")){
  458. this.addClass("o2_profile_empower_checkbox__checked o2_profile_empower_checkbox_checked");
  459. this.getParent().getParent().addClass("selected");
  460. }else{
  461. this.removeClass("o2_profile_empower_checkbox__checked o2_profile_empower_checkbox_checked");
  462. this.getParent().getParent().removeClass("selected");
  463. }
  464. })
  465. var tds = [];
  466. if(type=="myEmPower"){
  467. this.emPowerData[item.id]=item;
  468. tds.push(td.cloneNode().adopt(cblabel,new Element("div",{name:"toPerson",text:item.toPerson.split("@")[0]})));
  469. }else{
  470. tds.push(td.cloneNode().adopt(new Element("div",{name:"fromPerson",text:item.fromPerson.split("@")[0]})));
  471. }
  472. tds.push(td.cloneNode().adopt(new Element("div",{name:"type",text:this.lp.empower["type_"+item.type]})));
  473. tds.push(td.cloneNode().adopt(new Element("div",{name:"typeName",text:item.applicationName||item.processName||(item.type=='filter'?JSON.parse(item.filterListData)[0].value:"-")})));
  474. tds.push(td.cloneNode().adopt(new Element("div",{name:"startTime",text:item.startTime})));
  475. tds.push(td.cloneNode().adopt(new Element("div",{name:"completedTime",text:item.completedTime})));
  476. //后续添加编辑/删除/撤回按钮
  477. var _self = this;
  478. if(type=="myEmPower"){
  479. //启用、禁用按钮
  480. var endTime = new Date(item.completedTime);
  481. var startTime= new Date(item.startTime);
  482. var nowTime = new Date();
  483. //text:item.enable?_self.lp.empower.disable:_self.lp.empower.enable
  484. var enableClass = item.enable?"o2_profile_emPower_Disable":"o2_profile_emPower_Enable";
  485. var enableText = item.enable?_self.lp.empower.disable:_self.lp.empower.enable
  486. var isEnable = new Element("div."+enableClass).adopt(BtnImg.cloneNode(),BtnText.cloneNode().set("text",enableText)).addEvent("click",function(){
  487. this.enable = !this.enable;
  488. _self.action.editEmPower(this.id,this,function(json){
  489. //submitCount++;
  490. this.notice(this.lp.empower.saveOk,json.type);
  491. var content = this.content.getElement(".o2_profile_emPower_tab");
  492. content.getElement("table").empty();
  493. this.loadMyEmPower();
  494. }.bind(_self),null,false);
  495. }.bind(item));
  496. tds.push(td.cloneNode().setStyles({
  497. "margin":"auto"
  498. }).adopt(
  499. new Element("div.o2_profile_emPower_Edit").adopt(BtnImg.cloneNode(),BtnText.cloneNode().set("text",this.lp.empower.edit)).addEvent("click",function(e){
  500. var _data = this;
  501. _data.fromPerson = _data.fromIdentity;
  502. _data.toPerson = _data.toIdentity;
  503. _data.startTime = _data.startTime;
  504. _data.endTime = _data.completedTime;
  505. var editPopForm = new MWF.xApplication.Profile.emPowerPopupForm(null, _data, {
  506. "style": "empower",
  507. "width": "550",
  508. "height": layout.desktop.session.user.identityList.length>1?"490":"440",
  509. "hasTop": true,
  510. "hasIcon": false,
  511. "hasTopIcon" : false,
  512. "hasTopContent" : false,
  513. "draggable": true,
  514. "maxAction" : true,
  515. "closeAction": true,
  516. "isFull" : false,
  517. "startTime" : null,
  518. "endTime" : null,
  519. "isWholeday" : false,
  520. "title" : _self.lp.empower.editEmpower,
  521. "configData":{
  522. Process:(_data.type=="process"?[{name:_data.processName,id:_data.process,editon:_data.edition}]:[]),
  523. Application:(_data.type=="application"?[{name:_data.applicationName,id:_data.application}]:[])
  524. },
  525. "defaultCalendarId" : ""
  526. }, {
  527. app: _self,
  528. container : _self.content,
  529. lp : _self.lp,
  530. actions : _self.action,
  531. css : {}
  532. });
  533. editPopForm.edit();
  534. }.bind(item)),
  535. (nowTime<startTime||nowTime>endTime)&&false?"":(isEnable),
  536. new Element("div.o2_profile_emPower_WithDraw").adopt(BtnImg.cloneNode(),BtnText.cloneNode().set("text",this.lp.empower.withdraw)).set("empowerid",item.id).addEvent("click",function(){
  537. var _this = this;
  538. _self.action.deleteEmPower(_this.get("empowerid"),function(json){
  539. this.notice(this.lp.empower.withdrawOk,json.type);
  540. _this.getParent().getParent().destroy();
  541. }.bind(_self),null,false);
  542. })
  543. ));
  544. }/**/
  545. tr.adopt(tds);
  546. this.emPowerTable.adopt(tr);
  547. }
  548. }.bind(this));
  549. if(!this[type+"NoDataDiv"]){
  550. this[type+"NoDataDiv"] = new Element("div.o2_profile_emPower_noData").adopt(
  551. new Element("img",{src:"../x_component_Profile/$Main/newVersion/icon_wuweituo.png"}),
  552. new Element("div",{text:this.lp.empower.noData}),
  553. type=="myEmPower"?new Element("div.o2_profile_emPower_Add.mainColor_color",{text:"新建委托"}).addEvent("click",function(){
  554. var popForm = new MWF.xApplication.Profile.emPowerPopupForm(null, {}, {
  555. "style": "empower",
  556. "width": "550",
  557. "height": layout.desktop.session.user.identityList.length>1?"490":"440",
  558. "hasTop": true,
  559. "hasIcon": false,
  560. "hasTopIcon" : false,
  561. "hasTopContent" : false,
  562. "draggable": true,
  563. "maxAction" : true,
  564. "closeAction": true,
  565. "isFull" : false,
  566. "startTime" : null,
  567. "endTime" : null,
  568. "isWholeday" : false,
  569. "title" : "新建外出授权",
  570. "defaultCalendarId" : ""
  571. }, {
  572. app: this,
  573. container : this.content,
  574. lp : this.lp,
  575. actions : this.action,
  576. css : {}
  577. });
  578. if(layout.desktop.session.user.identityList.length>=1){
  579. popForm.create();
  580. }else{
  581. this.notice( this.lp.empower.alert2 ,"error");
  582. }
  583. }.bind(this)):""
  584. ).inject(content);
  585. }
  586. if(this.emPowerTable.getElements("tr").length==1){
  587. this[type+"NoDataDiv"].setStyle("display","");
  588. //table.adopt(new Element("tr").adopt(new Element("td")).adopt()));
  589. }else{
  590. if(this[type+"NoDataDiv"]){
  591. this[type+"NoDataDiv"].setStyle("display","none");
  592. }
  593. //this.myEmPowerTable.adopt(trs);
  594. }
  595. },
  596. loadPasswordConfigActions: function(){
  597. var i = (this.inBrowser||layout.viewMode=="Default")? 3 : 4;
  598. var inputs = this.tab.pages[i].contentNode.setStyle("min-height","300px").getElements("input");
  599. this.oldPasswordInputNode = inputs[0];
  600. this.passwordInputNode = inputs[1];
  601. this.morePasswordInputNode = inputs[2];
  602. this.savePasswordAction = this.tab.pages[i].contentNode.getElement(".o2_profile_savePasswordAction");
  603. this.oldPasswordInputNode.addEvents({
  604. "blur": function(){this.removeClass("o2_profile_inforContentInput_focus mainColor_border mainColor_color");},
  605. "focus": function(){this.addClass("o2_profile_inforContentInput_focus mainColor_border mainColor_color");}
  606. });
  607. this.passwordInputNode.addEvents({
  608. "blur": function(){this.removeClass("o2_profile_inforContentInput_focus mainColor_border mainColor_color");},
  609. "focus": function(){this.addClass("o2_profile_inforContentInput_focus mainColor_border mainColor_color");},
  610. "keyup" : function(){ this.checkPassowrdStrength( encodeURIComponent(this.passwordInputNode.get("value")) ) }.bind(this)
  611. });
  612. this.morePasswordInputNode.addEvents({
  613. "blur": function(){this.removeClass("o2_profile_inforContentInput_focus mainColor_border mainColor_color");},
  614. "focus": function(){this.addClass("o2_profile_inforContentInput_focus mainColor_border mainColor_color");}
  615. });
  616. this.savePasswordAction.addEvent("click", function(){
  617. this.changePassword();
  618. }.bind(this)).addClass("mainColor_bg");
  619. },
  620. loadSSOConfigAction: function(){
  621. var i = (this.inBrowser||layout.viewMode=="Default")? 4 : 5;
  622. this.ssoConfigAreaNode = this.tab.pages[i].contentNode.setStyle("min-height","300px").getElement(".o2_profile_ssoConfigArea");
  623. MWF.Actions.get("x_organization_assemble_authentication").listOauthServer(function(json){
  624. json.data.each(function(d){
  625. var node = new Element("a", {
  626. "class":"mainColor_color",
  627. "styles": {"font-size": "14px", "display": "block", "margin-bottom": "10px"},
  628. "text": d.displayName,
  629. "target": "_blank",
  630. "href": "../x_desktop/oauth.html?oauth="+encodeURIComponent(d.name)+"&redirect="+"&method=oauthBind"
  631. }).inject(this.ssoConfigAreaNode)
  632. }.bind(this));
  633. }.bind(this));
  634. },
  635. changeIcon: function(){
  636. var options = {};
  637. var width = "668";
  638. var height = "510";
  639. width = width.toInt();
  640. height = height.toInt();
  641. var size = this.content.getSize();
  642. var x = (size.x-width)/2;
  643. var y = (size.y-height)/2;
  644. if (x<0) x = 0;
  645. if (y<0) y = 0;
  646. if (layout.mobile){
  647. x = 20;
  648. y = 0;
  649. }
  650. var _self = this;
  651. MWF.require("MWF.xDesktop.Dialog", function() {
  652. MWF.require("MWF.widget.ImageClipper", function(){
  653. var dlg = new MWF.xDesktop.Dialog({
  654. "title": this.lp.changePersonIcon,
  655. "style": "image",
  656. "top": y,
  657. "left": x - 20,
  658. "fromTop": y,
  659. "fromLeft": x - 20,
  660. "width": width,
  661. "height": height,
  662. "html": "<div></div>",
  663. "maskNode": this.content,
  664. "container": this.content,
  665. "buttonList": [
  666. {
  667. "text": MWF.LP.process.button.ok,
  668. "action": function () {
  669. //_self.uploadPersonIcon();
  670. _self.image.uploadImage( function( json ){
  671. _self.action.getPerson(function(json){
  672. if (json.data){
  673. this.personData = json.data;
  674. _self.contentImgNode.set("src", _self.action.getPersonIcon());
  675. }
  676. this.close();
  677. }.bind(this));
  678. }.bind(this), null );
  679. }
  680. },
  681. {
  682. "text": MWF.LP.process.button.cancel,
  683. "action": function () {
  684. _self.image = null;
  685. this.close();
  686. }
  687. }
  688. ]
  689. });
  690. dlg.show();
  691. this.image = new MWF.widget.ImageClipper(dlg.content.getFirst(), {
  692. "aspectRatio": 1,
  693. "description" : "",
  694. "imageUrl" : this.action.getPersonIcon(),
  695. "resetEnable" : false,
  696. "data": null,
  697. "parameter": null,
  698. "action": this.action.action,
  699. "method": "changeIcon"
  700. });
  701. this.image.load();
  702. }.bind(this));
  703. }.bind(this))
  704. },
  705. uploadPersonIcon: function(){
  706. if (this.image){
  707. if( this.image.getResizedImage() ){
  708. this.action.changeIcon(function(){
  709. this.action.getPerson(function(json){
  710. if (json.data){
  711. this.personData = json.data;
  712. //if (this.personData.icon){
  713. this.contentImgNode.set("src", this.action.getPersonIcon());
  714. //}
  715. }
  716. }.bind(this))
  717. }.bind(this), null, this.image.getFormData(), this.image.resizedImage);
  718. }
  719. }
  720. },
  721. savePersonInfor: function(){
  722. // var array = [];
  723. // var ipAddress = this.ipAddressInputNode.get("value") || "";
  724. // 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]?)$/;
  725. // 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*$/;
  726. // if( ipAddress.trim() ){
  727. // ipAddress.split(",").each( function(ip){
  728. // if(!ip.match(ipV4Format) && !ip.match(ipV6Format))array.push( ip );
  729. // })
  730. // }
  731. // if( array.length > 0 ){
  732. // this.notice( this.lp.ipAddressIncorrectNotice + array.join(","), "error");
  733. // return false;
  734. // }
  735. this.personData.officePhone = this.officePhoneInputNode.get("value");
  736. this.personData.mail = this.mailInputNode.get("value");
  737. this.personData.mobile = this.mobileInputNode.get("value");
  738. this.personData.weixin = this.weixinInputNode.get("value");
  739. this.personData.qq = this.qqInputNode.get("value");
  740. this.personData.ipAddress = this.ipAddressInputNode.get("value");
  741. this.personData.signature = this.signatureInputNode.get("value");
  742. this.action.updatePerson(this.personData, function(){
  743. this.notice(this.lp.saveInforOk, "success");
  744. }.bind(this));
  745. },
  746. loadDesktopBackground: function(UINode){
  747. var currentSrc = layout.desktop.options.style;
  748. MWF.UD.getDataJson("layoutDesktop", function(json){
  749. if (json) currentSrc = json.src;
  750. }.bind(this), false);
  751. MWF.getJSON(layout.desktop.path+"styles.json", function(json){
  752. json.each(function(style){
  753. var img = MWF.defaultPath+"/xDesktop/$Layout/"+style.style+"/preview.jpg";
  754. //var dskImg = MWF.defaultPath+"/xDesktop/$Layout/"+style.style+"/desktop.jpg";
  755. var imgArea = new Element("div.o2_profile_previewBackground").inject(UINode);
  756. if (currentSrc==style.style){
  757. //imgArea.setStyles({"border": "4px solid #ffea00"});
  758. new Element("img.icon",{"src":"../x_component_Profile/$Main/newVersion/icon_ok2_click_copy_2.png"}).inject(imgArea);
  759. imgArea.addClass("profile_previewBackground_current");
  760. }
  761. new Element("img", {"src": img}).inject(imgArea);
  762. imgArea.store("dskimg", style.style);
  763. var _self = this;
  764. imgArea.addEvent("click", function(){ _self.selectDesktopImg(this, UINode); });
  765. }.bind(this));
  766. }.bind(this));
  767. },
  768. selectDesktopImg: function(item, UINode){
  769. var desktopImg = item.retrieve("dskimg");
  770. MWF.UD.putData("layoutDesktop", {"src": desktopImg}, function(){
  771. UINode.getChildren().each(function(node){
  772. //node.setStyles({"border": "4px solid #eeeeee"});
  773. node.removeClass("profile_previewBackground_current");
  774. if(node.getElement(".icon")){
  775. node.getElement(".icon").destroy();
  776. }
  777. }.bind(this));
  778. //item.setStyles({"border": "4px solid #ffea00"});
  779. new Element("img.icon",{"src":"../x_component_Profile/$Main/newVersion/icon_ok2_click_copy_2.png"}).inject(item);
  780. item.addClass("profile_previewBackground_current");
  781. var dskImg = MWF.defaultPath+"/xDesktop/$Layout/"+desktopImg+"/desktop.jpg";
  782. layout.desktop.node.setStyle("background-image", "url("+dskImg+")");
  783. }.bind(this));
  784. },
  785. changePassword: function(){
  786. var oldPassword = this.oldPasswordInputNode.get("value");
  787. var password = this.passwordInputNode.get("value");
  788. var morePassword = this.morePasswordInputNode.get("value");
  789. var remindNode = this.contentNode.getElement(".o2_profile_passwordWarmming");
  790. if (password!=morePassword){
  791. this.notice(this.lp.passwordNotMatch, "error");
  792. this.passwordInputNode.setStyles(this.css.inforContentInputNode_error);
  793. this.morePasswordInputNode.setStyles(this.css.inforContentInputNode_error);
  794. }else if(null||remindNode){
  795. this.notice(remindNode.get("text"), "error");
  796. }else{
  797. this.action.changePassword(oldPassword, password, morePassword, function(){
  798. this.oldPasswordInputNode.set("value", "");
  799. this.passwordInputNode.set("value", "");
  800. this.morePasswordInputNode.set("value", "");
  801. this.notice(this.lp.changePasswordOk, "success");
  802. }.bind(this));
  803. if (layout.config.mail){
  804. var url = "http://"+layout.config.mail+"//names.nsf?changepassword&password="+encodeURIComponent(oldPassword)+"&passwordnew="+encodeURIComponent(password)+"&passwordconfirm="+encodeURIComponent(password);
  805. var iframe = new Element("iframe", {"styles": {"display": "none"}}).inject(this.desktop.desktopNode);
  806. iframe.set("src", url);
  807. window.setTimeout(function(){
  808. iframe.destroy();
  809. }.bind(this), 2000);
  810. }
  811. }
  812. },
  813. getAction: function(callback){
  814. if (!this.acrion){
  815. this.action = MWF.Actions.get("x_organization_assemble_personal");
  816. if (callback) callback();
  817. }else{
  818. if (callback) callback();
  819. }
  820. },
  821. createPasswordStrengthNode : function(){
  822. var passwordStrengthArea = this.passwordRemindContainer;
  823. var lowNode = new Element( "div", {styles : this.css.passwordStrengthNode }).inject( passwordStrengthArea );
  824. this.lowColorNode = new Element( "div", {styles : this.css.passwordStrengthColor }).inject( lowNode );
  825. this.lowTextNode = new Element( "div", {styles : this.css.passwordStrengthText, text : this.lp.weak }).inject( lowNode );
  826. var middleNode = new Element( "div" , {styles : this.css.passwordStrengthNode }).inject( passwordStrengthArea );
  827. this.middleColorNode = new Element( "div", {styles : this.css.passwordStrengthColor }).inject( middleNode );
  828. this.middleTextNode = new Element( "div", {styles : this.css.passwordStrengthText, text : this.lp.middle }).inject( middleNode );
  829. var highNode = new Element("div", {styles : this.css.passwordStrengthNode }).inject( passwordStrengthArea );
  830. this.highColorNode = new Element( "div", {styles : this.css.passwordStrengthColor }).inject( highNode );
  831. this.highTextNode = new Element( "div", {styles : this.css.passwordStrengthText, text : this.lp.high }).inject( highNode );
  832. },
  833. getPasswordLevel: function( password, callback ){
  834. /*Level(级别)
  835. •0-3 : [easy]
  836. •4-6 : [midium]
  837. •7-9 : [strong]
  838. •10-12 : [very strong]
  839. •>12 : [extremely strong]
  840. */
  841. this.getAction( function( ){
  842. this.action.checkPassword( password, function( json ){
  843. if(callback)callback( json.data.value );
  844. }.bind(this), null, false );
  845. }.bind(this) );
  846. },
  847. getPasswordComplex : function(pwd){
  848. if( typeof pwd != "string")
  849. return false;
  850. var sum = 0;
  851. /*
  852. 5 分: 小于 8 个字符
  853. 10 分: 8 到 10 个字符
  854. 25 分: 大于 10 个字符
  855. */
  856. if(pwd.length<8){
  857. sum += 5;
  858. }else if(pwd.length<=10){
  859. sum += 10;
  860. }else{
  861. sum += 25;
  862. }
  863. /*
  864. 0 分: 没有字母
  865. 10 分: 全都是小(大)写字母
  866. 25 分: 大小写混合字母
  867. */
  868. var lowerReg = /[a-z]/;
  869. var uperReg = /[A-Z]/;
  870. if(pwd.match(lowerReg)&&pwd.match(uperReg)){
  871. sum += 25;
  872. }else if(!pwd.match(lowerReg)&&!pwd.match(uperReg)){
  873. sum += 0;
  874. }else{
  875. sum += 10;
  876. }
  877. /*
  878. 0 分: 没有数字
  879. 10 分: 1或2个数字
  880. 20 分: 大于 2 个数字
  881. */
  882. var numReg = /[0-9]/;
  883. var langReg = /[0-9]{3,}/;
  884. if(pwd.match(langReg)){
  885. sum += 20;
  886. }else if(pwd.match(numReg)){
  887. sum += 10;
  888. }else{
  889. sum += 0;
  890. }
  891. return sum;
  892. },
  893. checkPassowrdStrength: function(pwd){
  894. var i = (this.inBrowser||layout.viewMode=="Default")? 3 : 4;
  895. var passwordStrengthNode = this.tab.pages[i].contentNode.getElement(".o2_profile_passwordStrengthArea");
  896. var passwordRemindNode = this.tab.pages[i].contentNode.getElement(".o2_profile_passwordRemindNode");
  897. var nodes = passwordStrengthNode.getElements(".o2_profile_passwordStrengthColor");
  898. var lowColorNode = nodes[0];
  899. var middleColorNode = nodes[1];
  900. var highColorNode = nodes[2];
  901. nodes = passwordStrengthNode.getElements(".o2_profile_passwordStrengthText");
  902. var lowTextNode = nodes[0];
  903. var middleTextNode = nodes[1];
  904. var highTextNode = nodes[2];
  905. lowColorNode.removeClass("o2_profile_passwordStrengthColor_low");
  906. middleColorNode.removeClass("o2_profile_passwordStrengthColor_middle");
  907. highColorNode.removeClass("o2_profile_passwordStrengthColor_high");
  908. lowTextNode.removeClass("o2_profile_passwordStrengthText_current");
  909. middleTextNode.removeClass("o2_profile_passwordStrengthText_current");
  910. highTextNode.removeClass("o2_profile_passwordStrengthText_current");
  911. if (pwd==null||pwd==''){
  912. }else{
  913. this.getPasswordLevel( pwd, function( result ){
  914. if(result){
  915. passwordRemindNode.addClass("o2_profile_passwordWarmming").set("text",result);
  916. }else{
  917. passwordRemindNode.removeClass("o2_profile_passwordWarmming").set("text",this.lp.paswordRule);
  918. var score = this.getPasswordComplex(pwd);
  919. if(score<=40){
  920. lowColorNode.addClass("o2_profile_passwordStrengthColor_low");
  921. lowTextNode.addClass("o2_profile_passwordStrengthText_current");
  922. }else if(score<=55){
  923. middleColorNode.addClass("o2_profile_passwordStrengthColor_middle");
  924. middleTextNode.addClass("o2_profile_passwordStrengthText_current");
  925. }else{
  926. highColorNode.addClass("o2_profile_passwordStrengthColor_high");
  927. highTextNode.addClass("o2_profile_passwordStrengthText_current");
  928. }
  929. }
  930. /*switch(level) {
  931. case 0:
  932. case 1:
  933. case 2:
  934. case 3:
  935. lowColorNode.addClass("o2_profile_passwordStrengthColor_low");
  936. lowTextNode.addClass("o2_profile_passwordStrengthText_current");
  937. break;
  938. case 4:
  939. case 5:
  940. case 6:
  941. middleColorNode.addClass("o2_profile_passwordStrengthColor_middle");
  942. middleTextNode.addClass("o2_profile_passwordStrengthText_current");
  943. break;
  944. default:
  945. highColorNode.addClass("o2_profile_passwordStrengthColor_high");
  946. highTextNode.addClass("o2_profile_passwordStrengthText_current");
  947. }*/
  948. }.bind(this) )
  949. }
  950. }
  951. });
  952. /*----2019年8月30日---外出授权---表单*/
  953. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  954. MWF.xApplication.Profile.emPowerPopupForm = new Class({
  955. Extends : MPopupForm,
  956. options: {
  957. "style": "empower",
  958. "width": "550",
  959. "height": "440",
  960. "hasTop": true,
  961. "hasIcon": false,
  962. "hasTopIcon" : false,
  963. "hasTopContent" : false,
  964. "draggable": true,
  965. "maxAction" : true,
  966. "closeAction": true,
  967. "isFull" : false,
  968. "startTime" : null,
  969. "endTime" : null,
  970. "isWholeday" : false,
  971. "defaultCalendarId" : "",
  972. "onPostCreateBottom": function () {
  973. this.formBottomNode.getElement(".formOkActionNode").addClass("mainColor_bg");
  974. }
  975. },
  976. load: function () {
  977. //重新指定css文件,由于临时用,所以尽可能写一个文件里
  978. this.cssPath = "../x_component_Profile/$Main/"+this.options.style+"/css.wcss";
  979. this._loadCss();
  980. this.configData = this.options.configData||{};
  981. this.lp = this.lp.empower;
  982. //this.addEvent("queryOk",this.queryOk());
  983. },
  984. _createTableContent : function() {
  985. this.userName = layout.desktop.session.user.distinguishedName;
  986. this.userId = layout.desktop.session.user.id;
  987. this.userIdentityList = layout.desktop.session.user.identityList;
  988. var identityTextList = [];
  989. var identityList =[];
  990. this.userIdentityList.each(function(it){
  991. identityTextList.push(it.name+"("+it.unitName+")");
  992. identityList.push((it.distinguishedName));
  993. });
  994. //this.formTableContainer.setStyle("width","80%");
  995. var startTime, endTime, defaultStartDate, defaultStartTime, defaultEndDate, defaultEndTime;
  996. if( this.data.startTime && this.data.endTime ){
  997. startTime= this.date = typeOf( this.data.startTime )=="string" ? Date.parse( this.data.startTime ) : this.data.startTime;
  998. endTime= typeOf( this.data.endTime )=="string" ? Date.parse( this.data.endTime ) : this.data.endTime;
  999. defaultStartDate = startTime.format("%Y-%m-%d");
  1000. defaultStartTime = startTime.format("%H:%M");
  1001. defaultEndDate = endTime.format("%Y-%m-%d");
  1002. defaultEndTime = endTime.format("%H:%M");
  1003. }else{
  1004. startTime = this.date = new Date().increment("hour",1);
  1005. endTime = startTime.clone().increment("hour",1);
  1006. defaultStartDate = startTime.format("%Y-%m-%d");
  1007. defaultStartTime = startTime.format("%H") + ":00";
  1008. defaultEndDate = endTime.format("%Y-%m-%d");
  1009. defaultEndTime = endTime.format("%H") + ":00";
  1010. }
  1011. var data={};
  1012. this.formTableArea.set("html", this.getHtml());
  1013. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1014. this.form = new MForm(this.formTableArea, data, {
  1015. isEdited: this.isEdited || this.isNew,
  1016. style : "profile",
  1017. itemTemplate: {
  1018. fromPerson: { text: this.lp.fromPerson,type: "select", isEdited : (identityTextList.length>1),
  1019. selectText: identityTextList,
  1020. selectValue: identityList,
  1021. defaultValue: this.data.fromIdentity||identityList[0],
  1022. style:{
  1023. "width": "310px",
  1024. "height": "36px",
  1025. "box-shadow": "rgb(153, 153, 153) 0px 0px 0px",
  1026. "line-height": "36px",
  1027. "background": "#FFFFFF",
  1028. "border": "1px solid #DEDEDE",
  1029. "border-radius": "100px",
  1030. "font-family": "MicrosoftYaHei",
  1031. "padding":"0 5px",
  1032. "font-size": "14px",
  1033. "color": "#666666",
  1034. "margin": "0 0 10px 0"
  1035. }
  1036. },
  1037. toPerson: { text: this.lp.toPerson,type: "org", isEdited : this.isEdited || this.isNew, orgType: ["identity"], count : 1, orgWidgetOptions : {
  1038. "onLoadedInfor": function(item){
  1039. // this.loadAcceptAndReject( item );
  1040. }.bind(this)
  1041. },defaultValue:this.data.toPerson},
  1042. startDateInput: {
  1043. text: this.lp.startTime,
  1044. tType: "date",
  1045. defaultValue: defaultStartDate,
  1046. notEmpty: true
  1047. },
  1048. startTimeInput: {
  1049. tType: "time",
  1050. defaultValue: defaultStartTime,
  1051. className: ((this.isNew || this.isEdited || 1) ? "inputTimeUnformatWidth" : ""),
  1052. disable: data.isAllDayEvent
  1053. },
  1054. endDateInput: {
  1055. text: this.lp.completedTime,
  1056. tType: "date",
  1057. defaultValue: defaultEndDate,
  1058. notEmpty: true
  1059. },
  1060. endTimeInput: {
  1061. tType: "time",
  1062. defaultValue: defaultEndTime,
  1063. className: ((this.isNew || this.isEdited || 1) ? "inputTimeUnformatWidth" : ""),
  1064. disable: data.isAllDayEvent
  1065. },
  1066. type: {
  1067. text: this.lp.type, type: "radio",
  1068. selectText: [this.lp.type_all, this.lp.type_application, this.lp.type_process],
  1069. //selectText: ["全部", "应用", "流程"],
  1070. selectValue: ["all", "application", "process"],
  1071. defaultValue: this.data.type||"all",
  1072. event :{
  1073. "click":function(){
  1074. var type = this.form.getItem("type").getValue();
  1075. this.formTableArea.getElement("td[item=application]").parentNode.setStyle("display","none");
  1076. this.formTableArea.getElement("td[item=process]").parentNode.setStyle("display","none");
  1077. if(type=="all"){
  1078. //this.formTableArea.getElement("td[item=application]").parentNode.setStyle("display","");
  1079. //this.formTableArea.getElement("td[item=process]").parentNode.setStyle("display","");
  1080. }else{
  1081. this.formTableArea.getElement("td[item="+type+"]").parentNode.setStyle("display","");
  1082. }
  1083. }.bind(this)
  1084. }
  1085. }
  1086. },
  1087. onPostLoad:function(){
  1088. /*样式重构*/
  1089. this.formTableArea.getElements("td[item=type] div").forEach(function(item){
  1090. var labelRadio = new Element("label.o2_profile_empower_radio"+(item.getElement("input").get("checked")?".o2_profile_empower_radio__checked.o2_profile_empower_radio_checked":"")).adopt(item.getElement("input")).addEvent("click",function(){
  1091. this.getParent().getParent().getElements("label").removeClass("o2_profile_empower_radio__checked o2_profile_empower_radio_checked");
  1092. this.addClass("o2_profile_empower_radio__checked o2_profile_empower_radio_checked");
  1093. });
  1094. item.adopt(labelRadio,item.getElement("span"))
  1095. });
  1096. }.bind(this)
  1097. },this.app,this.css);
  1098. this.form.load();
  1099. }.bind(this));
  1100. /*重构单选框样式
  1101. * */
  1102. this.applicationNode = this.formTableArea.getElement("td[item=application]");
  1103. //this.applicationNode.empty();
  1104. this.selectApplicationNode = new Element("div.selectNode", {
  1105. width: "30",
  1106. height: "30",
  1107. }).inject(this.applicationNode).setStyles(this.css.selectNode).addEvents({
  1108. "hover":function(){
  1109. this.setStyle("background","url(../x_component_Profile/$Main/newVersion/icon_zengjia_blue2_click.png) center center no-repeat");
  1110. },
  1111. "blur":function(){
  1112. this.setStyle("background","url(../x_component_Profile/$Main/newVersion/icon_zengjia_blue2.png) center center no-repeat");
  1113. }
  1114. });
  1115. this.showApplicationNode = new Element("div.showNode", {
  1116. width: "200",
  1117. height: "30",
  1118. // text: "选择应用"
  1119. }).inject(this.applicationNode).setStyles(this.css.showNode);
  1120. this.createApplicationSelect(this.showApplicationNode,this.selectApplicationNode,"Application");
  1121. this.processNode = this.formTableArea.getElement("td[item=process]");
  1122. this.selectProcessNode = new Element("div.selectNode", {
  1123. width: "30",
  1124. height: "30",
  1125. }).inject(this.processNode).setStyles(this.css.selectNode);
  1126. this.showProcessNode = new Element("div.showNode", {
  1127. width: "200",
  1128. height: "30",
  1129. //text: "选择流程"
  1130. }).inject(this.processNode).setStyles(this.css.showNode);
  1131. this.createApplicationSelect(this.showProcessNode,this.selectProcessNode,"Process");
  1132. },
  1133. _ok: function (data, callback) {
  1134. //data 是表单的数据, callback 是正确的回调
  1135. //data.
  1136. var submitData = [];
  1137. //数据处理
  1138. var sdata = {};
  1139. sdata.fromIdentity = data.fromPerson;
  1140. sdata.fromPerson = data.fromPerson.split("@")[0];
  1141. sdata.toIdentity = data.toPerson;
  1142. sdata.toPerson = data.toPerson.split("@")[0];
  1143. sdata.startTime = data.startDateInput+" "+data.startTimeInput+":00";
  1144. sdata.completedTime = data.endDateInput+" "+data.endTimeInput+":00";
  1145. sdata.enable = true;
  1146. if(data.type=="all"){
  1147. sdata.type = data.type;
  1148. submitData.push(sdata);
  1149. }else if(data.type=="application"){
  1150. this.configData["Application"].forEach(function(item){
  1151. var subData = JSON.parse(JSON.stringify(sdata));
  1152. subData["application"] = item.id;
  1153. subData["applicationName"] = item.name;
  1154. subData["applicationAlias"] = item.alias;
  1155. subData.type = "application";
  1156. submitData.push(subData);
  1157. });
  1158. }else if(data.type=="process"){
  1159. this.configData["Process"].forEach(function(item){
  1160. var subData = JSON.parse(JSON.stringify(sdata));
  1161. subData["process"] = item.id;
  1162. subData["processName"] = item.name;
  1163. subData["processAlias"] = item.alias;
  1164. subData["edition"] = !!item.edition?item.edition:(item.id);
  1165. subData.type = "process";
  1166. submitData.push(subData);
  1167. });
  1168. }
  1169. /*this.saveConfigData=[];
  1170. this.saveConfigCount = submitData.length;*/
  1171. var submitCount=0;
  1172. submitData.forEach(function(item){
  1173. if(this.data.id&&submitCount==0){
  1174. this.actions.editEmPower(this.data.id,item,function(json){
  1175. submitCount++;
  1176. }.bind(this),null,false);
  1177. }else{
  1178. this.actions.createEmPower(item,function(json){
  1179. submitCount++;
  1180. }.bind(this),null,false);
  1181. }
  1182. }.bind(this));
  1183. if(!submitData.length){
  1184. this.app.notice( this.lp.alert1 ,"error");
  1185. }
  1186. if(submitCount>0){
  1187. var content = this.container.getElement(".o2_profile_emPower_tab");
  1188. content.getElement("table").empty();
  1189. this.app.loadMyEmPower();
  1190. }
  1191. if(submitData.length&&submitCount==submitData.length){
  1192. //this.close();
  1193. this.app.notice(this.lp.saveOk,"success");
  1194. this.close();
  1195. }else if(submitCount>0){
  1196. this.app.notice(this.lp.saveNotAll,"error");
  1197. this.close();
  1198. }
  1199. },
  1200. createApplicationSelect : function(node,selectNode,type){
  1201. if (this.configData[type]&&this.configData[type].length){
  1202. MWF.require("MWF.widget.O2Identity", function(){
  1203. var p = new MWF.widget.O2Process(this.configData[type][0], node);
  1204. }.bind(this));
  1205. }else{
  1206. this.configData[type]=[];
  1207. }
  1208. selectNode.addEvent("click", function(){
  1209. MWF.xDesktop.requireApp("Selector", "package", function(){
  1210. var options = {
  1211. "type": type,
  1212. "values": this.configData[type],
  1213. "count": 0,
  1214. "onComplete": function (items) {
  1215. node.empty();
  1216. this[type] = {};
  1217. this.configData[type] = [];
  1218. items.forEach(function(item,indext){
  1219. MWF.require("MWF.widget.O2Identity", function(){
  1220. var p = new MWF.widget.O2Process(item.data, node);
  1221. this[type] = {
  1222. "name": item.data.name,
  1223. "id": item.data.id,
  1224. "edition":item.data.edition,
  1225. "application": item.data.application,
  1226. "applicationName": item.data.applicationName,
  1227. "alias": item.data.alias
  1228. };
  1229. this.configData[type].include(this[type]);
  1230. }.bind(this));
  1231. }.bind(this));
  1232. }.bind(this)
  1233. };
  1234. var selector = new MWF.O2Selector(this.container, options);
  1235. }.bind(this));
  1236. }.bind(this));
  1237. },
  1238. getHtml : function(){
  1239. return "<table width='100%' bordr='0' cellpadding='0' cellspacing='0' styles='formTable' id='empowerEditTable'>" +
  1240. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  1241. "<tr style='display:"+ (this.userIdentityList.length>1?"":"none")+"'><td styles='formTableTitleRight' lable='fromPerson'></td>" +
  1242. " <td styles='formTableValue' colspan='2'>" +
  1243. " <div item='fromPerson'></div>" +
  1244. " </td>" +
  1245. "</tr>" +
  1246. "<tr><td styles='formTableTitleRight' lable='toPerson'></td>" +
  1247. " <td styles='formTableValue' colspan='2'>" +
  1248. " <div item='toPerson'></div>" +
  1249. //" <div item='selecttoPerson'></div>" +
  1250. " </td>" +
  1251. "</tr>" +
  1252. "<tr><td styles='formTableTitleRight' width='100' lable='startDateInput'></td>" +
  1253. " <td styles='formTableValue' item='startDateInput' width='205'></td>" +
  1254. " <td styles='formTableValue' item='startTimeInput'></td>" +
  1255. "</tr>" +
  1256. "<tr><td styles='formTableTitleRight' lable='endDateInput'></td>" +
  1257. " <td styles='formTableValue' item='endDateInput'></td>" +
  1258. " <td styles='formTableValue' item='endTimeInput'></td>" +
  1259. "</tr>" +
  1260. "<tr><td styles='formTableTitleRight' ></td>" +
  1261. " <td styles='formTableValue' item='type' colspan='2'></td>" +
  1262. "</tr>" +
  1263. "<tr style='display:"+(this.data.type=="application"?"":"none")+"'><td styles='formTableTitleRight' lable='application'>"+this.lp.application+"</td>" +
  1264. " <td styles='formTableValue1' item='application' colspan='2'></td>" +
  1265. "</tr>" +
  1266. "<tr style='display:"+(this.data.type=="process"?"":"none")+"'><td styles='formTableTitleRight' lable='process'>"+this.lp.process+"</td>" +
  1267. " <td styles='formTableValue1' item='process' colspan='2'></td>" +
  1268. "</tr>" +
  1269. "</table>";
  1270. }
  1271. });