|  | @@ -16,8 +16,8 @@ import (
 | 
	
		
			
				|  |  |  )
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // 获得合同项目节
 | 
	
		
			
				|  |  | -func (s *contractService) GetSecionTree(bidsectionId int, projectId int) *viewmodels.TreeSectionContract {
 | 
	
		
			
				|  |  | -	dataList := s.treeContractDao.GetAll(bidsectionId, projectId, 0)
 | 
	
		
			
				|  |  | +func (s *contractService) GetSecionTree(bidsectionId int, projectId int, treeType int) *viewmodels.TreeSectionContract {
 | 
	
		
			
				|  |  | +	dataList := s.treeContractDao.GetAll(bidsectionId, projectId, treeType)
 | 
	
		
			
				|  |  |  	sectionList := s.makeSectionTreeView(dataList)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	// Node := sectionRoot //父节点
 | 
	
	
		
			
				|  | @@ -27,13 +27,13 @@ func (s *contractService) GetSecionTree(bidsectionId int, projectId int) *viewmo
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // 获得项目节树和孩子们下的合同数据
 | 
	
		
			
				|  |  | -func (s *contractService) GetSectionTreeContract(attribution string, bidsectionId int, projectId int) []*viewmodels.Contracts {
 | 
	
		
			
				|  |  | -	s.treeContractDao.GetAttribution(attribution, bidsectionId, projectId, 0)
 | 
	
		
			
				|  |  | +func (s *contractService) GetSectionTreeContract(attribution string, bidsectionId int, projectId int, treeType int) []*viewmodels.Contracts {
 | 
	
		
			
				|  |  | +	s.treeContractDao.GetAttribution(attribution, bidsectionId, projectId, treeType)
 | 
	
		
			
				|  |  |  	return nil
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // 设置合同项目节初始数据-根据模板导入
 | 
	
		
			
				|  |  | -func (s *contractService) SetSection(templateNumber int, bidsectionId int, projectId int) error {
 | 
	
		
			
				|  |  | +func (s *contractService) SetSection(templateNumber int, bidsectionId int, projectId int, treeType int) error {
 | 
	
		
			
				|  |  |  	// 获得模板数据
 | 
	
		
			
				|  |  |  	templateTree := make([]*lib.ItemSectionTemplateTree, 0)
 | 
	
		
			
				|  |  |  	if templateNumber == 1 {
 | 
	
	
		
			
				|  | @@ -49,6 +49,7 @@ func (s *contractService) SetSection(templateNumber int, bidsectionId int, proje
 | 
	
		
			
				|  |  |  	for _, item := range templateTree {
 | 
	
		
			
				|  |  |  		section := &models.CmTreeContracts{}
 | 
	
		
			
				|  |  |  		section.TreeId = item.Id
 | 
	
		
			
				|  |  | +		section.TreeType = treeType
 | 
	
		
			
				|  |  |  		section.ParentId = item.ParentId
 | 
	
		
			
				|  |  |  		section.ProjectId = projectId
 | 
	
		
			
				|  |  |  		section.BidsectionId = bidsectionId
 | 
	
	
		
			
				|  | @@ -75,13 +76,13 @@ func (s *contractService) SetSection(templateNumber int, bidsectionId int, proje
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // 新增项目节
 | 
	
		
			
				|  |  | -func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int) error {
 | 
	
		
			
				|  |  | +func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error {
 | 
	
		
			
				|  |  |  	// 1.验证项目节ID
 | 
	
		
			
				|  |  |  	treeId, err := utils.GetDecryptId(sectionData.Id)
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
		
			
				|  |  |  		return err
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	sectionFather := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 | 
	
		
			
				|  |  | +	sectionFather := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
 | 
	
		
			
				|  |  |  	if sectionFather.Id == 0 {
 | 
	
		
			
				|  |  |  		return errors.New("未找到合同项目节")
 | 
	
		
			
				|  |  |  	}
 | 
	
	
		
			
				|  | @@ -96,7 +97,7 @@ func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	// 2 获得最大序号
 | 
	
		
			
				|  |  |  	// 2-1 孩子节点
 | 
	
		
			
				|  |  | -	childrenList := s.treeContractDao.GetChildren(treeId, bidsectionId, projectId, 0)
 | 
	
		
			
				|  |  | +	childrenList := s.treeContractDao.GetChildren(treeId, bidsectionId, projectId, treeType)
 | 
	
		
			
				|  |  |  	// 2-1 最大序号
 | 
	
		
			
				|  |  |  	serial := 1
 | 
	
		
			
				|  |  |  	if len(childrenList) != 0 {
 | 
	
	
		
			
				|  | @@ -107,6 +108,7 @@ func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract
 | 
	
		
			
				|  |  |  	code := fmt.Sprintf("%s%d", attribution, serial)
 | 
	
		
			
				|  |  |  	// 新增项目节
 | 
	
		
			
				|  |  |  	sectionCM := &models.CmTreeContracts{}
 | 
	
		
			
				|  |  | +	sectionCM.TreeId = treeType
 | 
	
		
			
				|  |  |  	sectionCM.ParentId = sectionFather.TreeId
 | 
	
		
			
				|  |  |  	sectionCM.Name = sectionData.Name
 | 
	
		
			
				|  |  |  	sectionCM.Depth = sectionFather.Depth + 1
 | 
	
	
		
			
				|  | @@ -128,13 +130,13 @@ func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // 保存名称
 | 
	
		
			
				|  |  | -func (s *contractService) SectionSave(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int) error {
 | 
	
		
			
				|  |  | +func (s *contractService) SectionSave(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error {
 | 
	
		
			
				|  |  |  	// 1.验证项目节ID
 | 
	
		
			
				|  |  |  	treeId, err := utils.GetDecryptId(sectionData.Id)
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
		
			
				|  |  |  		return err
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 | 
	
		
			
				|  |  | +	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
 | 
	
		
			
				|  |  |  	if section.Id == 0 {
 | 
	
		
			
				|  |  |  		return errors.New("未找到合同项目节")
 | 
	
		
			
				|  |  |  	}
 | 
	
	
		
			
				|  | @@ -157,13 +159,13 @@ func (s *contractService) SectionSave(sectionData *viewmodels.TreeSectionContrac
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // 更新序号
 | 
	
		
			
				|  |  | -func (s *contractService) UpdateSerial(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int) error {
 | 
	
		
			
				|  |  | +func (s *contractService) UpdateSerial(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error {
 | 
	
		
			
				|  |  |  	// 1.验证项目节ID
 | 
	
		
			
				|  |  |  	treeId, err := utils.GetDecryptId(sectionData.Id)
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
		
			
				|  |  |  		return err
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 | 
	
		
			
				|  |  | +	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
 | 
	
		
			
				|  |  |  	if section.Id == 0 {
 | 
	
		
			
				|  |  |  		return errors.New("未找到合同项目节")
 | 
	
		
			
				|  |  |  	}
 | 
	
	
		
			
				|  | @@ -173,7 +175,7 @@ func (s *contractService) UpdateSerial(sectionData *viewmodels.TreeSectionContra
 | 
	
		
			
				|  |  |  	// 	return errors.New("请在项目节第三层开始编辑")
 | 
	
		
			
				|  |  |  	// }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	err = s.treeContractDao.UpdateSerial(section, sectionData.Serial, 0)
 | 
	
		
			
				|  |  | +	err = s.treeContractDao.UpdateSerial(section, sectionData.Serial, treeType)
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
		
			
				|  |  |  		return errors.New("更新失败")
 | 
	
		
			
				|  |  |  	}
 | 
	
	
		
			
				|  | @@ -181,9 +183,9 @@ func (s *contractService) UpdateSerial(sectionData *viewmodels.TreeSectionContra
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // 项目节删除
 | 
	
		
			
				|  |  | -func (s *contractService) SectionDelete(treeId int, bidsectionId int, projectId int) error {
 | 
	
		
			
				|  |  | +func (s *contractService) SectionDelete(treeId int, bidsectionId int, projectId int, treeType int) error {
 | 
	
		
			
				|  |  |  	// 1.验证项目节ID
 | 
	
		
			
				|  |  | -	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 | 
	
		
			
				|  |  | +	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
 | 
	
		
			
				|  |  |  	if section.Id == 0 {
 | 
	
		
			
				|  |  |  		return errors.New("未找到合同项目节")
 | 
	
		
			
				|  |  |  	}
 | 
	
	
		
			
				|  | @@ -193,9 +195,9 @@ func (s *contractService) SectionDelete(treeId int, bidsectionId int, projectId
 | 
	
		
			
				|  |  |  	// 	return errors.New("请在项目节第三层开始编辑")
 | 
	
		
			
				|  |  |  	// }
 | 
	
		
			
				|  |  |  	// 1-2 有合同的不能编辑(包含孩子节点)
 | 
	
		
			
				|  |  | -	contractList := s.GetSectionTreeContract(section.Attribution, section.BidsectionId, section.ProjectId)
 | 
	
		
			
				|  |  | +	contractList := s.GetSectionTreeContract(section.Attribution, section.BidsectionId, section.ProjectId, treeType)
 | 
	
		
			
				|  |  |  	if len(contractList) != 0 {
 | 
	
		
			
				|  |  | -		return errors.New("该项目节已存在合同")
 | 
	
		
			
				|  |  | +		return errors.New("该项目节存在合同")
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	err := s.treeContractDao.Delete(section)
 | 
	
	
		
			
				|  | @@ -206,13 +208,13 @@ func (s *contractService) SectionDelete(treeId int, bidsectionId int, projectId
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // 项目节的层级移动
 | 
	
		
			
				|  |  | -func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int) error {
 | 
	
		
			
				|  |  | +func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error {
 | 
	
		
			
				|  |  |  	// 1.验证项目节ID
 | 
	
		
			
				|  |  |  	treeId, err := utils.GetDecryptId(sectionData.Id)
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
		
			
				|  |  |  		return err
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 | 
	
		
			
				|  |  | +	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
 | 
	
		
			
				|  |  |  	if section.Id == 0 {
 | 
	
		
			
				|  |  |  		return errors.New("未找到合同项目节")
 | 
	
		
			
				|  |  |  	}
 | 
	
	
		
			
				|  | @@ -221,7 +223,7 @@ func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract,
 | 
	
		
			
				|  |  |  	// 	return errors.New("请在项目节第三层开始编辑")
 | 
	
		
			
				|  |  |  	// }
 | 
	
		
			
				|  |  |  	// 1-2 有合同的不能编辑(包含孩子节点)
 | 
	
		
			
				|  |  | -	contractList := s.GetSectionTreeContract(section.Attribution, section.BidsectionId, section.ProjectId)
 | 
	
		
			
				|  |  | +	contractList := s.GetSectionTreeContract(section.Attribution, section.BidsectionId, section.ProjectId, treeType)
 | 
	
		
			
				|  |  |  	if len(contractList) != 0 {
 | 
	
		
			
				|  |  |  		return errors.New("该项目节已存在合同")
 | 
	
		
			
				|  |  |  	}
 | 
	
	
		
			
				|  | @@ -230,7 +232,7 @@ func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract,
 | 
	
		
			
				|  |  |  	elderBrother := &models.CmTreeContracts{}
 | 
	
		
			
				|  |  |  	if sectionData.Operation == "downDepth" {
 | 
	
		
			
				|  |  |  		// 获得前一个兄弟节点
 | 
	
		
			
				|  |  | -		elderBrotherList := s.treeContractDao.GetElderBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, 0)
 | 
	
		
			
				|  |  | +		elderBrotherList := s.treeContractDao.GetElderBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, treeType)
 | 
	
		
			
				|  |  |  		if len(elderBrotherList) == 0 {
 | 
	
		
			
				|  |  |  			return errors.New("项目节不能降级")
 | 
	
		
			
				|  |  |  		}
 | 
	
	
		
			
				|  | @@ -249,7 +251,7 @@ func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract,
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	// 4.执行升降级
 | 
	
		
			
				|  |  | -	err = s.treeContractDao.MoveDepth(section, elderBrother, sectionData.Operation, bidsectionId, projectId, 0)
 | 
	
		
			
				|  |  | +	err = s.treeContractDao.MoveDepth(section, elderBrother, sectionData.Operation, bidsectionId, projectId, treeType)
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
		
			
				|  |  |  		return err
 | 
	
		
			
				|  |  |  	}
 | 
	
	
		
			
				|  | @@ -258,13 +260,13 @@ func (s *contractService) MoveDepth(sectionData *viewmodels.TreeSectionContract,
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  // 项目节的排序移动
 | 
	
		
			
				|  |  | -func (s *contractService) MoveSerial(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int) error {
 | 
	
		
			
				|  |  | +func (s *contractService) MoveSerial(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error {
 | 
	
		
			
				|  |  |  	// 1.验证项目节ID
 | 
	
		
			
				|  |  |  	treeId, err := utils.GetDecryptId(sectionData.Id)
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
		
			
				|  |  |  		return err
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  | -	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
 | 
	
		
			
				|  |  | +	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
 | 
	
		
			
				|  |  |  	if section.Id == 0 {
 | 
	
		
			
				|  |  |  		return errors.New("未找到合同项目节")
 | 
	
		
			
				|  |  |  	}
 | 
	
	
		
			
				|  | @@ -273,7 +275,7 @@ func (s *contractService) MoveSerial(sectionData *viewmodels.TreeSectionContract
 | 
	
		
			
				|  |  |  	// 	return errors.New("请在项目节第三层开始编辑")
 | 
	
		
			
				|  |  |  	// }
 | 
	
		
			
				|  |  |  	// 1-2 有合同的不能编辑(包含孩子节点)
 | 
	
		
			
				|  |  | -	contractList := s.GetSectionTreeContract(section.Attribution, section.BidsectionId, section.ProjectId)
 | 
	
		
			
				|  |  | +	contractList := s.GetSectionTreeContract(section.Attribution, section.BidsectionId, section.ProjectId, treeType)
 | 
	
		
			
				|  |  |  	if len(contractList) != 0 {
 | 
	
		
			
				|  |  |  		return errors.New("该项目节已存在合同")
 | 
	
		
			
				|  |  |  	}
 | 
	
	
		
			
				|  | @@ -282,14 +284,14 @@ func (s *contractService) MoveSerial(sectionData *viewmodels.TreeSectionContract
 | 
	
		
			
				|  |  |  	brother := &models.CmTreeContracts{}
 | 
	
		
			
				|  |  |  	if sectionData.Operation == "downSerial" {
 | 
	
		
			
				|  |  |  		// 获得下一个兄弟
 | 
	
		
			
				|  |  | -		youngerBrotherList := s.treeContractDao.GetYoungerBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, 0)
 | 
	
		
			
				|  |  | +		youngerBrotherList := s.treeContractDao.GetYoungerBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, treeType)
 | 
	
		
			
				|  |  |  		if len(youngerBrotherList) == 0 {
 | 
	
		
			
				|  |  |  			return errors.New("项目节不能下移")
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  		brother = &youngerBrotherList[0]
 | 
	
		
			
				|  |  |  	} else if sectionData.Operation == "upSerial" {
 | 
	
		
			
				|  |  |  		// 获得上一个兄弟
 | 
	
		
			
				|  |  | -		elderBrotherList := s.treeContractDao.GetElderBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, 0)
 | 
	
		
			
				|  |  | +		elderBrotherList := s.treeContractDao.GetElderBrother(section.Serial, section.Depth, section.ParentId, bidsectionId, projectId, treeType)
 | 
	
		
			
				|  |  |  		if len(elderBrotherList) == 0 {
 | 
	
		
			
				|  |  |  			return errors.New("项目节不能上移")
 | 
	
		
			
				|  |  |  		}
 | 
	
	
		
			
				|  | @@ -299,7 +301,7 @@ func (s *contractService) MoveSerial(sectionData *viewmodels.TreeSectionContract
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	// 4.执行升降级
 | 
	
		
			
				|  |  | -	err = s.treeContractDao.MoveSerial(section, brother, sectionData.Operation, bidsectionId, projectId, 0)
 | 
	
		
			
				|  |  | +	err = s.treeContractDao.MoveSerial(section, brother, sectionData.Operation, bidsectionId, projectId, treeType)
 | 
	
		
			
				|  |  |  	if err != nil {
 | 
	
		
			
				|  |  |  		return err
 | 
	
		
			
				|  |  |  	}
 |