MyDetail.js 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190
  1. MWF.xDesktop.requireApp("Attendance", "Explorer", null, false);
  2. MWF.xDesktop.requireApp("Selector", "package", null, false);
  3. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  4. MWF.xApplication.Attendance.MyDetail = 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/$MyDetail/";
  14. this.cssPath = "/x_component_Attendance/$MyDetail/"+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.MyDetail.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.selfHoliday ){
  48. // this.selfHoliday = new MWF.xApplication.Attendance.MyDetail.SelfHoliday( this.selfHolidayArea, this );
  49. // this.selfHoliday.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.MyDetail.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.MyDetail.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.MyDetail.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 html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='filterTable'>"+
  125. "<tr>" +
  126. " <td styles='filterTableTitle'>"+ (new Date()).format("%Y年%m月") +"</td>"+
  127. " <td styles='filterTableTitle' lable='date'></td>"+
  128. " <td styles='filterTableValue' item='date'></td>" +
  129. " <td styles='filterTableTitle' lable='isAbsent'></td>"+
  130. " <td styles='filterTableValue' item='isAbsent'></td>" +
  131. " <td styles='filterTableTitle' lable='isLate'></td>"+
  132. " <td styles='filterTableValue' item='isLate'></td>" +
  133. " <td styles='filterTableTitle' lable='isLackOfTime'></td>"+
  134. " <td styles='filterTableValue' item='isLackOfTime'></td>" +
  135. " <td styles='filterTableValue' item='action'></td>" +
  136. "</tr>" +
  137. "</table>";
  138. this.fileterNode.set("html",html);
  139. MWF.xDesktop.requireApp("Template", "MForm", function(){
  140. this.form = new MForm( this.fileterNode, {}, {
  141. isEdited : true,
  142. itemTemplate : {
  143. date : { text : "日期", "type" : "select", "selectValue" : function(){
  144. var year = this.preMonthDate.getFullYear() ;
  145. var month = this.preMonthDate.getMonth() ;
  146. var date = new Date(year, month, 1);
  147. var days = [];
  148. days.push("");
  149. while (date.getMonth() === month) {
  150. var d = date.getDate().toString();
  151. if( d.length == 1 )d = "0"+d;
  152. days.push( d );
  153. date.setDate(date.getDate() + 1);
  154. }
  155. return days;
  156. }.bind(this)
  157. },
  158. isAbsent : { text: "缺勤", "type" : "select", "selectValue" : ["","true","false"], "selectText" : ["","缺勤","未缺勤"] },
  159. isLate : { text: "迟到", "type" : "select", "selectValue" : ["","true","false"], "selectText" : ["","迟到","未迟到"] },
  160. isLackOfTime : { text: "工时不足", "type" : "select", "selectValue" : ["","true","false"], "selectText" : ["","是","否"] },
  161. action : { "value" : "查询", type : "button", className : "filterButton", event : {
  162. click : function(){
  163. var result = this.form.getResult(false,null,false,true,false);
  164. var year = this.preMonthDate.getFullYear().toString();
  165. var month = (this.preMonthDate.getMonth()+1).toString();
  166. if( month.length == 1 )month = "0"+month;
  167. result.cycleYear = year;
  168. result.cycleMonth = month;
  169. if( typeOf( result.isAbsent ) == "string" )result.isAbsent = this.getBoolean( result.isAbsent );
  170. if( typeOf( result.isLate ) == "string" )result.isLate = this.getBoolean( result.isLate );
  171. if( typeOf( result.isLackOfTime ) == "string" )result.isLackOfTime = this.getBoolean( result.isLackOfTime );
  172. if( result.date && result.date !="" ){
  173. result.q_date = year + "-" + month + "-" + result.date;
  174. }
  175. this.loadView( result );
  176. }.bind(this)
  177. }}
  178. }
  179. }, this.app, this.css);
  180. this.form.load();
  181. }.bind(this), true);
  182. },
  183. //loadFilter2 : function(){
  184. // this.fileterNode = new Element("div.fileterNode", {
  185. // "styles" : this.css.fileterNode
  186. // }).inject(this.node)
  187. //
  188. // var table = new Element("table", {
  189. // "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.css.filterTable, "class" : "filterTable"
  190. // }).inject( this.fileterNode );
  191. // var tr = new Element("tr").inject(table);
  192. //
  193. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : this.preMonthDate.format(this.app.lp.dateFormatMonth) }).inject(tr);
  194. //
  195. // //this.createYearSelectTd( tr )
  196. // //this.createMonthSelectTd( tr )
  197. // this.createDateSelectTd( tr )
  198. // this.createIsAbsent(tr)
  199. // this.createIsLate( tr )
  200. // //this.createIsLeaveEarlier( tr )
  201. // this.createLackOfTimeCount(tr)
  202. // this.createActionTd( tr )
  203. //},
  204. //createYearSelectTd : function( tr ){
  205. // var _self = this;
  206. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "年度" }).inject(tr);
  207. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  208. // this.cycleYear = new MDomItem( td, {
  209. // "name" : "cycleYear",
  210. // "type" : "select",
  211. // "selectValue" : function(){
  212. // var years = [];
  213. // var year = new Date().getFullYear();
  214. // for(var i=0; i<6; i++ ){
  215. // years.push( year-- );
  216. // }
  217. // return years;
  218. // },
  219. // "event" : {
  220. // "change" : function(){ if(_self.dateSelecterTd)_self.createDateSelectTd() }
  221. // }
  222. // }, true, this.app );
  223. // this.cycleYear.load();
  224. //},
  225. //createMonthSelectTd : function( tr ){
  226. // var _self = this;
  227. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "月份" }).inject(tr);
  228. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  229. // this.cycleMonth = new MDomItem( td, {
  230. // "name" : "cycleMonth",
  231. // "type" : "select",
  232. // "defaultValue" : function(){
  233. // var month = (new Date().getMonth() + 1 ).toString();
  234. // return month.length == 1 ? "0"+month : month;
  235. // },
  236. // "selectValue" :["","01","02","03","04","05","06","07","08","09","10","11","12"],
  237. // "event" : {
  238. // "change" : function(){ if(_self.dateSelecterTd)_self.createDateSelectTd() }
  239. // }
  240. // }, true, this.app );
  241. // this.cycleMonth.load();
  242. //},
  243. //createDateSelectTd : function( tr ){
  244. // var _self = this;
  245. // if( tr ){
  246. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "日期" }).inject(tr);
  247. // this.dateSelecterTd = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  248. // }
  249. // if( this.q_date ){
  250. // this.dateSelecterTd.empty();
  251. // }
  252. // this.q_date = new MDomItem( this.dateSelecterTd, {
  253. // "name" : "q_date",
  254. // "type" : "select",
  255. // "selectValue" : function(){
  256. // var year = _self.cycleYear ? parseInt(_self.cycleYear.getValue()) : _self.preMonthDate.getFullYear() ;
  257. // var month = _self.cycleMonth ? (parseInt(_self.cycleMonth.getValue())-1) : _self.preMonthDate.getMonth() ;
  258. // var date = new Date(year, month, 1);
  259. // var days = [];
  260. // days.push("");
  261. // while (date.getMonth() === month) {
  262. // var d = date.getDate().toString();
  263. // if( d.length == 1 )d = "0"+d
  264. // days.push( d );
  265. // date.setDate(date.getDate() + 1);
  266. // }
  267. // return days;
  268. // }
  269. // }, true, this.app );
  270. // this.q_date.load();
  271. //},
  272. //createIsAbsent: function(tr){
  273. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "缺勤" }).inject(tr);
  274. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  275. // this.isAbsent = new MDomItem( td, {
  276. // "name" : "isAbsent",
  277. // "type" : "select",
  278. // "selectValue" : ["","true","false"],
  279. // "selectText" : ["","缺勤","未缺勤"],
  280. // }, true, this.app );
  281. // this.isAbsent.load();
  282. //},
  283. ////createIsLeaveEarlier: function(tr){
  284. //// var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "早退" }).inject(tr);
  285. //// var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  286. //// this.isLeaveEarlier = new MDomItem( td, {
  287. //// "name" : "isLeaveEarlier",
  288. //// "type" : "select",
  289. //// "selectValue" : ["-1","true","false"],
  290. //// "selectText" : ["","早退","未早退"],
  291. //// }, true, this.app );
  292. //// this.isLeaveEarlier.load();
  293. ////},
  294. //createLackOfTimeCount: function(tr){
  295. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "工时不足" }).inject(tr);
  296. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  297. // this.isLackOfTime = new MDomItem( td, {
  298. // "name" : "isLackOfTime",
  299. // "type" : "select",
  300. // "selectValue" : ["","true","false"],
  301. // "selectText" : ["","是","否"],
  302. // }, true, this.app );
  303. // this.isLackOfTime.load();
  304. //},
  305. //createIsLate: function(tr){
  306. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "迟到" }).inject(tr);
  307. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  308. // this.isLate = new MDomItem( td, {
  309. // "name" : "isLate",
  310. // "type" : "select",
  311. // "selectValue" : ["","true","false"],
  312. // "selectText" : ["","迟到","未迟到"],
  313. // }, true, this.app );
  314. // this.isLate.load();
  315. //},
  316. //createActionTd : function( tr ){
  317. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  318. // var input = new Element("button",{
  319. // "text" : "查询",
  320. // "styles" : this.css.filterButton
  321. // }).inject(td);
  322. // input.addEvent("click", function(){
  323. // //var filterData = {
  324. // // cycleYear : this.cycleYear.getValue(),
  325. // // cycleMonth : this.cycleMonth.getValue()
  326. // //}
  327. // var result = this.form.getResult(false, null,false,true,false);
  328. // var year = this.preMonthDate.getFullYear().toString();
  329. // var month = (this.preMonthDate.getMonth()+1).toString();
  330. // if( month.length == 1 )month = "0"+month;
  331. // var filterData = {
  332. // cycleYear : year,
  333. // cycleMonth : month
  334. // }
  335. // if( this.isAbsent && this.isAbsent.getValue()!=""){
  336. // filterData.isAbsent = this.getBoolean( this.isAbsent.getValue() );
  337. // }
  338. // if( this.isLeaveEarlier && this.isLeaveEarlier.getValue()!=""){
  339. // filterData.isLeaveEarlier = this.getBoolean( this.isLeaveEarlier.getValue());
  340. // }
  341. // if( this.isLate && this.isLate.getValue()!="" ){
  342. // filterData.isLate = this.getBoolean( this.isLate.getValue());
  343. // }
  344. // if( this.isLackOfTime && this.isLackOfTime.getValue()!=""){
  345. // filterData.isLackOfTime = this.getBoolean( this.isLackOfTime.getValue());
  346. // }
  347. // if( this.q_date && this.q_date.getValue()!="" ){
  348. // filterData.q_date = year + "-" + month + "-" + this.q_date.getValue();
  349. // }
  350. // this.loadView( filterData );
  351. // }.bind(this))
  352. //},
  353. getBoolean : function( value ){
  354. if( value === "true" )return true;
  355. if( value === "false" )return false;
  356. return value;
  357. },
  358. //selecePerson: function(){
  359. // var options = {
  360. // "type": "person",
  361. // "title": "选择人员",
  362. // "count" : "1",
  363. // "onComplete": function(items){
  364. // var names = [];
  365. // items.each(function(item){
  366. // names.push(item.data.name);
  367. // }.bind(this));
  368. // this.q_empName.setValue( names.join(",") )
  369. // }.bind(this)
  370. // };
  371. // var selector = new MWF.O2Selector(this.app.content, options);
  372. //},
  373. loadContentNode: function(){
  374. this.elementContentNode = new Element("div", {
  375. "styles": this.css.elementContentNode
  376. }).inject(this.node);
  377. this.app.addEvent("resize", function(){this.setContentSize();}.bind(this));
  378. },
  379. loadView : function( filterData ){
  380. this.elementContentNode.empty();
  381. if( this.view )delete this.view;
  382. this.view = new MWF.xApplication.Attendance.MyDetail.View(this.elementContentNode, this.app,this );
  383. this.view.filterData = filterData;
  384. this.view.load();
  385. this.setContentSize();
  386. },
  387. setContentSize: function(){
  388. var tabNodeSize = this.parent.tabs ? this.parent.tabs.tabNodeContainer.getSize() : {"x":0,"y":0};
  389. var fileterNodeSize = this.fileterNode ? this.fileterNode.getSize() : {"x":0,"y":0};
  390. var nodeSize = this.parent.node.getSize();
  391. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  392. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  393. //var filterSize = this.filterNode.getSize();
  394. var height = nodeSize.y-tabNodeSize.y-pt-pb-fileterNodeSize.y-20;
  395. this.elementContentNode.setStyle("height", ""+height+"px");
  396. this.pageCount = (height/40).toInt()+5;
  397. if (this.view && this.view.items.length<this.pageCount){
  398. this.view.loadElementList(this.pageCount-this.view.items.length);
  399. }
  400. }
  401. });
  402. MWF.xApplication.Attendance.MyDetail.SelfHoliday = new Class({
  403. Extends: MWF.xApplication.Attendance.MyDetail.Explorer,
  404. loadView : function( filterData ){
  405. this.elementContentNode.empty();
  406. if( this.view )delete this.view;
  407. this.view = new MWF.xApplication.Attendance.MyDetail.SelfHolidayView(this.elementContentNode, this.app,this );
  408. this.view.filterData = filterData;
  409. this.view.load();
  410. this.setContentSize();
  411. }
  412. });
  413. MWF.xApplication.Attendance.MyDetail.DetailStaticExplorer = new Class({
  414. Extends: MWF.xApplication.Attendance.MyDetail.Explorer,
  415. load: function(){
  416. //this.loadFilter();
  417. this.loadContentNode();
  418. this.setNodeScroll();
  419. var filterData = {
  420. cycleYear : this.preMonthDate.getFullYear().toString(),
  421. cycleMonth : this.preMonthDate.format(this.app.lp.dateFormatOnlyMonth)
  422. };
  423. this.loadView( filterData );
  424. },
  425. loadFilter : function(){
  426. this.fileterNode = new Element("div.fileterNode", {
  427. "styles" : this.css.fileterNode
  428. }).inject(this.node);
  429. var table = new Element("table", {
  430. "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.css.filterTable, "class" : "filterTable"
  431. }).inject( this.fileterNode );
  432. table.setStyle("width","360px");
  433. var tr = new Element("tr").inject(table);
  434. this.createYearSelectTd( tr );
  435. this.createMonthSelectTd( tr );
  436. //this.createDateSelectTd( tr )
  437. this.createActionTd( tr )
  438. },
  439. createMonthSelectTd : function( tr ){
  440. var _self = this;
  441. var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "月份" }).inject(tr);
  442. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  443. this.cycleMonth = new MDomItem( td, {
  444. "name" : "cycleMonth",
  445. "type" : "select",
  446. "selectValue" :["","01","02","03","04","05","06","07","08","09","10","11","12"],
  447. "event" : {
  448. "change" : function(){ if(_self.dateSelecterTd)_self.createDateSelectTd() }
  449. }
  450. }, true, this.app );
  451. this.cycleMonth.load();
  452. },
  453. createActionTd : function( tr ){
  454. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  455. var input = new Element("button",{
  456. "text" : "查询",
  457. "styles" : this.css.filterButton
  458. }).inject(td);
  459. input.addEvent("click", function(){
  460. //var filterData = {
  461. // cycleYear : this.cycleYear.getValue(),
  462. // cycleMonth : this.cycleMonth.getValue()
  463. //}
  464. var year = this.preMonthDate.getFullYear().toString();
  465. var month = (this.preMonthDate.getMonth()+1).toString();
  466. if( month.length == 1 )month = "0"+month;
  467. var filterData = {
  468. cycleYear : year,
  469. cycleMonth : month
  470. };
  471. if( this.isAbsent && this.isAbsent.getValue()!="" ){
  472. filterData.isAbsent = this.isAbsent.getValue();
  473. }
  474. if( this.isLeaveEarlier && this.isLeaveEarlier.getValue()!=""){
  475. filterData.isLeaveEarlier = this.isLeaveEarlier.getValue();
  476. }
  477. if( this.isLate && this.isLate.getValue()!="" ){
  478. filterData.isLate = this.isLate.getValue();
  479. }
  480. if( this.q_date && this.q_date.getValue()!="" ){
  481. filterData.q_date = year + "-" + month + "-" + this.q_date.getValue();
  482. }
  483. this.loadView( filterData );
  484. }.bind(this))
  485. },
  486. loadView : function( filterData ){
  487. this.elementContentNode.empty();
  488. if( this.view )delete this.view;
  489. this.view = new MWF.xApplication.Attendance.MyDetail.DetailStaticView(this.elementContentNode, this.app,this );
  490. this.view.filterData = filterData;
  491. this.view.listItemUrl = this.path+"listItem_detailStatic.json";
  492. this.view.load();
  493. this.setContentSize();
  494. }
  495. });
  496. MWF.xApplication.Attendance.MyDetail.SelfHolidayStaticExplorer = new Class({
  497. Extends: MWF.xApplication.Attendance.MyDetail.Explorer,
  498. loadView : function( filterData ){
  499. this.elementContentNode.empty();
  500. if( this.view )delete this.view;
  501. this.view = new MWF.xApplication.Attendance.MyDetail.SelfHolidayStaticView(this.elementContentNode, this.app,this );
  502. this.view.filterData = filterData;
  503. this.view.load();
  504. this.setContentSize();
  505. }
  506. });
  507. MWF.xApplication.Attendance.MyDetail.View = new Class({
  508. Extends: MWF.xApplication.Attendance.Explorer.View,
  509. _createItem: function(data){
  510. return new MWF.xApplication.Attendance.MyDetail.Document(this.table, data, this.explorer, this);
  511. },
  512. _getCurrentPageData: function(callback, count){
  513. if(!count)count=100;
  514. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  515. var filter = this.filterData || {};
  516. filter.key = this.sortField || this.sortFieldDefault || "";
  517. filter.order = this.sortType || this.sortTypeDefault || "";
  518. filter.q_empName = layout.desktop.session.user.distinguishedName;
  519. this.actions.listDetailFilterNext( id, count, filter, function(json){
  520. var data = json.data;
  521. data.each(function(d){
  522. d.APPEALABLE = this.explorer.config.APPEALABLE;
  523. }.bind(this));
  524. json.data = data;
  525. if( callback )callback(json);
  526. }.bind(this));
  527. //this.actions.listDetailFilterUser( filter, function(json){
  528. // if( callback )callback(json);
  529. //}.bind(this))
  530. },
  531. _removeDocument: function(documentData, all){
  532. },
  533. _createDocument: function(){
  534. },
  535. _openDocument: function( documentData ){
  536. }
  537. });
  538. MWF.xApplication.Attendance.MyDetail.SelfHolidayView = new Class({
  539. Extends: MWF.xApplication.Attendance.Explorer.View,
  540. _createItem: function(data){
  541. return new MWF.xApplication.Attendance.MyDetail.SelfHolidayDocument(this.table, data, this.explorer, this);
  542. },
  543. _getCurrentPageData: function(callback, count){
  544. var filter = this.filterData || {};
  545. filter.q_empName = layout.desktop.session.user.distinguishedName;
  546. this.actions.listDetailFilterUser( filter, function(json){
  547. if( callback )callback(json);
  548. }.bind(this))
  549. },
  550. _removeDocument: function(documentData, all){
  551. },
  552. _createDocument: function(){
  553. },
  554. _openDocument: function( documentData ){
  555. }
  556. });
  557. MWF.xApplication.Attendance.MyDetail.DetailStaticView = new Class({
  558. Extends: MWF.xApplication.Attendance.Explorer.View,
  559. _createItem: function(data){
  560. return new MWF.xApplication.Attendance.MyDetail.DetailStaticDocument(this.table, data, this.explorer, this);
  561. },
  562. _getCurrentPageData: function(callback, count){
  563. var filter = this.filterData || {};
  564. filter.key = this.sortField || this.sortFieldDefault || "";
  565. filter.order = this.sortType || this.sortTypeDefault || "";
  566. filter.q_empName = layout.desktop.session.user.distinguishedName;
  567. //if( filter.cycleMonth == "" )filter.cycleMonth="(0)";
  568. var month = (new Date().getMonth()+1).toString();
  569. if( month.length == 1 )month = "0"+month;
  570. filter.cycleMonth = month;
  571. this.actions.listStaticMonthPerson( filter.q_empName, filter.cycleYear,filter.cycleMonth, function(json){
  572. if( callback )callback(json);
  573. }.bind(this))
  574. },
  575. _removeDocument: function(documentData, all){
  576. },
  577. _createDocument: function(){
  578. },
  579. _openDocument: function( documentData ){
  580. }
  581. });
  582. MWF.xApplication.Attendance.MyDetail.SelfHolidayStaticView = new Class({
  583. Extends: MWF.xApplication.Attendance.Explorer.View,
  584. _createItem: function(data){
  585. return new MWF.xApplication.Attendance.MyDetail.SelfHolidayStaticDocument(this.table, data, this.explorer, this);
  586. },
  587. _getCurrentPageData: function(callback, count){
  588. var filter = this.filterData || {};
  589. this.actions.listDetailFilterUser( filter, function(json){
  590. if( callback )callback(json);
  591. }.bind(this))
  592. },
  593. _removeDocument: function(documentData, all){
  594. },
  595. _createDocument: function(){
  596. },
  597. _openDocument: function( documentData ){
  598. }
  599. });
  600. MWF.xApplication.Attendance.MyDetail.Document = new Class({
  601. Extends: MWF.xApplication.Attendance.Explorer.Document,
  602. appeal :function(){
  603. var form = new MWF.xApplication.Attendance.MyDetail.Appeal( this.explorer, this.data );
  604. form.create();
  605. },
  606. seeAppeal : function(){
  607. var form = new MWF.xApplication.Attendance.MyDetail.Appeal( this.explorer, this.data );
  608. form.open();
  609. }
  610. });
  611. MWF.xApplication.Attendance.MyDetail.SelfHolidayDocument = new Class({
  612. Extends: MWF.xApplication.Attendance.Explorer.Document
  613. });
  614. MWF.xApplication.Attendance.MyDetail.DetailStaticDocument = new Class({
  615. Extends: MWF.xApplication.Attendance.Explorer.Document
  616. });
  617. MWF.xApplication.Attendance.MyDetail.SelfHolidayStaticDocument = new Class({
  618. Extends: MWF.xApplication.Attendance.Explorer.Document
  619. });
  620. MWF.xApplication.Attendance.MyDetail.Appeal = new Class({
  621. Extends: MWF.widget.Common,
  622. initialize: function( explorer, detailData ){
  623. this.explorer = explorer;
  624. this.app = explorer.app;
  625. this.detailData = detailData;
  626. this.css = this.explorer.css;
  627. this.load();
  628. },
  629. load: function(){
  630. },
  631. open: function(e){
  632. this.isNew = false;
  633. this.isEdited = false;
  634. this.app.restActions.getAppeal(this.detailData.id, function(json){
  635. this.data = json.data;
  636. this.data.onDutyTime = this.detailData.onDutyTime;
  637. this.data.offDutyTime = this.detailData.offDutyTime;
  638. }.bind(this),null,false);
  639. if(!this.data)this.data = this.detailData || {};
  640. this._open();
  641. },
  642. create: function(){
  643. this.isNew = true;
  644. this.data = this.detailData || {};
  645. this._open();
  646. },
  647. edit: function(){
  648. this.isEdited = true;
  649. this.app.restActions.getAppeal(this.detailData.id, function(json){
  650. this.data = json.data;
  651. this.data.onDutyTime = this.detailData.onDutyTime;
  652. this.data.offDutyTime = this.detailData.offDutyTime;
  653. }.bind(this),null,false);
  654. if(!this.data)this.data = this.detailData || {};
  655. this._open();
  656. },
  657. _open : function(){
  658. this.createMarkNode = new Element("div", {
  659. "styles": this.css.createMarkNode,
  660. "events": {
  661. "mouseover": function(e){e.stopPropagation();},
  662. "mouseout": function(e){e.stopPropagation();}
  663. }
  664. }).inject(this.app.content, "after");
  665. this.createAreaNode = new Element("div", {
  666. "styles": this.css.createAreaNode
  667. });
  668. this.createNode();
  669. this.createAreaNode.inject(this.createMarkNode, "after");
  670. this.createAreaNode.fade("in");
  671. this.setCreateNodeSize();
  672. this.setCreateNodeSizeFun = this.setCreateNodeSize.bind(this);
  673. this.addEvent("resize", this.setCreateNodeSizeFun);
  674. },
  675. createNode: function(){
  676. var _self = this;
  677. this.createNode = new Element("div", {
  678. "styles": this.css.createNode
  679. }).inject(this.createAreaNode);
  680. this.createContainerNode = new Element("div", {
  681. "styles": this.css.createContainerNode
  682. }).inject(this.createNode);
  683. this.setScrollBar( this.createContainerNode );
  684. this.createIconNode = new Element("div", {
  685. "styles": this.isNew ? this.css.createNewNode : this.css.createIconNode
  686. }).inject(this.createContainerNode);
  687. this.createFormNode = new Element("div", {
  688. "styles": this.css.createFormNode
  689. }).inject(this.createContainerNode);
  690. this.createTableContainer = new Element("div", {
  691. "styles": this.css.createTableContainer
  692. }).inject(this.createFormNode);
  693. this.createTableArea = new Element("div", {
  694. "styles": this.css.createTableArea
  695. }).inject(this.createTableContainer);
  696. var d = this.data;
  697. var status = [];
  698. if(d.isGetSelfHolidays && d.selfHolidayDayTime == "全天" ) {
  699. status.push('请假或外出报备')
  700. }else if( d.isAbnormalDuty && d.abnormalDutyDayTime == "全天" ){
  701. status.push('异常打卡')
  702. }else if(d.isLackOfTime ) {
  703. status.push('工时不足')
  704. }else{
  705. if( d.isGetSelfHolidays && d.selfHolidayDayTime == "上午" ){
  706. status.push("请假或外出报备")
  707. }else if(d.isLate){
  708. status.push('迟到')
  709. }else if(d.isAbsent && (d.absentDayTime == "上午" || d.absentDayTime == "全天" ) ){
  710. status.push('缺勤')
  711. }else if( d.isAbnormalDuty && (d.abnormalDutyDayTime == "全天" || d.abnormalDutyDayTime == "上午")){
  712. status.push('异常打卡')
  713. }
  714. if( d.isGetSelfHolidays && d.selfHolidayDayTime == "下午" ){
  715. status.push("请假或外出报备");
  716. //}else if(d.isLeaveEarlier){
  717. // status.push( '早退')
  718. }else if(d.isAbsent && d.absentDayTime == "下午" ){
  719. status.push( '缺勤')
  720. }else if(d.isAbnormalDuty && d.abnormalDutyDayTime == "下午" ){
  721. status.push('异常打卡')
  722. }
  723. }
  724. this.data.statusShow = status.unique().join();
  725. var appealStatus = "发起";
  726. if (d.status == 0 ) {
  727. appealStatus = "待处理"
  728. } else if (d.status == 1) {
  729. appealStatus = "审批通过"
  730. } else if (d.status == -1) {
  731. appealStatus = "审批未通过"
  732. }
  733. //if (d.appealStatus == 1) {
  734. // appealStatus = "申诉中"
  735. //} else if (d.appealStatus == -1) {
  736. // appealStatus = "申诉未通过"
  737. //} else if (d.appealStatus == 9) {
  738. // appealStatus = "申诉通过"
  739. //}
  740. this.data.appealStatusShow = appealStatus;
  741. //var auditors = this.getAuditor();
  742. var identityList = this.getIdentity();
  743. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  744. "<tr><td colspan='4' styles='formTableHead'>申诉申请单</td></tr>" +
  745. "<tr><td styles='formTableTitle'>员工姓名</td>"+
  746. " <td styles='formTableValue'>"+this.data.empName.split("@")[0]+"</td>" +
  747. " <td styles='formTableTitle' lable='recordDateString'></td>"+
  748. " <td styles='formTableValue' item='recordDateString'></td></tr>"
  749. +"<tr><td styles='formTableTitle' lable='onDutyTime'></td>"+
  750. " <td styles='formTableValue' item='onDutyTime'></td>" +
  751. " <td styles='formTableTitle' lable='offDutyTime'></td>"+
  752. " <td styles='formTableValue' item='offDutyTime'></td></tr>" +
  753. ( ( this.isNew && identityList.identities.length > 1 ) ?
  754. "<tr><td styles='formTableTitle' lable='identity'></td>"+
  755. " <td styles='formTableValue' item='identity' colspan='3'></td></tr>" : ""
  756. ) +
  757. ( this.isNew ?
  758. "<tr><td styles='formTableTitle' lable='statusShow'></td>"+
  759. " <td styles='formTableValue' item='statusShow'></td>" +
  760. " <td styles='formTableTitle' lable='appealStatusShow'></td>"+
  761. " <td styles='formTableValue' item='appealStatusShow'></td></tr>"
  762. :
  763. "<tr><td styles='formTableTitle' lable='appealStatusShow'></td>"+
  764. " <td styles='formTableValue' item='appealStatusShow' colspan='3'></td></tr>"
  765. )
  766. +
  767. "<tr><td styles='formTableTitle' lable='appealReason'></td>"+
  768. " <td styles='formTableValue' item='appealReason' colspan='3'></td></tr>" +
  769. "<tr contain='selfHolidayType'><td styles='formTableTitle' lable='selfHolidayType'></td>"+
  770. " <td styles='formTableValue' item='selfHolidayType' colspan='3'></td></tr>" +
  771. "<tr contain='address'><td styles='formTableTitle' lable='address'></td>"+
  772. " <td styles='formTableValue' item='address' colspan='3'></td></tr>" +
  773. "<tr contain='startTime'><td styles='formTableTitle' lable='startTime'></td>"+
  774. " <td styles='formTableValue' item='startTime' colspan='3'></td></tr>" +
  775. "<tr contain='endTime'><td styles='formTableTitle' lable='endTime'></td>"+
  776. " <td styles='formTableValue' item='endTime' colspan='3'></td></tr>" +
  777. "<tr contain='appealDescription'><td styles='formTableTitle' lable='appealDescription'></td>"+
  778. " <td styles='formTableValue' item='appealDescription' colspan='3'></td></tr>" +
  779. "</table>";
  780. this.createTableArea.set("html",html);
  781. this.document = new MForm( this.createTableArea, this.data, {
  782. style : "popup",
  783. isEdited : this.isEdited || this.isNew,
  784. itemTemplate : {
  785. recordDateString : { text:"考勤日期", type : "innertext"},
  786. onDutyTime : { text:"上班打卡时间", type : "innertext"},
  787. offDutyTime : { text:"下班打卡时间", type : "innertext"},
  788. statusShow : { text:"考勤状态", type : "innertext" },
  789. appealStatusShow : { text:"审批状态",type : "innertext"},
  790. //processPerson1 : {
  791. // text : "审核人", type : "select", selectValue : auditors, selectText : function(){
  792. // var array = [];
  793. // auditors.each( function( a ){ array.push(a.split("@")[0] ) } );
  794. // return array;
  795. // }
  796. //},
  797. appealReason : {
  798. notEmpty : true,
  799. text:"申述原因",
  800. type : "select",
  801. selectValue : ["","临时请假","出差","因公外出","其他"],
  802. event : { change : function(mdi){
  803. _self.switchFieldByAppealReason(mdi.getValue());
  804. }}
  805. },
  806. identity : {
  807. notEmpty : true,
  808. text:"选择部门",
  809. type : "radio",
  810. defaultValue : function(){
  811. return identityList.identities[0];
  812. }.bind(this),
  813. selectText : identityList.units,
  814. selectValue : identityList.identities
  815. },
  816. address : { text:"地点" },
  817. selfHolidayType : {
  818. text:"请假类型",
  819. type : "select",
  820. selectValue : ["","带薪年休假","带薪病假","带薪福利假","扣薪事假","其他"]
  821. },
  822. startTime : { text:"开始日期", tType : "datetime" },
  823. endTime : { text:"结束日期", tType : "datetime" },
  824. appealDescription : { text:"事由" }
  825. }
  826. }, this.app,this.css);
  827. this.document.load();
  828. _self.switchFieldByAppealReason(this.data.appealReason);
  829. //createFormNode.set("html", html);
  830. //this.setScrollBar(this.createTableContainer)
  831. this.cancelActionNode = new Element("div", {
  832. "styles": this.css.createCancelActionNode,
  833. "text": this.app.lp.cancel
  834. }).inject(this.createFormNode);
  835. this.cancelActionNode.addEvent("click", function(e){
  836. this.cancelCreate(e);
  837. }.bind(this));
  838. if( this.isNew || this.isEdited ){
  839. this.createOkActionNode = new Element("div", {
  840. "styles": this.css.createOkActionNode,
  841. "text": this.app.lp.ok
  842. }).inject(this.createFormNode);
  843. this.createOkActionNode.addEvent("click", function(e){
  844. this.okCreate(e);
  845. }.bind(this));
  846. }
  847. },
  848. switchFieldByAppealReason : function( ar ){
  849. var tempField = ["selfHolidayType","startTime","endTime","address","appealDescription"];
  850. var showField = [];
  851. if( ar == "临时请假" ){
  852. showField = ["selfHolidayType","startTime","endTime"];
  853. }else if( ar == "出差" ){
  854. showField = ["address","startTime","endTime"];
  855. }else if( ar == "因公外出" ){
  856. showField = ["address","startTime","endTime","appealDescription"];
  857. }else if( ar == "其他" ){
  858. showField = ["appealDescription"];
  859. }
  860. tempField.each( function( f ){
  861. this.createTableArea.getElement("[contain='"+f+"']").setStyle("display", showField.contains(f) ? "" : "none" );
  862. if( this.isNew || this.isEdited )this.document.items[f].options.notEmpty = (showField.contains(f) ? true : false )
  863. }.bind(this))
  864. },
  865. getIdentity : function(){
  866. var identityList = { identities : [], units : [] };
  867. this.app.personActions.getPerson( function( json ){
  868. json.data.woIdentityList.each( function( id ){
  869. var unit = id.woUnit;
  870. identityList.identities.push( id.distinguishedName );
  871. identityList.units.push( unit.name );
  872. }.bind(this))
  873. }.bind(this), null, false );
  874. return identityList;
  875. },
  876. getAuditor : function(){
  877. //获取设置
  878. var setting = {};
  879. var result = [];
  880. this.app.restActions.listSetting(function(json){
  881. json.data.each(function( d ){
  882. setting[d.configCode] = d;
  883. }.bind(this))
  884. }.bind(this),null,false);
  885. if( setting.APPEAL_AUDITOR_TYPE && setting.APPEAL_AUDITOR_TYPE.configValue!="" && setting.APPEAL_AUDITOR_VALUE && setting.APPEAL_AUDITOR_VALUE.configValue!=""){
  886. if( setting.APPEAL_AUDITOR_TYPE.configValue == "汇报对象" ) {
  887. var d = {"personList": [layout.desktop.session.user.distinguishedName] };
  888. this.app.orgActions.listPersonSupDirectValue( d, function( json ){
  889. var superior = json.data.personList;
  890. if( !superior || !superior[0] ){
  891. this.app.notice("组织管理中没有配置您的汇报对象,请联系管理员", "error");
  892. }else{
  893. var p = superior[0];
  894. if( p.split("@")[ p.split("@").length - 1].toLowerCase() == "i" ){
  895. result.push( this.getPersonByIdentity( p ) )
  896. }else{
  897. result.push( p )
  898. }
  899. }
  900. }.bind(this), null, false );
  901. }else if( setting.APPEAL_AUDITOR_TYPE.configValue == "所属部门职位" ){
  902. this.app.personActions.getPerson( function( json ){
  903. json.data.woIdentityList.each( function( id ){
  904. var unit = id.woUnit;
  905. var d = {"name": setting.APPEAL_AUDITOR_VALUE.configValue, "unit": unit.distinguishedName};
  906. this.app.orgActions.getDutyValue( d, function( js ){
  907. var ids = js.data ? js.data.identityList : [];
  908. if ( typeOf( ids ) == "array" && ids[0] ) {
  909. ids.each( function( id ){
  910. result = result.concat( this.getPersonByIdentity( id ) );
  911. }.bind(this));
  912. }else{
  913. this.app.notice("系统中没有配置"+unit.name+"的"+setting.APPEAL_AUDITOR_VALUE.configValue+"职位,请联系管理员", "error");
  914. }
  915. }.bind(this),null ,false)
  916. }.bind(this))
  917. }.bind(this), null, false );
  918. }else if( setting.APPEAL_AUDITOR_TYPE.configValue == "人员属性" ){
  919. this.app.personActions.getPerson( function( json ){
  920. var attribute = setting.APPEAL_AUDITOR_VALUE.configValue;
  921. json.data.woPersonAttributeList.each( function( attr ){
  922. if( attr.name == attribute ){
  923. var p = attr.attributeList[0];
  924. if( p ){
  925. if( p.split("@")[ p.split("@").length - 1].toLowerCase() == "i" ){
  926. result.push( this.getPersonByIdentity( p ) )
  927. }else{
  928. result.push( p )
  929. }
  930. }
  931. }
  932. })
  933. }.bind(this),null ,false);
  934. if( result.length == 0 ){
  935. this.app.notice("系统中没有配置您的人员属性“"+setting.APPEAL_AUDITOR_VALUE.configValue+"”,请联系管理员", "error");
  936. }
  937. }else if( setting.APPEAL_AUDITOR_TYPE.configValue == "指定人" ){
  938. var p = setting.APPEAL_AUDITOR_TYPE.configValue;
  939. if( p.split("@")[ p.split("@").length - 1].toLowerCase() == "i" ){
  940. result.push( this.getPersonByIdentity( p ) )
  941. }else{
  942. result.push( p )
  943. }
  944. }
  945. }else{
  946. this.app.personActions.getPerson( function( json ){
  947. var attribute = "直接主管";
  948. json.data.woPersonAttributeList.each( function( attr ){
  949. if( attr.name == attribute ){
  950. var p = attr.attributeList[0];
  951. if( p ){
  952. if( p.split("@")[ p.split("@").length - 1].toLowerCase() == "i" ){
  953. result.push( this.getPersonByIdentity( p ) )
  954. }else{
  955. result.push( p )
  956. }
  957. }
  958. }
  959. })
  960. }.bind(this),null ,false);
  961. this.app.notice("系统中没有配置您的人员属性“直接主管”,请联系管理员", "error");
  962. }
  963. return result;
  964. },
  965. getPersonByIdentity : function( identity ){
  966. var d = {"identityList":[ identity ]};
  967. var result = [];
  968. this.app.orgActions.listPersonWithIdentityValue( d, function (js){
  969. result = js.data.personList;
  970. }.bind(this), null, false);
  971. return result;
  972. },
  973. setCreateNodeSize: function(){
  974. var size = this.app.node.getSize();
  975. var allSize = this.app.content.getSize();
  976. var height = "580";
  977. var width = "800";
  978. this.createAreaNode.setStyles({
  979. "width": ""+size.x+"px",
  980. "height": ""+size.y+"px"
  981. });
  982. var hY = height;
  983. var mY = (size.y-height)/2;
  984. this.createNode.setStyles({
  985. "height": ""+hY+"px",
  986. "margin-top": ""+mY+"px",
  987. "width" : ""+width+"px"
  988. });
  989. this.createContainerNode.setStyles({
  990. "height": ""+hY+"px"
  991. });
  992. var iconSize = this.createIconNode ? this.createIconNode.getSize() : {x:0,y:0};
  993. var formMargin = hY-iconSize.y-20;
  994. this.createFormNode.setStyles({
  995. "height": ""+formMargin+"px",
  996. "margin-top": ""+20+"px"
  997. });
  998. },
  999. cancelCreate: function(e){
  1000. this.createMarkNode.destroy();
  1001. this.createAreaNode.destroy();
  1002. delete this;
  1003. },
  1004. okCreate: function(e){
  1005. var data = this.document.getResult(true,",",true,false,true);
  1006. if (data ) {
  1007. var start = data.startTime;
  1008. var end = data.endTime;
  1009. if (start != "" && end != "") {
  1010. var starTime = new Date(start.replace(/-/g, "/"));
  1011. var endTime = new Date(end.replace(/-/g, "/"));
  1012. if (starTime >= endTime) {
  1013. this.app.notice("开始日期不能晚于结束日期", "error");
  1014. return;
  1015. }
  1016. }
  1017. this._ok( data )
  1018. }
  1019. //}else{
  1020. // this.app.notice( "请填写申诉原因和具体描述", "error");
  1021. //}
  1022. },
  1023. _ok: function( data ){
  1024. this.app.restActions.createAppeal(this.data.id, data, function (json) {
  1025. if (json.type == "ERROR") {
  1026. this.app.notice(json.message, "error");
  1027. } else {
  1028. this.createMarkNode.destroy();
  1029. this.createAreaNode.destroy();
  1030. if (this.explorer.view)this.explorer.view.reload();
  1031. this.app.notice("申诉已提交", "success");
  1032. }
  1033. }.bind(this));
  1034. },
  1035. selectDateTime : function( el, timeOnly, isTme, baseDate ){
  1036. var opt = {
  1037. "style": "xform",
  1038. "timeOnly": timeOnly,
  1039. "isTime": isTme,
  1040. "target": this.app.content
  1041. };
  1042. if( baseDate )opt.baseDate = baseDate;
  1043. MWF.require("MWF.widget.Calendar", function(){
  1044. var calendar = new MWF.widget.Calendar( el, opt );
  1045. calendar.show();
  1046. }.bind(this));
  1047. },
  1048. //getProcessPerson : function( callback ){
  1049. // this.getUnitByPerson( function( unitData ){
  1050. // this.app.restActions.listPermission( function(json){
  1051. // if( json.data.length == 0 ){
  1052. // this.app.notice( "系统未配置考勤员,请联系管理员!", "error");
  1053. // return;
  1054. // }
  1055. // var unitManager, topUnitManager, processer;
  1056. // json.data.each( function( d ){
  1057. // if( d.unitName == unitData.name ){
  1058. // unitManager = d.adminName;
  1059. // }
  1060. // if(d.unitName == unitData.topUnit ){
  1061. // topUnitManager = d.adminName;
  1062. // }
  1063. // })
  1064. // processer = unitManager || topUnitManager;
  1065. // if( !processer ){
  1066. // this.app.notice( "未设置您所在部门和公司的考勤管理员,请联系系统管理员!", "error");
  1067. // }else{
  1068. // if(callback)callback(processer)
  1069. // }
  1070. // }.bind(this))
  1071. // }.bind(this));
  1072. //},
  1073. getUnitByPerson : function( callback ){
  1074. var data = {"personList": [layout.desktop.session.user.distinguishedName] };
  1075. this.app.orgActions.listUnitWithPerson( function( json ){
  1076. if( json.data.length > 0 ){
  1077. if(callback)callback( json.data );
  1078. }else{
  1079. this.app.notice( "未找到您所在的部门,请联系管理员!", "error");
  1080. }
  1081. }.bind(this), function(){
  1082. this.app.notice( "未找到您所在的部门,请联系管理员!", "error");
  1083. }.bind(this), data, false )
  1084. }
  1085. });