Переглянути джерело

Merge branch 'fix/Attendcance' into 'develop'

Merge of fix/Attendcance to develop【考勤排班设置添加打卡策略】

See merge request o2oa/o2oa!682
胡起 5 роки тому
батько
коміт
8fcc6f12c1

+ 30 - 6
o2web/source/x_component_Attendance/$ScheduleExplorer/listItem.json

@@ -5,7 +5,15 @@
     "contentStyles" : "normalTdNode",
     "item" : "function(d){ return d.unitName.split('@')[0] }",
     "name" : "unitName",
-    "width" : "15%"
+    "width" : "11%"
+  },
+  {
+    "title" : "打卡策略",
+    "headStyles" : "normalThNode",
+    "contentStyles" : "normalTdNode",
+    "item" : "function(d){return {'1':'两次打卡(上午上班,下午下班)','2':'三次打卡(上午上班,下午下班加中午一次共三次)', '3':'四次打卡(上午下午都打上班下班卡)'}[d.signProxy] }",
+    "name" : "signProxy",
+    "width" : "11%"
   },
   {
     "title" : "上班时间",
@@ -13,7 +21,23 @@
     "contentStyles" : "normalTdNode",
     "item" : "onDutyTime",
     "name" : "onDutyTime",
-    "width" : "15%"
+    "width" : "11%"
+  },
+  {
+    "title" : "午休开始时间",
+    "headStyles" : "normalThNode",
+    "contentStyles" : "normalTdNode",
+    "item" : "middayRestStartTime",
+    "name" : "middayRestStartTime",
+    "width" : "11%"
+  },
+  {
+    "title" : "午休结束时间",
+    "headStyles" : "normalThNode",
+    "contentStyles" : "normalTdNode",
+    "item" : "middayRestEndTime",
+    "name" : "middayRestEndTime",
+    "width" : "11%"
   },
   {
     "title" : "下班时间",
@@ -21,7 +45,7 @@
     "contentStyles" : "normalTdNode",
     "item" : "offDutyTime",
     "name" : "offDutyTime",
-    "width" : "15%"
+    "width" : "11%"
   },
 
   {
@@ -30,7 +54,7 @@
     "contentStyles" : "normalTdNode",
     "item" : "lateStartTime",
     "name" : "lateStartTime",
-    "width" : "15%"
+    "width" : "11%"
   },
 
 //  {
@@ -47,7 +71,7 @@
     "contentStyles" : "normalTdNode",
     "item" : "absenceStartTime",
     "name" : "absenceStartTime",
-    "width" : "15%"
+    "width" : "11%"
   },
   {
     "access" : "admin",
@@ -56,7 +80,7 @@
     "contentStyles" : "normalTdNode",
     "item" : "actions",
     "name" : "actions",
-    "width" : "10%",
+    "width" : "11%",
     "sub" : [{
       "title" : "删除文件",
       "action" : "remove",

+ 12 - 9
o2web/source/x_component_Attendance/MyIndex.js

@@ -17,7 +17,7 @@ MWF.xApplication.Attendance.MyIndex = new Class({
         //"leaveEarly":"#fe8d03", //橙色,早退
         "noSign":"#ee807f", //粉红色,未签到
         "appealSuccess" : "#2ac497", //黄绿色,申诉通过
-        "lackOfTime" : "#dec674",//工时不足人次
+        //"lackOfTime" : "#dec674",//工时不足人次
         "abNormalDuty" : "#fedcbd"//异常打卡人次
     },
     initialize: function(node, app, actions, options){
@@ -705,7 +705,7 @@ MWF.xApplication.Attendance.MyIndex = new Class({
             late : 0,
             appealSuccess : 0,
             //leaveEarly : 0,
-            lackOfTime : 0,
+            //lackOfTime : 0,
             abNormalDuty : 0,
             normal : 0
         };
@@ -743,7 +743,7 @@ MWF.xApplication.Attendance.MyIndex = new Class({
 
             if( this.isAskForLevel(d,"pm") ){
                 totals.levelAsked = totals.levelAsked + 0.5;
-                events.push( {  text: '请假或外出报备', start: d.recordDateString,  backgroundColor :this.statusColor.levelAsked } )
+                events.push( {  text: this.lp.index.levelAsked, start: d.recordDateString,  backgroundColor :this.statusColor.levelAsked } )
             }else if( this.isAppealSuccess(d,"pm")){
                 events.push( {  text: this.lp.appealSuccess, start: d.recordDateString,  backgroundColor :this.statusColor.appealSuccess } );
                 totals.appealSuccess = totals.appealSuccess + 0.5;
@@ -756,10 +756,10 @@ MWF.xApplication.Attendance.MyIndex = new Class({
             //    totals.leaveEarly = totals.leaveEarly + 0.5
             }else if( this.isAbsent(d,"pm")){
                     totals.noSign = totals.noSign + 0.5;
-                    events.push( {  text: '缺勤', start: d.recordDateString,  backgroundColor :this.statusColor.noSign } )
-            }else if( this.isLackOfTime(d,"pm")){
+                    events.push( {  text: this.lp.index.absent, start: d.recordDateString,  backgroundColor :this.statusColor.noSign } )
+           /* }else if( this.isLackOfTime(d,"pm")){
                 events.push( {  text: this.lp.lackOfTime + ',' + this.lp.signTime + ':' + d.offDutyTime, start: d.recordDateString,  backgroundColor :this.statusColor.lackOfTime } );
-                totals.lackOfTime = totals.lackOfTime + 0.5
+                totals.lackOfTime = totals.lackOfTime + 0.5*/
             }else if( this.isAbnormalDuty(d,"pm")){
                 events.push( {  text: this.lp.abNormalDuty + ',' + this.lp.signTime + ':' + d.offDutyTime, start: d.recordDateString,  backgroundColor :this.statusColor.abNormalDuty } );
                 totals.abNormalDuty = totals.abNormalDuty + 0.5
@@ -768,8 +768,11 @@ MWF.xApplication.Attendance.MyIndex = new Class({
             }else if( this.isWeekend(d, "pm") ){
                 return;
             }else{
-                totals.normal = totals.normal + 0.5;
-                events.push( {  text: '出勤,打卡时间:'+ d.offDutyTime, start: d.recordDateString,  backgroundColor :this.statusColor.normal } )
+                if(!!d.offDutyTime){
+                    totals.normal = totals.normal + 0.5;
+                    events.push( {  text: this.lp.index.offDutyTime+ d.offDutyTime, start: d.recordDateString,  backgroundColor :this.statusColor.normal } )
+                }
+
             }
         }.bind(this) );
         this.totalData = totals;
@@ -783,7 +786,7 @@ MWF.xApplication.Attendance.MyIndex = new Class({
             noSign : (!totals.noSign || !total) ? 0 : ((totals.noSign/total * 100).toFixed(2)  + "%"),
             late : (!totals.late || !total) ? 0 : ((totals.late/total * 100).toFixed(2) + "%"),
             //leaveEarly : (!totals.leaveEarly || !total) ? 0 : ((totals.leaveEarly/total* 100).toFixed(2)  + "%"),
-            lackOfTime : (!totals.lackOfTime || !total) ? 0 : ((totals.lackOfTime/total * 100).toFixed(2) + "%"),
+            //lackOfTime : (!totals.lackOfTime || !total) ? 0 : ((totals.lackOfTime/total * 100).toFixed(2) + "%"),
             abNormalDuty : (!totals.abNormalDuty || !total) ? 0 : ((totals.abNormalDuty/total* 100).toFixed(2)  + "%"),
             normal : (!totals.normal || !total) ? 0 : ((totals.normal/total* 100).toFixed(2)  + "%"),
             appealSuccess  : (!totals.appealSuccess || !total) ? 0 : ((totals.appealSuccess/total * 100).toFixed(2)  + "%")

+ 119 - 8
o2web/source/x_component_Attendance/ScheduleExplorer.js

@@ -2,8 +2,8 @@ MWF.xDesktop.requireApp("Template", "Explorer", null, false);
 MWF.xDesktop.requireApp("Attendance", "Explorer", null, false);
 MWF.xDesktop.requireApp("Selector", "package", null, false);
 MWF.xApplication.Attendance.ScheduleExplorer = new Class({
-	Extends: MWF.xApplication.Attendance.Explorer,
-	Implements: [Options, Events],
+    Extends: MWF.xApplication.Attendance.Explorer,
+    Implements: [Options, Events],
 
     initialize: function(node, app, actions, options){
         this.setOptions(options);
@@ -35,7 +35,12 @@ MWF.xApplication.Attendance.ScheduleExplorer.View = new Class({
     },
 
     _getCurrentPageData: function(callback, count){
+
         this.actions.listSchedule(function(json){
+            json.data=json.data.map(function (v) {
+                v.signProxy = !v.signProxy?1:v.signProxy;
+                return v;
+            });
             if (callback) callback(json);
         });
     },
@@ -49,8 +54,21 @@ MWF.xApplication.Attendance.ScheduleExplorer.View = new Class({
         var schedule = new MWF.xApplication.Attendance.ScheduleExplorer.Schedule(this.explorer);
         schedule.create();
     },
+    copyObject: function(obj){
+        if(typeof obj != 'object'){
+            return obj;
+        }
+        var newobj = new Object(null);
+        for ( var attr in obj) {
+            newobj[attr] = this.copyObject(obj[attr]);
+        }
+        return newobj;
+    },
     _openDocument: function( documentData ){
-        var schedule = new MWF.xApplication.Attendance.ScheduleExplorer.Schedule(this.explorer, documentData );
+        var data =this.copyObject(documentData);
+
+        var schedule = new MWF.xApplication.Attendance.ScheduleExplorer.Schedule(this.explorer, data );
+
         schedule.edit();
     }
 
@@ -67,7 +85,7 @@ MWF.xApplication.Attendance.ScheduleExplorer.Schedule = new Class({
     Extends: MWF.xApplication.Attendance.Explorer.PopupForm,
     options : {
         "width": 600,
-        "height": 450,
+        "height": 500,
         "hasTop" : true,
         "hasBottom" : true,
         "title" : "",
@@ -76,40 +94,133 @@ MWF.xApplication.Attendance.ScheduleExplorer.Schedule = new Class({
     },
     _createTableContent: function(){
         var lp = this.app.lp.schedule;
-
+        var signProxy = this.data.signProxy;
         var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
             "<tr><td colspan='2' styles='formTableHead'>"+lp.setSchedule+"</td></tr>" +
             "<tr><td styles='formTabelTitle' lable='unitName'></td>"+
             "    <td styles='formTableValue' item='unitName'></td></tr>" +
+            "<tr><td styles='formTabelTitle' lable='signProxy'></td>"+
+            "    <td styles='formTableValue' item='signProxy'></td></tr>" +
             "<tr><td styles='formTabelTitle' lable='onDutyTime'></td>"+
             "    <td styles='formTableValue' item='onDutyTime'></td></tr>" +
+            "<tr style='"+(!signProxy||signProxy=="0"||signProxy=="1"?"display: none":"")+"'><td styles='formTabelTitle' lable='middayRestStartTime'></td>"+
+            "    <td styles='formTableValue' item='middayRestStartTime'></td></tr>" +
+            "<tr style='"+(!signProxy||signProxy=="0"||signProxy=="1"?"display: none":"")+"'><td styles='formTabelTitle' lable='middayRestEndTime'></td>"+
+            "    <td styles='formTableValue' item='middayRestEndTime'></td></tr>" +
             "<tr><td styles='formTabelTitle' lable='offDutyTime'></td>"+
             "    <td styles='formTableValue' item='offDutyTime'></td></tr>" +
             "<tr><td styles='formTabelTitle' lable='lateStartTime'></td>"+
             "    <td styles='formTableValue' item='lateStartTime'></td></tr>" +
+            "<tr style='"+(signProxy!="3"?"display: none":"")+"'><td styles='formTabelTitle' lable='leaveEarlyStartTimeMorning'></td>"+
+            "    <td styles='formTableValue' item='leaveEarlyStartTimeMorning'></td></tr>" +
+            "<tr style='"+(signProxy!="3"?"display: none":"")+"'><td styles='formTabelTitle' lable='lateStartTimeAfternoon'></td>"+
+            "    <td styles='formTableValue' item='lateStartTimeAfternoon'></td></tr>" +
             "<tr><td styles='formTabelTitle' lable='leaveEarlyStartTime'></td>"+
             "    <td styles='formTableValue' item='leaveEarlyStartTime'></td></tr>" +
             "<tr><td styles='formTabelTitle' lable='absenceStartTime'></td>"+
             "    <td styles='formTableValue' item='absenceStartTime'></td></tr>" +
             "</table>";
-        this.formTableArea.set("html",html);
 
+
+        this.formTableArea.set("html",html);
         MWF.xDesktop.requireApp("Template", "MForm", function(){
+
+            var ob = Object;
             this.form = new MForm( this.formTableArea, this.data, {
+                onPostLoad: function(){
+                    if(signProxy!=0&&signProxy!=1){
+                        if(signProxy==3)
+                            this.options.height=670;
+                        else
+                            this.options.height=570;
+                    }
+                }.bind(this),
                 isEdited : this.isEdited || this.isNew,
                 itemTemplate : {
                     unitName : { text: lp.unit,  type : "org", orgType : "unit" },
+                    signProxy : { text: lp.signProxy.name,  type : "select" ,selectText:ob.values(lp.signProxy.select),selectValue:ob.keys(lp.signProxy.select),style:{
+                            "width": "99%",
+                            "border": "1px solid rgb(153, 153, 153)",
+                            "border-radius": "3px",
+                            "box-shadow": "rgb(204, 204, 204) 0px 0px 6px",
+                            "min-height": "26px",
+                            "overflow": "hidden"
+                        },event :{
+                            "change":function(){
+                                var signProxy = this.form.getItem("signProxy").getValue();
+                                if(signProxy!="1"&&signProxy!="0"){
+                                    this.formTableArea.getElement("[lable=middayRestStartTime]").getParent().setStyle("display","table-row");
+                                    this.formTableArea.getElement("[lable=middayRestEndTime]").getParent().setStyle("display","table-row");
+                                    var tempH = "570px";
+                                    if(signProxy=="3"){
+                                        this.formTableArea.getElement("[lable=leaveEarlyStartTimeMorning]").getParent().setStyle("display","table-row");
+                                        this.formTableArea.getElement("[lable=lateStartTimeAfternoon]").getParent().setStyle("display","table-row");
+                                        tempH = "670px";
+                                        this.form.options.itemTemplate.lateStartTimeAfternoon.notEmpty=true;
+                                    }else{
+                                        this.formTableArea.getElement("[lable=leaveEarlyStartTimeMorning]").getParent().setStyle("display","none");
+                                        this.formTableArea.getElement("[lable=lateStartTimeAfternoon]").getParent().setStyle("display","none");
+                                        this.form.options.itemTemplate.lateStartTimeAfternoon.notEmpty=false;
+                                    }
+
+                                    this.formNode.setStyle("height",tempH);
+
+                                    this.form.options.itemTemplate.middayRestStartTime.text=lp.signProxy[signProxy].middayRestStartTime;
+                                    this.form.options.itemTemplate.middayRestEndTime.text=lp.signProxy[signProxy].middayRestEndTime;
+                                    this.form.options.itemTemplate.middayRestStartTime.notEmpty=true;
+                                    this.form.options.itemTemplate.middayRestEndTime.notEmpty=true;
+
+                                }else{
+                                    this.formTableArea.getElement("[lable=middayRestStartTime]").getParent().setStyle("display","none");
+                                    this.formTableArea.getElement("[lable=middayRestEndTime]").getParent().setStyle("display","none");
+                                    this.formTableArea.getElement("[lable=leaveEarlyStartTimeMorning]").getParent().setStyle("display","none");
+                                    this.formTableArea.getElement("[lable=lateStartTimeAfternoon]").getParent().setStyle("display","none");
+                                    this.formNode.setStyle("height","500px");
+
+                                    this.form.options.itemTemplate.middayRestStartTime.notEmpty=false;
+                                    this.form.options.itemTemplate.middayRestEndTime.notEmpty=false;
+                                    this.form.options.itemTemplate.lateStartTimeAfternoon.notEmpty=false;
+                                }
+                                this.form.data[0].signProxy = signProxy;
+                                this.form.load();
+
+                            }.bind(this)
+                        }},
                     onDutyTime : { text: lp.workTime, tType : "time",notEmpty:true },
+                    middayRestStartTime:{ text: lp.signProxy["2"].middayRestStartTime, tType : "time",notEmpty:(signProxy!=0&&signProxy!=1)?true:false },
+                    middayRestEndTime:{ text: lp.signProxy["2"].middayRestEndTime, tType : "time",notEmpty:(signProxy!=0&&signProxy!=1)?true:false },
                     offDutyTime : { text: lp.offTime,  tType : "time",notEmpty:true },
-                    lateStartTime : { text: lp.lateTime, tType : "time",notEmpty:true},
-                    leaveEarlyTime : {  text:lp.leaveEarlyTime, tType : "time" },
+                    lateStartTime : { text: lp.lateStartTime, tType : "time",notEmpty:true},
+                    leaveEarlyStartTimeMorning : { text: lp.leaveEarlyStartTimeMorning, tType : "time"},
+                    lateStartTimeAfternoon : { text: lp.lateStartTimeAfternoon, tType : "time",notEmpty:(signProxy!=0&&signProxy!=1)?true:false},
+                    //leaveEarlyTime : {  text:lp.leaveEarlyTime, tType : "time" },
+                    leaveEarlyStartTime : {  text:lp.leaveEarlyStartTime, tType : "time" },
+
                     absenceStartTime : { text:lp.absenteeismTime, tType : "time" }
                 }
             }, this.app);
+
             this.form.load();
+
         }.bind(this), true);
     },
     _ok: function( data, callback ){
+        //checkDate
+        var dateList = [];
+
+        var signProxy = data.signProxy;
+        if(signProxy!=1){
+            dateList= [data.onDutyTime,data.middayRestStartTime,data.middayRestEndTime,data.offDutyTime];
+        }else{
+            dateList= [data.onDutyTime,data.offDutyTime];
+        }
+        var D = Date.parse;
+        for(var i=0;i<dateList.length;i++){
+            if(i!=0&&D(dateList[i])-D(dateList[i-1])<0){
+                this.app.notice( this.app.lp.schedule.illegal[signProxy][i-1],"error",this.formNode,{x:"center",y:"center"});
+                return;
+            }
+        }
         this.app.restActions.saveSchedule(data, function(json){
             if( callback )callback(json);
         }.bind(this));

+ 32 - 2
o2web/source/x_component_Attendance/lp/zh-cn.js

@@ -72,8 +72,12 @@ MWF.xApplication.Attendance.LP = {
 	"index" : {
 		"attendanceCalendar":"考勤日历",
 		"pieChart" : "考勤汇总",
-		"lineChart" : "上下班走势"
+		"lineChart" : "上下班走势",
+		"absent":"缺勤",
+		"offDutyTime":"出勤,打卡时间:",
+		"levelAsked":"请假或外出报备"
 	},
+
 	"schedule" : {
 		"inputVaild" : "单位、上班时间、下班时间、迟到起算时间、旷工起算时间均不能为空",
 		"setSchedule" : "排班设置",
@@ -81,8 +85,34 @@ MWF.xApplication.Attendance.LP = {
 		"workTime" : "上班时间",
 		"offTime" : "下班时间",
 		"lateTime":"迟到起算时间",
+
 		"leaveEarlyTime":"早退起算时间",
-		"absenteeismTime":"旷工起算时间"
+		"absenteeismTime":"缺勤起算时间",
+		"illegal":{
+			"1":["下班时间不得早于上班时间"],
+			"2":["午休开始时间不得早于上班时间","午休结束时间不得早于午休开始时间","下班时间不得早于午休结束时间"],
+			"3":["上午下班时间不得早于上班时间","下午上班时间不得早于上午下班时间","下班时间不得早于下午上班时间"]
+		},
+		"lateStartTime":"上午迟到起算时间",
+		"leaveEarlyStartTime":"下午早退起算时间",
+		"leaveEarlyStartTimeMorning":"上午早退起算时间",
+		"lateStartTimeAfternoon":"下午迟到起算时间",
+		"signProxy":{
+			"name":"打卡策略",
+			"select":{
+				"1":"两次打卡(上午上班,下午下班)",
+				"2":"三次打卡(上午上班,下午下班加中午一次共三次)",
+				"3":"四次打卡(上午下午都打上班下班卡)"
+			},
+			"2":{
+				"middayRestStartTime":"午休开始时间",
+				"middayRestEndTime":"午休结束时间",
+			},
+			"3":{
+				"middayRestStartTime":"上午下班时间",
+				"middayRestEndTime":"下午上班时间",
+			}
+		}
 		//"" : "打卡有效时间",
 		//"" : "从",
 		//"" : "到",