UnitDingdingDetail.js 18 KB

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