|
@@ -92,15 +92,15 @@ func (s *contractService) SetSection(templateNumber int, bidsectionId int, proje
|
|
|
}
|
|
|
|
|
|
// 新增项目节
|
|
|
-func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error {
|
|
|
+func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) (*models.CmTreeContracts, error) {
|
|
|
// 1.验证项目节ID
|
|
|
treeId, err := utils.GetDecryptId(sectionData.Id)
|
|
|
if err != nil {
|
|
|
- return err
|
|
|
+ return nil, err
|
|
|
}
|
|
|
sectionFather := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
|
|
|
if sectionFather.Id == 0 {
|
|
|
- return errors.New("未找到合同项目节")
|
|
|
+ return nil, errors.New("未找到合同项目节")
|
|
|
}
|
|
|
// 1-1 深度为>=2才能新增项目节
|
|
|
// if sectionFather.Depth < 3 {
|
|
@@ -108,7 +108,7 @@ func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract
|
|
|
// }
|
|
|
// 1-2 项目节是否有合同
|
|
|
if sectionFather.ContractId != 0 {
|
|
|
- return errors.New("该项目节已存在合同")
|
|
|
+ return nil, errors.New("该项目节已存在合同")
|
|
|
}
|
|
|
|
|
|
// 2 获得最大序号
|
|
@@ -142,11 +142,11 @@ func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract
|
|
|
sectionCM.ContractReturned = "0"
|
|
|
sectionCM.ContractsPaid = "0"
|
|
|
|
|
|
- err = s.treeContractDao.Create(sectionCM)
|
|
|
+ data, err := s.treeContractDao.Create(sectionCM)
|
|
|
if err != nil {
|
|
|
- return err
|
|
|
+ return nil, err
|
|
|
}
|
|
|
- return nil
|
|
|
+ return data, nil
|
|
|
}
|
|
|
|
|
|
// 保存名称
|
|
@@ -378,5 +378,9 @@ func (s *contractService) makeSectionView(data *models.CmTreeContracts) *viewmod
|
|
|
section.ContractLocking = data.ContractLocking
|
|
|
|
|
|
section.CreateTime = data.CreateTime.Format(conf.SysTimeform)
|
|
|
+
|
|
|
+ //
|
|
|
+ section.Title = fmt.Sprintf("%s%d ", data.Attribution, data.Serial) + data.Name
|
|
|
+ section.Key = id
|
|
|
return section
|
|
|
}
|