MyDetail.js 56 KB

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