Main.js 63 KB

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