caipin hace 4 años
padre
commit
b82a811522

+ 13 - 0
dao/tree_contract_dao.go

@@ -57,6 +57,19 @@ func (d *TreeContractDao) GetAll(bidsectionId int, projectId int, treeType int)
 	}
 }
 
+// 获得最新ID
+func (d *TreeContractDao) GetLastId() *models.CmTreeContracts {
+	data := &models.CmTreeContracts{}
+	_, err := d.engine.
+		Desc("id").
+		Get(data)
+	if err != nil {
+		data.Id = 0
+		return data
+	}
+	return data
+}
+
 // 获得项目节所有合同
 func (d *TreeContractDao) GetContractAll(bidsectionId int, projectId int) []models.CmTreeContracts {
 	datalist := make([]models.CmTreeContracts, 0)

+ 3 - 0
services/contract_section_tree_service.go

@@ -106,8 +106,11 @@ func (s *contractService) SectionAdd(sectionData *viewmodels.TreeSectionContract
 	// 2-2 归属
 	attribution := fmt.Sprintf("%s%d-", sectionFather.Attribution, sectionFather.Serial)
 	code := fmt.Sprintf("%s%d", attribution, serial)
+	// 2-3获得新增ID
+	lastId := s.treeContractDao.GetLastId()
 	// 新增项目节
 	sectionCM := &models.CmTreeContracts{}
+	sectionCM.Id = lastId.Id
 	sectionCM.TreeType = treeType
 	sectionCM.ParentId = sectionFather.TreeId
 	sectionCM.Name = sectionData.Name

+ 5 - 5
services/contract_service.go

@@ -43,7 +43,7 @@ type ContractService interface {
 	ValidRuleContractPaid(ctx iris.Context) (*viewmodels.ContractsPaid, error)
 	ValidRuleContractPaidDel(ctx iris.Context) (*viewmodels.ContractsPaid, error)
 
-	Get(treeId int, bidsectionId int, projectId int) *viewmodels.TreeSectionContract
+	Get(treeId int, bidsectionId int, projectId int, treeType int) *viewmodels.TreeSectionContract
 	GetSectionTreeContract(attribution string, bidsectionId int, projectId int, treeType int) []*viewmodels.Contracts
 	GetSecionTree(bidsectionId int, projectId int, treeType int) *viewmodels.TreeSectionContract
 	SetSection(templateNumber int, bidsectionId int, projectIdInt int, treeType int) error
@@ -282,18 +282,18 @@ func (s *contractService) ValidRuleContractDel(ctx iris.Context) (*viewmodels.Co
 
 //------------------------------------------------------------
 // 获得项目节
-func (s *contractService) Get(treeId int, bidsectionId int, projectId int) *viewmodels.TreeSectionContract {
+func (s *contractService) Get(treeId int, bidsectionId int, projectId int, treeType int) *viewmodels.TreeSectionContract {
 	// 1.获得项目节
-	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, 0)
+	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
 	// 2.构造数据
 	sectionVM := s.makeSectionView(section)
 	// 3.更新 上移和下一的限制
-	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 {
 		sectionVM.IsEnd = true
 	}
 	sectionVM.ElderBrother = true
-	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 {
 		sectionVM.ElderBrother = false
 	}

+ 6 - 6
web/api/contract_api.go

@@ -155,7 +155,7 @@ func (c *ContractApi) GetIncome() {
 	}
 
 	// 获得项目节详情
-	section := c.ServiceContract.Get(treeId, bidsectionId, projectId)
+	section := c.ServiceContract.Get(treeId, bidsectionId, projectId, 0)
 
 	// 该项目节 子树下是否有合同
 	isContract := true
@@ -226,7 +226,7 @@ func (c *ContractApi) PostIncomeCreate() {
 	}
 
 	// 获得项目节
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt)
+	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 0)
 	// 合同ID
 	contractId, _ := utils.GetDecryptId(sectionDetail.ContractId)
 	contractDetail := c.ServiceContract.GetContract(contractId)
@@ -293,7 +293,7 @@ func (c *ContractApi) PostIncomeUpdate() {
 
 	//2.请求当前项目信息
 	// 1.验证项目节ID
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt)
+	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 0)
 	// 合同ID
 	contractId, _ := utils.GetDecryptId(sectionDetail.ContractId)
 	contractDetail := c.ServiceContract.GetContract(contractId)
@@ -358,7 +358,7 @@ func (c *ContractApi) Delete() {
 
 	//2.请求当前项目信息
 	// 1.验证项目节ID
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt)
+	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 0)
 
 	c.Ctx.JSON(iris.Map{"code": 0, "msg": "删除成功", "section": sectionDetail})
 }
@@ -413,7 +413,7 @@ func (c *ContractApi) PostClose() {
 		return
 	}
 	// 1.项目节信息
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt)
+	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 0)
 	c.Ctx.JSON(iris.Map{"code": 0, "msg": "关闭成功", "section": sectionDetail})
 }
 
@@ -467,7 +467,7 @@ func (c *ContractApi) PostUnlock() {
 		return
 	}
 	// 1.项目节信息
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt)
+	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 0)
 	c.Ctx.JSON(iris.Map{"code": 0, "msg": "解锁成功", "section": sectionDetail})
 }
 

+ 4 - 4
web/api/contract_expenditure_api.go

@@ -118,7 +118,7 @@ func (c *ContractApi) GetExpenditure() {
 	}
 
 	// 获得项目节详情
-	section := c.ServiceContract.Get(treeId, bidsectionId, projectId)
+	section := c.ServiceContract.Get(treeId, bidsectionId, projectId, 1)
 
 	// 该项目节 子树下是否有合同
 	isContract := true
@@ -194,7 +194,7 @@ func (c *ContractApi) PostExpenditureCreate() {
 	}
 
 	// 获得项目节
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt)
+	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 1)
 	// 合同ID
 	contractId, _ := utils.GetDecryptId(sectionDetail.ContractId)
 	contractDetail := c.ServiceContract.GetContract(contractId)
@@ -261,7 +261,7 @@ func (c *ContractApi) PostExpenditureUpdate() {
 
 	//2.请求当前项目信息
 	// 1.验证项目节ID
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt)
+	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 1)
 	// 合同ID
 	contractId, _ := utils.GetDecryptId(sectionDetail.ContractId)
 	contractDetail := c.ServiceContract.GetContract(contractId)
@@ -326,7 +326,7 @@ func (c *ContractApi) DeleteExpenditure() {
 
 	//2.请求当前项目信息
 	// 1.验证项目节ID
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt)
+	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, 1)
 
 	c.Ctx.JSON(iris.Map{"code": 0, "msg": "删除成功", "section": sectionDetail})
 }

+ 4 - 4
web/api/contract_section_tree_api.go

@@ -59,7 +59,7 @@ func (c *ContractApi) PostSectionDepth() {
 	//2.请求当前项目信息
 	// 1.验证项目节ID
 	treeId, _ := utils.GetDecryptId(sectionData.Id)
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt)
+	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
 
 	c.Ctx.JSON(iris.Map{
 		"code":    0,
@@ -114,7 +114,7 @@ func (c *ContractApi) PostSectionSerial() {
 	//2.请求当前项目信息
 	// 1.验证项目节ID
 	treeId, _ := utils.GetDecryptId(sectionData.Id)
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt)
+	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
 
 	c.Ctx.JSON(iris.Map{
 		"code":    0,
@@ -169,7 +169,7 @@ func (c *ContractApi) PostSectionSerialUpdate() {
 	//2.请求当前项目信息
 	// 1.验证项目节ID
 	treeId, _ := utils.GetDecryptId(sectionData.Id)
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt)
+	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
 
 	c.Ctx.JSON(iris.Map{
 		"code":    0,
@@ -327,7 +327,7 @@ func (c *ContractApi) PostSectionSave() {
 	//2.请求当前项目信息
 	// 1.验证项目节ID
 	treeId, _ := utils.GetDecryptId(sectionData.Id)
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt)
+	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
 
 	c.Ctx.JSON(iris.Map{"code": 0, "msg": "修改成功", "section": sectionDetail})
 }