This commit is contained in:
jhc 2023-05-08 10:52:00 +08:00
parent 57397737d2
commit 874c6d377a
6 changed files with 890 additions and 705 deletions

File diff suppressed because it is too large Load Diff

View File

@ -425,6 +425,12 @@ message SettingResponse {
// oa审批
message ApplyTime {
string Date = 1 [json_name = "date"];
string Hour = 2 [json_name = "hour"];
string M = 3 [json_name = "m"];
}
message ApprovalOA {
uint64 ID=1 [json_name = "ID"];
uint64 DeletedAt=2 [json_name = "deletedAt"];
@ -465,8 +471,7 @@ message OutWorkApply {
string ActionTime = 7 [json_name = "actionTime"];
string ApprovalID = 8 [json_name = "approvalID"];
int32 Status = 9 [json_name = "status"];
string BeginTime = 10 [json_name = "beginTime"];
string EndTime = 11 [json_name = "endTime"];
repeated ApplyTime ApplyTimes = 10 [json_name = "applyTimes"];
string Reason = 12 [json_name = "reason"];
float Hours = 13 [json_name = "hours"];
string OutWorkAddress = 14 [json_name = "outWorkAddress"];
@ -485,8 +490,7 @@ message MakeUpApply {
string ActionTime = 7 [json_name = "actionTime"];
string ApprovalID = 8 [json_name = "approvalID"];
int32 Status = 9 [json_name = "status"];
string MakeUpDate =10 [json_name = "makeUpDate"];
string MakeUpTime =11 [json_name = "makeUpTime"];
repeated ApplyTime ApplyTimes = 10 [json_name = "applyTimes"];
string Reason = 12 [json_name = "reason"];
repeated CopyUser CopyUsers = 13 [json_name = "copyUsers"];
repeated ApprovalUser ApprovalUsers = 14 [json_name = "approvalUsers"];
@ -504,7 +508,7 @@ message TurnoverApply {
int32 Status = 9 [json_name = "status"];
string HandoverUID = 10 [json_name = "handoverUID"];
string HandoverName = 11 [json_name = "handoverName"];
string TurnoverTime = 12 [json_name = "turnoverTime"];
repeated ApplyTime ApplyTimes = 12 [json_name = "applyTimes"];
string Reason = 13 [json_name = "reason"];
repeated CopyUser CopyUsers = 14 [json_name = "copyUsers"];
repeated ApprovalUser ApprovalUsers = 15 [json_name = "approvalUsers"];
@ -520,8 +524,7 @@ message OverTimeApply {
string ActionTime = 7 [json_name = "actionTime"];
string ApprovalID = 8 [json_name = "approvalID"];
int32 Status = 9 [json_name = "status"];
string BeginTime = 10 [json_name = "beginTime"];
string EndTime = 11 [json_name = "endTime"];
repeated ApplyTime ApplyTimes = 10 [json_name = "applyTimes"];
string Reason = 12 [json_name = "reason"];
float Hours = 13 [json_name = "hours"];
repeated CopyUser CopyUsers = 14 [json_name = "copyUsers"];
@ -538,8 +541,7 @@ message Leave {
string ActionTime = 7 [json_name = "actionTime"];
string ApprovalID = 8 [json_name = "approvalID"];
int32 Status = 9 [json_name = "status"];
string BeginTime = 10 [json_name = "beginTime"];
string EndTime = 11 [json_name = "endTime"];
repeated ApplyTime ApplyTimes = 10 [json_name = "applyTimes"];
string Reason = 12 [json_name = "reason"];
float Hours = 13 [json_name = "hours"];
float Days = 14 [json_name = "days"];
@ -547,28 +549,6 @@ message Leave {
repeated ApprovalUser ApprovalUsers = 16 [json_name = "approvalUsers"];
}
message CostInfo {
string Description = 1 [json_name = "description"];
string UnitPrice = 2 [json_name = "unitPrice"];
string CostUnit = 3 [json_name = "costUnit"];
int64 CostNum = 4 [json_name = "costNum"];
string TotalPrice = 5 [json_name = "totalPrice"];
string UsedDepartment = 6 [json_name = "usedDepartment"];
}
message InvoiceInfo {
string InvoiceDate = 1 [json_name = "invoiceDate"];
string InvoiceNo = 2 [json_name = "invoiceNo"];
string InvoiceProvider = 3 [json_name = "invoiceProvider"];
string Amount = 4 [json_name = "amount"];
string UseTo = 5 [json_name = "useTo"];
string Applicant = 6 [json_name = "applicant"];
string PaymentMethod = 7 [json_name = "paymentMethod"];
string PaymentObj = 8 [json_name = "paymentObj"];
string InvoiceType = 9 [json_name = "invoiceType"];
string Notes = 10 [json_name = "notes"];
}
//
message GetNameRequest {
@ -593,4 +573,27 @@ message FinancialForm {
repeated CostInfo CostInfo = 11 [json_name = "costInfo"];
string PaymentMethod = 12 [json_name = "paymentMethod"];
repeated InvoiceInfo InvoiceInfo = 13 [json_name = "invoiceInfo"];
}
message CostInfo {
string Description = 1 [json_name = "description"];
string UnitPrice = 2 [json_name = "unitPrice"];
string CostUnit = 3 [json_name = "costUnit"];
int64 CostNum = 4 [json_name = "costNum"];
string TotalPrice = 5 [json_name = "totalPrice"];
string UsedDepartment = 6 [json_name = "usedDepartment"];
}
message InvoiceInfo {
string InvoiceDate = 1 [json_name = "invoiceDate"];
string InvoiceNo = 2 [json_name = "invoiceNo"];
string InvoiceProvider = 3 [json_name = "invoiceProvider"];
string Amount = 4 [json_name = "amount"];
string UseTo = 5 [json_name = "useTo"];
string Applicant = 6 [json_name = "applicant"];
string PaymentMethod = 7 [json_name = "paymentMethod"];
string PaymentObj = 8 [json_name = "paymentObj"];
string InvoiceType = 9 [json_name = "invoiceType"];
string Notes = 10 [json_name = "notes"];
}

View File

@ -335,6 +335,9 @@ func (this *DetailSettingRequest) Validate() error {
func (this *SettingResponse) Validate() error {
return nil
}
func (this *ApplyTime) Validate() error {
return nil
}
func (this *ApprovalOA) Validate() error {
if this.LeaveApply != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.LeaveApply); err != nil {
@ -386,6 +389,13 @@ func (this *LeaveApply) Validate() error {
return nil
}
func (this *OutWorkApply) Validate() error {
for _, item := range this.ApplyTimes {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("ApplyTimes", err)
}
}
}
for _, item := range this.CopyUsers {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
@ -403,6 +413,13 @@ func (this *OutWorkApply) Validate() error {
return nil
}
func (this *MakeUpApply) Validate() error {
for _, item := range this.ApplyTimes {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("ApplyTimes", err)
}
}
}
for _, item := range this.CopyUsers {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
@ -420,6 +437,13 @@ func (this *MakeUpApply) Validate() error {
return nil
}
func (this *TurnoverApply) Validate() error {
for _, item := range this.ApplyTimes {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("ApplyTimes", err)
}
}
}
for _, item := range this.CopyUsers {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
@ -437,6 +461,13 @@ func (this *TurnoverApply) Validate() error {
return nil
}
func (this *OverTimeApply) Validate() error {
for _, item := range this.ApplyTimes {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("ApplyTimes", err)
}
}
}
for _, item := range this.CopyUsers {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
@ -454,6 +485,13 @@ func (this *OverTimeApply) Validate() error {
return nil
}
func (this *Leave) Validate() error {
for _, item := range this.ApplyTimes {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
return github_com_mwitkow_go_proto_validators.FieldError("ApplyTimes", err)
}
}
}
for _, item := range this.CopyUsers {
if item != nil {
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
@ -470,12 +508,6 @@ func (this *Leave) Validate() error {
}
return nil
}
func (this *CostInfo) Validate() error {
return nil
}
func (this *InvoiceInfo) Validate() error {
return nil
}
func (this *GetNameRequest) Validate() error {
return nil
}
@ -499,3 +531,9 @@ func (this *FinancialForm) Validate() error {
}
return nil
}
func (this *CostInfo) Validate() error {
return nil
}
func (this *InvoiceInfo) Validate() error {
return nil
}

View File

@ -76,23 +76,6 @@ const (
TypeArtExhibitionReward = "artExhibitionReward"
TypeOa = "oa" // oa 父类
/* 子类 */
TypeOaLeave = "oa_leave" // 事假
TypeOaSick = "oa_sick" // 病假
TypeOaAnnualLeave = "oa_annualLeave" // 年假
TypeOaDayOff = "oa_dayOff" // 调休
TypeOaMaritalLeave = "oa_maritalLeave" // 婚假
TypeOaMatingCheckLeave = "oa_matingCheckLeave" // 孕检假
TypeOaMaternityLeave = "oa_maternityLeave" // 产假
TypeOaPaternityLeave = "oa_paternityLeave" // 陪产假
TypeOaParentalLeave = "oa_parentalLeave" // 育儿假
TypeOaNursingLeave = "oa_nursingLeave" // 独生子女护理假
TypeOaFuneralLeave = "oa_funeralLeave" // 丧假
TypeOaMakeUp = "oa_makeUp" // 补卡
TypeOaOvertime = "oa_overtime" // 加班
TypeOaOutwork = "oa_outwork" // 外勤
TypeOaTurnover = "oa_turnover" // 离职
/* */
TypeFinancialForm = "financialFormApply"
)
@ -557,7 +540,8 @@ func MyAllWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
Preload("ExhibitionReward.ApprovalExhibitions").
Preload("ApprovalWorkFlows").
Preload("Exhibition.ApprovalExhibitions").
Preload("FinancialForm")
Preload("FinancialForm").
Preload("ApprovalOA")
//我未阅读的和我未操作的
DB.Model(&Approval{}).Where(&Approval{Type: in.Type}).Where(&Approval{NowUserId: in.UserID, Status: StatusDoing}).Order("id desc").Select("id").Find(&ids)
@ -595,7 +579,8 @@ func MyApprovalWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
Preload("ApprovalType.ApprovalTypeGroup").
Preload("ApprovalWorkFlows").
Preload("Exhibition.ApprovalExhibitions").
Preload("FinancialForm")
Preload("FinancialForm").
Preload("ApprovalOA")
if in.Type != "" {
modelObj = modelObj.Where(&Approval{Type: in.Type})
@ -653,7 +638,8 @@ func MyWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
Preload("ExhibitionReward.ApprovalExhibitions").
Preload("ApprovalWorkFlows").
Preload("Exhibition.ApprovalExhibitions").
Preload("FinancialForm")
Preload("FinancialForm").
Preload("ApprovalOA")
if in.Type != "" {
modelObj = modelObj.Where(&Approval{Type: in.Type})
@ -710,7 +696,8 @@ func MySubmitApprovals(in *approval.ListRequest) ([]*Approval, int64) {
Preload("ExhibitionReward.ApprovalExhibitions").
Preload("ApprovalType.ApprovalTypeGroup").
Preload("Exhibition.ApprovalExhibitions").
Preload("FinancialForm")
Preload("FinancialForm").
Preload("ApprovalOA")
if in.Status != 0 {
modelObj = modelObj.Where(&Approval{Status: int8(in.Status)})
@ -743,7 +730,8 @@ func MyReadApprovals(in *approval.ListRequest) ([]*Approval, int64) {
Preload("ExhibitionReward.ApprovalExhibitions").
Preload("ApprovalType.ApprovalTypeGroup").
Preload("Exhibition.ApprovalExhibitions").
Preload("FinancialForm")
Preload("FinancialForm").
Preload("ApprovalOA")
if in.Type != "" {
modelObj = modelObj.Where(&Approval{Type: in.Type})
@ -834,11 +822,10 @@ func getApprovalContentFactory(typeFiled string) (ApprovalContentInterface, erro
case TypeFinancialForm:
return &FinancialForm{}, nil
default:
v, _ := TypeMap[typeFiled]
if v == "oa" {
if TypeMap[typeFiled] == TypeOa {
return &ApprovalOA{}, nil
} else {
return &Approval{}, nil
return nil, errors.New("无法识别的审批类型")
}
}
}

View File

@ -16,12 +16,12 @@ type ApprovalOA struct {
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` // 创建时间
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` // 更新时间
ApprovalID uint64 `gorm:"column:approval_id" json:"approvalID"` // 申请的id
LeaveApply LeaveApply `json:"leaveApply" gorm:"column:leave_apply;type:json;comment:假期余额申请"`
OutWork OutWorkApply `json:"outWork" gorm:"column:out_work;type:json;comment:外勤"`
MakeUp MakeUpApply `json:"makeUp" gorm:"column:make_up;type:json;comment:加班"`
Turnover TurnoverApply `json:"turnover" gorm:"column:turnover;type:json;comment:离职"`
OverTime OverTimeApply `json:"overTime" gorm:"column:over_time;type:json;comment:加班"`
Leave Leave `json:"leave" gorm:"column:leave;type:json;comment:请假"`
LeaveApply *LeaveApply `json:"leaveApply" gorm:"column:leave_apply;type:json;comment:假期余额申请"`
OutWork *OutWorkApply `json:"outWork" gorm:"column:out_work;type:json;comment:外勤"`
MakeUp *MakeUpApply `json:"makeUp" gorm:"column:make_up;type:json;comment:加班"`
Turnover *TurnoverApply `json:"turnover" gorm:"column:turnover;type:json;comment:离职"`
OverTime *OverTimeApply `json:"overTime" gorm:"column:over_time;type:json;comment:加班"`
Leave *Leave `json:"leave" gorm:"column:leave;type:json;comment:请假"`
}
// LeaveApply
@ -52,8 +52,7 @@ type OutWorkApply struct {
DepartmentUID string `json:"departmentUID" gorm:"column:department_uid;type:text;comment:部门UID"` // 部门UID
ApplyType string `json:"applyType" gorm:"column:apply_type;type:varchar(255);comment:审批|请假类型"`
ActionTime string `json:"actionTime" gorm:"column:action_time;type:varchar(255);comment:操作|申请时间"`
BeginTime string `json:"beginTime" gorm:"column:begin_time;type:varchar(255);comment:开始时间"`
EndTime string `json:"endTime" gorm:"column:end_time;type:varchar(255);comment:结束时间"`
ApplyTimes ApplyTimes `json:"applyTimes" gorm:"column:apply_times;type:json;comment:时间"`
Hours float32 `json:"hours" gorm:"column:hours;type:decimal(10,2);comment:时长(小时)"`
OutWorkAddress string `json:"outWorkAddress" gorm:"column:out_work_address;type:varchar(255);comment:外勤地址"`
Vehicle string `json:"vehicle" gorm:"column:vehicle;type:varchar(255);comment:交通工具"`
@ -74,8 +73,7 @@ type MakeUpApply struct {
DepartmentUID string `json:"departmentUID" gorm:"column:department_uid;type:text;comment:部门UID"` // 部门UID
ApplyType string `json:"applyType" gorm:"column:apply_type;type:varchar(255);comment:审批|请假类型"`
ActionTime string `json:"actionTime" gorm:"column:action_time;type:varchar(255);comment:操作|申请时间"`
MakeUpDate string `json:"makeUpDate" gorm:"column:make_up_date;type:varchar(255);comment:补卡日期"`
MakeUpTime string `json:"makeUpTime" gorm:"column:make_up_time;type:varchar(255);comment:补卡时间"`
ApplyTimes ApplyTimes `json:"applyTimes" gorm:"column:apply_times;type:json;comment:时间"`
Reason string `json:"reason" gorm:"column:reason;type:varchar(255);comment:理由"`
ApprovalID string `json:"approvalID" gorm:"column:approval_id;type:varchar(255);comment:审批系统中的approvalID"`
Status int32 `json:"status" gorm:"column:status;type:int;comment:状态(目前和审批系统状态同步)"`
@ -96,7 +94,7 @@ type TurnoverApply struct {
Reason string `json:"reason" gorm:"column:reason;type:varchar(255);comment:理由"`
HandoverUID string `json:"handoverUID" gorm:"column:handover_uid;type:varchar(255);comment:交接人"`
HandoverName string `json:"handoverName" gorm:"column:handover_name;type:varchar(255);comment:交接人姓名"`
TurnoverTime string `json:"turnoverTime" gorm:"column:turnover_time;type:varchar(255);comment:离职时间"`
ApplyTimes ApplyTimes `json:"applyTimes" gorm:"column:apply_times;type:json;comment:时间"`
ApprovalID string `json:"approvalID" gorm:"column:approval_id;type:varchar(255);comment:审批系统中的approvalID"`
Status int32 `json:"status" gorm:"column:status;type:int;comment:状态(目前和审批系统状态同步)"`
ApprovalUsers ApprovalUsers `json:"approvalUsers" gorm:"column:approval_users;type:json;comment:审批人"`
@ -114,8 +112,7 @@ type OverTimeApply struct {
ApplyType string `json:"applyType" gorm:"column:apply_type;type:varchar(255);comment:审批|请假类型"`
ApprovalID string `json:"approvalID" gorm:"column:approval_id;type:varchar(255);comment:审批系统中的approvalID"`
ActionTime string `json:"actionTime" gorm:"column:action_time;type:varchar(255);comment:操作|申请时间"`
BeginTime string `json:"beginTime" gorm:"column:begin_time;type:varchar(255);comment:开始时间"`
EndTime string `json:"endTime" gorm:"column:end_time;type:varchar(255);comment:结束时间"`
ApplyTimes ApplyTimes `json:"applyTimes" gorm:"column:apply_times;type:json;comment:时间"`
Reason string `json:"reason" gorm:"column:reason;type:varchar(255);comment:理由"`
Hours float32 `json:"hours" gorm:"column:hours;type:decimal(10,2);comment:时长(小时)"`
Status int32 `json:"status" gorm:"column:status;type:int;comment:状态(目前和审批系统状态同步)"`
@ -134,8 +131,7 @@ type Leave struct {
ApplyType string `json:"applyType" gorm:"column:apply_type;type:varchar(255);comment:审批|请假类型"`
ActionTime string `json:"actionTime" gorm:"column:action_time;type:varchar(255);comment:操作|申请时间"`
ApprovalID string `json:"approvalID" gorm:"column:approval_id;type:varchar(255);comment:审批系统中的approvalID"`
BeginTime string `json:"beginTime" gorm:"column:begin_time;type:varchar(255);comment:开始时间"`
EndTime string `json:"endTime" gorm:"column:end_time;type:varchar(255);comment:结束时间"`
ApplyTimes ApplyTimes `json:"applyTimes" gorm:"column:apply_times;type:json;comment:时间"`
Reason string `json:"reason" gorm:"column:reason;type:varchar(255);comment:理由"`
Hours float32 `json:"hours" gorm:"column:hours;type:decimal(10,2);comment:时长(小时)"`
Days float32 `json:"days" gorm:"column:days;type:decimal(10,2);comment:时长(天)"`
@ -146,6 +142,14 @@ type Leave struct {
type VerifyFiles []string
type ApplyTime struct {
Date string `json:"date"` // 日期 2023-05-08
Hour string `json:"hour"` // 时间 09:00
M string `json:"m"` // 上午|下午
}
type ApplyTimes []ApplyTime
var sonMap = map[string]string{
"leave": "leave", // 事假
"sick": "leave", // 病假
@ -194,17 +198,25 @@ func (oa *ApprovalOA) GetApproval(id uint64) (*Approval, error) {
func (oa *ApprovalOA) SaveApprovalContent(in *approval.CreateRequest, a *Approval) error {
copier.CopyWithOption(&oa, in.ApprovalOA, copier.Option{DeepCopy: true})
oa.ApprovalID = a.ID
if err := oa.addOtherInfo(a); err != nil {
if err := oa.copyOAToModel(in, a); err != nil {
return err
}
return DB.Create(&oa).Error
}
func (oa *ApprovalOA) addOtherInfo(a *Approval) error {
func (oa *ApprovalOA) copyOAToModel(in *approval.CreateRequest, a *Approval) error {
copier.CopyWithOption(&oa, in.ApprovalOA, copier.Option{DeepCopy: true})
oa.ApprovalID = a.ID
if err := oa.addOtherInfoToModel(in, a); err != nil {
return err
}
return nil
}
func (oa *ApprovalOA) addOtherInfoToModel(in *approval.CreateRequest, a *Approval) error {
if v, ok := sonMap[a.ApprovalType.KeyWord]; ok {
switch v {
case "leave":
@ -215,30 +227,80 @@ func (oa *ApprovalOA) addOtherInfo(a *Approval) error {
}
oa.Leave.ApprovalID = strconv.FormatUint(a.ID, 10)
oa.Leave.Status = int32(a.Status)
applyTimes := make([]ApplyTime, 0)
for i := 0; i < len(in.ApprovalOA.Leave.ApplyTimes); i++ {
applyTimes = append(applyTimes, ApplyTime{
Date: in.ApprovalOA.Leave.ApplyTimes[i].Date,
Hour: in.ApprovalOA.Leave.ApplyTimes[i].Hour,
M: in.ApprovalOA.Leave.ApplyTimes[i].M,
})
}
oa.Leave.ApplyTimes = applyTimes
case "makeUp":
oa.MakeUp.ApprovalUsers = a.ApprovalUsers
oa.MakeUp.CopyUsers = a.CopyUsers
oa.MakeUp.ApplyType = a.ApprovalType.KeyWord
oa.MakeUp.ApprovalID = strconv.FormatUint(a.ID, 10)
oa.MakeUp.Status = int32(a.Status)
applyTimes := make([]ApplyTime, 0)
for i := 0; i < len(in.ApprovalOA.MakeUp.ApplyTimes); i++ {
applyTimes = append(applyTimes, ApplyTime{
Date: in.ApprovalOA.MakeUp.ApplyTimes[i].Date,
Hour: in.ApprovalOA.MakeUp.ApplyTimes[i].Hour,
M: in.ApprovalOA.MakeUp.ApplyTimes[i].M,
})
}
oa.MakeUp.ApplyTimes = applyTimes
case "overTime":
oa.OverTime.ApprovalUsers = a.ApprovalUsers
oa.OverTime.CopyUsers = a.CopyUsers
oa.OverTime.ApplyType = a.ApprovalType.KeyWord
oa.OverTime.ApprovalID = strconv.FormatUint(a.ID, 10)
oa.OverTime.Status = int32(a.Status)
applyTimes := make([]ApplyTime, 0)
for i := 0; i < len(in.ApprovalOA.OverTime.ApplyTimes); i++ {
applyTimes = append(applyTimes, ApplyTime{
Date: in.ApprovalOA.OverTime.ApplyTimes[i].Date,
Hour: in.ApprovalOA.OverTime.ApplyTimes[i].Hour,
M: in.ApprovalOA.OverTime.ApplyTimes[i].M,
})
}
oa.OverTime.ApplyTimes = applyTimes
case "outWork":
oa.OutWork.ApprovalUsers = a.ApprovalUsers
oa.OutWork.CopyUsers = a.CopyUsers
oa.OutWork.ApplyType = a.ApprovalType.KeyWord
oa.OutWork.ApprovalID = strconv.FormatUint(a.ID, 10)
oa.OutWork.Status = int32(a.Status)
applyTimes := make([]ApplyTime, 0)
for i := 0; i < len(in.ApprovalOA.OutWork.ApplyTimes); i++ {
applyTimes = append(applyTimes, ApplyTime{
Date: in.ApprovalOA.OutWork.ApplyTimes[i].Date,
Hour: in.ApprovalOA.OutWork.ApplyTimes[i].Hour,
M: in.ApprovalOA.OutWork.ApplyTimes[i].M,
})
}
oa.OutWork.ApplyTimes = applyTimes
case "turnover":
oa.Turnover.ApprovalUsers = a.ApprovalUsers
oa.Turnover.CopyUsers = a.CopyUsers
oa.Turnover.ApplyType = a.ApprovalType.KeyWord
oa.Turnover.ApprovalID = strconv.FormatUint(a.ID, 10)
oa.Turnover.Status = int32(a.Status)
applyTimes := make([]ApplyTime, 0)
for i := 0; i < len(in.ApprovalOA.Turnover.ApplyTimes); i++ {
applyTimes = append(applyTimes, ApplyTime{
Date: in.ApprovalOA.Turnover.ApplyTimes[i].Date,
Hour: in.ApprovalOA.Turnover.ApplyTimes[i].Hour,
M: in.ApprovalOA.Turnover.ApplyTimes[i].M,
})
}
oa.Turnover.ApplyTimes = applyTimes
case "leaveApply":
oa.LeaveApply.ApprovalUsers = a.ApprovalUsers
oa.LeaveApply.CopyUsers = a.CopyUsers
@ -262,11 +324,51 @@ func (oa *ApprovalOA) UpdateApprovalContent(in *approval.CreateRequest, a *Appro
oa.ID = entity.ID
if err := oa.copyOAToModel(in, a); err != nil {
return err
}
return DB.Model(&oa).Updates(oa).Error
}
func (oa *ApprovalOA) BuildResContent(a *Approval, request *approval.CreateRequest) {
if err := oa.copyOAToRpc(a, request); err != nil {
return
}
}
func (oa *ApprovalOA) copyOAToRpc(a *Approval, in *approval.CreateRequest) error {
copier.CopyWithOption(&in.ApprovalOA, a, copier.Option{DeepCopy: true})
if err := oa.addOtherInfoToRpc(a, in); err != nil {
return err
}
return nil
}
func (oa *ApprovalOA) addOtherInfoToRpc(a *Approval, in *approval.CreateRequest) error {
if oa.Leave != nil {
copier.CopyWithOption(&a.ApprovalOA.Leave.ApplyTimes, in.ApprovalOA.Leave.ApplyTimes, copier.Option{DeepCopy: true})
}
if oa.MakeUp != nil {
copier.CopyWithOption(&a.ApprovalOA.MakeUp.ApplyTimes, in.ApprovalOA.MakeUp.ApplyTimes, copier.Option{DeepCopy: true})
}
if oa.Turnover != nil {
copier.CopyWithOption(&a.ApprovalOA.Turnover.ApplyTimes, in.ApprovalOA.Turnover.ApplyTimes, copier.Option{DeepCopy: true})
}
if oa.OverTime != nil {
copier.CopyWithOption(&a.ApprovalOA.OverTime.ApplyTimes, in.ApprovalOA.OverTime.ApplyTimes, copier.Option{DeepCopy: true})
}
if oa.OutWork != nil {
copier.CopyWithOption(&a.ApprovalOA.OutWork.ApplyTimes, in.ApprovalOA.OutWork.ApplyTimes, copier.Option{DeepCopy: true})
}
return nil
}
func (oa *ApprovalOA) DeleteApproval(p *Approval) error {

View File

@ -14,7 +14,9 @@ func migration() {
addTable(&ApprovalReward{})
addTable(&FinancialFormSetting{}) // 财务报表审批 设置信息
addTable(&FinancialForm{}) // 财务报表审批 设置信息
addTable(&FinancialForm{}) // 财务报表审批
addTable(&ApprovalOA{}) // OA
//增加字段
addColumn(&ApprovalType{}, "is_normal")