caipin пре 4 година
родитељ
комит
c5e68e865c
2 измењених фајлова са 15 додато и 1 уклоњено
  1. 14 0
      dao/tree_contract_dao.go
  2. 1 1
      services/contract_section_tree_service.go

+ 14 - 0
dao/tree_contract_dao.go

@@ -130,6 +130,20 @@ func (d *TreeContractDao) GetChildren(parentId int, bidsectionId int, projectId
 	}
 }
 
+// 获得节点的孩子-是项目节
+func (d *TreeContractDao) GetChildrenBySection(parentId int, bidsectionId int, projectId int, treeType int) []models.CmTreeContracts {
+	datalist := make([]models.CmTreeContracts, 0)
+	err := d.engine.
+		Asc("serial").
+		Where("parent_id=?  and bidsection_id=? and project_id=? and tree_type=? and contract_id=0", parentId, bidsectionId, projectId, treeType).
+		Find(&datalist)
+	if err != nil {
+		return datalist
+	} else {
+		return datalist
+	}
+}
+
 //根据序号和深度获得前一个兄弟节点
 func (d *TreeContractDao) GetElderBrother(serial int, depth int, parentId int, bidsectionId int, projectId int, treeType int) []models.CmTreeContracts {
 	datalist := make([]models.CmTreeContracts, 0)

+ 1 - 1
services/contract_section_tree_service.go

@@ -116,7 +116,7 @@ func (s *contractService) ContractSectionAdd(sectionData *viewmodels.TreeSection
 
 	// 2 获得最大序号
 	// 2-1 孩子节点
-	childrenList := s.treeContractDao.GetChildren(treeId, bidsectionId, projectId, treeType)
+	childrenList := s.treeContractDao.GetChildrenBySection(treeId, bidsectionId, projectId, treeType)
 
 	// 2-2.检查是否可以添加项目节
 	// 新建合同,项目层级必须在第二层以下,当第一层没有孩子可以添加合同