Main.js 63 KB

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