WorkDate.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.hr.attendance.WorkDate', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'hr.attendance.WorkDate','core.form.Panel',
  8. 'core.button.Add','core.button.Save','core.button.Close',
  9. 'core.button.Update','core.button.Delete','core.form.YnField',
  10. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger'
  11. ],
  12. init:function(){
  13. var me = this;
  14. this.control({
  15. 'erpSaveButton': {
  16. click: function(btn){
  17. var flag=1;
  18. flag=me.check();
  19. if(flag){
  20. this.FormUtil.beforeSave(this);
  21. }
  22. }
  23. },
  24. 'erpCloseButton': {
  25. afterrender:function(btn){
  26. var form = me.getForm(btn);
  27. var degree=Ext.getCmp('wd_degree').value;
  28. if(degree==1){
  29. Ext.Array.each(form.items.items,function(f){
  30. if(f.groupName=='正班二'){//||f.groupName=='正班三'
  31. f.hide();
  32. }
  33. });
  34. }else if(degree==2){
  35. Ext.Array.each(form.items.items,function(f){
  36. if(f.groupName=='正班二'){
  37. f.show();
  38. }
  39. /*if(f.groupName=='正班三'){
  40. f.hide();
  41. }*/
  42. });
  43. }else if(degree==3){
  44. Ext.Array.each(form.items.items,function(f){
  45. if(f.groupName=='正班二'||f.groupName=='正班三'){
  46. f.show();
  47. }
  48. });
  49. }
  50. },
  51. click: function(btn){
  52. this.FormUtil.beforeClose(this);
  53. }
  54. },
  55. 'erpUpdateButton': {
  56. click: function(btn){
  57. var flag=1;
  58. flag=me.check();
  59. if(flag){
  60. this.FormUtil.onUpdate(this);
  61. }
  62. }
  63. },
  64. 'erpDeleteButton': {
  65. click: function(btn){
  66. me.FormUtil.onDelete(Ext.getCmp('wd_id').value);
  67. }
  68. },
  69. 'erpAddButton': {
  70. click: function(){
  71. me.FormUtil.onAdd('addWorkDate', '新增考勤项目', 'jsps/hr/attendance/workdate.jsp');
  72. }
  73. },
  74. 'field[name=wd_degree]':{
  75. change:function(f){
  76. var form =Ext.getCmp('form');
  77. if(f.value==1){
  78. Ext.Array.each(form.items.items,function(f){
  79. if(f.groupName=='正班二'){//||f.groupName=='正班三'
  80. f.hide();
  81. }
  82. });
  83. }else if(f.value==2){
  84. Ext.Array.each(form.items.items,function(f){
  85. if(f.groupName=='正班二'){
  86. f.show();
  87. }
  88. /*if(f.groupName=='正班三'){
  89. f.hide();
  90. }*/
  91. });
  92. }else if(f.value==3){
  93. Ext.Array.each(form.items.items,function(f){
  94. if(f.groupName=='正班二'||f.groupName=='正班三'){
  95. f.show();
  96. }
  97. });
  98. }
  99. }
  100. },
  101. //正班一
  102. 'field[name=wd_ondutyone]':{
  103. change : function(c) {
  104. var t = c.getValue();
  105. Ext.getCmp('wd_onend1').setValue(t);
  106. Ext.getCmp('wd_onbeg1').setMaxValue(t);
  107. Ext.getCmp('wd_offdutyone').setMinValue(t);
  108. if(t&&Ext.getCmp('wd_onbeg1').getValue()){
  109. var a=Ext.getCmp('wd_onend1').getValue().getHours()*60+Ext.getCmp('wd_onend1').getValue().getMinutes();
  110. var b=Ext.getCmp('wd_onbeg1').getValue().getHours()*60+Ext.getCmp('wd_onbeg1').getValue().getMinutes();
  111. Ext.getCmp('wd_before1').setValue(a-b);//计提前
  112. }else{
  113. Ext.getCmp('wd_before1').setValue(0);
  114. }
  115. }
  116. },
  117. 'field[name=wd_onbeg1]':{
  118. change : function(c) {
  119. if(Ext.getCmp('wd_onend1').getValue()&&c.value){
  120. var a=Ext.getCmp('wd_onend1').getValue().getHours()*60+Ext.getCmp('wd_onend1').getValue().getMinutes();
  121. var b=Ext.getCmp('wd_onbeg1').getValue().getHours()*60+Ext.getCmp('wd_onbeg1').getValue().getMinutes();
  122. Ext.getCmp('wd_before1').setValue(a-b);//计提前
  123. }else{
  124. Ext.getCmp('wd_before1').setValue(0);
  125. }
  126. }
  127. },
  128. 'field[name=wd_offdutyone]':{
  129. change : function(c) {
  130. var t = c.getValue();
  131. Ext.getCmp('wd_offbeg1').setValue(t);
  132. Ext.getCmp('wd_offend1').setMinValue(t);
  133. Ext.getCmp('wd_ondutyone').setMaxValue(t);
  134. if(t&&Ext.getCmp('wd_offend1').getValue()){
  135. var a=Ext.getCmp('wd_offend1').getValue().getHours()*60+Ext.getCmp('wd_offend1').getValue().getMinutes();
  136. var b=Ext.getCmp('wd_offbeg1').getValue().getHours()*60+Ext.getCmp('wd_offbeg1').getValue().getMinutes();
  137. Ext.getCmp('wd_last1').setValue(a-b);//计提前
  138. }else{
  139. Ext.getCmp('wd_last1').setValue(0);
  140. }
  141. }
  142. },
  143. 'field[name=wd_offend1]':{
  144. change : function(c) {
  145. if(Ext.getCmp('wd_offbeg1').getValue()&&c.value){
  146. var a=Ext.getCmp('wd_offend1').getValue().getHours()*60+Ext.getCmp('wd_offend1').getValue().getMinutes();
  147. var b=Ext.getCmp('wd_offbeg1').getValue().getHours()*60+Ext.getCmp('wd_offbeg1').getValue().getMinutes();
  148. Ext.getCmp('wd_last1').setValue(a-b);
  149. }else{
  150. Ext.getCmp('wd_last1').setValue(0);
  151. }
  152. }
  153. },
  154. 'field[name=wd_overw1]':{
  155. change : function(c) {
  156. if(c.getValue()){
  157. Ext.getCmp('wd_overh1').setValue(false);
  158. }
  159. }
  160. },
  161. 'field[name=wd_overh1]':{
  162. change : function(c) {
  163. if(c.getValue()){
  164. Ext.getCmp('wd_overw1').setValue(false);
  165. }
  166. }
  167. },//正班二
  168. 'field[name=wd_ondutytwo]':{
  169. change : function(c) {
  170. var t = c.getValue();
  171. Ext.getCmp('wd_onend2').setValue(t);
  172. Ext.getCmp('wd_onbeg2').setMaxValue(t);
  173. Ext.getCmp('wd_offdutytwo').setMinValue(t);
  174. if(t&&Ext.getCmp('wd_onbeg2').getValue()){
  175. var a=Ext.getCmp('wd_onend2').getValue().getHours()*60+Ext.getCmp('wd_onend2').getValue().getMinutes();
  176. var b=Ext.getCmp('wd_onbeg2').getValue().getHours()*60+Ext.getCmp('wd_onbeg2').getValue().getMinutes();
  177. Ext.getCmp('wd_before2').setValue(a-b);//计提前
  178. }else{
  179. Ext.getCmp('wd_before2').setValue(0);
  180. }
  181. }
  182. },
  183. 'field[name=wd_onbeg2]':{
  184. change : function(c) {
  185. if(Ext.getCmp('wd_onend2').getValue()&&c.value){
  186. var a=Ext.getCmp('wd_onend2').getValue().getHours()*60+Ext.getCmp('wd_onend2').getValue().getMinutes();
  187. var b=Ext.getCmp('wd_onbeg2').getValue().getHours()*60+Ext.getCmp('wd_onbeg2').getValue().getMinutes();
  188. Ext.getCmp('wd_before2').setValue(a-b);//计提前
  189. }else{
  190. Ext.getCmp('wd_before2').setValue(0);//计提前
  191. }
  192. }
  193. },
  194. 'field[name=wd_offdutytwo]':{
  195. change : function(c) {
  196. var t = c.getValue();
  197. Ext.getCmp('wd_offbeg2').setValue(t);
  198. Ext.getCmp('wd_offend2').setMinValue(t);
  199. Ext.getCmp('wd_ondutytwo').setMaxValue(t);
  200. if(t&&Ext.getCmp('wd_offend2').getValue()){
  201. var a=Ext.getCmp('wd_offend2').getValue().getHours()*60+Ext.getCmp('wd_offend2').getValue().getMinutes();
  202. var b=Ext.getCmp('wd_offbeg2').getValue().getHours()*60+Ext.getCmp('wd_offbeg2').getValue().getMinutes();
  203. Ext.getCmp('wd_last2').setValue(a-b);
  204. }else{
  205. Ext.getCmp('wd_last2').setValue(0);
  206. }
  207. }
  208. },
  209. 'field[name=wd_offend2]':{
  210. change : function(c) {
  211. if(Ext.getCmp('wd_offbeg2').getValue()&&c.value){
  212. var a=Ext.getCmp('wd_offend2').getValue().getHours()*60+Ext.getCmp('wd_offend2').getValue().getMinutes();
  213. var b=Ext.getCmp('wd_offbeg2').getValue().getHours()*60+Ext.getCmp('wd_offbeg2').getValue().getMinutes();
  214. Ext.getCmp('wd_last2').setValue(a-b);
  215. }else{
  216. Ext.getCmp('wd_last2').setValue(0);
  217. }
  218. }
  219. },
  220. 'field[name=wd_overw2]':{
  221. change : function(c) {
  222. if(c.getValue()){
  223. Ext.getCmp('wd_overh2').setValue(false);
  224. }
  225. }
  226. },
  227. 'field[name=wd_overh2]':{
  228. change : function(c) {
  229. if(c.getValue()){
  230. Ext.getCmp('wd_overw2').setValue(false);
  231. }
  232. }
  233. },//正班三
  234. 'field[name=wd_ondutythree]':{
  235. change : function(c) {
  236. var t = c.getValue();
  237. Ext.getCmp('wd_onend3').setValue(t);
  238. Ext.getCmp('wd_onbeg3').setMaxValue(t);
  239. Ext.getCmp('wd_offdutythree').setMinValue(t);
  240. if(t&&Ext.getCmp('wd_onbeg3').getValue()){
  241. var a=Ext.getCmp('wd_onend3').getValue().getHours()*60+Ext.getCmp('wd_onend3').getValue().getMinutes();
  242. var b=Ext.getCmp('wd_onbeg3').getValue().getHours()*60+Ext.getCmp('wd_onbeg3').getValue().getMinutes();
  243. Ext.getCmp('wd_before3').setValue(a-b);//计提前
  244. }else{
  245. Ext.getCmp('wd_before3').setValue(0);//计提前
  246. }
  247. }
  248. },
  249. 'field[name=wd_onbeg3]':{
  250. change : function(c) {
  251. if(Ext.getCmp('wd_onend3').getValue()&&c.value){
  252. var a=Ext.getCmp('wd_onend3').getValue().getHours()*60+Ext.getCmp('wd_onend3').getValue().getMinutes();
  253. var b=Ext.getCmp('wd_onbeg3').getValue().getHours()*60+Ext.getCmp('wd_onbeg3').getValue().getMinutes();
  254. Ext.getCmp('wd_before3').setValue(a-b);//计提前
  255. }else{
  256. Ext.getCmp('wd_before3').setValue(0);//计提前
  257. }
  258. }
  259. },
  260. 'field[name=wd_offdutythree]':{
  261. change : function(c) {
  262. var t = c.getValue();
  263. Ext.getCmp('wd_offbeg3').setValue(t);
  264. Ext.getCmp('wd_offend3').setMinValue(t);
  265. Ext.getCmp('wd_ondutythree').setMaxValue(t);
  266. if(t&&Ext.getCmp('wd_offend3').getValue()){
  267. var a=Ext.getCmp('wd_offend3').getValue().getHours()*60+Ext.getCmp('wd_offend3').getValue().getMinutes();
  268. var b=Ext.getCmp('wd_offbeg3').getValue().getHours()*60+Ext.getCmp('wd_offbeg3').getValue().getMinutes();
  269. Ext.getCmp('wd_last3').setValue(a-b);
  270. }else{
  271. Ext.getCmp('wd_last3').setValue(0);//计提前
  272. }
  273. }
  274. },
  275. 'field[name=wd_offend3]':{
  276. change : function(c) {
  277. if(Ext.getCmp('wd_offbeg3').getValue()&&c.value){
  278. var a=Ext.getCmp('wd_offend3').getValue().getHours()*60+Ext.getCmp('wd_offend3').getValue().getMinutes();
  279. var b=Ext.getCmp('wd_offbeg3').getValue().getHours()*60+Ext.getCmp('wd_offbeg3').getValue().getMinutes();
  280. Ext.getCmp('wd_last3').setValue(a-b);
  281. }else{
  282. Ext.getCmp('wd_last3').setValue(0);
  283. }
  284. }
  285. },
  286. 'field[name=wd_overw3]':{
  287. change : function(c) {
  288. if(c.getValue()){
  289. Ext.getCmp('wd_overh3').setValue(false);
  290. }
  291. }
  292. },
  293. 'field[name=wd_overh3]':{
  294. change : function(c) {
  295. if(c.getValue()){
  296. Ext.getCmp('wd_overw3').setValue(false);
  297. }
  298. }
  299. }
  300. });
  301. },
  302. getForm: function(btn){
  303. return btn.ownerCt.ownerCt;
  304. },
  305. check:function(){
  306. var hours=Ext.getCmp('wd_hours').value-0;
  307. if(hours>24){
  308. showError('班次时数不能大于24');
  309. return 0;
  310. }
  311. var wd_degree=Ext.getCmp('wd_degree').value;//班段数量
  312. if(wd_degree==1){
  313. return this.checkW1();
  314. }else if(wd_degree==2){
  315. return this.checkW2();
  316. }else if(wd_degree==3){
  317. return this.checkW3();
  318. }
  319. },
  320. checkW1:function(){
  321. //正班一
  322. var w1_on=Ext.getCmp('wd_ondutyone').value;
  323. var w1_off=Ext.getCmp('wd_offdutyone').value;
  324. var w1_ondk=Ext.getCmp('wd_onbeg1').value;
  325. var w1_offdk=Ext.getCmp('wd_offend1').value;
  326. if(!(w1_on&&w1_off&&w1_ondk&&w1_offdk)){
  327. showError('正班一时间设置不完整');
  328. return 0;
  329. };
  330. return 1;
  331. },
  332. checkW2:function(){
  333. var f1=this.checkW1();
  334. //正班二
  335. if(f1){
  336. var w2_on=Ext.getCmp('wd_ondutytwo').value;
  337. var w2_off=Ext.getCmp('wd_offdutytwo').value;
  338. var w2_ondk=Ext.getCmp('wd_onbeg2').value;
  339. var w2_offdk=Ext.getCmp('wd_offend2').value;
  340. if(!(w2_on&&w2_off&&w2_ondk&&w2_offdk)){
  341. showError('正班二时间设置不完整');
  342. return 0;
  343. }else{
  344. if(Ext.getCmp('wd_offend1').value>=w2_ondk){
  345. showError('正班二上班打卡起始时间要晚于正班一下班打卡结束时间');
  346. return 0;
  347. }
  348. };
  349. return 1;
  350. }
  351. return 0;
  352. },
  353. checkW3:function(){
  354. var f1=this.checkW2();
  355. if(f1){
  356. //正班三
  357. var w3_on=Ext.getCmp('wd_ondutythree').value;
  358. var w3_off=Ext.getCmp('wd_offdutythree').value;
  359. var w3_ondk=Ext.getCmp('wd_onbeg3').value;
  360. var w3_offdk=Ext.getCmp('wd_offend3').value;
  361. if(!(w3_on&&w3_off&&w3_ondk&&w3_offdk)){
  362. showError('正班三时间设置不完整');
  363. return 0;
  364. }else{
  365. if(Ext.getCmp('wd_offend2').value>=w3_ondk){
  366. showError('正班三上班打卡起始时间要晚于正班二下班打卡结束时间');
  367. return 0;
  368. }
  369. };
  370. return 1;
  371. }
  372. return 0;
  373. }
  374. });