UnitDingdingDetail.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. MWF.xDesktop.requireApp("Attendance", "Explorer", null, false);
  2. MWF.xDesktop.requireApp("Selector", "package", null, false);
  3. MWF.xApplication.Attendance.UnitDingdingDetail = 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/$UnitDetail/";
  13. this.cssPath = "../x_component_Attendance/$UnitDetail/" + 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, "部门打卡明细", false);
  31. this.detailPage.contentNodeArea.set("class", "detailPage");
  32. this.detailPage.addEvent("show", function () {
  33. if (!this.detailExplorer) {
  34. this.detailExplorer = new MWF.xApplication.Attendance.UnitDingdingDetail.Explorer(this.detailArea, this);
  35. this.detailExplorer.load();
  36. }
  37. }.bind(this));
  38. this.detailStaticPage = this.tabs.addTab(this.detailStaticArea, "部门打卡率统计", false);
  39. this.detailStaticPage.contentNodeArea.set("class", "detailStaticPage");
  40. this.detailStaticPage.addEvent("show", function () {
  41. if (!this.detailStaticExplorer) {
  42. this.detailStaticExplorer = new MWF.xApplication.Attendance.UnitDingdingDetail.DetailStaticExplorer(this.detailStaticArea, this);
  43. this.detailStaticExplorer.load();
  44. }
  45. }.bind(this));
  46. this.tabs.pages[0].showTab();
  47. }.bind(this));
  48. }
  49. });
  50. MWF.xApplication.Attendance.UnitDingdingDetail.Explorer = new Class({
  51. Extends: MWF.xApplication.Attendance.Explorer,
  52. Implements: [Options, Events],
  53. initialize: function (node, parent, options) {
  54. this.setOptions(options);
  55. this.parent = parent;
  56. this.app = parent.app;
  57. this.lp = this.app.lp;
  58. this.css = parent.css;
  59. this.path = parent.path;
  60. this.actions = parent.actions;
  61. this.node = $(node);
  62. this.initData();
  63. if (!this.peopleActions) this.peopleActions = new MWF.xAction.org.express.RestActions();
  64. },
  65. initData: function () {
  66. this.toolItemNodes = [];
  67. },
  68. reload: function () {
  69. this.node.empty();
  70. this.load();
  71. },
  72. load: function () {
  73. this.loadFilter();
  74. this.loadContentNode();
  75. this.setNodeScroll();
  76. },
  77. loadFilter: function () {
  78. this.fileterNode = new Element("div.fileterNode", {
  79. "styles": this.css.fileterNode
  80. }).inject(this.node);
  81. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='filterTable'>" +
  82. "<tr>" +
  83. " <td styles='filterTableValue' lable='unit'></td>" +
  84. " <td styles='filterTableTitle' item='unit'></td>" +
  85. " <td styles='filterTableTitle' lable='year'></td>" +
  86. " <td styles='filterTableValue' item='year'></td>" +
  87. " <td styles='filterTableTitle' lable='month'></td>" +
  88. " <td styles='filterTableValue' item='month'></td>" +
  89. " <td styles='filterTableTitle' lable='day'></td>" +
  90. " <td styles='filterTableValue' item='day'></td>" +
  91. " <td styles='filterTableTitle' lable='checkType'></td>" +
  92. " <td styles='filterTableValue' item='checkType'></td>" +
  93. " <td styles='filterTableTitle' lable='timeResult'></td>" +
  94. " <td styles='filterTableValue' item='timeResult'></td>" +
  95. " <td styles='filterTableValue' item='action'></td>" +
  96. "</tr>" +
  97. "</table>";
  98. this.fileterNode.set("html", html);
  99. MWF.xDesktop.requireApp("Template", "MForm", function () {
  100. this.form = new MForm(this.fileterNode, {}, {
  101. isEdited: true,
  102. itemTemplate: {
  103. unit: { text: "部门", type: "org", orgType: "unit", notEmpty: true, style: { "min-width": "200px" } },
  104. year: {
  105. text: "年度",
  106. "type": "select",
  107. "selectValue": function () {
  108. var years = [];
  109. var year = new Date().getFullYear();
  110. for (var i = 0; i < 6; i++) {
  111. years.push(year--);
  112. }
  113. return years;
  114. },
  115. "event": {
  116. "change": function (item, ev) {
  117. var values = this.getDateSelectValue();
  118. item.form.getItem("day").resetItemOptions(values, values)
  119. }.bind(this)
  120. }
  121. },
  122. month: {
  123. text: "月份",
  124. "type": "select",
  125. "defaultValue": function () {
  126. var month = (new Date().getMonth() + 1).toString();
  127. return month.length == 1 ? "0" + month : month;
  128. },
  129. "selectValue": ["", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"],
  130. "event": {
  131. "change": function (item, ev) {
  132. var values = this.getDateSelectValue();
  133. item.form.getItem("day").resetItemOptions(values, values)
  134. }.bind(this)
  135. }
  136. },
  137. day: { text: "日期", "type": "select", "selectValue": this.getDateSelectValue.bind(this) },
  138. checkType: { text: "打卡类型", "type": "select", "selectValue": ["", "OnDuty", "OffDuty"], "selectText": ["", "上班打卡", "下班打卡"] },
  139. timeResult: { text: "打卡结果", "type": "select", "selectValue": ["", "Normal", "Early", "Late", "SeriousLate", "Absenteeism", "NotSigned"], "selectText": ["", "正常", "早退", "迟到", "严重迟到", "旷工迟到", "未打卡"] },
  140. action: {
  141. "value": "查询", type: "button", className: "filterButton", event: {
  142. click: function () {
  143. var result = this.form.getResult(true, ",", true, true, false);
  144. if (!result) return;
  145. if (result.day && result.day != "") {
  146. result.q_date = result.year + "-" + result.month + "-" + result.day;
  147. }
  148. this.loadView(result);
  149. }.bind(this)
  150. }
  151. }
  152. }
  153. }, this.app, this.css);
  154. this.form.load();
  155. }.bind(this), true);
  156. },
  157. getDateSelectValue: function () {
  158. if (this.form) {
  159. var year = parseInt(this.form.getItem("year").getValue());
  160. var month = parseInt(this.form.getItem("month").getValue()) - 1;
  161. } else {
  162. var year = (new Date()).getFullYear();
  163. var month = (new Date()).getMonth();
  164. }
  165. var date = new Date(year, month, 1);
  166. var days = [];
  167. days.push("");
  168. while (date.getMonth() === month) {
  169. var d = date.getDate().toString();
  170. if (d.length == 1) d = "0" + d;
  171. days.push(d);
  172. date.setDate(date.getDate() + 1);
  173. }
  174. return days;
  175. },
  176. loadContentNode: function () {
  177. this.elementContentNode = new Element("div", {
  178. "styles": this.css.elementContentNode
  179. }).inject(this.node);
  180. this.app.addEvent("resize", function () { this.setContentSize(); }.bind(this));
  181. },
  182. loadView: function (filterData) {
  183. this.elementContentNode.empty();
  184. if (this.view) delete this.view;
  185. this.view = new MWF.xApplication.Attendance.UnitDingdingDetail.View(this.elementContentNode, this.app, this);
  186. this.view.filterData = filterData;
  187. this.view.listItemUrl = this.path + "listItem_dingding.json";
  188. this.view.load();
  189. this.setContentSize();
  190. },
  191. setContentSize: function () {
  192. var tabNodeSize = this.parent.tabs ? this.parent.tabs.tabNodeContainer.getSize() : { "x": 0, "y": 0 };
  193. var fileterNodeSize = this.fileterNode ? this.fileterNode.getSize() : { "x": 0, "y": 0 };
  194. var nodeSize = this.parent.node.getSize();
  195. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  196. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  197. //var filterSize = this.filterNode.getSize();
  198. var height = nodeSize.y - tabNodeSize.y - pt - pb - fileterNodeSize.y - 20;
  199. this.elementContentNode.setStyle("height", "" + height + "px");
  200. this.pageCount = (height / 40).toInt() + 5;
  201. if (this.view && this.view.items.length < this.pageCount) {
  202. this.view.loadElementList(this.pageCount - this.view.items.length);
  203. }
  204. }
  205. });
  206. MWF.xApplication.Attendance.UnitDingdingDetail.DetailStaticExplorer = new Class({
  207. Extends: MWF.xApplication.Attendance.UnitDingdingDetail.Explorer,
  208. loadFilter: function () {
  209. this.fileterNode = new Element("div.fileterNode", {
  210. "styles": this.css.fileterNode
  211. }).inject(this.node);
  212. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' style='width: 660px;font-size: 14px;color:#666'>" +
  213. "<tr>" +
  214. " <td styles='filterTableValue' lable='q_unitName'></td>" +
  215. " <td styles='filterTableTitle' item='q_unitName'></td>" +
  216. " <td styles='filterTableTitle' lable='cycleYear'></td>" +
  217. " <td styles='filterTableValue' item='cycleYear'></td>" +
  218. " <td styles='filterTableTitle' lable='cycleMonth'></td>" +
  219. " <td styles='filterTableValue' item='cycleMonth'></td>" +
  220. " <td styles='filterTableValue' item='action'></td>" +
  221. "</tr>" +
  222. "</table>";
  223. this.fileterNode.set("html", html);
  224. MWF.xDesktop.requireApp("Template", "MForm", function () {
  225. this.form = new MForm(this.fileterNode, {}, {
  226. isEdited: true,
  227. itemTemplate: {
  228. q_unitName: { text: "部门", type: "org", orgType: "unit", notEmpty: true, style: { "min-width": "200px" } },
  229. cycleYear: {
  230. text: "年度",
  231. "type": "select",
  232. "selectValue": function () {
  233. var years = [];
  234. var year = new Date().getFullYear();
  235. for (var i = 0; i < 6; i++) {
  236. years.push(year--);
  237. }
  238. return years;
  239. }
  240. },
  241. cycleMonth: {
  242. text: "月份", notEmpty: true,
  243. "type": "select",
  244. "defaultValue": function () {
  245. var month = (new Date().getMonth() + 1).toString();
  246. return month.length == 1 ? "0" + month : month;
  247. },
  248. "selectValue": ["", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]
  249. },
  250. action: {
  251. "value": "查询", type: "button", className: "filterButton", event: {
  252. click: function () {
  253. var result = this.form.getResult(true, ",", true, true, false);
  254. if (!result) return;
  255. this.loadView(result);
  256. }.bind(this)
  257. }
  258. }
  259. }
  260. }, this.app, this.css);
  261. this.form.load();
  262. }.bind(this), true);
  263. },
  264. loadView: function (filterData) {
  265. this.elementContentNode.empty();
  266. if (this.view) delete this.view;
  267. this.view = new MWF.xApplication.Attendance.UnitDingdingDetail.DetailStaticView(this.elementContentNode, this.app, this);
  268. this.view.filterData = filterData;
  269. this.view.listItemUrl = this.path + "listItem_dingding_detailStatic.json";
  270. this.view.load();
  271. this.setContentSize();
  272. }
  273. });
  274. MWF.xApplication.Attendance.UnitDingdingDetail.View = new Class({
  275. Extends: MWF.xApplication.Attendance.Explorer.View,
  276. _createItem: function (data) {
  277. return new MWF.xApplication.Attendance.UnitDingdingDetail.Document(this.table, data, this.explorer, this);
  278. },
  279. _getCurrentPageData: function (callback, count) {
  280. if (!count) count = 20;
  281. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  282. var filter = this.filterData || {};
  283. var action = o2.Actions.load("x_attendance_assemble_control");
  284. action.DingdingAttendanceAction.listNextDingdingAttendance(id, count, filter, function (json) {
  285. if (callback) callback(json);
  286. }.bind(this));
  287. },
  288. _removeDocument: function (documentData, all) {
  289. },
  290. _createDocument: function () {
  291. },
  292. _openDocument: function (documentData) {
  293. }
  294. });
  295. MWF.xApplication.Attendance.UnitDingdingDetail.DetailStaticView = new Class({
  296. Extends: MWF.xApplication.Attendance.Explorer.View,
  297. _createItem: function (data) {
  298. return new MWF.xApplication.Attendance.UnitDingdingDetail.DetailStaticDocument(this.table, data, this.explorer, this);
  299. },
  300. _getCurrentPageData: function (callback, count) {
  301. var filter = this.filterData || {};
  302. var action = o2.Actions.load("x_attendance_assemble_control");
  303. action.DingdingAttendanceStatisticAction.personMonthWithUnit(filter.q_unitName, filter.cycleYear, filter.cycleMonth, function (json) {
  304. if (callback) callback(json);
  305. }.bind(this));
  306. },
  307. _removeDocument: function (documentData, all) {
  308. },
  309. _createDocument: function () {
  310. },
  311. _openDocument: function (documentData) {
  312. }
  313. });
  314. MWF.xApplication.Attendance.UnitDingdingDetail.Document = new Class({
  315. Extends: MWF.xApplication.Attendance.Explorer.Document
  316. });
  317. MWF.xApplication.Attendance.UnitDingdingDetail.DetailStaticDocument = new Class({
  318. Extends: MWF.xApplication.Attendance.Explorer.Document
  319. });