| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.hr.attendance.WorkDate', {
- extend: 'Ext.app.Controller',
- FormUtil: Ext.create('erp.util.FormUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- views:[
- 'hr.attendance.WorkDate','core.form.Panel',
- 'core.button.Add','core.button.Save','core.button.Close',
- 'core.button.Update','core.button.Delete','core.form.YnField',
- 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger'
- ],
- init:function(){
- var me = this;
- this.control({
- 'erpSaveButton': {
- click: function(btn){
- var flag=1;
- flag=me.check();
- if(flag){
- this.FormUtil.beforeSave(this);
- }
-
- }
- },
- 'erpCloseButton': {
- afterrender:function(btn){
- var form = me.getForm(btn);
- var degree=Ext.getCmp('wd_degree').value;
- if(degree==1){
- Ext.Array.each(form.items.items,function(f){
- if(f.groupName=='正班二'){//||f.groupName=='正班三'
- f.hide();
- }
- });
- }else if(degree==2){
- Ext.Array.each(form.items.items,function(f){
- if(f.groupName=='正班二'){
- f.show();
- }
- /*if(f.groupName=='正班三'){
- f.hide();
- }*/
- });
- }else if(degree==3){
- Ext.Array.each(form.items.items,function(f){
- if(f.groupName=='正班二'||f.groupName=='正班三'){
- f.show();
- }
- });
- }
-
- },
- click: function(btn){
- this.FormUtil.beforeClose(this);
- }
- },
- 'erpUpdateButton': {
- click: function(btn){
- var flag=1;
- flag=me.check();
- if(flag){
- this.FormUtil.onUpdate(this);
- }
- }
- },
- 'erpDeleteButton': {
- click: function(btn){
- me.FormUtil.onDelete(Ext.getCmp('wd_id').value);
- }
- },
- 'erpAddButton': {
- click: function(){
- me.FormUtil.onAdd('addWorkDate', '新增考勤项目', 'jsps/hr/attendance/workdate.jsp');
- }
- },
- 'field[name=wd_degree]':{
- change:function(f){
- var form =Ext.getCmp('form');
- if(f.value==1){
- Ext.Array.each(form.items.items,function(f){
- if(f.groupName=='正班二'){//||f.groupName=='正班三'
- f.hide();
- }
- });
- }else if(f.value==2){
- Ext.Array.each(form.items.items,function(f){
- if(f.groupName=='正班二'){
- f.show();
- }
- /*if(f.groupName=='正班三'){
- f.hide();
- }*/
- });
- }else if(f.value==3){
- Ext.Array.each(form.items.items,function(f){
- if(f.groupName=='正班二'||f.groupName=='正班三'){
- f.show();
- }
- });
- }
- }
- },
- //正班一
- 'field[name=wd_ondutyone]':{
- change : function(c) {
- var t = c.getValue();
- Ext.getCmp('wd_onend1').setValue(t);
- Ext.getCmp('wd_onbeg1').setMaxValue(t);
- Ext.getCmp('wd_offdutyone').setMinValue(t);
- if(t&&Ext.getCmp('wd_onbeg1').getValue()){
- var a=Ext.getCmp('wd_onend1').getValue().getHours()*60+Ext.getCmp('wd_onend1').getValue().getMinutes();
- var b=Ext.getCmp('wd_onbeg1').getValue().getHours()*60+Ext.getCmp('wd_onbeg1').getValue().getMinutes();
- Ext.getCmp('wd_before1').setValue(a-b);//计提前
- }else{
- Ext.getCmp('wd_before1').setValue(0);
- }
- }
- },
- 'field[name=wd_onbeg1]':{
- change : function(c) {
- if(Ext.getCmp('wd_onend1').getValue()&&c.value){
- var a=Ext.getCmp('wd_onend1').getValue().getHours()*60+Ext.getCmp('wd_onend1').getValue().getMinutes();
- var b=Ext.getCmp('wd_onbeg1').getValue().getHours()*60+Ext.getCmp('wd_onbeg1').getValue().getMinutes();
- Ext.getCmp('wd_before1').setValue(a-b);//计提前
- }else{
- Ext.getCmp('wd_before1').setValue(0);
- }
- }
- },
- 'field[name=wd_offdutyone]':{
- change : function(c) {
- var t = c.getValue();
- Ext.getCmp('wd_offbeg1').setValue(t);
- Ext.getCmp('wd_offend1').setMinValue(t);
- Ext.getCmp('wd_ondutyone').setMaxValue(t);
- if(t&&Ext.getCmp('wd_offend1').getValue()){
- var a=Ext.getCmp('wd_offend1').getValue().getHours()*60+Ext.getCmp('wd_offend1').getValue().getMinutes();
- var b=Ext.getCmp('wd_offbeg1').getValue().getHours()*60+Ext.getCmp('wd_offbeg1').getValue().getMinutes();
- Ext.getCmp('wd_last1').setValue(a-b);//计提前
- }else{
- Ext.getCmp('wd_last1').setValue(0);
- }
- }
- },
- 'field[name=wd_offend1]':{
- change : function(c) {
- if(Ext.getCmp('wd_offbeg1').getValue()&&c.value){
- var a=Ext.getCmp('wd_offend1').getValue().getHours()*60+Ext.getCmp('wd_offend1').getValue().getMinutes();
- var b=Ext.getCmp('wd_offbeg1').getValue().getHours()*60+Ext.getCmp('wd_offbeg1').getValue().getMinutes();
- Ext.getCmp('wd_last1').setValue(a-b);
- }else{
- Ext.getCmp('wd_last1').setValue(0);
- }
- }
- },
- 'field[name=wd_overw1]':{
- change : function(c) {
- if(c.getValue()){
- Ext.getCmp('wd_overh1').setValue(false);
- }
- }
- },
- 'field[name=wd_overh1]':{
- change : function(c) {
- if(c.getValue()){
- Ext.getCmp('wd_overw1').setValue(false);
- }
- }
- },//正班二
- 'field[name=wd_ondutytwo]':{
- change : function(c) {
- var t = c.getValue();
- Ext.getCmp('wd_onend2').setValue(t);
- Ext.getCmp('wd_onbeg2').setMaxValue(t);
- Ext.getCmp('wd_offdutytwo').setMinValue(t);
- if(t&&Ext.getCmp('wd_onbeg2').getValue()){
- var a=Ext.getCmp('wd_onend2').getValue().getHours()*60+Ext.getCmp('wd_onend2').getValue().getMinutes();
- var b=Ext.getCmp('wd_onbeg2').getValue().getHours()*60+Ext.getCmp('wd_onbeg2').getValue().getMinutes();
- Ext.getCmp('wd_before2').setValue(a-b);//计提前
- }else{
- Ext.getCmp('wd_before2').setValue(0);
- }
- }
- },
- 'field[name=wd_onbeg2]':{
- change : function(c) {
- if(Ext.getCmp('wd_onend2').getValue()&&c.value){
- var a=Ext.getCmp('wd_onend2').getValue().getHours()*60+Ext.getCmp('wd_onend2').getValue().getMinutes();
- var b=Ext.getCmp('wd_onbeg2').getValue().getHours()*60+Ext.getCmp('wd_onbeg2').getValue().getMinutes();
- Ext.getCmp('wd_before2').setValue(a-b);//计提前
- }else{
- Ext.getCmp('wd_before2').setValue(0);//计提前
- }
- }
- },
- 'field[name=wd_offdutytwo]':{
- change : function(c) {
- var t = c.getValue();
- Ext.getCmp('wd_offbeg2').setValue(t);
- Ext.getCmp('wd_offend2').setMinValue(t);
- Ext.getCmp('wd_ondutytwo').setMaxValue(t);
- if(t&&Ext.getCmp('wd_offend2').getValue()){
- var a=Ext.getCmp('wd_offend2').getValue().getHours()*60+Ext.getCmp('wd_offend2').getValue().getMinutes();
- var b=Ext.getCmp('wd_offbeg2').getValue().getHours()*60+Ext.getCmp('wd_offbeg2').getValue().getMinutes();
- Ext.getCmp('wd_last2').setValue(a-b);
- }else{
- Ext.getCmp('wd_last2').setValue(0);
- }
- }
- },
- 'field[name=wd_offend2]':{
- change : function(c) {
- if(Ext.getCmp('wd_offbeg2').getValue()&&c.value){
- var a=Ext.getCmp('wd_offend2').getValue().getHours()*60+Ext.getCmp('wd_offend2').getValue().getMinutes();
- var b=Ext.getCmp('wd_offbeg2').getValue().getHours()*60+Ext.getCmp('wd_offbeg2').getValue().getMinutes();
- Ext.getCmp('wd_last2').setValue(a-b);
- }else{
- Ext.getCmp('wd_last2').setValue(0);
- }
- }
- },
- 'field[name=wd_overw2]':{
- change : function(c) {
- if(c.getValue()){
- Ext.getCmp('wd_overh2').setValue(false);
- }
- }
- },
- 'field[name=wd_overh2]':{
- change : function(c) {
- if(c.getValue()){
- Ext.getCmp('wd_overw2').setValue(false);
- }
- }
- },//正班三
- 'field[name=wd_ondutythree]':{
- change : function(c) {
- var t = c.getValue();
- Ext.getCmp('wd_onend3').setValue(t);
- Ext.getCmp('wd_onbeg3').setMaxValue(t);
- Ext.getCmp('wd_offdutythree').setMinValue(t);
- if(t&&Ext.getCmp('wd_onbeg3').getValue()){
- var a=Ext.getCmp('wd_onend3').getValue().getHours()*60+Ext.getCmp('wd_onend3').getValue().getMinutes();
- var b=Ext.getCmp('wd_onbeg3').getValue().getHours()*60+Ext.getCmp('wd_onbeg3').getValue().getMinutes();
- Ext.getCmp('wd_before3').setValue(a-b);//计提前
- }else{
- Ext.getCmp('wd_before3').setValue(0);//计提前
- }
- }
- },
- 'field[name=wd_onbeg3]':{
- change : function(c) {
- if(Ext.getCmp('wd_onend3').getValue()&&c.value){
- var a=Ext.getCmp('wd_onend3').getValue().getHours()*60+Ext.getCmp('wd_onend3').getValue().getMinutes();
- var b=Ext.getCmp('wd_onbeg3').getValue().getHours()*60+Ext.getCmp('wd_onbeg3').getValue().getMinutes();
- Ext.getCmp('wd_before3').setValue(a-b);//计提前
- }else{
- Ext.getCmp('wd_before3').setValue(0);//计提前
- }
- }
- },
- 'field[name=wd_offdutythree]':{
- change : function(c) {
- var t = c.getValue();
- Ext.getCmp('wd_offbeg3').setValue(t);
- Ext.getCmp('wd_offend3').setMinValue(t);
- Ext.getCmp('wd_ondutythree').setMaxValue(t);
- if(t&&Ext.getCmp('wd_offend3').getValue()){
- var a=Ext.getCmp('wd_offend3').getValue().getHours()*60+Ext.getCmp('wd_offend3').getValue().getMinutes();
- var b=Ext.getCmp('wd_offbeg3').getValue().getHours()*60+Ext.getCmp('wd_offbeg3').getValue().getMinutes();
- Ext.getCmp('wd_last3').setValue(a-b);
- }else{
- Ext.getCmp('wd_last3').setValue(0);//计提前
- }
- }
- },
- 'field[name=wd_offend3]':{
- change : function(c) {
- if(Ext.getCmp('wd_offbeg3').getValue()&&c.value){
- var a=Ext.getCmp('wd_offend3').getValue().getHours()*60+Ext.getCmp('wd_offend3').getValue().getMinutes();
- var b=Ext.getCmp('wd_offbeg3').getValue().getHours()*60+Ext.getCmp('wd_offbeg3').getValue().getMinutes();
- Ext.getCmp('wd_last3').setValue(a-b);
- }else{
- Ext.getCmp('wd_last3').setValue(0);
- }
- }
- },
- 'field[name=wd_overw3]':{
- change : function(c) {
- if(c.getValue()){
- Ext.getCmp('wd_overh3').setValue(false);
- }
- }
- },
- 'field[name=wd_overh3]':{
- change : function(c) {
- if(c.getValue()){
- Ext.getCmp('wd_overw3').setValue(false);
- }
- }
- }
- });
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- },
- check:function(){
- var hours=Ext.getCmp('wd_hours').value-0;
- if(hours>24){
- showError('班次时数不能大于24');
- return 0;
- }
- var wd_degree=Ext.getCmp('wd_degree').value;//班段数量
- if(wd_degree==1){
- return this.checkW1();
- }else if(wd_degree==2){
- return this.checkW2();
- }else if(wd_degree==3){
- return this.checkW3();
- }
- },
- checkW1:function(){
- //正班一
- var w1_on=Ext.getCmp('wd_ondutyone').value;
- var w1_off=Ext.getCmp('wd_offdutyone').value;
- var w1_ondk=Ext.getCmp('wd_onbeg1').value;
- var w1_offdk=Ext.getCmp('wd_offend1').value;
- if(!(w1_on&&w1_off&&w1_ondk&&w1_offdk)){
- showError('正班一时间设置不完整');
- return 0;
- };
- return 1;
- },
- checkW2:function(){
- var f1=this.checkW1();
- //正班二
- if(f1){
- var w2_on=Ext.getCmp('wd_ondutytwo').value;
- var w2_off=Ext.getCmp('wd_offdutytwo').value;
- var w2_ondk=Ext.getCmp('wd_onbeg2').value;
- var w2_offdk=Ext.getCmp('wd_offend2').value;
- if(!(w2_on&&w2_off&&w2_ondk&&w2_offdk)){
- showError('正班二时间设置不完整');
- return 0;
- }else{
- if(Ext.getCmp('wd_offend1').value>=w2_ondk){
- showError('正班二上班打卡起始时间要晚于正班一下班打卡结束时间');
- return 0;
- }
- };
- return 1;
- }
- return 0;
- },
- checkW3:function(){
- var f1=this.checkW2();
- if(f1){
- //正班三
- var w3_on=Ext.getCmp('wd_ondutythree').value;
- var w3_off=Ext.getCmp('wd_offdutythree').value;
- var w3_ondk=Ext.getCmp('wd_onbeg3').value;
- var w3_offdk=Ext.getCmp('wd_offend3').value;
- if(!(w3_on&&w3_off&&w3_ondk&&w3_offdk)){
- showError('正班三时间设置不完整');
- return 0;
- }else{
- if(Ext.getCmp('wd_offend2').value>=w3_ondk){
- showError('正班三上班打卡起始时间要晚于正班二下班打卡结束时间');
- return 0;
- }
- };
- return 1;
- }
- return 0;
- }
- });
|