Main.js 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431
  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. var paswordRule = layout.config.passwordRegexHint || this.lp.paswordRule;
  918. passwordRemindNode.removeClass("o2_profile_passwordWarmming").set("text",paswordRule);
  919. var score = this.getPasswordComplex(pwd);
  920. if(score<=40){
  921. lowColorNode.addClass("o2_profile_passwordStrengthColor_low");
  922. lowTextNode.addClass("o2_profile_passwordStrengthText_current");
  923. }else if(score<=55){
  924. middleColorNode.addClass("o2_profile_passwordStrengthColor_middle");
  925. middleTextNode.addClass("o2_profile_passwordStrengthText_current");
  926. }else{
  927. highColorNode.addClass("o2_profile_passwordStrengthColor_high");
  928. highTextNode.addClass("o2_profile_passwordStrengthText_current");
  929. }
  930. }
  931. /*switch(level) {
  932. case 0:
  933. case 1:
  934. case 2:
  935. case 3:
  936. lowColorNode.addClass("o2_profile_passwordStrengthColor_low");
  937. lowTextNode.addClass("o2_profile_passwordStrengthText_current");
  938. break;
  939. case 4:
  940. case 5:
  941. case 6:
  942. middleColorNode.addClass("o2_profile_passwordStrengthColor_middle");
  943. middleTextNode.addClass("o2_profile_passwordStrengthText_current");
  944. break;
  945. default:
  946. highColorNode.addClass("o2_profile_passwordStrengthColor_high");
  947. highTextNode.addClass("o2_profile_passwordStrengthText_current");
  948. }*/
  949. }.bind(this) )
  950. }
  951. }
  952. });
  953. /*----2019年8月30日---外出授权---表单*/
  954. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  955. MWF.xApplication.Profile.emPowerPopupForm = new Class({
  956. Extends : MPopupForm,
  957. options: {
  958. "style": "empower",
  959. "width": "550",
  960. "height": "440",
  961. "hasTop": true,
  962. "hasIcon": false,
  963. "hasTopIcon" : false,
  964. "hasTopContent" : false,
  965. "draggable": true,
  966. "maxAction" : true,
  967. "closeAction": true,
  968. "isFull" : false,
  969. "startTime" : null,
  970. "endTime" : null,
  971. "isWholeday" : false,
  972. "defaultCalendarId" : "",
  973. "onPostCreateBottom": function () {
  974. this.formBottomNode.getElement(".formOkActionNode").addClass("mainColor_bg");
  975. }
  976. },
  977. load: function () {
  978. //重新指定css文件,由于临时用,所以尽可能写一个文件里
  979. this.cssPath = "../x_component_Profile/$Main/"+this.options.style+"/css.wcss";
  980. this._loadCss();
  981. this.configData = this.options.configData||{};
  982. this.lp = this.lp.empower;
  983. //this.addEvent("queryOk",this.queryOk());
  984. },
  985. _createTableContent : function() {
  986. this.userName = layout.desktop.session.user.distinguishedName;
  987. this.userId = layout.desktop.session.user.id;
  988. this.userIdentityList = layout.desktop.session.user.identityList;
  989. var identityTextList = [];
  990. var identityList =[];
  991. this.userIdentityList.each(function(it){
  992. identityTextList.push(it.name+"("+it.unitName+")");
  993. identityList.push((it.distinguishedName));
  994. });
  995. //this.formTableContainer.setStyle("width","80%");
  996. var startTime, endTime, defaultStartDate, defaultStartTime, defaultEndDate, defaultEndTime;
  997. if( this.data.startTime && this.data.endTime ){
  998. startTime= this.date = typeOf( this.data.startTime )=="string" ? Date.parse( this.data.startTime ) : this.data.startTime;
  999. endTime= typeOf( this.data.endTime )=="string" ? Date.parse( this.data.endTime ) : this.data.endTime;
  1000. defaultStartDate = startTime.format("%Y-%m-%d");
  1001. defaultStartTime = startTime.format("%H:%M");
  1002. defaultEndDate = endTime.format("%Y-%m-%d");
  1003. defaultEndTime = endTime.format("%H:%M");
  1004. }else{
  1005. startTime = this.date = new Date().increment("hour",1);
  1006. endTime = startTime.clone().increment("hour",1);
  1007. defaultStartDate = startTime.format("%Y-%m-%d");
  1008. defaultStartTime = startTime.format("%H") + ":00";
  1009. defaultEndDate = endTime.format("%Y-%m-%d");
  1010. defaultEndTime = endTime.format("%H") + ":00";
  1011. }
  1012. var data={};
  1013. this.formTableArea.set("html", this.getHtml());
  1014. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1015. this.form = new MForm(this.formTableArea, data, {
  1016. isEdited: this.isEdited || this.isNew,
  1017. style : "profile",
  1018. itemTemplate: {
  1019. fromPerson: { text: this.lp.fromPerson,type: "select", isEdited : (identityTextList.length>1),
  1020. selectText: identityTextList,
  1021. selectValue: identityList,
  1022. defaultValue: this.data.fromIdentity||identityList[0],
  1023. style:{
  1024. "width": "310px",
  1025. "height": "36px",
  1026. "box-shadow": "rgb(153, 153, 153) 0px 0px 0px",
  1027. "line-height": "36px",
  1028. "background": "#FFFFFF",
  1029. "border": "1px solid #DEDEDE",
  1030. "border-radius": "100px",
  1031. "font-family": "MicrosoftYaHei",
  1032. "padding":"0 5px",
  1033. "font-size": "14px",
  1034. "color": "#666666",
  1035. "margin": "0 0 10px 0"
  1036. }
  1037. },
  1038. toPerson: { text: this.lp.toPerson,type: "org", isEdited : this.isEdited || this.isNew, orgType: ["identity"], count : 1, orgWidgetOptions : {
  1039. "onLoadedInfor": function(item){
  1040. // this.loadAcceptAndReject( item );
  1041. }.bind(this)
  1042. },defaultValue:this.data.toPerson},
  1043. startDateInput: {
  1044. text: this.lp.startTime,
  1045. tType: "date",
  1046. defaultValue: defaultStartDate,
  1047. notEmpty: true
  1048. },
  1049. startTimeInput: {
  1050. tType: "time",
  1051. defaultValue: defaultStartTime,
  1052. className: ((this.isNew || this.isEdited || 1) ? "inputTimeUnformatWidth" : ""),
  1053. disable: data.isAllDayEvent
  1054. },
  1055. endDateInput: {
  1056. text: this.lp.completedTime,
  1057. tType: "date",
  1058. defaultValue: defaultEndDate,
  1059. notEmpty: true
  1060. },
  1061. endTimeInput: {
  1062. tType: "time",
  1063. defaultValue: defaultEndTime,
  1064. className: ((this.isNew || this.isEdited || 1) ? "inputTimeUnformatWidth" : ""),
  1065. disable: data.isAllDayEvent
  1066. },
  1067. type: {
  1068. text: this.lp.type, type: "radio",
  1069. selectText: [this.lp.type_all, this.lp.type_application, this.lp.type_process],
  1070. //selectText: ["全部", "应用", "流程"],
  1071. selectValue: ["all", "application", "process"],
  1072. defaultValue: this.data.type||"all",
  1073. event :{
  1074. "click":function(){
  1075. var type = this.form.getItem("type").getValue();
  1076. this.formTableArea.getElement("td[item=application]").parentNode.setStyle("display","none");
  1077. this.formTableArea.getElement("td[item=process]").parentNode.setStyle("display","none");
  1078. if(type=="all"){
  1079. //this.formTableArea.getElement("td[item=application]").parentNode.setStyle("display","");
  1080. //this.formTableArea.getElement("td[item=process]").parentNode.setStyle("display","");
  1081. }else{
  1082. this.formTableArea.getElement("td[item="+type+"]").parentNode.setStyle("display","");
  1083. }
  1084. }.bind(this)
  1085. }
  1086. }
  1087. },
  1088. onPostLoad:function(){
  1089. /*样式重构*/
  1090. this.formTableArea.getElements("td[item=type] div").forEach(function(item){
  1091. 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(){
  1092. this.getParent().getParent().getElements("label").removeClass("o2_profile_empower_radio__checked o2_profile_empower_radio_checked");
  1093. this.addClass("o2_profile_empower_radio__checked o2_profile_empower_radio_checked");
  1094. });
  1095. item.adopt(labelRadio,item.getElement("span"))
  1096. });
  1097. }.bind(this)
  1098. },this.app,this.css);
  1099. this.form.load();
  1100. }.bind(this));
  1101. /*重构单选框样式
  1102. * */
  1103. this.applicationNode = this.formTableArea.getElement("td[item=application]");
  1104. //this.applicationNode.empty();
  1105. this.selectApplicationNode = new Element("div.selectNode", {
  1106. width: "30",
  1107. height: "30",
  1108. }).inject(this.applicationNode).setStyles(this.css.selectNode).addEvents({
  1109. "hover":function(){
  1110. this.setStyle("background","url(../x_component_Profile/$Main/newVersion/icon_zengjia_blue2_click.png) center center no-repeat");
  1111. },
  1112. "blur":function(){
  1113. this.setStyle("background","url(../x_component_Profile/$Main/newVersion/icon_zengjia_blue2.png) center center no-repeat");
  1114. }
  1115. });
  1116. this.showApplicationNode = new Element("div.showNode", {
  1117. width: "200",
  1118. height: "30",
  1119. // text: "选择应用"
  1120. }).inject(this.applicationNode).setStyles(this.css.showNode);
  1121. this.createApplicationSelect(this.showApplicationNode,this.selectApplicationNode,"Application");
  1122. this.processNode = this.formTableArea.getElement("td[item=process]");
  1123. this.selectProcessNode = new Element("div.selectNode", {
  1124. width: "30",
  1125. height: "30",
  1126. }).inject(this.processNode).setStyles(this.css.selectNode);
  1127. this.showProcessNode = new Element("div.showNode", {
  1128. width: "200",
  1129. height: "30",
  1130. //text: "选择流程"
  1131. }).inject(this.processNode).setStyles(this.css.showNode);
  1132. this.createApplicationSelect(this.showProcessNode,this.selectProcessNode,"Process");
  1133. },
  1134. _ok: function (data, callback) {
  1135. //data 是表单的数据, callback 是正确的回调
  1136. //data.
  1137. var submitData = [];
  1138. //数据处理
  1139. var sdata = {};
  1140. sdata.fromIdentity = data.fromPerson;
  1141. sdata.fromPerson = data.fromPerson.split("@")[0];
  1142. sdata.toIdentity = data.toPerson;
  1143. sdata.toPerson = data.toPerson.split("@")[0];
  1144. sdata.startTime = data.startDateInput+" "+data.startTimeInput+":00";
  1145. sdata.completedTime = data.endDateInput+" "+data.endTimeInput+":00";
  1146. sdata.enable = true;
  1147. if(data.type=="all"){
  1148. sdata.type = data.type;
  1149. submitData.push(sdata);
  1150. }else if(data.type=="application"){
  1151. this.configData["Application"].forEach(function(item){
  1152. var subData = JSON.parse(JSON.stringify(sdata));
  1153. subData["application"] = item.id;
  1154. subData["applicationName"] = item.name;
  1155. subData["applicationAlias"] = item.alias;
  1156. subData.type = "application";
  1157. submitData.push(subData);
  1158. });
  1159. }else if(data.type=="process"){
  1160. this.configData["Process"].forEach(function(item){
  1161. var subData = JSON.parse(JSON.stringify(sdata));
  1162. subData["process"] = item.id;
  1163. subData["processName"] = item.name;
  1164. subData["processAlias"] = item.alias;
  1165. subData["edition"] = !!item.edition?item.edition:(item.id);
  1166. subData.type = "process";
  1167. submitData.push(subData);
  1168. });
  1169. }
  1170. /*this.saveConfigData=[];
  1171. this.saveConfigCount = submitData.length;*/
  1172. var submitCount=0;
  1173. submitData.forEach(function(item){
  1174. if(this.data.id&&submitCount==0){
  1175. this.actions.editEmPower(this.data.id,item,function(json){
  1176. submitCount++;
  1177. }.bind(this),null,false);
  1178. }else{
  1179. this.actions.createEmPower(item,function(json){
  1180. submitCount++;
  1181. }.bind(this),null,false);
  1182. }
  1183. }.bind(this));
  1184. if(!submitData.length){
  1185. this.app.notice( this.lp.alert1 ,"error");
  1186. }
  1187. if(submitCount>0){
  1188. var content = this.container.getElement(".o2_profile_emPower_tab");
  1189. content.getElement("table").empty();
  1190. this.app.loadMyEmPower();
  1191. }
  1192. if(submitData.length&&submitCount==submitData.length){
  1193. //this.close();
  1194. this.app.notice(this.lp.saveOk,"success");
  1195. this.close();
  1196. }else if(submitCount>0){
  1197. this.app.notice(this.lp.saveNotAll,"error");
  1198. this.close();
  1199. }
  1200. },
  1201. createApplicationSelect : function(node,selectNode,type){
  1202. if (this.configData[type]&&this.configData[type].length){
  1203. MWF.require("MWF.widget.O2Identity", function(){
  1204. var p = new MWF.widget.O2Process(this.configData[type][0], node);
  1205. }.bind(this));
  1206. }else{
  1207. this.configData[type]=[];
  1208. }
  1209. selectNode.addEvent("click", function(){
  1210. MWF.xDesktop.requireApp("Selector", "package", function(){
  1211. var options = {
  1212. "type": type,
  1213. "values": this.configData[type],
  1214. "count": 0,
  1215. "onComplete": function (items) {
  1216. node.empty();
  1217. this[type] = {};
  1218. this.configData[type] = [];
  1219. items.forEach(function(item,indext){
  1220. MWF.require("MWF.widget.O2Identity", function(){
  1221. var p = new MWF.widget.O2Process(item.data, node);
  1222. this[type] = {
  1223. "name": item.data.name,
  1224. "id": item.data.id,
  1225. "edition":item.data.edition,
  1226. "application": item.data.application,
  1227. "applicationName": item.data.applicationName,
  1228. "alias": item.data.alias
  1229. };
  1230. this.configData[type].include(this[type]);
  1231. }.bind(this));
  1232. }.bind(this));
  1233. }.bind(this)
  1234. };
  1235. var selector = new MWF.O2Selector(this.container, options);
  1236. }.bind(this));
  1237. }.bind(this));
  1238. },
  1239. getHtml : function(){
  1240. return "<table width='100%' bordr='0' cellpadding='0' cellspacing='0' styles='formTable' id='empowerEditTable'>" +
  1241. //"<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  1242. "<tr style='display:"+ (this.userIdentityList.length>1?"":"none")+"'><td styles='formTableTitleRight' lable='fromPerson'></td>" +
  1243. " <td styles='formTableValue' colspan='2'>" +
  1244. " <div item='fromPerson'></div>" +
  1245. " </td>" +
  1246. "</tr>" +
  1247. "<tr><td styles='formTableTitleRight' lable='toPerson'></td>" +
  1248. " <td styles='formTableValue' colspan='2'>" +
  1249. " <div item='toPerson'></div>" +
  1250. //" <div item='selecttoPerson'></div>" +
  1251. " </td>" +
  1252. "</tr>" +
  1253. "<tr><td styles='formTableTitleRight' width='100' lable='startDateInput'></td>" +
  1254. " <td styles='formTableValue' item='startDateInput' width='205'></td>" +
  1255. " <td styles='formTableValue' item='startTimeInput'></td>" +
  1256. "</tr>" +
  1257. "<tr><td styles='formTableTitleRight' lable='endDateInput'></td>" +
  1258. " <td styles='formTableValue' item='endDateInput'></td>" +
  1259. " <td styles='formTableValue' item='endTimeInput'></td>" +
  1260. "</tr>" +
  1261. "<tr><td styles='formTableTitleRight' ></td>" +
  1262. " <td styles='formTableValue' item='type' colspan='2'></td>" +
  1263. "</tr>" +
  1264. "<tr style='display:"+(this.data.type=="application"?"":"none")+"'><td styles='formTableTitleRight' lable='application'>"+this.lp.application+"</td>" +
  1265. " <td styles='formTableValue1' item='application' colspan='2'></td>" +
  1266. "</tr>" +
  1267. "<tr style='display:"+(this.data.type=="process"?"":"none")+"'><td styles='formTableTitleRight' lable='process'>"+this.lp.process+"</td>" +
  1268. " <td styles='formTableValue1' item='process' colspan='2'></td>" +
  1269. "</tr>" +
  1270. "</table>";
  1271. }
  1272. });