MyDetail.js 58 KB

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