PeopleDingdingDetail.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. MWF.xDesktop.requireApp("Attendance", "Explorer", null, false);
  2. MWF.xDesktop.requireApp("Selector", "package", null, false);
  3. MWF.xApplication.Attendance.PeopleDingdingDetail = new Class({
  4. Extends: MWF.widget.Common,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default"
  8. },
  9. initialize: function (node, app, actions, options) {
  10. this.setOptions(options);
  11. this.app = app;
  12. this.path = "../x_component_Attendance/$PeopleDetail/";
  13. this.cssPath = "../x_component_Attendance/$PeopleDetail/" + this.options.style + "/css.wcss";
  14. this._loadCss();
  15. this.actions = actions;
  16. this.node = $(node);
  17. },
  18. load: function () {
  19. this.loadTab();
  20. },
  21. loadTab: function () {
  22. this.tabNode = new Element("div", { "styles": this.css.tabNode }).inject(this.node);
  23. this.detailArea = new Element("div", { "styles": this.css.tabPageContainer }).inject(this.tabNode);
  24. //this.selfHolidayArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode)
  25. this.detailStaticArea = new Element("div", { "styles": this.css.tabPageContainer }).inject(this.tabNode);
  26. //this.selfHolidayStaticArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode)
  27. MWF.require("MWF.widget.Tab", function () {
  28. this.tabs = new MWF.widget.Tab(this.tabNode, { "style": "attendance" });
  29. this.tabs.load();
  30. this.detailPage = this.tabs.addTab(this.detailArea, this.app.lp.personSigninDetail, false);
  31. this.detailPage.contentNodeArea.set("class", "detailPage");
  32. this.detailPage.addEvent("show", function () {
  33. this.detailPage.tabNode.addClass( "mainColor_border" );
  34. this.detailPage.textNode.addClass( "mainColor_color" );
  35. if (!this.detailExplorer) {
  36. this.detailExplorer = new MWF.xApplication.Attendance.PeopleDingdingDetail.Explorer(this.detailArea, this);
  37. this.detailExplorer.load();
  38. }
  39. }.bind(this)).addEvent("hide", function(){
  40. this.detailPage.tabNode.removeClass( "mainColor_border" );
  41. this.detailPage.textNode.removeClass( "mainColor_color" );
  42. }.bind(this));
  43. this.detailStaticPage = this.tabs.addTab(this.detailStaticArea, this.app.lp.personSigninStatic, false);
  44. this.detailStaticPage.contentNodeArea.set("class", "detailStaticPage");
  45. this.detailStaticPage.addEvent("show", function () {
  46. this.detailStaticPage.tabNode.addClass( "mainColor_border" );
  47. this.detailStaticPage.textNode.addClass( "mainColor_color" );
  48. if (!this.detailStaticExplorer) {
  49. this.detailStaticExplorer = new MWF.xApplication.Attendance.PeopleDingdingDetail.DetailStaticExplorer(this.detailStaticArea, this);
  50. this.detailStaticExplorer.load();
  51. }
  52. }.bind(this)).addEvent("hide", function(){
  53. this.detailStaticPage.tabNode.removeClass( "mainColor_border" );
  54. this.detailStaticPage.textNode.removeClass( "mainColor_color" );
  55. }.bind(this));
  56. this.tabs.pages[0].showTab();
  57. }.bind(this));
  58. }
  59. });
  60. MWF.xApplication.Attendance.PeopleDingdingDetail.Explorer = new Class({
  61. Extends: MWF.xApplication.Attendance.Explorer,
  62. Implements: [Options, Events],
  63. initialize: function (node, parent, options) {
  64. this.setOptions(options);
  65. this.parent = parent;
  66. this.app = parent.app;
  67. this.css = parent.css;
  68. this.path = parent.path;
  69. this.actions = parent.actions;
  70. this.node = $(node);
  71. this.initData();
  72. if (!this.peopleActions) this.peopleActions = new MWF.xAction.org.express.RestActions();
  73. },
  74. initData: function () {
  75. this.toolItemNodes = [];
  76. },
  77. reload: function () {
  78. this.node.empty();
  79. this.load();
  80. },
  81. load: function () {
  82. this.loadFilter();
  83. this.loadContentNode();
  84. this.loadView({}, true);
  85. this.setNodeScroll();
  86. },
  87. loadFilter: function () {
  88. var lp = MWF.xApplication.Attendance.LP;
  89. this.fileterNode = new Element("div.fileterNode", {
  90. "styles": this.app.css.fileterNode
  91. }).inject(this.node);
  92. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='filterTable' style='width: 1000px;'>" +
  93. "<tr>" +
  94. " <td styles='filterTableValue' lable='person'></td>" +
  95. " <td styles='filterTableTitle' item='person'></td>" +
  96. " <td styles='filterTableTitle' lable='year'></td>" +
  97. " <td styles='filterTableValue' item='year'></td>" +
  98. " <td styles='filterTableTitle' lable='month'></td>" +
  99. " <td styles='filterTableValue' item='month'></td>" +
  100. " <td styles='filterTableTitle' lable='day'></td>" +
  101. " <td styles='filterTableValue' item='day'></td>" +
  102. " <td styles='filterTableTitle' lable='checkType'></td>" +
  103. " <td styles='filterTableValue' item='checkType'></td>" +
  104. " <td styles='filterTableTitle' lable='timeResult'></td>" +
  105. " <td styles='filterTableValue' item='timeResult'></td>" +
  106. " <td styles='filterTableValue' item='action'></td>" +
  107. "</tr>" +
  108. "</table>";
  109. this.fileterNode.set("html", html);
  110. MWF.xDesktop.requireApp("Template", "MForm", function () {
  111. var empSelector = { text : lp.person, type : "org", orgType : "person", notEmpty : true, style : {"min-width": "100px" } };
  112. if( !this.app.isAdmin() && this.app.manageUnits ){
  113. empSelector = { text : lp.person, type : "org", orgType : "identity", "units": this.app.manageUnits, orgOptions: {
  114. "resultType": "person",
  115. } , notEmpty : true, style : {"min-width": "100px" } };
  116. }
  117. this.form = new MForm(this.fileterNode, {}, {
  118. style: "attendance",
  119. isEdited: true,
  120. itemTemplate: {
  121. person: empSelector,
  122. year: {
  123. text: lp.annuaal,
  124. "type": "select",
  125. "selectValue": function () {
  126. var years = [];
  127. var year = new Date().getFullYear();
  128. for (var i = 0; i < 6; i++) {
  129. years.push(year--);
  130. }
  131. return years;
  132. },
  133. "event": {
  134. "change": function (item, ev) {
  135. var values = this.getDateSelectValue();
  136. item.form.getItem("day").resetItemOptions(values, values)
  137. }.bind(this)
  138. }
  139. },
  140. month: {
  141. text: lp.months,
  142. "type": "select",
  143. "defaultValue": function () {
  144. var month = (new Date().getMonth() + 1).toString();
  145. return month.length == 1 ? "0" + month : month;
  146. },
  147. "selectValue": ["", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"],
  148. "event": {
  149. "change": function (item, ev) {
  150. var values = this.getDateSelectValue();
  151. item.form.getItem("day").resetItemOptions(values, values)
  152. }.bind(this)
  153. }
  154. },
  155. day: { text: lp.date, "type": "select", "selectValue": this.getDateSelectValue.bind(this) },
  156. checkType: { text: lp.signinType, "type": "select", "selectValue": ["", "OnDuty", "OffDuty"], "selectText": lp.signinTypeSelectText },
  157. timeResult: { text: lp.signinResult, "type": "select", "selectValue": ["", "Normal", "Early", "Late", "SeriousLate", "Absenteeism", "NotSigned"], "selectText": lp.signinResultSelectText },
  158. action: {
  159. "value": lp.query, type: "button", className: "filterButton", clazz:"mainColor_bg", event: {
  160. click: function () {
  161. var result = this.form.getResult(true, ",", true, true, false);
  162. if (!result) return;
  163. if (result.day && result.day != "") {
  164. result.q_date = result.year + "-" + result.month + "-" + result.day;
  165. }
  166. this.loadView(result);
  167. }.bind(this)
  168. }
  169. }
  170. }
  171. }, this.app, this.app.css);
  172. this.form.load();
  173. }.bind(this), true);
  174. },
  175. getDateSelectValue: function () {
  176. if (this.form) {
  177. var year = parseInt(this.form.getItem("year").getValue());
  178. var month = parseInt(this.form.getItem("month").getValue()) - 1;
  179. } else {
  180. var year = (new Date()).getFullYear();
  181. var month = (new Date()).getMonth();
  182. }
  183. var date = new Date(year, month, 1);
  184. var days = [];
  185. days.push("");
  186. while (date.getMonth() === month) {
  187. var d = date.getDate().toString();
  188. if (d.length == 1) d = "0" + d;
  189. days.push(d);
  190. date.setDate(date.getDate() + 1);
  191. }
  192. return days;
  193. },
  194. loadContentNode: function () {
  195. this.elementContentNode = new Element("div", {
  196. "styles": this.css.elementContentNode
  197. }).inject(this.node);
  198. this.app.addEvent("resize", function () { this.setContentSize(); }.bind(this));
  199. this.elementContentNode.addEvent("scroll", function () {
  200. var scroll = this.elementContentNode.getScroll();
  201. if(this.fileterNode)this.fileterNode.scrollTo(scroll.x);
  202. }.bind(this));
  203. },
  204. loadView: function (filterData, onlyShowTitle) {
  205. this.elementContentNode.empty();
  206. if (this.view) delete this.view;
  207. this.view = new MWF.xApplication.Attendance.PeopleDingdingDetail.View(this.elementContentNode, this.app, this);
  208. this.view.filterData = filterData;
  209. this.view.listItemUrl = this.path + "listItem_dingding.json";
  210. this.view.load( onlyShowTitle );
  211. this.setContentSize();
  212. },
  213. setContentSize: function () {
  214. var tabNodeSize = this.parent.tabs ? this.parent.tabs.tabNodeContainer.getSize() : { "x": 0, "y": 0 };
  215. var fileterNodeSize = this.fileterNode ? this.fileterNode.getSize() : { "x": 0, "y": 0 };
  216. var nodeSize = this.parent.node.getSize();
  217. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  218. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  219. //var filterSize = this.filterNode.getSize();
  220. var height = nodeSize.y - tabNodeSize.y - pt - pb - fileterNodeSize.y - 20;
  221. this.elementContentNode.setStyle("height", "" + height + "px");
  222. this.pageCount = (height / 40).toInt() + 5;
  223. if (this.view && this.view.items.length < this.pageCount) {
  224. this.view.loadElementList(this.pageCount - this.view.items.length);
  225. }
  226. }
  227. });
  228. MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHoliday = new Class({
  229. Extends: MWF.xApplication.Attendance.PeopleDingdingDetail.Explorer,
  230. loadView: function (filterData) {
  231. this.elementContentNode.empty();
  232. if (this.view) delete this.view;
  233. this.view = new MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayView(this.elementContentNode, this.app, this);
  234. this.view.filterData = filterData;
  235. this.view.load();
  236. this.setContentSize();
  237. }
  238. });
  239. MWF.xApplication.Attendance.PeopleDingdingDetail.DetailStaticExplorer = new Class({
  240. Extends: MWF.xApplication.Attendance.PeopleDingdingDetail.Explorer,
  241. loadFilter: function () {
  242. var lp = MWF.xApplication.Attendance.LP;
  243. this.fileterNode = new Element("div.fileterNode", {
  244. "styles": this.app.css.fileterNode
  245. }).inject(this.node);
  246. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' style='width: 560px;font-size: 14px;color:#666'>" +
  247. "<tr>" +
  248. " <td styles='filterTableValue' lable='q_empName'></td>" +
  249. " <td styles='filterTableTitle' item='q_empName'></td>" +
  250. " <td styles='filterTableTitle' lable='cycleYear'></td>" +
  251. " <td styles='filterTableValue' item='cycleYear'></td>" +
  252. " <td styles='filterTableTitle' lable='cycleMonth'></td>" +
  253. " <td styles='filterTableValue' item='cycleMonth'></td>" +
  254. " <td styles='filterTableValue' item='action'></td>" +
  255. "</tr>" +
  256. "</table>";
  257. this.fileterNode.set("html", html);
  258. MWF.xDesktop.requireApp("Template", "MForm", function () {
  259. var empSelector = { text : lp.person, type : "org", orgType : "person", notEmpty : true, style : {"min-width": "100px" } };
  260. if( !this.app.isAdmin() && this.app.manageUnits ){
  261. empSelector = { text : lp.person, type : "org", orgType : "identity", "units": this.app.manageUnits, orgOptions: {
  262. "resultType": "person",
  263. } , notEmpty : true, style : {"min-width": "100px" } };
  264. }
  265. this.form = new MForm(this.fileterNode, {}, {
  266. style: "attendance",
  267. isEdited: true,
  268. itemTemplate: {
  269. q_empName: empSelector,
  270. cycleYear: {
  271. text: lp.annuaal,
  272. "type": "select",
  273. "selectValue": function () {
  274. var years = [];
  275. var year = new Date().getFullYear();
  276. for (var i = 0; i < 6; i++) {
  277. years.push(year--);
  278. }
  279. return years;
  280. }
  281. },
  282. cycleMonth: {
  283. text: lp.months,
  284. "type": "select",
  285. "defaultValue": function () {
  286. var month = (new Date().getMonth() + 1).toString();
  287. return month.length == 1 ? "0" + month : month;
  288. },
  289. "selectValue": ["", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]
  290. },
  291. action: {
  292. "value": lp.query, type: "button", className: "filterButton", clazz:"mainColor_bg", event: {
  293. click: function () {
  294. var result = this.form.getResult(true, ",", true, true, false);
  295. if (!result) return;
  296. this.loadView(result);
  297. }.bind(this)
  298. }
  299. }
  300. }
  301. }, this.app, this.app.css);
  302. this.form.load();
  303. }.bind(this), true);
  304. },
  305. loadView: function (filterData) {
  306. this.elementContentNode.empty();
  307. if (this.view) delete this.view;
  308. this.view = new MWF.xApplication.Attendance.PeopleDingdingDetail.DetailStaticView(this.elementContentNode, this.app, this);
  309. this.view.filterData = filterData;
  310. this.view.listItemUrl = this.path + "listItem_dingding_detailStatic.json";
  311. this.view.load();
  312. this.setContentSize();
  313. }
  314. });
  315. MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayStaticExplorer = new Class({
  316. Extends: MWF.xApplication.Attendance.PeopleDingdingDetail.Explorer,
  317. loadView: function (filterData) {
  318. this.elementContentNode.empty();
  319. if (this.view) delete this.view;
  320. this.view = new MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayStaticView(this.elementContentNode, this.app, this);
  321. this.view.filterData = filterData;
  322. this.view.load();
  323. this.setContentSize();
  324. }
  325. });
  326. MWF.xApplication.Attendance.PeopleDingdingDetail.View = new Class({
  327. Extends: MWF.xApplication.Attendance.Explorer.View,
  328. _createItem: function (data) {
  329. return new MWF.xApplication.Attendance.PeopleDingdingDetail.Document(this.table, data, this.explorer, this);
  330. },
  331. _getCurrentPageData: function (callback, count) {
  332. if (!count) count = 20;
  333. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  334. var filter = this.filterData || {};
  335. var action = o2.Actions.load("x_attendance_assemble_control");
  336. action.DingdingAttendanceAction.listNextDingdingAttendance(id, count, filter, function (json) {
  337. if (callback) callback(json);
  338. }.bind(this));
  339. },
  340. _removeDocument: function (documentData, all) {
  341. },
  342. _createDocument: function () {
  343. },
  344. _openDocument: function (documentData) {
  345. }
  346. });
  347. MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayView = new Class({
  348. Extends: MWF.xApplication.Attendance.Explorer.View,
  349. _createItem: function (data) {
  350. return new MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayDocument(this.table, data, this.explorer, this);
  351. },
  352. _getCurrentPageData: function (callback, count) {
  353. var filter = this.filterData || {};
  354. this.actions.listDetailFilter(filter, function (json) {
  355. if (callback) callback(json);
  356. }.bind(this))
  357. },
  358. _removeDocument: function (documentData, all) {
  359. },
  360. _createDocument: function () {
  361. },
  362. _openDocument: function (documentData) {
  363. }
  364. });
  365. MWF.xApplication.Attendance.PeopleDingdingDetail.DetailStaticView = new Class({
  366. Extends: MWF.xApplication.Attendance.Explorer.View,
  367. _createItem: function (data) {
  368. return new MWF.xApplication.Attendance.PeopleDingdingDetail.DetailStaticDocument(this.table, data, this.explorer, this);
  369. },
  370. _getCurrentPageData: function (callback, count) {
  371. var filter = this.filterData || {};
  372. var action = o2.Actions.load("x_attendance_assemble_control");
  373. action.DingdingAttendanceStatisticAction.personMonth(filter.q_empName, filter.cycleYear, filter.cycleMonth, function (json) {
  374. // var data = json.data;
  375. // data.sort(function (a, b) {
  376. // return parseInt(b.statisticYear + b.statisticMonth) - parseInt(a.statisticYear + a.statisticMonth)
  377. // });
  378. // json.data = data;
  379. if (callback) callback(json);
  380. }.bind(this))
  381. },
  382. _removeDocument: function (documentData, all) {
  383. },
  384. _createDocument: function () {
  385. },
  386. _openDocument: function (documentData) {
  387. }
  388. });
  389. MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayStaticView = new Class({
  390. Extends: MWF.xApplication.Attendance.Explorer.View,
  391. _createItem: function (data) {
  392. return new MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayStaticDocument(this.table, data, this.explorer, this);
  393. },
  394. _getCurrentPageData: function (callback, count) {
  395. var filter = this.filterData || {};
  396. this.actions.listDetailFilter(filter, function (json) {
  397. if (callback) callback(json);
  398. }.bind(this))
  399. },
  400. _removeDocument: function (documentData, all) {
  401. },
  402. _createDocument: function () {
  403. },
  404. _openDocument: function (documentData) {
  405. }
  406. });
  407. MWF.xApplication.Attendance.PeopleDingdingDetail.Document = new Class({
  408. Extends: MWF.xApplication.Attendance.Explorer.Document
  409. });
  410. MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayDocument = new Class({
  411. Extends: MWF.xApplication.Attendance.Explorer.Document
  412. });
  413. MWF.xApplication.Attendance.PeopleDingdingDetail.DetailStaticDocument = new Class({
  414. Extends: MWF.xApplication.Attendance.Explorer.Document
  415. });
  416. MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayStaticDocument = new Class({
  417. Extends: MWF.xApplication.Attendance.Explorer.Document
  418. });