|
@@ -17,53 +17,21 @@ import (
|
|
|
|
|
|
// 获得合同项目节
|
|
|
func (s *contractService) GetSecionTree(bidsectionId int, projectId int) *viewmodels.TreeSectionContract {
|
|
|
- sectionList := make([]*viewmodels.TreeSectionContract, 0)
|
|
|
dataList := s.treeContractDao.GetAll(bidsectionId, projectId)
|
|
|
- // 生成根
|
|
|
- sectionRoot := &viewmodels.TreeSectionContract{}
|
|
|
- id, _ := comm.AesEncrypt(strconv.Itoa(0), conf.SignSecret)
|
|
|
- parentId, _ := comm.AesEncrypt(strconv.Itoa(-1), conf.SignSecret)
|
|
|
- sectionRoot.Id = id
|
|
|
- sectionRoot.Name = "root"
|
|
|
- sectionRoot.ParentId = parentId
|
|
|
- sectionList = append(sectionList, sectionRoot)
|
|
|
- for _, data := range dataList {
|
|
|
- section := &viewmodels.TreeSectionContract{}
|
|
|
- id, _ := comm.AesEncrypt(strconv.Itoa(data.TreeId), conf.SignSecret)
|
|
|
- parentId, _ := comm.AesEncrypt(strconv.Itoa(data.ParentId), conf.SignSecret)
|
|
|
- projectId, _ := comm.AesEncrypt(strconv.Itoa(data.ProjectId), conf.SignSecret)
|
|
|
- contractId, _ := comm.AesEncrypt(strconv.Itoa(data.ContractId), conf.SignSecret)
|
|
|
- bidsectionId, _ := comm.AesEncrypt(strconv.Itoa(data.BidsectionId), conf.SignSecret)
|
|
|
- section.Id = id
|
|
|
- section.Name = data.Name
|
|
|
- section.ParentId = parentId
|
|
|
- section.Depth = data.Depth + 1
|
|
|
- section.Serial = data.Serial
|
|
|
- section.Attribution = data.Attribution
|
|
|
- section.Code = data.Code
|
|
|
- section.ProjectId = projectId
|
|
|
- section.BidsectionId = bidsectionId
|
|
|
- section.ContractId = contractId
|
|
|
-
|
|
|
- section.ElderBrother = true
|
|
|
- section.IsEnd = false
|
|
|
-
|
|
|
- section.Name = data.Name
|
|
|
- section.ContractCode = data.ContractCode
|
|
|
- section.ContractPrice = data.ContractPrice
|
|
|
- section.ContractReturned = data.ContractReturned
|
|
|
- section.ContractsPaid = data.ContractsPaid
|
|
|
- section.ContractStatus = data.ContractStatus
|
|
|
-
|
|
|
- section.CreateTime = data.CreateTime.Format(conf.SysTimeform)
|
|
|
- sectionList = append(sectionList, section)
|
|
|
- }
|
|
|
+ sectionList := s.makeSectionTreeView(dataList)
|
|
|
|
|
|
- Node := sectionRoot //父节点
|
|
|
+ // Node := sectionRoot //父节点
|
|
|
+ Node := sectionList[0] //父节点
|
|
|
comm.MakeSectionContract(sectionList, Node)
|
|
|
return Node
|
|
|
}
|
|
|
|
|
|
+// 获得项目节树和孩子们下的合同数据
|
|
|
+func (s *contractService) GetSectionTreeContract(attribution string, bidsectionId int, projectId int) []*viewmodels.Contracts {
|
|
|
+ s.treeContractDao.GetAttribution(attribution, bidsectionId, projectId)
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
// 设置合同项目节初始数据-根据模板导入
|
|
|
func (s *contractService) SetSection(templateNumber int, bidsectionId int, projectId int) error {
|
|
|
// 获得模板数据
|
|
@@ -268,3 +236,54 @@ func (s *contractService) MoveSerial(sectionData *viewmodels.TreeSectionContract
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
+
|
|
|
+// 构造项目节树
|
|
|
+func (s *contractService) makeSectionTreeView(dataList []models.CmTreeContracts) []*viewmodels.TreeSectionContract {
|
|
|
+ sectionList := make([]*viewmodels.TreeSectionContract, 0)
|
|
|
+ // 生成根
|
|
|
+ sectionRoot := &viewmodels.TreeSectionContract{}
|
|
|
+ id, _ := comm.AesEncrypt(strconv.Itoa(0), conf.SignSecret)
|
|
|
+ parentId, _ := comm.AesEncrypt(strconv.Itoa(-1), conf.SignSecret)
|
|
|
+ sectionRoot.Id = id
|
|
|
+ sectionRoot.Name = "root"
|
|
|
+ sectionRoot.ParentId = parentId
|
|
|
+ sectionList = append(sectionList, sectionRoot)
|
|
|
+ for _, data := range dataList {
|
|
|
+ section := s.makeSectionView(&data)
|
|
|
+ sectionList = append(sectionList, section)
|
|
|
+ }
|
|
|
+ return sectionList
|
|
|
+}
|
|
|
+
|
|
|
+// 构造一个项目节View
|
|
|
+func (s *contractService) makeSectionView(data *models.CmTreeContracts) *viewmodels.TreeSectionContract {
|
|
|
+ section := &viewmodels.TreeSectionContract{}
|
|
|
+ id, _ := comm.AesEncrypt(strconv.Itoa(data.TreeId), conf.SignSecret)
|
|
|
+ parentId, _ := comm.AesEncrypt(strconv.Itoa(data.ParentId), conf.SignSecret)
|
|
|
+ projectId, _ := comm.AesEncrypt(strconv.Itoa(data.ProjectId), conf.SignSecret)
|
|
|
+ contractId, _ := comm.AesEncrypt(strconv.Itoa(data.ContractId), conf.SignSecret)
|
|
|
+ bidsectionId, _ := comm.AesEncrypt(strconv.Itoa(data.BidsectionId), conf.SignSecret)
|
|
|
+ section.Id = id
|
|
|
+ section.Name = data.Name
|
|
|
+ section.ParentId = parentId
|
|
|
+ section.Depth = data.Depth + 1
|
|
|
+ section.Serial = data.Serial
|
|
|
+ section.Attribution = data.Attribution
|
|
|
+ section.Code = data.Code
|
|
|
+ section.ProjectId = projectId
|
|
|
+ section.BidsectionId = bidsectionId
|
|
|
+ section.ContractId = contractId
|
|
|
+
|
|
|
+ section.ElderBrother = true
|
|
|
+ section.IsEnd = false
|
|
|
+
|
|
|
+ section.Name = data.Name
|
|
|
+ section.ContractCode = data.ContractCode
|
|
|
+ section.ContractPrice = data.ContractPrice
|
|
|
+ section.ContractReturned = data.ContractReturned
|
|
|
+ section.ContractsPaid = data.ContractsPaid
|
|
|
+ section.ContractStatus = data.ContractStatus
|
|
|
+
|
|
|
+ section.CreateTime = data.CreateTime.Format(conf.SysTimeform)
|
|
|
+ return section
|
|
|
+}
|