فهرست منبع

test 出差申请人可关闭申请

hsun 1 سال پیش
والد
کامیت
e8b1f777f0
2فایلهای تغییر یافته به همراه31 افزوده شده و 5 حذف شده
  1. 30 5
      controllers/business_trip/business_apply.go
  2. 1 0
      models/tables/business_trip/business_apply.go

+ 30 - 5
controllers/business_trip/business_apply.go

@@ -699,8 +699,14 @@ func (this *BusinessTrip) ApplyDetail() {
 		this.FailWithMessage("获取数据失败", "获取数据失败:"+err.Error())
 		return
 	}
+
+	// 审批人/申请人均可关闭
 	if item.ApproveId == sysUserId {
 		item.IsApprove = true
+		item.IsClose = true
+	}
+	if sysUserId == item.BusinessApplyId {
+		item.IsClose = true
 	}
 	this.OkDetailed(item, "获取成功")
 }
@@ -734,9 +740,18 @@ func (this *BusinessTrip) Close() {
 		this.FailWithMessage("获取数据失败!", "获取数据失败!GetBusinessApplyById:"+err.Error())
 		return
 	}
+	if sysUser.AdminId != businessApplyItem.BusinessApplyId && sysUser.AdminId != businessApplyItem.ApproveId {
+		this.FailWithMessage("无权操作", "无权操作")
+		return
+	}
+	// 判断是申请人还是审批人操作的关闭
+	isApply := false
+	if sysUser.AdminId == businessApplyItem.ApplyAdminId {
+		isApply = true
+	}
 
-	fmt.Println(req.BusinessApplyId)
-	fmt.Println(req.CloseReason)
+	//fmt.Println(req.BusinessApplyId)
+	//fmt.Println(req.CloseReason)
 
 	whereParams := make(map[string]interface{})
 	updateParams := make(map[string]interface{})
@@ -767,23 +782,33 @@ func (this *BusinessTrip) Close() {
 		return
 	}
 
+	// 审批人关闭时, 发送消息给申请人
+	// 若为申请人自己关闭, 则消息发送给审批人
+	receiveUserId := businessApplyItem.ApplyAdminId
+	if isApply {
+		receiveUserId = businessApplyItem.ApproveId
+	}
 	{
 		//系统消息
 		sourceType := 10
 		content := businessApplyItem.ApplyRealName + " " + businessApplyItem.Province + businessApplyItem.City + businessApplyItem.Reason + "出差申请已关闭"
-		go services.AddCompanyApprovalMessage(sysUserId, businessApplyItem.ApplyAdminId, 0, businessApplyItem.BusinessApplyId, 1, sourceType, 1, "", content, content, "", "")
+		go services.AddCompanyApprovalMessage(sysUserId, receiveUserId, 0, businessApplyItem.BusinessApplyId, 1, sourceType, 1, "", content, content, "", "")
 	}
 
 	//模板消息
 	{
 		status := "已关闭"
-		applyItem, _ := admin.GetAdminById(businessApplyItem.ApplyAdminId)
+		receiver, _ := admin.GetAdminById(receiveUserId)
+		//applyItem, _ := admin.GetAdminById(businessApplyItem.ApplyAdminId)
 		wxAppPath := "pages-approve/businessTrip/detail?id=" + strconv.Itoa(req.BusinessApplyId)
 		first := "您的出差申请已被关闭"
+		if isApply {
+			first = fmt.Sprintf("%s的出差申请已关闭", businessApplyItem.ApplyRealName)
+		}
 		keyword1 := businessApplyItem.Reason + "出差申请" + status
 		keyword2 := status
 		var remark string
-		go services.SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppPath, applyItem.Mobile)
+		go services.SendWxMsgWithRoadshowDeleteNotice(first, keyword1, keyword2, remark, wxAppPath, receiver.Mobile)
 	}
 	this.OkWithMessage("关闭成功")
 }

+ 1 - 0
models/tables/business_trip/business_apply.go

@@ -74,6 +74,7 @@ type BusinessApplyView struct {
 	IsApprove       bool   `description:"是否审批人,true:是,false:否"`
 	CloseReason     string `description:"关闭理由"`
 	CloseTime       string `description:"关闭时间"`
+	IsClose         bool   `description:"true,可关闭,false,不可关闭"`
 }
 
 func GetBusinessApplyListCount(condition string, pars []interface{}) (count int, err error) {