瀏覽代碼

fix:approve

zqbao 6 月之前
父節點
當前提交
6d544ea9c8
共有 3 個文件被更改,包括 81 次插入7 次删除
  1. 76 3
      controllers/bi_approve/bi_approve.go
  2. 2 2
      models/bi_approve/bi_approve.go
  3. 3 2
      services/bi_approve/bi_approve_flow.go

+ 76 - 3
controllers/bi_approve/bi_approve.go

@@ -3,6 +3,8 @@ package biapprove
 import (
 	"eta_gn/eta_api/controllers"
 	"eta_gn/eta_api/models"
+	"eta_gn/eta_api/utils"
+	"time"
 )
 
 type BIApproveController struct {
@@ -15,9 +17,7 @@ type BIApproveController struct {
 // @Param   PageSize			query	int		true	"每页数据条数"
 // @Param   CurrentIndex		query	int		true	"当前页页码"
 // @Param   ListType			query   int     true	"列表类型:1-待处理;2-已处理;3-我发起的"
-// @Param   ReportType			query   int     false	"报告类型:1-中文研报;2-英文研报;3-智能研报"
-// @Param   ClassifyIdFirst		query	int		false	"一级分类ID"
-// @Param   ClassifyIdSecond	query	int		false	"二级分类ID"
+// @Param   ClassifyId			query	int		false	"分类ID"
 // @Param   Keyword				query	string	false	"搜索关键词"
 // @Param   ApproveState		query	int		false	"审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回"
 // @Param   TimeType			query	int		false	"时间类型:1-提交时间;2-处理时间;3-审批时间"
@@ -37,4 +37,77 @@ func (this *BIApproveController) List() {
 		this.ServeJSON()
 	}()
 
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	listType, _ := this.GetInt("ListType")
+	approveState, _ := this.GetInt("ApproveState")
+	timeType, _ := this.GetInt("TimeType")
+	startTime := this.GetString("StartTime")
+	endTime := this.GetString("EndTime")
+	// sortField, _ := this.GetInt("SortField")
+	// sortRule, _ := this.GetInt("SortRule")
+	classifyId, _ := this.GetInt("ClassifyId")
+	keyword := this.GetString("Keyword")
+
+	var pars []interface{}
+	var condition string
+
+	if pageSize <= 0 {
+		pageSize = utils.PageSize10
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+
+	if classifyId > 0 {
+		condition += ` AND classify_id = ? `
+		pars = append(pars, classifyId)
+	}
+	if keyword != "" {
+		condition += ` AND bi_title LIKE ? `
+		pars = utils.GetLikeKeywordPars(pars, keyword, 1)
+	}
+	if approveState > 0 {
+		condition += ` AND a.state = ? `
+		pars = append(pars, approveState)
+	}
+	if startTime != "" && endTime != "" {
+		_, err := time.Parse(utils.FormatDate, startTime)
+		if err != nil {
+			br.Msg = "开始时间格式错误"
+			return
+		}
+		endTime, err := time.Parse(utils.FormatDate, endTime)
+		endTime = endTime.AddDate(0, 0, 1)
+		switch timeType {
+		case 1:
+			condition += ` AND create_time BETWEEN ? AND ? `
+			pars = append(pars, startTime, endTime)
+		case 2:
+			condition += ` AND approve_time BETWEEN ? AND ? `
+			pars = append(pars, startTime, endTime)
+		case 3:
+			condition += ` AND approve_time BETWEEN ? AND ? `
+			pars = append(pars, startTime, endTime)
+		default:
+			br.Msg = "时间类型错误"
+			return
+		}
+	}
+
+	switch listType {
+	case 1:
+		condition += ` AND a.state = 1 AND a.approve_user_id = ?`
+		pars = append(pars, this.SysUser.AdminId)
+	case 2:
+		condition += ` AND a.state IN (2,3) AND a.approve_user_id = ?`
+		pars = append(pars, this.SysUser.AdminId)
+	case 3:
+		condition += ` AND a.state = ? `
+		pars = append(pars, this.GetSession("username"))
+	default:
+		br.Msg = "列表类型错误"
+		return
+	}
+
 }

+ 2 - 2
models/bi_approve/bi_approve.go

@@ -5,9 +5,9 @@ import "time"
 type BiApprove struct {
 	BiApproveId   int       `gorm:"column:bi_approve_id;primary_key"`
 	BiId          int       `gorm:"column:bi_id"`
-	BiTitle       string    `gorm:"column:bi_tittle"`
+	BiTitle       string    `gorm:"column:bi_title"`
 	ClassifyId    int       `gorm:"column:classify_id"`
-	State         int       `gorm:"column:state"`
+	State         int       `gorm:"column:state"` //  '审批状态:1-待审批;2-已审批;3-已驳回;4-已撤回'
 	FlowId        int       `gorm:"column:flow_id"`
 	FlowVersion   int       `gorm:"column:flow_version"`
 	StartNodeId   int       `gorm:"column:start_node_id"`

+ 3 - 2
services/bi_approve/bi_approve_flow.go

@@ -112,6 +112,7 @@ func SaveBiApproveFlow(flow *request.BiApproveFlowSaveReq) (ok bool, msg string,
 	return
 }
 
+// GetBiApproveFlowDetail 获取审批流详情
 func GetBiApproveFlowDetail(flowId int) (detail *response.BiApproveFlowDetailResp, msg string, err error) {
 	flowInfo, err := biapprove.GetBiApproveFlowById(flowId)
 	if err != nil {
@@ -130,7 +131,7 @@ func GetBiApproveFlowDetail(flowId int) (detail *response.BiApproveFlowDetailRes
 	}
 	return
 }
-
+// DeleteBiApproveFlow 删除审批流
 func DeleteBiApproveFlow(flowId int) (ok bool, msg string, err error) {
 	ok, err = CheckDeleteBiApproveFlow(flowId)
 	if err != nil {
@@ -153,7 +154,7 @@ func DeleteBiApproveFlow(flowId int) (ok bool, msg string, err error) {
 	ok = true
 	return
 }
-
+// CheckDeleteBiApproveFlow 检查是否可以删除审批流
 func CheckDeleteBiApproveFlow(flowId int) (ok bool, err error) {
 	_, err = biapprove.GetBiApproveFlowById(flowId)
 	if err != nil {