LogView.js 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481
  1. MWF.xApplication.ThreeMember = MWF.xApplication.ThreeMember || {};
  2. MWF.require("MWF.widget.O2Identity", null, false);
  3. //MWF.xDesktop.requireApp("ThreeMember", "Access", null, false);
  4. //MWF.xDesktop.requireApp("ThreeMember", "Actions.RestActions", null, false);
  5. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  6. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  7. MWF.xApplication.ThreeMember.LogView = new Class({
  8. Extends: MWF.widget.Common,
  9. Implements: [Options, Events],
  10. options: {
  11. "style": "default",
  12. "viewPageNum": 1,
  13. "module": "",
  14. "operation": "",
  15. "filterModule": false,
  16. "title": MWF.xApplication.ThreeMember.LP.title
  17. },
  18. initialize: function(node, app, options){
  19. this.setOptions(options);
  20. this.path = "../x_component_ThreeMember/$LogView/";
  21. this.cssPath = "../x_component_ThreeMember/$LogView/"+this.options.style+"/css.wcss";
  22. this._loadCss();
  23. this.app = app;
  24. this.content = $(node);
  25. this.lp = MWF.xApplication.ThreeMember.LP;
  26. this.load();
  27. },
  28. reload: function () {
  29. this.clearContent();
  30. this.load();
  31. },
  32. load: function () {
  33. this.content.setStyle("overflow", "hidden");
  34. this.node = new Element("div", {
  35. "styles": this.css.node
  36. }).inject(this.content);
  37. this.naviNode = new Element("div.naviNode", {
  38. "styles": this.css.naviNode
  39. }).inject(this.node);
  40. this.contentContainerNode = new Element("div.contentContainerNode", {
  41. "styles": this.css.contentContainerNode
  42. }).inject(this.node);
  43. this.createTop();
  44. this.createContent();
  45. this.loaNavi();
  46. },
  47. loaNavi: function (callback) {
  48. debugger;
  49. var naviOpt = {};
  50. naviOpt.module = this.options.module || "all";
  51. naviOpt.operation = this.options.operation;
  52. this.navi = new MWF.xApplication.ThreeMember.LogView.Navi(this, this.naviNode, naviOpt);
  53. },
  54. createTop: function () {
  55. this.topContainerNode = new Element("div.topContainerNode", {
  56. "styles": this.css.topContainerNode
  57. }).inject(this.contentContainerNode);
  58. this.topNode = new Element("div.topNode", {
  59. "styles": this.css.topNode
  60. }).inject(this.topContainerNode);
  61. this.topContentNode = new Element("div", {
  62. "styles": this.css.topContentNode
  63. }).inject(this.topNode);
  64. this.loadLogFilter();
  65. },
  66. createContent: function () {
  67. this.middleNode = new Element("div.middleNode", {
  68. "styles": this.css.middleNode
  69. }).inject(this.contentContainerNode);
  70. this.contentNode = new Element("div.contentNode", {
  71. "styles": this.css.contentNode
  72. }).inject(this.middleNode);
  73. // this.loadView();
  74. this.setContentSizeFun = this.setContentSize.bind(this);
  75. this.app.addEvent("resize", this.setContentSizeFun);
  76. // this.setContentSize();
  77. },
  78. toConfig: function(){
  79. if (this.view) {
  80. this.view.destroy();
  81. this.view = null;
  82. }
  83. this.configNavi = null;
  84. this.naviNode.empty();
  85. this.topContentNode.empty();
  86. this.contentNode.empty();
  87. this.createConfigAction = new Element("button", {
  88. "type": "button",
  89. "text": this.lp.createConfig,
  90. "styles": this.css.createConfigAction,
  91. "events": {
  92. click: function () {
  93. this.view._create();
  94. }.bind(this)
  95. }
  96. }).inject( this.topContentNode, "before" );
  97. this.loadConfigFilter();
  98. this.navi = new MWF.xApplication.ThreeMember.LogView.ConfigNavi(this, this.naviNode, {});
  99. this.configNavi = this.navi;
  100. },
  101. toView: function(){
  102. if (this.view) {
  103. this.view.destroy();
  104. this.view = null;
  105. }
  106. this.configNavi = null;
  107. this.naviNode.empty();
  108. this.topContentNode.empty();
  109. this.contentNode.empty();
  110. if(this.createConfigAction){
  111. this.createConfigAction.destroy();
  112. this.createConfigAction = null;
  113. }
  114. this.loadLogFilter();
  115. this.navi = new MWF.xApplication.ThreeMember.LogView.Navi(this, this.naviNode, {});
  116. },
  117. getOffsetY: function (node) {
  118. return (node.getStyle("margin-top").toInt() || 0) +
  119. (node.getStyle("margin-bottom").toInt() || 0) +
  120. (node.getStyle("padding-top").toInt() || 0) +
  121. (node.getStyle("padding-bottom").toInt() || 0) +
  122. (node.getStyle("border-top-width").toInt() || 0) +
  123. (node.getStyle("border-bottom-width").toInt() || 0);
  124. },
  125. setContentSize: function () {
  126. var nodeSize = this.node.getSize();
  127. var h = nodeSize.y - this.getOffsetY(this.node);
  128. var topY = this.topContainerNode ? (this.getOffsetY(this.topContainerNode) + this.topContainerNode.getSize().y) : 0;
  129. h = h - topY;
  130. h = h - this.getOffsetY(this.viewContainerNode);
  131. var pageSize = (this.view && this.view.pagingContainerBottom) ? this.view.pagingContainerBottom.getComputedSize() : {totalHeight: 0};
  132. h = h - pageSize.totalHeight;
  133. // this.viewContainerNode.setStyle("height", "" + h + "px");
  134. this.view.viewWrapNode.setStyles({
  135. "height": "" + h + "px",
  136. "overflow": "auto"
  137. });
  138. },
  139. loadView: function (filterData) {
  140. if (this.view) this.view.destroy();
  141. this.contentNode.empty();
  142. var viewContainerNode = this.viewContainerNode = new Element("div.viewContainerNode", {
  143. "styles": this.css.viewContainerNode
  144. }).inject(this.contentNode);
  145. this.view = new MWF.xApplication.ThreeMember.LogView.View(viewContainerNode, this.app, this, {
  146. templateUrl: this.path + this.options.style + "/listItem.json",
  147. "pagingEnable": true,
  148. "wrapView": true,
  149. "noItemText": this.lp.noItem,
  150. // "scrollType": "window",
  151. "pagingPar": {
  152. pagingBarUseWidget: true,
  153. position: ["bottom"],
  154. style: "blue_round",
  155. hasReturn: false,
  156. currentPage: this.options.viewPageNum,
  157. countPerPage: 15,
  158. visiblePages: 9,
  159. hasNextPage: true,
  160. hasPrevPage: true,
  161. hasTruningBar: true,
  162. hasJumper: true,
  163. returnText: "",
  164. hiddenWithDisable: false,
  165. text: {
  166. prePage: "",
  167. nextPage: "",
  168. firstPage: this.lp.firstPage,
  169. lastPage: this.lp.lastPage
  170. },
  171. onPostLoad: function () {
  172. debugger;
  173. this.setContentSize();
  174. }.bind(this)
  175. }
  176. }, {
  177. lp: this.lp
  178. });
  179. var fData = filterData || {};
  180. if( !fData.startTime )fData.startTime = this.form.getItem("startTime").getValue();
  181. if( !fData.endTime )fData.endTime = this.form.getItem("endTime").getValue();
  182. Object.each( (this.navi ? this.navi.currentStatus : {}) || {}, function (value, key) {
  183. fData[key] = value;
  184. });
  185. this.view.filterData = fData;
  186. this.view.load();
  187. },
  188. loadConfigView: function(filterData){
  189. if (this.view) this.view.destroy();
  190. this.contentNode.empty();
  191. var viewContainerNode = this.viewContainerNode = new Element("div.viewContainerNode", {
  192. "styles": this.css.viewContainerNode
  193. }).inject(this.contentNode);
  194. this.view = new MWF.xApplication.ThreeMember.LogView.ConfigView(viewContainerNode, this.app, this, {
  195. templateUrl: this.path + this.options.style + "/listItemConfig.json",
  196. "pagingEnable": true,
  197. "wrapView": true,
  198. "noItemText": this.lp.noItem,
  199. // "scrollType": "window",
  200. "pagingPar": {
  201. pagingBarUseWidget: true,
  202. position: ["bottom"],
  203. style: "blue_round",
  204. hasReturn: false,
  205. currentPage: this.options.viewPageNum,
  206. countPerPage: 15,
  207. visiblePages: 9,
  208. hasNextPage: true,
  209. hasPrevPage: true,
  210. hasTruningBar: true,
  211. hasJumper: true,
  212. returnText: "",
  213. hiddenWithDisable: false,
  214. text: {
  215. prePage: "",
  216. nextPage: "",
  217. firstPage: this.lp.firstPage,
  218. lastPage: this.lp.lastPage
  219. },
  220. onPostLoad: function () {
  221. debugger;
  222. this.setContentSize();
  223. }.bind(this)
  224. }
  225. }, {
  226. lp: this.lp
  227. });
  228. var fData = filterData || {};
  229. Object.each( (this.configNavi ? this.configNavi.currentStatus : {}) || {}, function (value, key) {
  230. fData[key] = value;
  231. });
  232. this.view.filterData = fData;
  233. this.view.load();
  234. },
  235. clear: function () {
  236. if (this.setContentSizeFun) this.removeEvent("resize", this.setContentSizeFun);
  237. if( this.navi )this.navi.destroy();
  238. if( this.naviNode ){
  239. this.naviNode.destroy();
  240. }
  241. if (this.contentContainerNode) {
  242. this.contentContainerNode.destroy();
  243. //this.middleNode.destroy();
  244. //this.contentNode.destroy();
  245. }
  246. this.node.destroy();
  247. },
  248. loadConfigFilter: function () {
  249. var lp = MWF.xApplication.ThreeMember.LP;
  250. this.fileterNode = new Element("div.fileterNode", {
  251. "styles": this.css.fileterNode
  252. }).inject(this.topContentNode);
  253. var html = "<table width='100%' bordr='0' cellpadding='0' cellspacing='0' styles='filterTable'>" + //style='width: 900px;'
  254. "<tr>";
  255. if( this.options.filterModule ) {
  256. html += "<td styles='filterTableTitle' lable='module'></td>" +
  257. " <td styles='filterTableValue' item='module'></td>"+
  258. " <td styles='filterTableTitle' lable='operation'></td>" +
  259. " <td styles='filterTableValue' item='operation'></td>";
  260. }
  261. html +=
  262. " <td styles='filterTableTitle' lable='httpType'></td>" +
  263. " <td styles='filterTableValue' item='httpType'></td>"+
  264. " <td styles='filterTableTitle' lable='matchUrl'></td>" +
  265. " <td styles='filterTableValue' item='matchUrl'></td>"+
  266. " <td styles='filterTableValue' item='action'></td>" +
  267. " <td styles='filterTableValue' item='reset'></td>" +
  268. "</tr>" +
  269. "</table>";
  270. this.fileterNode.set("html", html);
  271. this.configForm = new MForm(this.fileterNode, {}, {
  272. style: "attendance",
  273. isEdited: true,
  274. itemTemplate: {
  275. module: {
  276. "text": lp.module,
  277. "type": "select",
  278. "style": {"max-width": "150px"},
  279. "selectValue": function () {
  280. var array = [""];
  281. o2.Actions.load("x_auditlog_assemble_control").AuditConfigAction.listModule(function (json) {
  282. array = array.concat(json.data.valueList);
  283. }.bind(this), null, false);
  284. return array;
  285. },
  286. "event": {
  287. "change": function (item, ev) {
  288. var array;
  289. var v = item.getValue();
  290. if (v) {
  291. o2.Actions.load("x_auditlog_assemble_control").AuditConfigAction.listOperation(v, function (json) {
  292. array = [""].concat(json.data.valueList);
  293. }.bind(this), null, false);
  294. } else {
  295. array = [];
  296. }
  297. item.form.getItem("operation").resetItemOptions(array, array)
  298. }.bind(this)
  299. }
  300. },
  301. operation: {text: lp.operation, "type": "select", "style": {"max-width": "150px"}, "selectValue": []},
  302. httpType: {text: lp.httpType, "type": "select", "selectValue": ["","GET","POST","PUT","DELETE"]},
  303. matchUrl: {
  304. text: lp.httpUrl
  305. },
  306. action: {
  307. "value": lp.query, type: "button", className: "filterButton", event: {
  308. click: function () {
  309. var result = this.configForm.getResult(false, null, false, true, false);
  310. for (var key in result) {
  311. if (!result[key]) {
  312. delete result[key];
  313. } else if (key === "person" && result[key].length > 0) {
  314. result[key] = result[key][0].split("@")[1];
  315. }
  316. }
  317. this.loadConfigView(result);
  318. }.bind(this)
  319. }
  320. },
  321. reset: {
  322. "value": lp.reset, type: "button", className: "filterButtonGrey", event: {
  323. click: function () {
  324. this.configForm.reset();
  325. this.loadConfigView();
  326. }.bind(this)
  327. }
  328. },
  329. }
  330. }, this, this.css);
  331. this.configForm.load();
  332. },
  333. loadLogFilter: function () {
  334. var lp = MWF.xApplication.ThreeMember.LP;
  335. this.fileterNode = new Element("div.fileterNode", {
  336. "styles": this.css.fileterNode
  337. }).inject(this.topContentNode);
  338. var html = "<table width='100%' bordr='0' cellpadding='0' cellspacing='0' styles='filterTable'>" + //style='width: 900px;'
  339. "<tr>";
  340. if( !o2.AC.isAuditManager() || o2.AC.isSystemManager() || this.app.managerEnabled ){
  341. html += "<td styles='filterTableTitle' lable='person'></td>" +
  342. "<td styles='filterTableValue' item='person'></td>";
  343. }
  344. if( this.options.filterModule ) {
  345. html += "<td styles='filterTableTitle' lable='module'></td>" +
  346. " <td styles='filterTableValue' item='module'></td>" +
  347. " <td styles='filterTableTitle' lable='operation'></td>" +
  348. " <td styles='filterTableValue' item='operation'></td>";
  349. }
  350. html += "<td styles='filterTableTitle' lable='startTime'></td>" +
  351. " <td styles='filterTableValue' item='startTime' style='width: 150px;'></td>" +
  352. " <td styles='filterTableTitle' lable='endTime'></td>" +
  353. " <td styles='filterTableValue' item='endTime' style='width: 150px;'></td>" +
  354. " <td styles='filterTableValue' item='action'></td>" +
  355. " <td styles='filterTableValue' item='reset'></td>" +
  356. "</tr>" +
  357. "</table>";
  358. this.fileterNode.set("html", html);
  359. this.form = new MForm(this.fileterNode, {}, {
  360. style: "attendance",
  361. isEdited: true,
  362. itemTemplate: {
  363. person: {
  364. "text": lp.person,
  365. "type": "org",
  366. "orgType": "identity",
  367. "orgOptions": {"resultType": "person"},
  368. "style": {"min-width": "100px"},
  369. "orgWidgetOptions": {"disableInfor": true}
  370. },
  371. module: {
  372. "text": lp.module,
  373. "type": "select",
  374. "style": {"max-width": "150px"},
  375. "selectValue": function () {
  376. var array = [""];
  377. o2.Actions.load("x_auditlog_assemble_control").AuditConfigAction.listModule(function (json) {
  378. array = array.concat(json.data.valueList);
  379. }.bind(this), null, false);
  380. return array;
  381. },
  382. "event": {
  383. "change": function (item, ev) {
  384. var array;
  385. var v = item.getValue();
  386. if (v) {
  387. o2.Actions.load("x_auditlog_assemble_control").AuditConfigAction.listOperation(v, function (json) {
  388. array = [""].concat(json.data.valueList);
  389. }.bind(this), null, false);
  390. } else {
  391. array = [];
  392. }
  393. item.form.getItem("operation").resetItemOptions(array, array)
  394. }.bind(this)
  395. }
  396. },
  397. operation: {text: lp.operation, "type": "select", "style": {"max-width": "150px"}, "selectValue": []},
  398. startTime: {
  399. text: lp.startTime,
  400. "tType": "datetime",
  401. "defaultValue": new Date().decrement('day', 1).format("%Y-%m-%d") + " 00:00:00",
  402. "calendarOptions": {"secondEnable": true, "format": "db", "clearEnable": false}
  403. },
  404. endTime: {
  405. text: lp.endTime,
  406. "tType": "datetime",
  407. "defaultValue": new Date().format("%Y-%m-%d") + " 23:59:59",
  408. "calendarOptions": {"secondEnable": true, "format": "db", "clearEnable": false}
  409. },
  410. action: {
  411. "value": lp.query, type: "button", className: "filterButton", event: {
  412. click: function () {
  413. var result = this.form.getResult(false, null, false, true, false);
  414. for (var key in result) {
  415. if (!result[key]) {
  416. delete result[key];
  417. } else if (key === "person" && result[key].length > 0) {
  418. result[key] = result[key][0].split("@")[1];
  419. }
  420. }
  421. this.loadView(result);
  422. }.bind(this)
  423. }
  424. },
  425. reset: {
  426. "value": lp.reset, type: "button", className: "filterButtonGrey", event: {
  427. click: function () {
  428. this.form.reset();
  429. this.loadView();
  430. }.bind(this)
  431. }
  432. },
  433. }
  434. }, this, this.css);
  435. this.form.load();
  436. },
  437. recordStatus: function () {
  438. var status = this.navi.currentStatus || {};
  439. status.explorer = "logview";
  440. return status;
  441. }
  442. });
  443. MWF.xApplication.ThreeMember.LogView.Navi = new Class({
  444. Implements: [Options, Events],
  445. options: {
  446. "module": "all"
  447. },
  448. initialize: function (explorer, node, options) {
  449. this.setOptions(options);
  450. this.app = explorer.app;
  451. this.explorer = explorer;
  452. this.node = $(node);
  453. this.css = this.explorer.css;
  454. this.currentMenu = null;
  455. this.currentItem = null;
  456. this.load();
  457. },
  458. load: function () {
  459. this.naviActionNode = new Element("div.naviTopNode", {
  460. "styles": this.css.naviActionNode,
  461. "text": this.explorer.lp.syncLog,
  462. "events":{
  463. click: function () {
  464. o2.Actions.load("x_auditlog_assemble_control").AuditLogAction.executeTodayDispatch(function(json){
  465. if(json.data.value){
  466. this.app.notice(this.explorer.lp.syncLogSuccess)
  467. }
  468. }.bind(this))
  469. }.bind(this)
  470. }
  471. }).inject(this.node);
  472. this.scrollNode = new Element("div.naviScrollNode", {"styles": this.css.naviScrollNode}).inject(this.node);
  473. this.areaNode = new Element("div.naviAreaNode", {"styles": this.css.naviAreaNode}).inject(this.scrollNode);
  474. if( !o2.AC.isAuditManager() || o2.AC.isSystemManager() || this.app.managerEnabled ){
  475. this.configNode = new Element("div.naviConfigNode", {
  476. "styles": this.css.naviConfigNode,
  477. "text": this.explorer.lp.logConfig,
  478. "events": {
  479. "click": function () {
  480. this.explorer.toConfig();
  481. }.bind(this)
  482. }
  483. }).inject(this.node);
  484. new Element("div.naviConfigIconNode", {
  485. "styles": this.css.naviConfigIconNode
  486. }).inject(this.configNode, "top");
  487. }
  488. // this.naviTopNode = new Element("div.naviTopNode", {
  489. // "styles": this.css.naviTopNode,
  490. // "text": this.explorer.lp.title
  491. // }).inject(this.areaNode);
  492. this.createAllNode();
  493. o2.Actions.load("x_auditlog_assemble_control").AuditConfigAction.listModule(function (json) {
  494. json.data.valueList.each(function (text) {
  495. this.createMenuNode(text);
  496. }.bind(this));
  497. this.setContentSize();
  498. this.setContentSizeFun = this.setContentSize.bind(this);
  499. this.app.addEvent("resize", this.setContentSizeFun);
  500. }.bind(this));
  501. },
  502. destroy: function(){
  503. if(this.setContentSizeFun)this.app.removeEvent("resize", this.setContentSizeFun );
  504. this.scrollNode.destroy();
  505. },
  506. createAllNode: function () {
  507. var _self = this;
  508. this.naviAllNode = new Element("div.naviAllNode", {
  509. "styles": this.css.naviAllNode,
  510. "text": this.explorer.lp.all
  511. }).inject(this.areaNode);
  512. this.naviAllNode.addEvents({
  513. "mouseover": function () {
  514. if (_self.currentAll != this) this.setStyles(_self.explorer.css.naviAllNode_over);
  515. },
  516. "mouseout": function () {
  517. if (_self.currentAll != this) this.setStyles(_self.explorer.css.naviAllNode_normal);
  518. },
  519. "click": function (ev) {
  520. _self.setCurrentAll();
  521. ev.stopPropagation();
  522. }
  523. });
  524. if (this.options.module === "all") {
  525. this.naviAllNode.click();
  526. }
  527. },
  528. setCurrentAll: function () {
  529. this.cancelCurrent();
  530. this.currentStatus = null;
  531. this.currentAll = this.naviAllNode;
  532. this.naviAllNode.setStyles(this.css.naviAllNode_current);
  533. if (this.explorer.form) {
  534. // this.explorer.form.reset();
  535. if(this.explorer.options.filterModule){
  536. this.explorer.form.getItem("module").items[0].fireEvent("change");
  537. }
  538. }
  539. this.explorer.loadView()
  540. },
  541. createMenuNode: function (text) {
  542. var _self = this;
  543. var menuNode = new Element("div", {
  544. "styles": this.css.naviMenuNode
  545. });
  546. menuNode.setStyles(this.css.naviMenuNode_collapse);
  547. var iconNode = new Element("div", {
  548. "styles": this.css.naviMenuIconNode_collapse
  549. }).inject(menuNode);
  550. var textNode = new Element("div", {
  551. "styles": this.css.naviMenuTextNode,
  552. "text": text
  553. }).inject(menuNode);
  554. menuNode.inject(this.areaNode);
  555. var menuObj = {
  556. "module": text,
  557. "collapse": true,
  558. "node": menuNode,
  559. "iconNode": iconNode
  560. };
  561. iconNode.addEvents({
  562. click: function (ev) {
  563. _self.expandOrCollapse(menuObj);
  564. ev.stopPropagation();
  565. }
  566. });
  567. menuNode.addEvents({
  568. "mouseover": function () {
  569. if (_self.currentMenu != this) this.setStyles(_self.explorer.css.naviMenuNode_over);
  570. },
  571. "mouseout": function () {
  572. if (_self.currentMenu != this) this.setStyles(_self.explorer.css.naviMenuNode_normal);
  573. },
  574. "click": function (ev) {
  575. _self.setCurrentMenu(menuObj);
  576. ev.stopPropagation();
  577. }
  578. });
  579. if (this.options.module === text) {
  580. if (this.options.operation) {
  581. iconNode.click();
  582. } else {
  583. menuNode.click()
  584. }
  585. }
  586. },
  587. cancelCurrent: function () {
  588. if (this.currentMenu) {
  589. this.currentMenu.setStyles(this.css.naviMenuNode);
  590. this.currentMenu.setStyles(this.css.naviMenuNode_normal);
  591. this.currentMenu = false;
  592. }
  593. if (this.currentItem) {
  594. this.currentItem.setStyles(this.css.naviItemNode);
  595. this.currentItem = false;
  596. }
  597. if (this.currentAll) {
  598. this.currentAll.setStyles(this.css.naviAllNode_normal);
  599. this.currentAll = false;
  600. }
  601. this.currentStatus = null;
  602. },
  603. setCurrentMenu: function (menuObj) {
  604. this.cancelCurrent();
  605. this.currentStatus = {
  606. module: menuObj.module
  607. };
  608. this.currentMenu = menuObj.node;
  609. menuObj.node.setStyles(this.css.naviMenuNode_current);
  610. // this.explorer.form.reset();
  611. if(this.explorer.options.filterModule) {
  612. this.explorer.form.getItem("module").setValue(menuObj.module);
  613. this.explorer.form.getItem("module").items[0].fireEvent("change");
  614. }
  615. this.explorer.loadView({"module": menuObj.module})
  616. },
  617. expandOrCollapse: function (menuObj) {
  618. if (!menuObj.itemContainer) {
  619. menuObj.itemContainer = new Element("div").inject(menuObj.node, "after");
  620. o2.Actions.load("x_auditlog_assemble_control").AuditConfigAction.listOperation(menuObj.module, function (json) {
  621. json.data.valueList.each(function (operation) {
  622. this.createItemNode(operation, menuObj);
  623. }.bind(this))
  624. }.bind(this));
  625. } else {
  626. menuObj.itemContainer.setStyle("display", menuObj.collapse ? "" : "none");
  627. }
  628. menuObj.iconNode.setStyles(menuObj.collapse ? this.css.naviMenuIconNode_expand : this.css.naviMenuIconNode_collapse);
  629. menuObj.collapse = !menuObj.collapse;
  630. },
  631. createItemNode: function (operation, menuObj) {
  632. var _self = this;
  633. var itemNode = new Element("div", {
  634. "styles": this.css.naviItemNode
  635. });
  636. var itemObj = {
  637. "module": menuObj.module,
  638. "operation": operation,
  639. "node": itemNode
  640. };
  641. var textNode = new Element("div", {
  642. "styles": this.css.naviItemTextNode,
  643. "text": operation
  644. });
  645. textNode.inject(itemNode);
  646. itemNode.inject(menuObj.itemContainer);
  647. itemNode.addEvents({
  648. "mouseover": function () {
  649. if (_self.currentItem != this) this.setStyles(_self.explorer.css.naviItemNode_over);
  650. },
  651. "mouseout": function () {
  652. if (_self.currentItem != this) this.setStyles(_self.explorer.css.naviItemNode);
  653. },
  654. "mousedown": function () {
  655. if (_self.currentItem != this) this.setStyles(_self.explorer.css.naviItemNode_down);
  656. },
  657. "mouseup": function () {
  658. if (_self.currentItem != this) this.setStyles(_self.explorer.css.naviItemNode_over);
  659. },
  660. "click": function () {
  661. _self.setCurrentItem(itemObj);
  662. }
  663. });
  664. if (operation === this.options.operation) {
  665. itemNode.click();
  666. }
  667. },
  668. setCurrentItem: function (itemObj) {
  669. this.cancelCurrent();
  670. this.currentStatus = {
  671. module: itemObj.module,
  672. operation: itemObj.operation
  673. };
  674. this.currentItem = itemObj.node;
  675. itemObj.node.setStyles(this.css.naviItemNode_current);
  676. //this.explorer.form.reset();
  677. if(this.explorer.options.filterModule) {
  678. this.explorer.form.getItem("module").setValue(itemObj.module);
  679. this.explorer.form.getItem("module").items[0].fireEvent("change");
  680. this.explorer.form.getItem("operation").setValue(itemObj.operation);
  681. }
  682. this.explorer.loadView({
  683. "module": itemObj.module,
  684. "operation": itemObj.operation
  685. })
  686. },
  687. setContentSize: function () {
  688. // var nodeSize = this.explorer.node.getSize();
  689. // var h = nodeSize.y - this.explorer.getOffsetY(this.explorer.node);
  690. // this.node.setStyle("height", h);
  691. //
  692. // if( this.naviActionNode ){
  693. // h = h - this.naviActionNode.getSize().y - this.explorer.getOffsetY(this.naviActionNode);
  694. // }
  695. // this.scrollNode.setStyle("height", h);
  696. }
  697. });
  698. MWF.xApplication.ThreeMember.LogView.View = new Class({
  699. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  700. _createDocument: function (data, index) {
  701. return new MWF.xApplication.ThreeMember.LogView.Document(this.viewNode, data, this.explorer, this, null, index);
  702. },
  703. _getCurrentPageData: function (callback, count, pageNum) {
  704. this.clearBody();
  705. if (!count) count = 15;
  706. if (!pageNum) {
  707. if (this.pageNum) {
  708. pageNum = this.pageNum = this.pageNum + 1;
  709. } else {
  710. pageNum = this.pageNum = 1;
  711. }
  712. } else {
  713. this.pageNum = pageNum;
  714. }
  715. var filter = this.filterData || {};
  716. o2.Actions.load("x_auditlog_assemble_control").AuditLogAction.listPaging(pageNum, count, filter, function (json) {
  717. if (!json.data) json.data = [];
  718. if (!json.count) json.count = 0;
  719. if (callback) callback(json);
  720. }.bind(this))
  721. },
  722. _removeDocument: function (documentData, all) {
  723. },
  724. _create: function () {
  725. },
  726. _openDocument: function (documentData) {
  727. var form = new MWF.xApplication.ThreeMember.LogView.LogForm({app: this.app}, documentData );
  728. form.open();
  729. },
  730. _queryCreateViewNode: function () {
  731. },
  732. _postCreateViewNode: function (viewNode) {
  733. },
  734. _queryCreateViewHead: function () {
  735. },
  736. _postCreateViewHead: function (headNode) {
  737. }
  738. });
  739. MWF.xApplication.ThreeMember.LogView.Document = new Class({
  740. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  741. mouseoverDocument: function (itemNode, ev) {
  742. var removeNode = itemNode.getElements("[styles='removeNode']")[0];
  743. if (removeNode) removeNode.setStyle("opacity", 1)
  744. },
  745. mouseoutDocument: function (itemNode, ev) {
  746. var removeNode = itemNode.getElements("[styles='removeNode']")[0];
  747. if (removeNode) removeNode.setStyle("opacity", 0)
  748. },
  749. _queryCreateDocumentNode: function (itemData) {
  750. },
  751. _postCreateDocumentNode: function (itemNode, itemData) {
  752. //var iconNode = itemNode.getElements("[item='icon']")[0];
  753. //MWF.getJSON( this.view.pictureUrlHost + iconNode.get("picUrl"), function( json ){
  754. // iconNode.set("src", json.data.value);
  755. //} )
  756. },
  757. open: function () {
  758. this.view._openDocument(this.data);
  759. }
  760. });
  761. MWF.xApplication.ThreeMember.LogView.LogForm = new Class({
  762. Extends: MPopupForm,
  763. Implements: [Options, Events],
  764. options: {
  765. "style": "attendanceV2",
  766. "width": "800",
  767. "height": "700",
  768. "hasTop": true,
  769. "hasIcon": false,
  770. "hasTopIcon" : false,
  771. "hasTopContent" : false,
  772. "draggable": true,
  773. "maxAction" : true,
  774. "resizeable" : true,
  775. "closeAction": true,
  776. "title": MWF.xApplication.ThreeMember.LP.logDetail,
  777. "hideBottomWhenReading": true,
  778. "closeByClickMaskWhenReading": true,
  779. },
  780. _postLoad: function(){
  781. o2.Actions.load("x_auditlog_assemble_control").AuditLogAction.get(this.data.id, function (json) {
  782. this.data = json.data;
  783. if( this.data.sendData ){
  784. this.setSize( null, 700 );
  785. }else{
  786. this.setSize( null, 400 );
  787. }
  788. this._createTableContent_();
  789. }.bind(this))
  790. },
  791. _createTableContent: function(){},
  792. _createTableContent_: function () {
  793. var data = this.data;
  794. data.spendTime1 = data.spendTime+this.lp.millisecond;
  795. data.person1 = data.person.split("@")[0];
  796. this.formTableArea.set("html", this.getHtml());
  797. this.formTableContainer.setStyle("width","90%");
  798. MWF.xDesktop.requireApp("Template", "MForm", function () {
  799. this.form = new MForm(this.formTableArea, data, {
  800. isEdited: this.isEdited || this.isNew,
  801. style : "attendance",
  802. hasColon : true,
  803. itemTemplate: {
  804. person1: { text : this.lp.person, type : "innertext" },
  805. node: { text : this.lp.node, type : "innertext" },
  806. clientIp: { text : this.lp.clientIp, type : "innertext" },
  807. httpType: { text : this.lp.httpType, type : "innertext" },
  808. module: { text : this.lp.module, type : "innertext" },
  809. operation: { text : this.lp.operation, type : "innertext" },
  810. httpStatus: { text : this.lp.httpStatus, type : "innertext" },
  811. spendTime1: { text : this.lp.spendTime1, type : "innertext" },
  812. requestTime: { text : this.lp.requestTime, type : "innertext" },
  813. createTime: { text : this.lp.createTime, type : "innertext" },
  814. updateTime: { text : this.lp.updateTime, type : "innertext" },
  815. httpUrl: { text : this.lp.httpUrl, type : "innertext" },
  816. sendData1: { text : this.lp.sendData, type : "innertext" },
  817. }
  818. }, this.app);
  819. this.form.load();
  820. this.loadScriptEditor();
  821. }.bind(this), true);
  822. },
  823. getHtml : function(){
  824. return "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='table-layout:fixed;'>" +
  825. "<tr><td styles='formTableTitle' lable='person1' width='70' ></td>" +
  826. " <td styles='formTableValue' item='person1' width='200'></td>" +
  827. " <td styles='formTableTitle' lable='node' width='100'></td>" +
  828. " <td styles='formTableValue' item='node' width='200'></td></tr>" +
  829. "<tr><td styles='formTableTitle' lable='clientIp'></td>" +
  830. " <td styles='formTableValue' item='clientIp'></td>" +
  831. " <td styles='formTableTitle' lable='httpType'></td>" +
  832. " <td styles='formTableValue' item='httpType'></td></tr>" +
  833. "<tr><td styles='formTableTitle' lable='module'></td>" +
  834. " <td styles='formTableValue' item='module'></td>" +
  835. " <td styles='formTableTitle' lable='operation'></td>" +
  836. " <td styles='formTableValue' item='operation'></td></tr>" +
  837. "<tr><td styles='formTableTitle' lable='requestTime'></td>" +
  838. " <td styles='formTableValue' item='requestTime'></td>" +
  839. " <td styles='formTableTitle' lable='spendTime1'></td>" +
  840. " <td styles='formTableValue' item='spendTime1'></td></tr>" +
  841. "<tr><td styles='formTableTitle' lable='httpStatus'></td>" +
  842. " <td styles='formTableValue' item='httpStatus'></td>" +
  843. " <td styles='formTableTitle'></td>" +
  844. " <td styles='formTableValue'></td></tr>" +
  845. // "<tr><td styles='formTableTitle' lable='createTime'></td>" +
  846. // " <td styles='formTableValue' item='createTime'></td>" +
  847. // " <td styles='formTableTitle' lable='updateTime'></td>" +
  848. // " <td styles='formTableValue' item='updateTime'></td></tr>" +
  849. "<tr><td styles='formTableTitle' lable='httpUrl'></td>" +
  850. " <td styles='formTableValue' item='httpUrl' colspan='3'></td></tr>" +
  851. "<tr><td styles='formTableTitle' lable='sendData1'></td>" +
  852. " <td styles='formTableValue' item='sendData1' colspan='3'></td></tr>" +
  853. "</table>"+
  854. "<div item='sendData'></div>"
  855. },
  856. loadScriptEditor:function(){
  857. if( !this.data.sendData )return;
  858. MWF.require("MWF.widget.JavascriptEditor", null, false);
  859. var value;
  860. try{
  861. debugger;
  862. var json = JSON.parse(this.data.sendData);
  863. value = JSON.stringify(json, null, "\t");
  864. }catch (e) {}
  865. var sendDataNode = this.formTableContainer.getElement('[item="sendData"]');
  866. if( value ){
  867. this.scriptEditor = new MWF.widget.JavascriptEditor(sendDataNode, {
  868. "forceType": "ace",
  869. "option": {"value": value, "mode" : "json" }
  870. });
  871. this.scriptEditor.load(function(){
  872. this.scriptEditor.setValue(value);
  873. this.scriptEditor.editor.setReadOnly(true);
  874. this.addEvent("afterResize", function () {
  875. this.resizeScript();
  876. }.bind(this))
  877. this.addEvent("queryClose", function () {
  878. this.scriptEditor.destroy();
  879. }.bind(this))
  880. this.resizeScript();
  881. }.bind(this));
  882. }else{
  883. this.form.getItem("sendData1").container.set("text", this.data.sendData);
  884. sendDataNode.hide();
  885. }
  886. },
  887. resizeScript: function () {
  888. var size = this.formTableContainer.getSize();
  889. var tableSize = this.formTableContainer.getElement('table').getSize();
  890. this.formTableContainer.getElement('[item="sendData"]').setStyle("height", size.y - tableSize.y);
  891. if(this.scriptEditor && this.scriptEditor.editor)this.scriptEditor.editor.resize();
  892. }
  893. });
  894. MWF.xApplication.ThreeMember.LogView.ConfigNavi = new Class({
  895. Extends: MWF.xApplication.ThreeMember.LogView.Navi,
  896. load: function () {
  897. this.scrollNode = new Element("div.naviScrollNode", {"styles": this.css.naviScrollNode}).inject(this.node);
  898. this.areaNode = new Element("div.naviAreaNode", {"styles": this.css.naviAreaNode}).inject(this.scrollNode);
  899. this.configNode = new Element("div.naviViewNode", {
  900. "styles": this.css.naviViewNode,
  901. "text": this.explorer.lp.viewLog,
  902. "events": {
  903. "click": function () {
  904. this.explorer.toView();
  905. }.bind(this)
  906. }
  907. }).inject(this.node);
  908. new Element("div.naviViewIconNode", {
  909. "styles": this.css.naviViewIconNode
  910. }).inject(this.configNode, "top");
  911. this.createAllNode();
  912. this.configItemMap = {};
  913. o2.Actions.load("x_auditlog_assemble_control").AuditConfigAction.listModule(function (json) {
  914. this.moduleData = json.data.valueList;
  915. json.data.valueList.each(function (text) {
  916. this.createConfigItemNode(text);
  917. }.bind(this));
  918. this.setContentSize();
  919. this.setContentSizeFun = this.setContentSize.bind(this);
  920. this.app.addEvent("resize", this.setContentSizeFun);
  921. }.bind(this));
  922. },
  923. createAllNode: function () {
  924. var _self = this;
  925. this.naviAllNode = new Element("div.naviAllConfigNode", {
  926. "styles": this.css.naviAllConfigNode,
  927. "text": this.explorer.lp.allConfig
  928. }).inject(this.areaNode);
  929. this.naviAllNode.addEvents({
  930. "mouseover": function () {
  931. if (_self.currentAll != this) this.setStyles(_self.explorer.css.naviAllNode_over);
  932. },
  933. "mouseout": function () {
  934. if (_self.currentAll != this) this.setStyles(_self.explorer.css.naviAllNode_normal);
  935. },
  936. "click": function (ev) {
  937. _self.setCurrentAll();
  938. ev.stopPropagation();
  939. }
  940. });
  941. if (this.options.module === "all") {
  942. this.naviAllNode.click();
  943. }
  944. },
  945. setCurrentAll: function () {
  946. this.cancelCurrentConfig();
  947. this.currentStatus = null;
  948. this.currentAll = this.naviAllNode;
  949. this.naviAllNode.setStyles(this.css.naviAllNode_current);
  950. if (this.explorer.configForm) {
  951. // this.explorer.form.reset();
  952. if(this.explorer.options.filterModule){
  953. this.explorer.configForm.getItem("module").items[0].fireEvent("change");
  954. }
  955. }
  956. this.explorer.loadConfigView();
  957. },
  958. createConfigItemNode: function (text) {
  959. var _self = this;
  960. var configItemNode = new Element("div", {
  961. "styles": this.css.naviConfigItemNode,
  962. "text": text
  963. });
  964. this.configItemMap[text] = configItemNode;
  965. // var textNode = new Element("div", {
  966. // "styles": this.css.naviConfigItemTextNode,
  967. // "text": text
  968. // }).inject(configItemNode);
  969. configItemNode.inject(this.areaNode);
  970. var configItemObj = {
  971. "module": text,
  972. "collapse": true,
  973. "node": configItemNode
  974. };
  975. configItemNode.addEvents({
  976. "mouseover": function () {
  977. if (_self.currentConfigNode != this) this.setStyles(_self.explorer.css.naviConfigItemNode_over);
  978. },
  979. "mouseout": function () {
  980. if (_self.currentConfigNode != this) this.setStyles(_self.explorer.css.naviConfigItemNode);
  981. },
  982. "click": function (ev) {
  983. _self.setCurrentConfig(configItemObj);
  984. ev.stopPropagation();
  985. }
  986. });
  987. if (this.options.module === text) {
  988. configItemNode.click()
  989. }
  990. },
  991. destroy: function(){
  992. if(this.setContentSizeFun)this.app.removeEvent("resize", this.setContentSizeFun );
  993. this.scrollNode.destroy();
  994. },
  995. cancelCurrentConfig: function () {
  996. if (this.currentAll) {
  997. this.currentAll.setStyles(this.css.naviAllNode_normal);
  998. this.currentAll = false;
  999. }
  1000. if (this.currentConfigNode) {
  1001. this.currentConfigNode.setStyles(this.css.naviConfigItemNode);
  1002. this.currentConfigNode = false;
  1003. }
  1004. this.currentStatus = null;
  1005. },
  1006. setCurrentConfig: function (configItemObj) {
  1007. this.cancelCurrentConfig();
  1008. this.currentStatus = {
  1009. module: configItemObj.module
  1010. };
  1011. this.currentConfigNode = configItemObj.node;
  1012. configItemObj.node.setStyles(this.css.naviConfigItemNode_current);
  1013. // if(this.explorer.options.filterModule) {
  1014. // this.explorer.form.getItem("module").setValue(menuObj.module);
  1015. // this.explorer.form.getItem("module").items[0].fireEvent("change");
  1016. // }
  1017. this.explorer.loadConfigView({"module": configItemObj.module});
  1018. },
  1019. checkReload: function ( module ) {
  1020. if( this.moduleData.contains( module ) ){
  1021. if( this.currentStatus && this.currentStatus.module === module ){
  1022. }else{
  1023. this.configItemMap[module].click();
  1024. }
  1025. return false;
  1026. }else{
  1027. this.options.module = module;
  1028. this.reloadConfigItems();
  1029. return true;
  1030. }
  1031. },
  1032. reloadConfigItems: function () {
  1033. Object.each(this.configItemMap, function (item) {
  1034. item.destroy();
  1035. });
  1036. this.configItemMap = {};
  1037. o2.Actions.load("x_auditlog_assemble_control").AuditConfigAction.listModule(function (json) {
  1038. this.moduleData = json.data.valueList;
  1039. json.data.valueList.each(function (text) {
  1040. this.createConfigItemNode(text);
  1041. }.bind(this));
  1042. }.bind(this));
  1043. }
  1044. });
  1045. MWF.xApplication.ThreeMember.LogView.ConfigView = new Class({
  1046. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  1047. _createDocument: function (data, index) {
  1048. return new MWF.xApplication.ThreeMember.LogView.ConfigDocument(this.viewNode, data, this.explorer, this, null, index);
  1049. },
  1050. _getCurrentPageData: function (callback, count, pageNum) {
  1051. this.clearBody();
  1052. if (!count) count = 15;
  1053. if (!pageNum) {
  1054. if (this.pageNum) {
  1055. pageNum = this.pageNum = this.pageNum + 1;
  1056. } else {
  1057. pageNum = this.pageNum = 1;
  1058. }
  1059. } else {
  1060. this.pageNum = pageNum;
  1061. }
  1062. var filter = this.filterData || {};
  1063. o2.Actions.load("x_auditlog_assemble_control").AuditConfigAction.listPaging(pageNum, count, filter, function (json) {
  1064. if (!json.data) json.data = [];
  1065. if (!json.count) json.count = 0;
  1066. if (callback) callback(json);
  1067. }.bind(this))
  1068. },
  1069. _removeDocument: function (documentData, all) {
  1070. var id = documentData.id;
  1071. o2.Actions.load("x_auditlog_assemble_control").AuditConfigAction.delete(documentData.id, function (json) {
  1072. this.items.erase(this.documents[id]);
  1073. this.documents[id].destroy();
  1074. MWF.release(this.documents[id]);
  1075. delete this.documents[id];
  1076. this.app.notice(this.app.lp.deleteConfigOK, "success");
  1077. }.bind(this))
  1078. },
  1079. _create: function () {
  1080. var form = new MWF.xApplication.ThreeMember.LogView.ConfigForm({app: this.app, view:this}, {} );
  1081. form.create();
  1082. },
  1083. _openDocument: function (documentData) {
  1084. var form = new MWF.xApplication.ThreeMember.LogView.ConfigForm({app: this.app, view:this}, documentData );
  1085. form.edit();
  1086. },
  1087. _queryCreateViewNode: function () {
  1088. },
  1089. _postCreateViewNode: function (viewNode) {
  1090. },
  1091. _queryCreateViewHead: function () {
  1092. },
  1093. _postCreateViewHead: function (headNode) {
  1094. }
  1095. });
  1096. MWF.xApplication.ThreeMember.LogView.ConfigDocument = new Class({
  1097. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  1098. mouseoverDocument: function (itemNode, ev) {
  1099. var removeNode = itemNode.getElements("[styles='removeNode']")[0];
  1100. if (removeNode) removeNode.setStyle("opacity", 1)
  1101. },
  1102. mouseoutDocument: function (itemNode, ev) {
  1103. var removeNode = itemNode.getElements("[styles='removeNode']")[0];
  1104. if (removeNode) removeNode.setStyle("opacity", 0)
  1105. },
  1106. _queryCreateDocumentNode: function (itemData) {
  1107. },
  1108. _postCreateDocumentNode: function (itemNode, itemData) {
  1109. //var iconNode = itemNode.getElements("[item='icon']")[0];
  1110. //MWF.getJSON( this.view.pictureUrlHost + iconNode.get("picUrl"), function( json ){
  1111. // iconNode.set("src", json.data.value);
  1112. //} )
  1113. },
  1114. open: function () {
  1115. this.view._openDocument(this.data);
  1116. },
  1117. remove: function (e) {
  1118. var lp = this.lp || this.view.lp || this.app.lp;
  1119. var text = lp.deleteConfigText.replace(/{title}/g, this.data.title);
  1120. var _self = this;
  1121. this.node.setStyles(this.css.documentNode_remove);
  1122. this.readyRemove = true;
  1123. this.view.lockNodeStyle = true;
  1124. this.app.confirm("warn", e, lp.deleteConfig, text, 350, 120, function () {
  1125. _self.view._removeDocument(_self.data, false);
  1126. _self.view.lockNodeStyle = false;
  1127. this.close();
  1128. }, function () {
  1129. _self.node.setStyles(_self.css.documentNode);
  1130. _self.readyRemove = false;
  1131. _self.view.lockNodeStyle = false;
  1132. this.close();
  1133. });
  1134. },
  1135. });
  1136. MWF.xApplication.ThreeMember.LogView.ConfigForm = new Class({
  1137. Extends: MPopupForm,
  1138. Implements: [Options, Events],
  1139. options: {
  1140. "style": "attendanceV2",
  1141. "width": "800",
  1142. "height": "700",
  1143. "hasTop": true,
  1144. "hasIcon": false,
  1145. "hasTopIcon" : false,
  1146. "hasTopContent" : false,
  1147. "draggable": true,
  1148. "maxAction" : true,
  1149. "resizeable" : true,
  1150. "closeAction": true,
  1151. "title": MWF.xApplication.ThreeMember.LP.configDetail,
  1152. "hideBottomWhenReading": true,
  1153. "closeByClickMaskWhenReading": true,
  1154. "buttonList": [{ "type":"ok" }, { "type":"cancel" }]
  1155. },
  1156. _postLoad: function(){
  1157. if( this.data.id ){
  1158. o2.Actions.load("x_auditlog_assemble_control").AuditConfigAction.get(this.data.id, function (json) {
  1159. this.data = json.data;
  1160. this._createTableContent_();
  1161. }.bind(this))
  1162. }else{
  1163. this._createTableContent_();
  1164. }
  1165. },
  1166. _createTableContent: function(){},
  1167. _createTableContent_: function () {
  1168. var data = this.data;
  1169. this.formTableArea.set("html", this.getHtml());
  1170. this.formTableContainer.setStyle("width","90%");
  1171. var contextText = [""], contextValue = [""];
  1172. Object.each(layout.serviceAddressList, function (value, key) {
  1173. contextText.push( value.name + "(" + key +")" );
  1174. contextValue.push( key );
  1175. });
  1176. var context = "";
  1177. if( this.data.matchUrl ){
  1178. context = this.data.matchUrl.split("/")[1] || "";
  1179. }
  1180. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1181. this.form = new MForm(this.formTableArea, data, {
  1182. isEdited: this.isEdited || this.isNew,
  1183. style : "attendance",
  1184. hasColon : true,
  1185. itemTemplate: {
  1186. context: { text : this.lp.moduleSelect, type : "select", selectValue: contextValue, selectText: contextText, value: context, event:{
  1187. change: function () {
  1188. this.setActionSelect()
  1189. }.bind(this)
  1190. }},
  1191. action: {"text": this.lp.actionSelect, type:"select", event:{
  1192. change: function () {
  1193. this.setMethodSelect()
  1194. }.bind(this)
  1195. }},
  1196. method: {"text": this.lp.methodSelect, type:"select", event:{
  1197. change: function (item, ev) {
  1198. debugger;
  1199. var v = item.getValue();
  1200. if( v.contains("||") ){
  1201. var vs = v.split("||");
  1202. this.form.getItem("httpType").setValue(vs[0]);
  1203. var url = "/"+ this.form.getItem("context").getValue() + "/"+ vs[1];
  1204. this.form.getItem("matchUrl").setValue( url );
  1205. }else{
  1206. this.form.getItem("httpType").setValue("");
  1207. this.form.getItem("matchUrl").setValue( "" );
  1208. }
  1209. }.bind(this)
  1210. }},
  1211. module: { text : this.lp.module, notEmpty: true },
  1212. operation: { text : this.lp.operation, type : "text", notEmpty: true },
  1213. httpType: { text : this.lp.httpType, type : "select", selectValue: ["", "GET","POST","PUT","DELETE"] , notEmpty: true},
  1214. status: { text : this.lp.httpStatus, type : "select", selectValue: ["true", "false"], selectText:["启用","禁用"], notEmpty: true, value: this.data.status === false ? "false": "true" },
  1215. matchUrl: { text : this.lp.httpUrl, notEmpty: true },
  1216. }
  1217. }, this.app);
  1218. this.form.load();
  1219. //this.loadScriptEditor();
  1220. this.setActionSelect();
  1221. this.setMethodSelect();
  1222. }.bind(this), true);
  1223. },
  1224. setActionSelect: function(){
  1225. var root = this.form.getItem("context").getValue();
  1226. if( root ){
  1227. var json = this.getApi( root );
  1228. var selectValue = json.map(function (j) {
  1229. return j.name;
  1230. });
  1231. this.form.getItem("action").resetItemOptions( [""].concat(selectValue) );
  1232. }else{
  1233. this.form.getItem("action").resetItemOptions( [] );
  1234. }
  1235. this.form.getItem("method").resetItemOptions( [] );
  1236. },
  1237. setMethodSelect: function(){
  1238. var root = this.form.getItem("context").getValue();
  1239. var action = this.form.getItem("action").getValue();
  1240. if( root && action ){
  1241. var json = this.getApi( root );
  1242. var texts = [""];
  1243. var values = [""];
  1244. json.each(function (j) {
  1245. if( j.name === action ){
  1246. j.methods.each(function (m) {
  1247. texts.push(m.name);
  1248. values.push( m.method + "||" + m.uri.replace( /{[^}]+}/g, "*"));
  1249. debugger;
  1250. });
  1251. }
  1252. });
  1253. this.form.getItem("method").resetItemOptions( values, texts );
  1254. }else{
  1255. this.form.getItem("method").resetItemOptions( [] );
  1256. }
  1257. },
  1258. getApi: function( root ){
  1259. if( !this.loadedActions )this.loadedActions = {};
  1260. if (this.loadedActions[root]) return this.loadedActions[root];
  1261. //if (MWF.Actions.loadedActions[root]) return MWF.Actions.loadedActions[root];
  1262. var jaxrs = null;
  1263. var url = MWF.Actions.getHost(root)+"/"+root+"/describe/api.json";
  1264. MWF.getJSON(url, function(json){jaxrs = json.jaxrs;}.bind(this), false, false, false);
  1265. this.loadedActions[root] = jaxrs;
  1266. return jaxrs;
  1267. },
  1268. getHtml : function(){
  1269. return "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='table-layout:fixed;'>" +
  1270. "<tr><td styles='formTableTitle' lable='context' width='70' ></td>" +
  1271. " <td styles='formTableValue' item='context' colspan='3'></td>" +
  1272. "<tr><td styles='formTableTitle' lable='action' width='70' ></td>" +
  1273. " <td styles='formTableValue' item='action' width='200'></td>" +
  1274. " <td styles='formTableTitleRight' lable='method' width='100'></td>" +
  1275. " <td styles='formTableValue' item='method' width='200'></td></tr>" +
  1276. "<tr><td styles='formTableTitle' width='70' ></td>" +
  1277. " <td styles='formTableValue' colspan='3'>"+this.lp.selectNote+"</td>" +
  1278. "<tr><td styles='formTableTitle' lable='module'></td>" +
  1279. " <td styles='formTableValue' item='module'></td>" +
  1280. " <td styles='formTableTitleRight' lable='operation'></td>" +
  1281. " <td styles='formTableValue' item='operation'></td></tr>" +
  1282. "<tr><td styles='formTableTitle' lable='httpType'></td>" +
  1283. " <td styles='formTableValue' item='httpType'></td>" +
  1284. " <td styles='formTableTitleRight' lable='status'></td>" +
  1285. " <td styles='formTableValue' item='status'></td></tr>" +
  1286. "<tr><td styles='formTableTitle' lable='matchUrl'></td>" +
  1287. " <td styles='formTableValue' item='matchUrl' colspan='3'></td></tr>" +
  1288. "</table>";
  1289. },
  1290. _ok: function (data, callback) {
  1291. debugger;
  1292. this.data.status = this.data.status !== "false";
  1293. if( this.data.id ){
  1294. o2.Actions.load("x_auditlog_assemble_control").AuditConfigAction.update( this.data.id, data, function(json){
  1295. if( callback )callback(json);
  1296. }.bind(this), function( errorObj ){
  1297. var error = JSON.parse( errorObj.responseText );
  1298. this.app.notice( error.message, error );
  1299. }.bind(this));
  1300. }else{
  1301. o2.Actions.load("x_auditlog_assemble_control").AuditConfigAction.save( data, function(json){
  1302. //this.explorer.view = null;
  1303. debugger;
  1304. if( this.explorer.view.explorer.navi.checkReload( data.module ) ){
  1305. this.explorer.view = null;
  1306. }
  1307. if( callback )callback(json);
  1308. }.bind(this), function( errorObj ){
  1309. var error = JSON.parse( errorObj.responseText );
  1310. this.app.notice( error.message, error );
  1311. }.bind(this));
  1312. }
  1313. }
  1314. // loadScriptEditor:function(){
  1315. // if( !this.data.sendData )return;
  1316. // MWF.require("MWF.widget.JavascriptEditor", null, false);
  1317. // var value;
  1318. // try{
  1319. // debugger;
  1320. // var json = JSON.parse(this.data.sendData);
  1321. // value = JSON.stringify(json, null, "\t");
  1322. // }catch (e) {}
  1323. //
  1324. // var sendDataNode = this.formTableContainer.getElement('[item="sendData"]');
  1325. // if( value ){
  1326. // this.scriptEditor = new MWF.widget.JavascriptEditor(sendDataNode, {
  1327. // "forceType": "ace",
  1328. // "option": {"value": value, "mode" : "json" }
  1329. // });
  1330. // this.scriptEditor.load(function(){
  1331. // this.scriptEditor.setValue(value);
  1332. // this.scriptEditor.editor.setReadOnly(true);
  1333. // this.addEvent("afterResize", function () {
  1334. // this.resizeScript();
  1335. // }.bind(this))
  1336. // this.addEvent("queryClose", function () {
  1337. // this.scriptEditor.destroy();
  1338. // }.bind(this))
  1339. // this.resizeScript();
  1340. // }.bind(this));
  1341. // }else{
  1342. // this.form.getItem("sendData1").container.set("text", this.data.sendData);
  1343. // sendDataNode.hide();
  1344. // }
  1345. // },
  1346. // resizeScript: function () {
  1347. // var size = this.formTableContainer.getSize();
  1348. // var tableSize = this.formTableContainer.getElement('table').getSize();
  1349. // this.formTableContainer.getElement('[item="sendData"]').setStyle("height", size.y - tableSize.y);
  1350. // if(this.scriptEditor && this.scriptEditor.editor)this.scriptEditor.editor.resize();
  1351. // }
  1352. });
  1353. var getDateDiff = function (publishTime) {
  1354. if (!publishTime) return "";
  1355. var dateTimeStamp = Date.parse(publishTime.replace(/-/gi, "/"));
  1356. var minute = 1000 * 60;
  1357. var hour = minute * 60;
  1358. var day = hour * 24;
  1359. var halfamonth = day * 15;
  1360. var month = day * 30;
  1361. var year = month * 12;
  1362. var now = new Date().getTime();
  1363. var diffValue = now - dateTimeStamp;
  1364. if (diffValue < 0) {
  1365. //若日期不符则弹出窗口告之
  1366. //alert("结束日期不能小于开始日期!");
  1367. }
  1368. var yesterday = new Date().decrement('day', 1);
  1369. var beforYesterday = new Date().decrement('day', 2);
  1370. var yearC = diffValue / year;
  1371. var monthC = diffValue / month;
  1372. var weekC = diffValue / (7 * day);
  1373. var dayC = diffValue / day;
  1374. var hourC = diffValue / hour;
  1375. var minC = diffValue / minute;
  1376. if (yesterday.getFullYear() == dateTimeStamp.getFullYear() && yesterday.getMonth() == dateTimeStamp.getMonth() && yesterday.getDate() == dateTimeStamp.getDate()) {
  1377. result = MWF.xApplication.ThreeMember.LP.yesterday + " " + dateTimeStamp.getHours() + ":" + dateTimeStamp.getMinutes();
  1378. } else if (beforYesterday.getFullYear() == dateTimeStamp.getFullYear() && beforYesterday.getMonth() == dateTimeStamp.getMonth() && beforYesterday.getDate() == dateTimeStamp.getDate()) {
  1379. result = MWF.xApplication.ThreeMember.LP.twoDaysAgo + " " + dateTimeStamp.getHours() + ":" + dateTimeStamp.getMinutes();
  1380. } else if (yearC > 1) {
  1381. result = dateTimeStamp.getFullYear() + "-" + (dateTimeStamp.getMonth() + 1) + "-" + dateTimeStamp.getDate();
  1382. } else if (monthC >= 1) {
  1383. //result= parseInt(monthC) + "个月前";
  1384. // s.getFullYear()+"年";
  1385. result = dateTimeStamp.getFullYear() + "-" + (dateTimeStamp.getMonth() + 1) + "-" + dateTimeStamp.getDate();
  1386. } else if (weekC >= 1) {
  1387. result = parseInt(weekC) + MWF.xApplication.ThreeMember.LP.weekAgo;
  1388. } else if (dayC >= 1) {
  1389. result = parseInt(dayC) + MWF.xApplication.ThreeMember.LP.dayAgo;
  1390. } else if (hourC >= 1) {
  1391. result = parseInt(hourC) + MWF.xApplication.ThreeMember.LP.hourAgo;
  1392. } else if (minC >= 1) {
  1393. result = parseInt(minC) + MWF.xApplication.ThreeMember.LP.minuteAgo;
  1394. } else
  1395. result = MWF.xApplication.ThreeMember.LP.publishJustNow;
  1396. return result;
  1397. };