Main.js 63 KB

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