mode_jiaban.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * 加班费的计算每个企业都不一样,我们没办法写出公式,请自己修改代码哦
  3. */
  4. function initbodys(){
  5. $(form('stime')).blur(function(){
  6. changetotal();
  7. });
  8. $(form('etime')).blur(function(){
  9. changetotal();
  10. });
  11. if(form('jiatype'))$(form('jiatype')).change(function(){
  12. changetype(true);
  13. });
  14. changetype(false);
  15. $(form('uname')).blur(function(){
  16. loadinstyrs();
  17. });
  18. }
  19. function loadinstyrs(){
  20. if(!form('base_deptname'))return;
  21. var uid = '';
  22. if(form('uid'))uid = form('uid').value;
  23. js.ajax(geturlact('getuinfo'),{'uid':uid},function(d){
  24. if(d){
  25. form('base_deptname').value=d.deptname;
  26. }
  27. },'get,json');
  28. }
  29. function changetype(bo){
  30. if(!form('jiatype'))return;
  31. var v = form('jiatype').value;
  32. var o = $('#div_jiafee').parent().parent();
  33. if(v=='1'){
  34. o.show();
  35. if(bo)changetotal();
  36. }else{
  37. o.hide();
  38. if(bo)form('jiafee').value='0';
  39. }
  40. }
  41. function changesubmit(d){
  42. if(d.etime<=d.stime)return '截止时间必须大于开始时间';
  43. if(d.stime.substr(0,10)!=d.etime.substr(0,10)){
  44. //return '不允许跨日申请';
  45. }
  46. var st=parseFloat(d.totals);
  47. if(st<=0)return '加班时间必须大于0';
  48. }
  49. function changetotal(){
  50. var st = form('stime').value,
  51. et = form('etime').value;
  52. if(isempt(st)||isempt(et)){
  53. form('totals').value='0';
  54. return;
  55. }
  56. if(et<=st){
  57. js.setmsg('截止时间必须大于开始时间');
  58. return;
  59. }
  60. if(st.substr(0,10)!=et.substr(0,10)){
  61. //js.setmsg('不允许跨日申请');
  62. //return;
  63. }
  64. var jty = 0;
  65. if(form('jiatype'))jty = form('jiatype').value;
  66. js.ajax(geturlact('total'),{stime:st,etime:et,jiatype:jty}, function(da){
  67. var a= js.decode(da);
  68. form('totals').value=a[0];
  69. if(form('jiafee'))form('jiafee').value=a[2];
  70. js.setmsg(a[1]);
  71. },'post');
  72. }