caipin před 4 roky
rodič
revize
dc64480dd7
2 změnil soubory, kde provedl 6 přidání a 1 odebrání
  1. 4 0
      comm/functions.go
  2. 2 1
      services/contract_section_tree_service.go

+ 4 - 0
comm/functions.go

@@ -161,7 +161,9 @@ func HaveChildContract(Data []*viewmodels.FolderContract, node *viewmodels.Folde
 
 // 创建合同项目节树
 func MakeSectionContract(Data []*viewmodels.TreeSectionContract, node *viewmodels.TreeSectionContract) { //参数为父节点,添加父节点的子节点指针切片
+
 	childs, _ := haveChildSectionContract(Data, node) //判断节点是否有子节点并返回
+
 	if childs != nil {
 		// 往父节点添加子节点
 		// 孩子们从小到大排序
@@ -203,11 +205,13 @@ func swapContract(child []*viewmodels.TreeSectionContract, i int, minIndex int)
 
 // 是否有子树
 func haveChildSectionContract(Data []*viewmodels.TreeSectionContract, node *viewmodels.TreeSectionContract) (child []*viewmodels.TreeSectionContract, yes bool) {
+
 	for _, v := range Data {
 		if v.ParentId == node.Id {
 			child = append(child, v)
 		}
 	}
+
 	if child != nil {
 		yes = true
 	}

+ 2 - 1
services/contract_section_tree_service.go

@@ -413,6 +413,7 @@ func (s *contractService) makeSectionTreeView(dataList []models.CmTreeContracts)
 	sectionRoot.Id = id
 	sectionRoot.Name = "root"
 	sectionRoot.ParentId = parentId
+	sectionRoot.Children = make([]*viewmodels.TreeSectionContract, 0)
 	sectionList = append(sectionList, sectionRoot)
 	for _, data := range dataList {
 		section := s.makeSectionView(&data)
@@ -439,7 +440,7 @@ func (s *contractService) makeSectionView(data *models.CmTreeContracts) *viewmod
 	section.ProjectId = projectId
 	section.BidsectionId = bidsectionId
 	section.ContractId = contractId
-
+	section.Children = make([]*viewmodels.TreeSectionContract, 0)
 	section.ElderBrother = true
 	section.IsEnd = false