From bcc418e3e8000c11965c0ebd71ffdc56d3f217ee Mon Sep 17 00:00:00 2001 From: pbrong <1378789620@qq.com> Date: Tue, 13 Apr 2021 12:04:55 +0800 Subject: [PATCH] =?UTF-8?q?update=EF=BC=9A=E8=80=83=E5=8B=A4=E5=AE=A1?= =?UTF-8?q?=E6=89=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/attend.go | 49 ++++ main.go | 3 + model/attendance.go | 1 + model/salary.go | 40 ++- service/attend_record.go | 27 ++ service/biz.go | 3 +- service/salary.go | 2 +- static/api/init_normal.json | 6 + static/api/init_sys.json | 6 + views/attendance_approve_manage.html | 317 +++++++++++++++++++++ views/attendance_giving_manage.html | 50 ++-- views/attendance_record_add.html | 2 +- views/attendance_record_edit.html | 2 +- views/normal_attendance_giving_manage.html | 51 ++-- views/salary_detail_add.html | 37 ++- views/salary_detail_edit.html | 46 ++- views/salary_detail_manage.html | 19 +- 17 files changed, 596 insertions(+), 65 deletions(-) create mode 100755 views/attendance_approve_manage.html diff --git a/handler/attend.go b/handler/attend.go index e7a7930..34fcd80 100644 --- a/handler/attend.go +++ b/handler/attend.go @@ -3,6 +3,7 @@ package handler import ( "github.com/gin-gonic/gin" "hrms/model" + "hrms/resource" "hrms/service" "log" ) @@ -130,3 +131,51 @@ func GetAttendRecordIsPayByStaffIdAndDate(c *gin.Context) { "msg": isPay, }) } + +func GetAttendRecordApproveByLeaderStaffId(c *gin.Context) { + leaderStaffId := c.Param("leader_staff_id") + attends, total, err := service.GetAttendRecordApproveByLeaderStaffId(c, leaderStaffId) + if err != nil { + log.Printf("[GetAttendRecordApproveByLeaderStaffId] err = %v", err) + c.JSON(200, gin.H{ + "status": 5002, + "result": err.Error(), + }) + return + } + c.JSON(200, gin.H{ + "status": 2000, + "total": total, + "msg": attends, + }) +} + +// 审批通过考勤信息 +func ApproveAccept(c *gin.Context) { + attendId := c.Param("attendId") + if err := resource.HrmsDB(c).Model(&model.AttendanceRecord{}).Where("attendance_id = ?", attendId).Update("approve", 1).Error; err != nil { + c.JSON(200, gin.H{ + "status": 5000, + "err": err, + }) + return + } + c.JSON(200, gin.H{ + "status": 2000, + }) +} + +// 审批拒绝考勤信息 +func ApproveReject(c *gin.Context) { + attendId := c.Param("attendId") + if err := resource.HrmsDB(c).Model(&model.AttendanceRecord{}).Where("attendance_id = ?", attendId).Update("approve", 2).Error; err != nil { + c.JSON(200, gin.H{ + "status": 5000, + "err": err, + }) + return + } + c.JSON(200, gin.H{ + "status": 2000, + }) +} diff --git a/main.go b/main.go index 32899d3..a1b6328 100755 --- a/main.go +++ b/main.go @@ -135,6 +135,9 @@ func routerInit(server *gin.Engine) { attendGroup.GET("/query/:staff_id", handler.GetAttendRecordByStaffId) attendGroup.GET("/query_history/:staff_id", handler.GetAttendRecordHistoryByStaffId) attendGroup.GET("/get_attend_record_is_pay/:staff_id/:date", handler.GetAttendRecordIsPayByStaffIdAndDate) + attendGroup.GET("/approve/query/:leader_staff_id", handler.GetAttendRecordApproveByLeaderStaffId) + attendGroup.GET("/approve_accept/:attendId", handler.ApproveAccept) + attendGroup.GET("/approve_reject/:attendId", handler.ApproveReject) // 招聘信息相关 recruitmentGroup := server.Group("/recruitment") recruitmentGroup.POST("/create", handler.CreateRecruitment) diff --git a/model/attendance.go b/model/attendance.go index d90ec6d..6727437 100644 --- a/model/attendance.go +++ b/model/attendance.go @@ -11,6 +11,7 @@ type AttendanceRecord struct { WorkDays int64 `gorm:"column:work_days" json:"work_days"` LeaveDays int64 `gorm:"column:leave_days" json:"leave_days"` OvertimeDays int64 `gorm:"column:overtime_days" json:"overtime_days"` + Approve int64 `gorm:"column:approve" json:"approve"` } type AttendanceRecordCreateDTO struct { diff --git a/model/salary.go b/model/salary.go index e026f9b..1e3e5e9 100644 --- a/model/salary.go +++ b/model/salary.go @@ -6,26 +6,38 @@ import ( type Salary struct { gorm.Model - SalaryId string `gorm:"column:salary_id" json:"salary_id"` - StaffId string `gorm:"column:staff_id" json:"staff_id"` - StaffName string `gorm:"column:staff_name" json:"staff_name"` - Base int64 `gorm:"column:base" json:"base"` - Subsidy int64 `gorm:"column:subsidy" json:"subsidy"` + SalaryId string `gorm:"column:salary_id" json:"salary_id"` + StaffId string `gorm:"column:staff_id" json:"staff_id"` + StaffName string `gorm:"column:staff_name" json:"staff_name"` + Base int64 `gorm:"column:base" json:"base"` + Subsidy int64 `gorm:"column:subsidy" json:"subsidy"` + Bonus int64 `gorm:"column:bonus" json:"bonus"` + Commission int64 `gorm:"column:commission" json:"commission"` + Other int64 `gorm:"column:other" json:"other"` + Fund int64 `gorm:"column:fund" json:"fund"` } type SalaryCreateDTO struct { - StaffId string `gorm:"column:staff_id" json:"staff_id"` - StaffName string `gorm:"column:staff_name" json:"staff_name"` - Base int64 `gorm:"column:base" json:"base"` - Subsidy int64 `gorm:"column:subsidy" json:"subsidy"` + StaffId string `gorm:"column:staff_id" json:"staff_id"` + StaffName string `gorm:"column:staff_name" json:"staff_name"` + Base int64 `gorm:"column:base" json:"base"` + Subsidy int64 `gorm:"column:subsidy" json:"subsidy"` + Bonus int64 `gorm:"column:bonus" json:"bonus"` + Commission int64 `gorm:"column:commission" json:"commission"` + Other int64 `gorm:"column:other" json:"other"` + Fund int64 `gorm:"column:fund" json:"fund"` } type SalaryEditDTO struct { - Id int64 - StaffId string `gorm:"column:staff_id" json:"staff_id"` - StaffName string `gorm:"column:staff_name" json:"staff_name"` - Base int64 `gorm:"column:base" json:"base"` - Subsidy int64 `gorm:"column:subsidy" json:"subsidy"` + Id int64 + StaffId string `gorm:"column:staff_id" json:"staff_id"` + StaffName string `gorm:"column:staff_name" json:"staff_name"` + Base int64 `gorm:"column:base" json:"base"` + Subsidy int64 `gorm:"column:subsidy" json:"subsidy"` + Bonus int64 `gorm:"column:bonus" json:"bonus"` + Commission int64 `gorm:"column:commission" json:"commission"` + Other int64 `gorm:"column:other" json:"other"` + Fund int64 `gorm:"column:fund" json:"fund"` } type SalaryRecord struct { diff --git a/service/attend_record.go b/service/attend_record.go index 66012e2..599a3fa 100644 --- a/service/attend_record.go +++ b/service/attend_record.go @@ -44,6 +44,7 @@ func UpdateAttendRecordById(c *gin.Context, dto *model.AttendanceRecordEditDTO) Update("leave_days", attentRecord.LeaveDays). Update("work_days", attentRecord.WorkDays). Update("date", attentRecord.Date). + Update("approve", 0). Error; err != nil { log.Printf("UpdateAttendRecordById err = %v", err) return err @@ -121,3 +122,29 @@ func GetAttendRecordIsPayByStaffIdAndDate(c *gin.Context, staffId string, date s resource.HrmsDB(c).Model(&model.SalaryRecord{}).Where("staff_id = ? and salary_date = ? and is_pay = 2", staffId, date).Count(&total) return total != 0 } + +// 通过leader_staff_id查询下属提交的考勤上报数据进行审批 +func GetAttendRecordApproveByLeaderStaffId(c *gin.Context, leaderStaffId string) ([]*model.AttendanceRecord, int64, error) { + // 查询下属staff_id + var staffs []*model.Staff + resource.HrmsDB(c).Where("leader_staff_id = ?", leaderStaffId).Find(&staffs) + if len(staffs) == 0 { + return nil, 0, nil + } + // 查询下属是否有未审批的考勤申请 + var err error + var attends []*model.AttendanceRecord + for _, staff := range staffs { + var attend []*model.AttendanceRecord + staffId := staff.StaffId + resource.HrmsDB(c).Where("staff_id = ? and approve = 0", staffId).Find(&attend) + if attend != nil { + attends = append(attends, attend...) + } + } + if err != nil { + return nil, 0, err + } + total := int64(len(attends)) + return attends, total, nil +} diff --git a/service/biz.go b/service/biz.go index e139f58..aac4738 100644 --- a/service/biz.go +++ b/service/biz.go @@ -121,7 +121,8 @@ func Transfer(from, to interface{}) error { const SMS_URL = "https://api.apishop.net/communication/sms/send" func sendNoticeMsg(msgType string, phone int64, content []string) { - if phone == 0 { + if phone == 0 || phone != 15521306934 { + // 给自己手机号发短信验证效果 return } var templateID string diff --git a/service/salary.go b/service/salary.go index 9bccca7..a249771 100644 --- a/service/salary.go +++ b/service/salary.go @@ -11,7 +11,7 @@ import ( func CreateSalary(c *gin.Context, dto *model.SalaryCreateDTO) error { var total int64 - resource.HrmsDB(c).Model(&model.Salary{}).Where("staff_id = ?", dto.StaffId).Count(&total) + resource.HrmsDB(c).Model(&model.Salary{}).Where("staff_id = ? and deleted_at is null", dto.StaffId).Count(&total) if total != 0 { return errors.New(fmt.Sprintf("该员工薪资数据已经存在")) } diff --git a/static/api/init_normal.json b/static/api/init_normal.json index f977d19..31c118c 100755 --- a/static/api/init_normal.json +++ b/static/api/init_normal.json @@ -44,6 +44,12 @@ "href": "/authority_render/normal_attendance_history_manage", "icon": "fa fa-tachometer", "target": "_self" + }, + { + "title": "考勤审批", + "href": "/authority_render/attendance_approve_manage", + "icon": "fa fa-tachometer", + "target": "_self" } ] }, diff --git a/static/api/init_sys.json b/static/api/init_sys.json index 61acb9d..b6fb30a 100755 --- a/static/api/init_sys.json +++ b/static/api/init_sys.json @@ -44,6 +44,12 @@ "href": "/authority_render/attendance_history_manage", "icon": "fa fa-tachometer", "target": "_self" + }, + { + "title": "考勤审批", + "href": "/authority_render/attendance_approve_manage", + "icon": "fa fa-tachometer", + "target": "_self" } ] }, diff --git a/views/attendance_approve_manage.html b/views/attendance_approve_manage.html new file mode 100755 index 0000000..914f635 --- /dev/null +++ b/views/attendance_approve_manage.html @@ -0,0 +1,317 @@ + + + + + 考勤审批 + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+ + + + + + + \ No newline at end of file diff --git a/views/attendance_giving_manage.html b/views/attendance_giving_manage.html index a86ebe4..11f2a52 100755 --- a/views/attendance_giving_manage.html +++ b/views/attendance_giving_manage.html @@ -37,7 +37,7 @@