PersonDetail.js 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  1. MWF.xDesktop.requireApp("Attendance", "Explorer", null, false);
  2. MWF.xDesktop.requireApp("Organization", "Selector.package", null, false);
  3. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  4. MWF.xApplication.Attendance.PersonDetail = new Class({
  5. Extends: MWF.widget.Common,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default"
  9. },
  10. initialize: function(node, app, actions, options){
  11. this.setOptions(options);
  12. this.app = app;
  13. this.path = "/x_component_Attendance/$PersonDetail/";
  14. this.cssPath = "/x_component_Attendance/$PersonDetail/"+this.options.style+"/css.wcss";
  15. this._loadCss();
  16. this.actions = actions;
  17. this.node = $(node);
  18. },
  19. load: function(){
  20. //options = {
  21. // "name": "直接主管",
  22. // "personName": this.workContext.getWork().creatorPerson
  23. //}
  24. //return this.org.getPersonAttribute(options);
  25. this.loadTab();
  26. },
  27. loadTab : function(){
  28. this.tabNode = new Element("div",{"styles" : this.css.tabNode }).inject(this.node)
  29. this.detailArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode)
  30. //this.selfHolidayArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode)
  31. this.detailStaticArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode)
  32. //this.selfHolidayStaticArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode)
  33. MWF.require("MWF.widget.Tab", function(){
  34. this.tabs = new MWF.widget.Tab(this.tabNode, {"style": "attendance"});
  35. this.tabs.load();
  36. this.detailPage = this.tabs.addTab(this.detailArea, "我的出勤明细", false);
  37. this.detailPage.contentNodeArea.set("class","detailPage");
  38. this.detailPage.addEvent("show",function(){
  39. if( !this.detailExplorer ){
  40. this.detailExplorer = new MWF.xApplication.Attendance.PersonDetail.Explorer( this.detailArea, this );
  41. this.detailExplorer.load();
  42. }
  43. }.bind(this))
  44. //this.selfHolidayPage = this.tabs.addTab(this.selfHolidayArea, "我的休假明细", false);
  45. //this.selfHolidayPage.contentNodeArea.set("class","selfHolidayPage");
  46. //this.selfHolidayPage.addEvent("show",function(){
  47. // if( !this.selfHolidayExplorer ){
  48. // this.selfHolidayExplorer = new MWF.xApplication.Attendance.PersonDetail.SelfHolidayExplorer( this.selfHolidayArea, this );
  49. // this.selfHolidayExplorer.load();
  50. // }
  51. //}.bind(this))
  52. this.detailStaticPage = this.tabs.addTab(this.detailStaticArea, "我的出勤率统计", false);
  53. this.detailStaticPage.contentNodeArea.set("class","detailStaticPage");
  54. this.detailStaticPage.addEvent("show",function(){
  55. if( !this.detailStaticExplorer ){
  56. this.detailStaticExplorer = new MWF.xApplication.Attendance.PersonDetail.DetailStaticExplorer( this.detailStaticArea, this );
  57. this.detailStaticExplorer.load();
  58. }
  59. }.bind(this))
  60. //this.selfHolidayStaticPage = this.tabs.addTab(this.selfHolidayStaticArea, "我的休假统计", false);
  61. //this.selfHolidayStaticPage.contentNodeArea.set("class","selfHolidayStaticPage");
  62. //this.selfHolidayStaticPage.addEvent("show",function(){
  63. // if( !this.selfHolidayStaticExplorer ){
  64. // this.selfHolidayStaticExplorer = new MWF.xApplication.Attendance.PersonDetail.SelfHolidayStaticExplorer( this.selfHolidayStaticArea, this );
  65. // this.selfHolidayStaticExplorer.load();
  66. // }
  67. //}.bind(this))
  68. this.tabs.pages[0].showTab();
  69. }.bind(this));
  70. }
  71. })
  72. MWF.xApplication.Attendance.PersonDetail.Explorer = new Class({
  73. Extends: MWF.xApplication.Attendance.Explorer,
  74. Implements: [Options, Events],
  75. initialize: function(node, parent, options){
  76. this.setOptions(options);
  77. this.parent = parent;
  78. this.app = parent.app;
  79. this.css = parent.css;
  80. this.path = parent.path;
  81. this.actions = parent.actions;
  82. this.node = $(node);
  83. this.preMonthDate = new Date();
  84. //this.preMonthDate.decrement("month", 1);
  85. this.initData();
  86. if (!this.peopleActions) this.peopleActions = new MWF.xAction.org.express.RestActions();
  87. },
  88. initData: function(){
  89. this.toolItemNodes = [];
  90. },
  91. reload: function(){
  92. this.node.empty();
  93. this.load();
  94. },
  95. load: function(){
  96. this.loadConfig();
  97. this.loadFilter();
  98. this.loadContentNode();
  99. this.setNodeScroll();
  100. var month = (this.preMonthDate.getMonth()+1).toString();
  101. if( month.length == 1 )month = "0"+month;
  102. var filterData = {
  103. cycleYear : this.preMonthDate.getFullYear().toString(),
  104. cycleMonth : month
  105. }
  106. this.loadView( filterData );
  107. },
  108. loadConfig : function(){
  109. this.config = {};
  110. var v;
  111. this.actions.getSettingCode( "APPEALABLE", function(json){
  112. v = json.data ? json.data.configValue : null
  113. },null, false)
  114. if( !v ){
  115. this.config.APPEALABLE = true;
  116. }else{
  117. this.config.APPEALABLE = (v != "false" )
  118. }
  119. },
  120. loadFilter : function(){
  121. this.fileterNode = new Element("div.fileterNode", {
  122. "styles" : this.css.fileterNode
  123. }).inject(this.node)
  124. var table = new Element("table", {
  125. "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.css.filterTable, "class" : "filterTable"
  126. }).inject( this.fileterNode );
  127. var tr = new Element("tr").inject(table);
  128. var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : this.preMonthDate.format(this.app.lp.dateFormatMonth) }).inject(tr);
  129. //this.createYearSelectTd( tr )
  130. //this.createMonthSelectTd( tr )
  131. this.createDateSelectTd( tr )
  132. this.createIsAbsent(tr)
  133. this.createIsLate( tr )
  134. //this.createIsLeaveEarlier( tr )
  135. this.createLackOfTimeCount(tr)
  136. this.createActionTd( tr )
  137. },
  138. createYearSelectTd : function( tr ){
  139. var _self = this;
  140. var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "年度" }).inject(tr);
  141. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  142. this.cycleYear = new MDomItem( td, {
  143. "name" : "cycleYear",
  144. "type" : "select",
  145. "selectValue" : function(){
  146. var years = [];
  147. var year = new Date().getFullYear();
  148. for(var i=0; i<6; i++ ){
  149. years.push( year-- );
  150. }
  151. return years;
  152. },
  153. "event" : {
  154. "change" : function(){ if(_self.dateSelecterTd)_self.createDateSelectTd() }
  155. }
  156. }, true, this.app );
  157. this.cycleYear.load();
  158. },
  159. createMonthSelectTd : function( tr ){
  160. var _self = this;
  161. var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "月份" }).inject(tr);
  162. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  163. this.cycleMonth = new MDomItem( td, {
  164. "name" : "cycleMonth",
  165. "type" : "select",
  166. "defaultValue" : function(){
  167. var month = (new Date().getMonth() + 1 ).toString();
  168. return month.length == 1 ? "0"+month : month;
  169. },
  170. "selectValue" :["","01","02","03","04","05","06","07","08","09","10","11","12"],
  171. "event" : {
  172. "change" : function(){ if(_self.dateSelecterTd)_self.createDateSelectTd() }
  173. }
  174. }, true, this.app );
  175. this.cycleMonth.load();
  176. },
  177. createDateSelectTd : function( tr ){
  178. var _self = this;
  179. if( tr ){
  180. var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "日期" }).inject(tr);
  181. this.dateSelecterTd = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  182. }
  183. if( this.q_date ){
  184. this.dateSelecterTd.empty();
  185. }
  186. this.q_date = new MDomItem( this.dateSelecterTd, {
  187. "name" : "q_date",
  188. "type" : "select",
  189. "selectValue" : function(){
  190. var year = _self.cycleYear ? parseInt(_self.cycleYear.getValue()) : _self.preMonthDate.getFullYear() ;
  191. var month = _self.cycleMonth ? (parseInt(_self.cycleMonth.getValue())-1) : _self.preMonthDate.getMonth() ;
  192. var date = new Date(year, month, 1);
  193. var days = [];
  194. days.push("");
  195. while (date.getMonth() === month) {
  196. var d = date.getDate().toString();
  197. if( d.length == 1 )d = "0"+d
  198. days.push( d );
  199. date.setDate(date.getDate() + 1);
  200. }
  201. return days;
  202. }
  203. }, true, this.app );
  204. this.q_date.load();
  205. },
  206. createIsAbsent: function(tr){
  207. var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "缺勤" }).inject(tr);
  208. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  209. this.isAbsent = new MDomItem( td, {
  210. "name" : "isAbsent",
  211. "type" : "select",
  212. "selectValue" : ["","true","false"],
  213. "selectText" : ["","缺勤","未缺勤"],
  214. }, true, this.app );
  215. this.isAbsent.load();
  216. },
  217. //createIsLeaveEarlier: function(tr){
  218. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "早退" }).inject(tr);
  219. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  220. // this.isLeaveEarlier = new MDomItem( td, {
  221. // "name" : "isLeaveEarlier",
  222. // "type" : "select",
  223. // "selectValue" : ["-1","true","false"],
  224. // "selectText" : ["","早退","未早退"],
  225. // }, true, this.app );
  226. // this.isLeaveEarlier.load();
  227. //},
  228. createLackOfTimeCount: function(tr){
  229. var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "工时不足" }).inject(tr);
  230. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  231. this.isLackOfTime = new MDomItem( td, {
  232. "name" : "isLackOfTime",
  233. "type" : "select",
  234. "selectValue" : ["","true","false"],
  235. "selectText" : ["","是","否"],
  236. }, true, this.app );
  237. this.isLackOfTime.load();
  238. },
  239. createIsLate: function(tr){
  240. var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "迟到" }).inject(tr);
  241. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  242. this.isLate = new MDomItem( td, {
  243. "name" : "isLate",
  244. "type" : "select",
  245. "selectValue" : ["","true","false"],
  246. "selectText" : ["","迟到","未迟到"],
  247. }, true, this.app );
  248. this.isLate.load();
  249. },
  250. createActionTd : function( tr ){
  251. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  252. var input = new Element("button",{
  253. "text" : "查询",
  254. "styles" : this.css.filterButton
  255. }).inject(td);
  256. input.addEvent("click", function(){
  257. //var filterData = {
  258. // cycleYear : this.cycleYear.getValue(),
  259. // cycleMonth : this.cycleMonth.getValue()
  260. //}
  261. var year = this.preMonthDate.getFullYear().toString();
  262. var month = (this.preMonthDate.getMonth()+1).toString();
  263. if( month.length == 1 )month = "0"+month;
  264. var filterData = {
  265. cycleYear : year,
  266. cycleMonth : month
  267. }
  268. if( this.isAbsent && this.isAbsent.getValue()!=""){
  269. filterData.isAbsent = this.getBoolean( this.isAbsent.getValue() );
  270. }
  271. if( this.isLeaveEarlier && this.isLeaveEarlier.getValue()!=""){
  272. filterData.isLeaveEarlier = this.getBoolean( this.isLeaveEarlier.getValue());
  273. }
  274. if( this.isLate && this.isLate.getValue()!="" ){
  275. filterData.isLate = this.getBoolean( this.isLate.getValue());
  276. }
  277. if( this.isLackOfTime && this.isLackOfTime.getValue()!=""){
  278. filterData.isLackOfTime = this.getBoolean( this.isLackOfTime.getValue());
  279. }
  280. if( this.q_date && this.q_date.getValue()!="" ){
  281. filterData.q_date = year + "-" + month + "-" + this.q_date.getValue();
  282. }
  283. this.loadView( filterData );
  284. }.bind(this))
  285. },
  286. getBoolean : function( value ){
  287. if( value === "true" )return true;
  288. if( value === "false" )return false;
  289. return value;
  290. },
  291. selecePerson: function(){
  292. var options = {
  293. "type": "person",
  294. "title": "选择人员",
  295. "count" : "1",
  296. "onComplete": function(items){
  297. var names = [];
  298. items.each(function(item){
  299. names.push(item.data.name);
  300. }.bind(this));
  301. this.q_empName.setValue( names.join(",") )
  302. }.bind(this)
  303. };
  304. var selector = new MWF.OrgSelector(this.app.content, options);
  305. },
  306. loadContentNode: function(){
  307. this.elementContentNode = new Element("div", {
  308. "styles": this.css.elementContentNode
  309. }).inject(this.node);
  310. this.app.addEvent("resize", function(){this.setContentSize();}.bind(this));
  311. },
  312. loadView : function( filterData ){
  313. this.elementContentNode.empty();
  314. if( this.view )delete this.view;
  315. this.view = new MWF.xApplication.Attendance.PersonDetail.View(this.elementContentNode, this.app,this );
  316. this.view.filterData = filterData
  317. this.view.load();
  318. this.setContentSize();
  319. },
  320. setContentSize: function(){
  321. var tabNodeSize = this.parent.tabs ? this.parent.tabs.tabNodeContainer.getSize() : {"x":0,"y":0};
  322. var fileterNodeSize = this.fileterNode ? this.fileterNode.getSize() : {"x":0,"y":0};
  323. var nodeSize = this.parent.node.getSize();
  324. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  325. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  326. //var filterSize = this.filterNode.getSize();
  327. var height = nodeSize.y-tabNodeSize.y-pt-pb-fileterNodeSize.y-20;
  328. this.elementContentNode.setStyle("height", ""+height+"px");
  329. this.pageCount = (height/40).toInt()+5;
  330. if (this.view && this.view.items.length<this.pageCount){
  331. this.view.loadElementList(this.pageCount-this.view.items.length);
  332. }
  333. }
  334. });
  335. MWF.xApplication.Attendance.PersonDetail.SelfHolidayExplorer = new Class({
  336. Extends: MWF.xApplication.Attendance.PersonDetail.Explorer,
  337. loadView : function( filterData ){
  338. this.elementContentNode.empty();
  339. if( this.view )delete this.view;
  340. this.view = new MWF.xApplication.Attendance.PersonDetail.SelfHolidayView(this.elementContentNode, this.app,this );
  341. this.view.filterData = filterData
  342. this.view.load();
  343. this.setContentSize();
  344. }
  345. })
  346. MWF.xApplication.Attendance.PersonDetail.DetailStaticExplorer = new Class({
  347. Extends: MWF.xApplication.Attendance.PersonDetail.Explorer,
  348. load: function(){
  349. //this.loadFilter();
  350. this.loadContentNode();
  351. this.setNodeScroll();
  352. var filterData = {
  353. cycleYear : this.preMonthDate.getFullYear().toString(),
  354. cycleMonth : this.preMonthDate.format(this.app.lp.dateFormatOnlyMonth)
  355. }
  356. this.loadView( filterData );
  357. },
  358. loadFilter : function(){
  359. this.fileterNode = new Element("div.fileterNode", {
  360. "styles" : this.css.fileterNode
  361. }).inject(this.node)
  362. var table = new Element("table", {
  363. "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.css.filterTable, "class" : "filterTable"
  364. }).inject( this.fileterNode );
  365. table.setStyle("width","360px");
  366. var tr = new Element("tr").inject(table);
  367. this.createYearSelectTd( tr )
  368. this.createMonthSelectTd( tr )
  369. //this.createDateSelectTd( tr )
  370. this.createActionTd( tr )
  371. },
  372. createMonthSelectTd : function( tr ){
  373. var _self = this;
  374. var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "月份" }).inject(tr);
  375. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  376. this.cycleMonth = new MDomItem( td, {
  377. "name" : "cycleMonth",
  378. "type" : "select",
  379. "selectValue" :["","01","02","03","04","05","06","07","08","09","10","11","12"],
  380. "event" : {
  381. "change" : function(){ if(_self.dateSelecterTd)_self.createDateSelectTd() }
  382. }
  383. }, true, this.app );
  384. this.cycleMonth.load();
  385. },
  386. createActionTd : function( tr ){
  387. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  388. var input = new Element("button",{
  389. "text" : "查询",
  390. "styles" : this.css.filterButton
  391. }).inject(td);
  392. input.addEvent("click", function(){
  393. //var filterData = {
  394. // cycleYear : this.cycleYear.getValue(),
  395. // cycleMonth : this.cycleMonth.getValue()
  396. //}
  397. var year = this.preMonthDate.getFullYear().toString();
  398. var month = (this.preMonthDate.getMonth()+1).toString();
  399. if( month.length == 1 )month = "0"+month;
  400. var filterData = {
  401. cycleYear : year,
  402. cycleMonth : month
  403. }
  404. if( this.isAbsent && this.isAbsent.getValue()!="" ){
  405. filterData.isAbsent = this.isAbsent.getValue();
  406. }
  407. if( this.isLeaveEarlier && this.isLeaveEarlier.getValue()!=""){
  408. filterData.isLeaveEarlier = this.isLeaveEarlier.getValue();
  409. }
  410. if( this.isLate && this.isLate.getValue()!="" ){
  411. filterData.isLate = this.isLate.getValue();
  412. }
  413. if( this.q_date && this.q_date.getValue()!="" ){
  414. filterData.q_date = year + "-" + month + "-" + this.q_date.getValue();
  415. }
  416. this.loadView( filterData );
  417. }.bind(this))
  418. },
  419. loadView : function( filterData ){
  420. this.elementContentNode.empty();
  421. if( this.view )delete this.view;
  422. this.view = new MWF.xApplication.Attendance.PersonDetail.DetailStaticView(this.elementContentNode, this.app,this );
  423. this.view.filterData = filterData;
  424. this.view.listItemUrl = this.path+"listItem_detailStatic.json";
  425. this.view.load();
  426. this.setContentSize();
  427. }
  428. })
  429. MWF.xApplication.Attendance.PersonDetail.SelfHolidayStaticExplorer = new Class({
  430. Extends: MWF.xApplication.Attendance.PersonDetail.Explorer,
  431. loadView : function( filterData ){
  432. this.elementContentNode.empty();
  433. if( this.view )delete this.view;
  434. this.view = new MWF.xApplication.Attendance.PersonDetail.SelfHolidayStaticView(this.elementContentNode, this.app,this );
  435. this.view.filterData = filterData
  436. this.view.load();
  437. this.setContentSize();
  438. }
  439. })
  440. MWF.xApplication.Attendance.PersonDetail.View = new Class({
  441. Extends: MWF.xApplication.Attendance.Explorer.View,
  442. _createItem: function(data){
  443. return new MWF.xApplication.Attendance.PersonDetail.Document(this.table, data, this.explorer, this);
  444. },
  445. _getCurrentPageData: function(callback, count){
  446. if(!count)count=100;
  447. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  448. var filter = this.filterData || {};
  449. filter.key = this.sortField || this.sortFieldDefault || "";
  450. filter.order = this.sortType || this.sortTypeDefault || "";
  451. filter.q_empName = layout.desktop.session.user.name;
  452. this.actions.listDetailFilterNext( id, count, filter, function(json){
  453. var data = json.data;
  454. data.each(function(d){
  455. d.APPEALABLE = this.explorer.config.APPEALABLE;
  456. }.bind(this));
  457. json.data = data;
  458. if( callback )callback(json);
  459. }.bind(this))
  460. //this.actions.listDetailFilterUser( filter, function(json){
  461. // if( callback )callback(json);
  462. //}.bind(this))
  463. },
  464. _removeDocument: function(documentData, all){
  465. },
  466. _createDocument: function(){
  467. },
  468. _openDocument: function( documentData ){
  469. }
  470. })
  471. MWF.xApplication.Attendance.PersonDetail.SelfHolidayView = new Class({
  472. Extends: MWF.xApplication.Attendance.Explorer.View,
  473. _createItem: function(data){
  474. return new MWF.xApplication.Attendance.PersonDetail.SelfHolidayDocument(this.table, data, this.explorer, this);
  475. },
  476. _getCurrentPageData: function(callback, count){
  477. var filter = this.filterData || {};
  478. filter.q_empName = layout.desktop.session.user.name;
  479. this.actions.listDetailFilterUser( filter, function(json){
  480. if( callback )callback(json);
  481. }.bind(this))
  482. },
  483. _removeDocument: function(documentData, all){
  484. },
  485. _createDocument: function(){
  486. },
  487. _openDocument: function( documentData ){
  488. }
  489. })
  490. MWF.xApplication.Attendance.PersonDetail.DetailStaticView = new Class({
  491. Extends: MWF.xApplication.Attendance.Explorer.View,
  492. _createItem: function(data){
  493. return new MWF.xApplication.Attendance.PersonDetail.DetailStaticDocument(this.table, data, this.explorer, this);
  494. },
  495. _getCurrentPageData: function(callback, count){
  496. var filter = this.filterData || {};
  497. filter.key = this.sortField || this.sortFieldDefault || "";
  498. filter.order = this.sortType || this.sortTypeDefault || "";
  499. filter.q_empName = layout.desktop.session.user.name;
  500. //if( filter.cycleMonth == "" )filter.cycleMonth="(0)";
  501. var month = (new Date().getMonth()+1).toString();
  502. if( month.length == 1 )month = "0"+month;
  503. filter.cycleMonth = month;
  504. this.actions.listStaticMonthPerson( filter.q_empName, filter.cycleYear,filter.cycleMonth, function(json){
  505. if( callback )callback(json);
  506. }.bind(this))
  507. },
  508. _removeDocument: function(documentData, all){
  509. },
  510. _createDocument: function(){
  511. },
  512. _openDocument: function( documentData ){
  513. }
  514. })
  515. MWF.xApplication.Attendance.PersonDetail.SelfHolidayStaticView = new Class({
  516. Extends: MWF.xApplication.Attendance.Explorer.View,
  517. _createItem: function(data){
  518. return new MWF.xApplication.Attendance.PersonDetail.SelfHolidayStaticDocument(this.table, data, this.explorer, this);
  519. },
  520. _getCurrentPageData: function(callback, count){
  521. var filter = this.filterData || {};
  522. this.actions.listDetailFilterUser( filter, function(json){
  523. if( callback )callback(json);
  524. }.bind(this))
  525. },
  526. _removeDocument: function(documentData, all){
  527. },
  528. _createDocument: function(){
  529. },
  530. _openDocument: function( documentData ){
  531. }
  532. })
  533. MWF.xApplication.Attendance.PersonDetail.Document = new Class({
  534. Extends: MWF.xApplication.Attendance.Explorer.Document,
  535. appeal :function(){
  536. var form = new MWF.xApplication.Attendance.PersonDetail.Appeal( this.explorer, this.data );
  537. form.create();
  538. },
  539. seeAppeal : function(){
  540. var form = new MWF.xApplication.Attendance.PersonDetail.Appeal( this.explorer, this.data );
  541. form.open();
  542. }
  543. })
  544. MWF.xApplication.Attendance.PersonDetail.SelfHolidayDocument = new Class({
  545. Extends: MWF.xApplication.Attendance.Explorer.Document
  546. })
  547. MWF.xApplication.Attendance.PersonDetail.DetailStaticDocument = new Class({
  548. Extends: MWF.xApplication.Attendance.Explorer.Document
  549. })
  550. MWF.xApplication.Attendance.PersonDetail.SelfHolidayStaticDocument = new Class({
  551. Extends: MWF.xApplication.Attendance.Explorer.Document
  552. })
  553. MWF.xApplication.Attendance.PersonDetail.Appeal = new Class({
  554. Extends: MWF.widget.Common,
  555. initialize: function( explorer, detailData ){
  556. this.explorer = explorer;
  557. this.app = explorer.app;
  558. this.detailData = detailData;
  559. this.css = this.explorer.css;
  560. this.load();
  561. },
  562. load: function(){
  563. },
  564. open: function(e){
  565. this.isNew = false;
  566. this.isEdited = false;
  567. this.app.restActions.getAppeal(this.detailData.id, function(json){
  568. this.data = json.data;
  569. this.data.onDutyTime = this.detailData.onDutyTime;
  570. this.data.offDutyTime = this.detailData.offDutyTime;
  571. }.bind(this),null,false)
  572. if(!this.data)this.data = this.detailData || {};
  573. this._open();
  574. },
  575. create: function(){
  576. this.isNew = true;
  577. this.data = this.detailData || {};
  578. this._open();
  579. },
  580. edit: function(){
  581. this.isEdited = true;
  582. this.app.restActions.getAppeal(this.detailData.id, function(json){
  583. this.data = json.data;
  584. this.data.onDutyTime = this.detailData.onDutyTime;
  585. this.data.offDutyTime = this.detailData.offDutyTime;
  586. }.bind(this),null,false)
  587. if(!this.data)this.data = this.detailData || {};
  588. this._open();
  589. },
  590. _open : function(){
  591. this.createMarkNode = new Element("div", {
  592. "styles": this.css.createMarkNode,
  593. "events": {
  594. "mouseover": function(e){e.stopPropagation();},
  595. "mouseout": function(e){e.stopPropagation();}
  596. }
  597. }).inject(this.app.content, "after");
  598. this.createAreaNode = new Element("div", {
  599. "styles": this.css.createAreaNode
  600. });
  601. this.createNode();
  602. this.createAreaNode.inject(this.createMarkNode, "after");
  603. this.createAreaNode.fade("in");
  604. this.setCreateNodeSize();
  605. this.setCreateNodeSizeFun = this.setCreateNodeSize.bind(this);
  606. this.addEvent("resize", this.setCreateNodeSizeFun);
  607. },
  608. createNode: function(){
  609. var _self = this;
  610. this.createNode = new Element("div", {
  611. "styles": this.css.createNode
  612. }).inject(this.createAreaNode);
  613. this.createContainerNode = new Element("div", {
  614. "styles": this.css.createContainerNode
  615. }).inject(this.createNode);
  616. this.setScrollBar( this.createContainerNode );
  617. this.createIconNode = new Element("div", {
  618. "styles": this.isNew ? this.css.createNewNode : this.css.createIconNode
  619. }).inject(this.createContainerNode);
  620. this.createFormNode = new Element("div", {
  621. "styles": this.css.createFormNode
  622. }).inject(this.createContainerNode);
  623. this.createTableContainer = new Element("div", {
  624. "styles": this.css.createTableContainer
  625. }).inject(this.createFormNode);
  626. this.createTableArea = new Element("div", {
  627. "styles": this.css.createTableArea
  628. }).inject(this.createTableContainer);
  629. var d = this.data;
  630. var status = [];
  631. if(d.isGetSelfHolidays && d.selfHolidayDayTime == "全天" ) {
  632. status.push('请假或外出报备')
  633. }else if( d.isAbnormalDuty && d.abnormalDutyDayTime == "全天" ){
  634. status.push('异常打卡')
  635. }else if(d.isLackOfTime ) {
  636. status.push('工时不足')
  637. }else{
  638. if( d.isGetSelfHolidays && d.selfHolidayDayTime == "上午" ){
  639. status.push("请假或外出报备")
  640. }else if(d.isLate){
  641. status.push('迟到')
  642. }else if(d.isAbsent && (d.absentDayTime == "上午" || d.absentDayTime == "全天" ) ){
  643. status.push('缺勤')
  644. }else if( d.isAbnormalDuty && (d.abnormalDutyDayTime == "全天" || d.abnormalDutyDayTime == "上午")){
  645. status.push('异常打卡')
  646. }
  647. if( d.isGetSelfHolidays && d.selfHolidayDayTime == "下午" ){
  648. status.push("请假或外出报备")
  649. //}else if(d.isLeaveEarlier){
  650. // status.push( '早退')
  651. }else if(d.isAbsent && d.absentDayTime == "下午" ){
  652. status.push( '缺勤')
  653. }else if(d.isAbnormalDuty && d.abnormalDutyDayTime == "下午" ){
  654. status.push('异常打卡')
  655. }
  656. }
  657. this.data.statusShow = status.unique().join();
  658. var appealStatus = "发起";
  659. if (d.status == 0 ) {
  660. appealStatus = "待处理"
  661. } else if (d.status == 1) {
  662. appealStatus = "审批通过"
  663. } else if (d.status == -1) {
  664. appealStatus = "审批未通过"
  665. }
  666. //if (d.appealStatus == 1) {
  667. // appealStatus = "申诉中"
  668. //} else if (d.appealStatus == -1) {
  669. // appealStatus = "申诉未通过"
  670. //} else if (d.appealStatus == 9) {
  671. // appealStatus = "申诉通过"
  672. //}
  673. this.data.appealStatusShow = appealStatus;
  674. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  675. "<tr><td colspan='4' styles='formTableHead'>申诉申请单</td></tr>" +
  676. "<tr><td styles='formTableTitle' lable='empName'></td>"+
  677. " <td styles='formTableValue' item='empName'></td>" +
  678. " <td styles='formTableTitle' lable='recordDateString'></td>"+
  679. " <td styles='formTableValue' item='recordDateString'></td></tr>"
  680. +"<tr><td styles='formTableTitle' lable='onDutyTime'></td>"+
  681. " <td styles='formTableValue' item='onDutyTime'></td>" +
  682. " <td styles='formTableTitle' lable='offDutyTime'></td>"+
  683. " <td styles='formTableValue' item='offDutyTime'></td></tr>" +
  684. ( this.isNew ?
  685. "<tr><td styles='formTableTitle' lable='statusShow'></td>"+
  686. " <td styles='formTableValue' item='statusShow'></td>" +
  687. " <td styles='formTableTitle' lable='appealStatusShow'></td>"+
  688. " <td styles='formTableValue' item='appealStatusShow'></td></tr>"
  689. :
  690. "<tr><td styles='formTableTitle' lable='appealStatusShow'></td>"+
  691. " <td styles='formTableValue' item='appealStatusShow' colspan='3'></td></tr>"
  692. )
  693. +
  694. "<tr><td styles='formTableTitle' lable='appealReason'></td>"+
  695. " <td styles='formTableValue' item='appealReason' colspan='3'></td></tr>" +
  696. "<tr contain='selfHolidayType'><td styles='formTableTitle' lable='selfHolidayType'></td>"+
  697. " <td styles='formTableValue' item='selfHolidayType' colspan='3'></td></tr>" +
  698. "<tr contain='address'><td styles='formTableTitle' lable='address'></td>"+
  699. " <td styles='formTableValue' item='address' colspan='3'></td></tr>" +
  700. "<tr contain='startTime'><td styles='formTableTitle' lable='startTime'></td>"+
  701. " <td styles='formTableValue' item='startTime' colspan='3'></td></tr>" +
  702. "<tr contain='endTime'><td styles='formTableTitle' lable='endTime'></td>"+
  703. " <td styles='formTableValue' item='endTime' colspan='3'></td></tr>" +
  704. "<tr contain='appealDescription'><td styles='formTableTitle' lable='appealDescription'></td>"+
  705. " <td styles='formTableValue' item='appealDescription' colspan='3'></td></tr>" +
  706. "</table>"
  707. this.createTableArea.set("html",html);
  708. this.document = new MForm( this.createTableArea, this.data, {
  709. style : "popup",
  710. isEdited : this.isEdited || this.isNew,
  711. itemTemplate : {
  712. empName : { text:"员工姓名", type : "innertext" },
  713. recordDateString : { text:"考勤日期", type : "innertext"},
  714. onDutyTime : { text:"上班打卡时间", type : "innertext"},
  715. offDutyTime : { text:"下班打卡时间", type : "innertext"},
  716. statusShow : { text:"考勤状态", type : "innertext" },
  717. appealStatusShow : { text:"审批状态",type : "innertext"},
  718. appealReason : {
  719. notEmpty : true,
  720. text:"申述原因",
  721. type : "select",
  722. selectValue : ["","临时请假","出差","因公外出","其他"],
  723. event : { change : function(mdi){
  724. _self.switchFieldByAppealReason(mdi.getValue());
  725. }}
  726. },
  727. address : { text:"地点" },
  728. selfHolidayType : {
  729. text:"请假类型",
  730. type : "select",
  731. selectValue : ["","带薪年休假","带薪病假","带薪福利假","扣薪事假","其他"]
  732. },
  733. startTime : { text:"开始日期", tType : "datetime" },
  734. endTime : { text:"结束日期", tType : "datetime" },
  735. appealDescription : { text:"事由" }
  736. }
  737. }, this.app,this.css);
  738. this.document.load();
  739. _self.switchFieldByAppealReason(this.data.appealReason);
  740. //createFormNode.set("html", html);
  741. //this.setScrollBar(this.createTableContainer)
  742. this.cancelActionNode = new Element("div", {
  743. "styles": this.css.createCancelActionNode,
  744. "text": this.app.lp.cancel
  745. }).inject(this.createFormNode);
  746. this.cancelActionNode.addEvent("click", function(e){
  747. this.cancelCreate(e);
  748. }.bind(this));
  749. if( this.isNew || this.isEdited ){
  750. this.createOkActionNode = new Element("div", {
  751. "styles": this.css.createOkActionNode,
  752. "text": this.app.lp.ok
  753. }).inject(this.createFormNode);
  754. this.createOkActionNode.addEvent("click", function(e){
  755. this.okCreate(e);
  756. }.bind(this));
  757. }
  758. },
  759. switchFieldByAppealReason : function( ar ){
  760. var tempField = ["selfHolidayType","startTime","endTime","address","appealDescription"];
  761. var showField = [];
  762. if( ar == "临时请假" ){
  763. showField = ["selfHolidayType","startTime","endTime"];
  764. }else if( ar == "出差" ){
  765. showField = ["address","startTime","endTime"];
  766. }else if( ar == "因公外出" ){
  767. showField = ["address","startTime","endTime","appealDescription"];
  768. }else if( ar == "其他" ){
  769. showField = ["appealDescription"];
  770. }
  771. tempField.each( function( f ){
  772. this.createTableArea.getElement("[contain='"+f+"']").setStyle("display", showField.contains(f) ? "" : "none" );
  773. if( this.isNew || this.isEdited )this.document.items[f].options.notEmpty = (showField.contains(f) ? true : false )
  774. }.bind(this))
  775. },
  776. setCreateNodeSize: function(){
  777. var size = this.app.node.getSize();
  778. var allSize = this.app.content.getSize();
  779. var height = "550";
  780. var width = "800";
  781. this.createAreaNode.setStyles({
  782. "width": ""+size.x+"px",
  783. "height": ""+size.y+"px"
  784. });
  785. var hY = height;
  786. var mY = (size.y-height)/2;
  787. this.createNode.setStyles({
  788. "height": ""+hY+"px",
  789. "margin-top": ""+mY+"px",
  790. "width" : ""+width+"px"
  791. });
  792. this.createContainerNode.setStyles({
  793. "height": ""+hY+"px"
  794. });
  795. var iconSize = this.createIconNode ? this.createIconNode.getSize() : {x:0,y:0};
  796. var formMargin = hY-iconSize.y-20;
  797. this.createFormNode.setStyles({
  798. "height": ""+formMargin+"px",
  799. "margin-top": ""+20+"px"
  800. });
  801. },
  802. cancelCreate: function(e){
  803. this.createMarkNode.destroy();
  804. this.createAreaNode.destroy();
  805. delete this;
  806. },
  807. okCreate: function(e){
  808. var data = this.document.getResult(true,",",true,false,true);
  809. if (data ) {
  810. var start = data.startTime;
  811. var end = data.endTime;
  812. if (start != "" && end != "") {
  813. var starTime = new Date(start.replace(/-/g,"/"));
  814. var endTime = new Date(end.replace(/-/g,"/"));
  815. if (starTime >= endTime) {
  816. this.app.notice("开始日期不能晚于结束日期", "error");
  817. return;
  818. }
  819. }
  820. //获取设置
  821. var setting = {};
  822. this.app.restActions.listSetting(function(json){
  823. json.data.each(function( d ){
  824. setting[d.configCode] = d;
  825. }.bind(this))
  826. }.bind(this),null,false);
  827. if( setting.APPEAL_AUDITOR_TYPE && setting.APPEAL_AUDITOR_TYPE.configValue!="" && setting.APPEAL_AUDITOR_VALUE && setting.APPEAL_AUDITOR_VALUE.configValue!=""){
  828. if( setting.APPEAL_AUDITOR_TYPE.configValue == "所属部门职位" ){
  829. this.getDepartmentByPerson( function( department ){
  830. this.app.restActions.getDepartmentDuty( setting.APPEAL_AUDITOR_VALUE.configValue, department.name, function( json ){
  831. var flag = false;
  832. if (json.data) {
  833. var list = json.data.identityList;
  834. if (list && list.length > 0 && list[0] != "") {
  835. flag = true;
  836. this._ok( list[0], data )
  837. }
  838. }
  839. if (!flag) {
  840. this.app.notice("系统中没有配置"+department.name+"的"+setting.APPEAL_AUDITOR_VALUE.configValue+"职位,请联系管理员", "error");
  841. }
  842. }.bind(this) )
  843. }.bind(this) )
  844. }else if( setting.APPEAL_AUDITOR_TYPE.configValue == "人员属性" ){
  845. this.app.restActions.getPersonAttribute(setting.APPEAL_AUDITOR_VALUE.configValue, layout.desktop.session.user.name, function (json) {
  846. var flag = false;
  847. if (json.data) {
  848. var list = json.data.attributeList;
  849. if (list && list.length > 0 && list[0] != "") {
  850. flag = true;
  851. this._ok( list[0], data )
  852. }
  853. }
  854. if (!flag) {
  855. this.app.notice("系统中还没有配置您的"+setting.APPEAL_AUDITOR_VALUE.configValue+",请联系管理员", "error");
  856. }
  857. }.bind(this))
  858. }else if( setting.APPEAL_AUDITOR_TYPE.configValue == "指定人" ){
  859. this._ok( setting.APPEAL_AUDITOR_VALUE.configValue, data, true )
  860. }
  861. }else{
  862. this.app.restActions.getPersonAttribute("直接主管", layout.desktop.session.user.name, function (json) {
  863. var flag = false;
  864. if (json.data) {
  865. var list = json.data.attributeList;
  866. if (list && list.length > 0 && list[0] != "") {
  867. flag = true;
  868. this._ok( list[0], data )
  869. }
  870. }
  871. if (!flag) {
  872. this.app.notice("系统中还没有配置您的直接主管,请联系管理员", "error");
  873. }
  874. }.bind(this))
  875. }
  876. }
  877. //}else{
  878. // this.app.notice( "请填写申诉原因和具体描述", "error");
  879. //}
  880. },
  881. _ok: function( identity, data, isName ){
  882. if( isName ){
  883. data.processPerson1 = identity;
  884. this.app.restActions.createAppeal(this.data.id, data, function (json) {
  885. if (json.type == "ERROR") {
  886. this.app.notice(json.message, "error");
  887. } else {
  888. this.createMarkNode.destroy();
  889. this.createAreaNode.destroy();
  890. if (this.explorer.view)this.explorer.view.reload();
  891. this.app.notice("申诉已提交至" + data.processPerson1, "success");
  892. }
  893. }.bind(this));
  894. }else{
  895. this.app.restActions.getPersonByIdentity( identity, function (js) {
  896. data.processPerson1 = js.data.name;
  897. this.app.restActions.createAppeal(this.data.id, data, function (json) {
  898. if (json.type == "ERROR") {
  899. this.app.notice(json.message, "error");
  900. } else {
  901. this.createMarkNode.destroy();
  902. this.createAreaNode.destroy();
  903. if (this.explorer.view)this.explorer.view.reload();
  904. this.app.notice("申诉已提交至" + data.processPerson1, "success");
  905. }
  906. }.bind(this));
  907. }.bind(this))
  908. }
  909. },
  910. selectDateTime : function( el, timeOnly, isTme, baseDate ){
  911. var opt = {
  912. "style": "xform",
  913. "timeOnly": timeOnly,
  914. "isTime": isTme,
  915. "target": this.app.content
  916. }
  917. if( baseDate )opt.baseDate = baseDate;
  918. MWF.require("MWF.widget.Calendar", function(){
  919. var calendar = new MWF.widget.Calendar( el, opt );
  920. calendar.show();
  921. }.bind(this));
  922. },
  923. //getProcessPerson : function( callback ){
  924. // this.getDepartmentByPerson( function( departmentData ){
  925. // this.app.restActions.listPermission( function(json){
  926. // if( json.data.length == 0 ){
  927. // this.app.notice( "系统未配置考勤员,请联系管理员!", "error");
  928. // return;
  929. // }
  930. // var departmentManager, companyManager, processer;
  931. // json.data.each( function( d ){
  932. // if( d.organizationName == departmentData.name ){
  933. // departmentManager = d.adminName;
  934. // }
  935. // if(d.organizationName == departmentData.company ){
  936. // companyManager = d.adminName;
  937. // }
  938. // })
  939. // processer = departmentManager || companyManager;
  940. // if( !processer ){
  941. // this.app.notice( "未设置您所在部门和公司的考勤管理员,请联系系统管理员!", "error");
  942. // }else{
  943. // if(callback)callback(processer)
  944. // }
  945. // }.bind(this))
  946. // }.bind(this));
  947. //},
  948. getDepartmentByPerson : function( callback ){
  949. this.app.restActions.listDepartmentByPerson( function( json ){
  950. if( json.data.length > 0 ){
  951. if(callback)callback( json.data[0] );
  952. }else{
  953. this.app.notice( "未找到您所在的部门,请联系管理员!", "error");
  954. }
  955. }.bind(this), function(){
  956. this.app.notice( "未找到您所在的部门,请联系管理员!", "error");
  957. }, layout.desktop.session.user.name, false )
  958. }
  959. })