PeopleDingdingDetail.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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, "个人打卡明细", 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.PeopleDingdingDetail.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.PeopleDingdingDetail.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.PeopleDingdingDetail.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.css = parent.css;
  58. this.path = parent.path;
  59. this.actions = parent.actions;
  60. this.node = $(node);
  61. this.initData();
  62. if (!this.peopleActions) this.peopleActions = new MWF.xAction.org.express.RestActions();
  63. },
  64. initData: function () {
  65. this.toolItemNodes = [];
  66. },
  67. reload: function () {
  68. this.node.empty();
  69. this.load();
  70. },
  71. load: function () {
  72. this.loadFilter();
  73. this.loadContentNode();
  74. this.setNodeScroll();
  75. },
  76. loadFilter: function () {
  77. this.fileterNode = new Element("div.fileterNode", {
  78. "styles": this.css.fileterNode
  79. }).inject(this.node);
  80. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='filterTable'>" +
  81. "<tr>" +
  82. " <td styles='filterTableValue' lable='person'></td>" +
  83. " <td styles='filterTableTitle' item='person'></td>" +
  84. " <td styles='filterTableTitle' lable='year'></td>" +
  85. " <td styles='filterTableValue' item='year'></td>" +
  86. " <td styles='filterTableTitle' lable='month'></td>" +
  87. " <td styles='filterTableValue' item='month'></td>" +
  88. " <td styles='filterTableTitle' lable='day'></td>" +
  89. " <td styles='filterTableValue' item='day'></td>" +
  90. " <td styles='filterTableTitle' lable='checkType'></td>" +
  91. " <td styles='filterTableValue' item='checkType'></td>" +
  92. " <td styles='filterTableTitle' lable='timeResult'></td>" +
  93. " <td styles='filterTableValue' item='timeResult'></td>" +
  94. " <td styles='filterTableValue' item='action'></td>" +
  95. "</tr>" +
  96. "</table>";
  97. this.fileterNode.set("html", html);
  98. MWF.xDesktop.requireApp("Template", "MForm", function () {
  99. this.form = new MForm(this.fileterNode, {}, {
  100. isEdited: true,
  101. itemTemplate: {
  102. person: { text: "人员", type: "org", orgType: "person", notEmpty: true, style: { "min-width": "100px" } },
  103. year: {
  104. text: "年度",
  105. "type": "select",
  106. "selectValue": function () {
  107. var years = [];
  108. var year = new Date().getFullYear();
  109. for (var i = 0; i < 6; i++) {
  110. years.push(year--);
  111. }
  112. return years;
  113. },
  114. "event": {
  115. "change": function (item, ev) {
  116. var values = this.getDateSelectValue();
  117. item.form.getItem("day").resetItemOptions(values, values)
  118. }.bind(this)
  119. }
  120. },
  121. month: {
  122. text: "月份",
  123. "type": "select",
  124. "defaultValue": function () {
  125. var month = (new Date().getMonth() + 1).toString();
  126. return month.length == 1 ? "0" + month : month;
  127. },
  128. "selectValue": ["", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"],
  129. "event": {
  130. "change": function (item, ev) {
  131. var values = this.getDateSelectValue();
  132. item.form.getItem("day").resetItemOptions(values, values)
  133. }.bind(this)
  134. }
  135. },
  136. day: { text: "日期", "type": "select", "selectValue": this.getDateSelectValue.bind(this) },
  137. checkType: { text: "打卡类型", "type": "select", "selectValue": ["", "OnDuty", "OffDuty"], "selectText": ["", "上班打卡", "下班打卡"] },
  138. timeResult: { text: "打卡结果", "type": "select", "selectValue": ["", "Normal", "Early", "Late", "SeriousLate", "Absenteeism", "NotSigned"], "selectText": ["", "正常", "早退", "迟到", "严重迟到", "旷工迟到", "未打卡"] },
  139. action: {
  140. "value": "查询", type: "button", className: "filterButton", event: {
  141. click: function () {
  142. var result = this.form.getResult(true, ",", true, true, false);
  143. if (!result) return;
  144. if (result.day && result.day != "") {
  145. result.q_date = result.year + "-" + result.month + "-" + result.day;
  146. }
  147. this.loadView(result);
  148. }.bind(this)
  149. }
  150. }
  151. }
  152. }, this.app, this.css);
  153. this.form.load();
  154. }.bind(this), true);
  155. },
  156. getDateSelectValue: function () {
  157. if (this.form) {
  158. var year = parseInt(this.form.getItem("year").getValue());
  159. var month = parseInt(this.form.getItem("month").getValue()) - 1;
  160. } else {
  161. var year = (new Date()).getFullYear();
  162. var month = (new Date()).getMonth();
  163. }
  164. var date = new Date(year, month, 1);
  165. var days = [];
  166. days.push("");
  167. while (date.getMonth() === month) {
  168. var d = date.getDate().toString();
  169. if (d.length == 1) d = "0" + d;
  170. days.push(d);
  171. date.setDate(date.getDate() + 1);
  172. }
  173. return days;
  174. },
  175. loadContentNode: function () {
  176. this.elementContentNode = new Element("div", {
  177. "styles": this.css.elementContentNode
  178. }).inject(this.node);
  179. this.app.addEvent("resize", function () { this.setContentSize(); }.bind(this));
  180. },
  181. loadView: function (filterData) {
  182. this.elementContentNode.empty();
  183. if (this.view) delete this.view;
  184. this.view = new MWF.xApplication.Attendance.PeopleDingdingDetail.View(this.elementContentNode, this.app, this);
  185. this.view.filterData = filterData;
  186. this.view.listItemUrl = this.path + "listItem_dingding.json";
  187. this.view.load();
  188. this.setContentSize();
  189. },
  190. setContentSize: function () {
  191. var tabNodeSize = this.parent.tabs ? this.parent.tabs.tabNodeContainer.getSize() : { "x": 0, "y": 0 };
  192. var fileterNodeSize = this.fileterNode ? this.fileterNode.getSize() : { "x": 0, "y": 0 };
  193. var nodeSize = this.parent.node.getSize();
  194. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  195. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  196. //var filterSize = this.filterNode.getSize();
  197. var height = nodeSize.y - tabNodeSize.y - pt - pb - fileterNodeSize.y - 20;
  198. this.elementContentNode.setStyle("height", "" + height + "px");
  199. this.pageCount = (height / 40).toInt() + 5;
  200. if (this.view && this.view.items.length < this.pageCount) {
  201. this.view.loadElementList(this.pageCount - this.view.items.length);
  202. }
  203. }
  204. });
  205. MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHoliday = new Class({
  206. Extends: MWF.xApplication.Attendance.PeopleDingdingDetail.Explorer,
  207. loadView: function (filterData) {
  208. this.elementContentNode.empty();
  209. if (this.view) delete this.view;
  210. this.view = new MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayView(this.elementContentNode, this.app, this);
  211. this.view.filterData = filterData;
  212. this.view.load();
  213. this.setContentSize();
  214. }
  215. });
  216. MWF.xApplication.Attendance.PeopleDingdingDetail.DetailStaticExplorer = new Class({
  217. Extends: MWF.xApplication.Attendance.PeopleDingdingDetail.Explorer,
  218. loadFilter: function () {
  219. this.fileterNode = new Element("div.fileterNode", {
  220. "styles": this.css.fileterNode
  221. }).inject(this.node);
  222. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' style='width: 460px;font-size: 14px;color:#666'>" +
  223. "<tr>" +
  224. " <td styles='filterTableValue' lable='q_empName'></td>" +
  225. " <td styles='filterTableTitle' item='q_empName'></td>" +
  226. " <td styles='filterTableTitle' lable='cycleYear'></td>" +
  227. " <td styles='filterTableValue' item='cycleYear'></td>" +
  228. " <td styles='filterTableTitle' lable='cycleMonth'></td>" +
  229. " <td styles='filterTableValue' item='cycleMonth'></td>" +
  230. " <td styles='filterTableValue' item='action'></td>" +
  231. "</tr>" +
  232. "</table>";
  233. this.fileterNode.set("html", html);
  234. MWF.xDesktop.requireApp("Template", "MForm", function () {
  235. this.form = new MForm(this.fileterNode, {}, {
  236. isEdited: true,
  237. itemTemplate: {
  238. q_empName: { text: "人员", type: "org", orgType: "person", notEmpty: true, style: { "min-width": "100px" } },
  239. cycleYear: {
  240. text: "年度",
  241. "type": "select",
  242. "selectValue": function () {
  243. var years = [];
  244. var year = new Date().getFullYear();
  245. for (var i = 0; i < 6; i++) {
  246. years.push(year--);
  247. }
  248. return years;
  249. }
  250. },
  251. cycleMonth: {
  252. text: "月份",
  253. "type": "select",
  254. "defaultValue": function () {
  255. var month = (new Date().getMonth() + 1).toString();
  256. return month.length == 1 ? "0" + month : month;
  257. },
  258. "selectValue": ["", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]
  259. },
  260. action: {
  261. "value": "查询", type: "button", className: "filterButton", event: {
  262. click: function () {
  263. var result = this.form.getResult(true, ",", true, true, false);
  264. if (!result) return;
  265. this.loadView(result);
  266. }.bind(this)
  267. }
  268. }
  269. }
  270. }, this.app, this.css);
  271. this.form.load();
  272. }.bind(this), true);
  273. },
  274. loadView: function (filterData) {
  275. this.elementContentNode.empty();
  276. if (this.view) delete this.view;
  277. this.view = new MWF.xApplication.Attendance.PeopleDingdingDetail.DetailStaticView(this.elementContentNode, this.app, this);
  278. this.view.filterData = filterData;
  279. this.view.listItemUrl = this.path + "listItem_dingding_detailStatic.json";
  280. this.view.load();
  281. this.setContentSize();
  282. }
  283. });
  284. MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayStaticExplorer = new Class({
  285. Extends: MWF.xApplication.Attendance.PeopleDingdingDetail.Explorer,
  286. loadView: function (filterData) {
  287. this.elementContentNode.empty();
  288. if (this.view) delete this.view;
  289. this.view = new MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayStaticView(this.elementContentNode, this.app, this);
  290. this.view.filterData = filterData;
  291. this.view.load();
  292. this.setContentSize();
  293. }
  294. });
  295. MWF.xApplication.Attendance.PeopleDingdingDetail.View = new Class({
  296. Extends: MWF.xApplication.Attendance.Explorer.View,
  297. _createItem: function (data) {
  298. return new MWF.xApplication.Attendance.PeopleDingdingDetail.Document(this.table, data, this.explorer, this);
  299. },
  300. _getCurrentPageData: function (callback, count) {
  301. if (!count) count = 20;
  302. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  303. var filter = this.filterData || {};
  304. var action = o2.Actions.load("x_attendance_assemble_control");
  305. action.DingdingAttendanceAction.listNextDingdingAttendance(id, count, filter, function (json) {
  306. if (callback) callback(json);
  307. }.bind(this));
  308. },
  309. _removeDocument: function (documentData, all) {
  310. },
  311. _createDocument: function () {
  312. },
  313. _openDocument: function (documentData) {
  314. }
  315. });
  316. MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayView = new Class({
  317. Extends: MWF.xApplication.Attendance.Explorer.View,
  318. _createItem: function (data) {
  319. return new MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayDocument(this.table, data, this.explorer, this);
  320. },
  321. _getCurrentPageData: function (callback, count) {
  322. var filter = this.filterData || {};
  323. this.actions.listDetailFilter(filter, function (json) {
  324. if (callback) callback(json);
  325. }.bind(this))
  326. },
  327. _removeDocument: function (documentData, all) {
  328. },
  329. _createDocument: function () {
  330. },
  331. _openDocument: function (documentData) {
  332. }
  333. });
  334. MWF.xApplication.Attendance.PeopleDingdingDetail.DetailStaticView = new Class({
  335. Extends: MWF.xApplication.Attendance.Explorer.View,
  336. _createItem: function (data) {
  337. return new MWF.xApplication.Attendance.PeopleDingdingDetail.DetailStaticDocument(this.table, data, this.explorer, this);
  338. },
  339. _getCurrentPageData: function (callback, count) {
  340. var filter = this.filterData || {};
  341. var action = o2.Actions.load("x_attendance_assemble_control");
  342. action.DingdingAttendanceStatisticAction.personMonth(filter.q_empName, filter.cycleYear, filter.cycleMonth, function (json) {
  343. // var data = json.data;
  344. // data.sort(function (a, b) {
  345. // return parseInt(b.statisticYear + b.statisticMonth) - parseInt(a.statisticYear + a.statisticMonth)
  346. // });
  347. // json.data = data;
  348. if (callback) callback(json);
  349. }.bind(this))
  350. },
  351. _removeDocument: function (documentData, all) {
  352. },
  353. _createDocument: function () {
  354. },
  355. _openDocument: function (documentData) {
  356. }
  357. });
  358. MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayStaticView = new Class({
  359. Extends: MWF.xApplication.Attendance.Explorer.View,
  360. _createItem: function (data) {
  361. return new MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayStaticDocument(this.table, data, this.explorer, this);
  362. },
  363. _getCurrentPageData: function (callback, count) {
  364. var filter = this.filterData || {};
  365. this.actions.listDetailFilter(filter, function (json) {
  366. if (callback) callback(json);
  367. }.bind(this))
  368. },
  369. _removeDocument: function (documentData, all) {
  370. },
  371. _createDocument: function () {
  372. },
  373. _openDocument: function (documentData) {
  374. }
  375. });
  376. MWF.xApplication.Attendance.PeopleDingdingDetail.Document = new Class({
  377. Extends: MWF.xApplication.Attendance.Explorer.Document
  378. });
  379. MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayDocument = new Class({
  380. Extends: MWF.xApplication.Attendance.Explorer.Document
  381. });
  382. MWF.xApplication.Attendance.PeopleDingdingDetail.DetailStaticDocument = new Class({
  383. Extends: MWF.xApplication.Attendance.Explorer.Document
  384. });
  385. MWF.xApplication.Attendance.PeopleDingdingDetail.SelfHolidayStaticDocument = new Class({
  386. Extends: MWF.xApplication.Attendance.Explorer.Document
  387. });