Main.js 59 KB

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