|
@@ -235,6 +235,12 @@ func AddReportClassify(classifyName string, parentId int, chartPermissionIdList
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ err, errMsg = checkClassifyApprove(parentClassifyItem)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
childClassifyCount, err = models.GetCountClassifyChildByParentId(parentId)
|
|
|
if err != nil {
|
|
@@ -376,6 +382,70 @@ func AddReportClassify(classifyName string, parentId int, chartPermissionIdList
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func checkClassifyApprove(currClassify *models.Classify) (err error, errMsg string) {
|
|
|
+ errMsg = `判断是否有审批流关联失败`
|
|
|
+ var firstClassifyId, secondClassifyId int
|
|
|
+ if currClassify.ParentId > 0 {
|
|
|
+ parentClassifyItem, tmpErr := models.GetClassifyById(currClassify.ParentId)
|
|
|
+ if tmpErr != nil {
|
|
|
+ err = tmpErr
|
|
|
+ errMsg = "获取父级分类信息失败"
|
|
|
+ if tmpErr.Error() == utils.ErrNoRow() {
|
|
|
+ errMsg = "父级分类不存在"
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ firstClassifyId = parentClassifyItem.Id
|
|
|
+ secondClassifyId = currClassify.Id
|
|
|
+ } else {
|
|
|
+ firstClassifyId = currClassify.Id
|
|
|
+ }
|
|
|
+
|
|
|
+ {
|
|
|
+ flowOb := new(report_approve.ReportApproveFlow)
|
|
|
+
|
|
|
+ existCond := fmt.Sprintf(` AND %s = ? AND %s = ? AND %s = ? AND %s = ?`, report_approve.ReportApproveFlowCols.ReportType, report_approve.ReportApproveFlowCols.ClassifyFirstId, report_approve.ReportApproveFlowCols.ClassifySecondId, report_approve.ReportApproveFlowCols.ClassifyThirdId)
|
|
|
+ existPars := make([]interface{}, 0)
|
|
|
+ existPars = append(existPars, report_approve.FlowReportTypeChinese, firstClassifyId, secondClassifyId, 0)
|
|
|
+ flowItem, e := flowOb.GetItemByCondition(existCond, existPars, "")
|
|
|
+ if e != nil {
|
|
|
+
|
|
|
+ if e.Error() != utils.ErrNoRow() {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = errors.New("获取审批流是否已存在失败, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if flowItem == nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ approvingOb := new(report_approve.ReportApprove)
|
|
|
+ approvingCond := fmt.Sprintf(` AND %s = ? AND %s = ? AND %s = ?`, report_approve.ReportApproveCols.FlowId, report_approve.ReportApproveCols.FlowVersion, report_approve.ReportApproveCols.State)
|
|
|
+ approvingPars := make([]interface{}, 0)
|
|
|
+ approvingPars = append(approvingPars, flowItem.ReportApproveFlowId, flowItem.CurrVersion, report_approve.ReportApproveStateApproving)
|
|
|
+ count, e := approvingOb.GetCountByCondition(approvingCond, approvingPars)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("获取审批流关联进行中的审批数失败. Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if count > 0 {
|
|
|
+ errMsg = "当前有未走完流程的报告,请走完流程后再做变更"
|
|
|
+ err = errors.New(errMsg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
|