caipin 4 年 前
コミット
144b1a23e2

+ 17 - 1
dao/tree_contract_dao.go

@@ -2,7 +2,7 @@
  * @description: 合同项目节相关数据库操作
  * @Author: CP
  * @Date: 2020-11-02 11:37:32
- * @FilePath: \construction_management\dao\tree_contract_dao.go
+ * @FilePath: \design_quantity\dao\tree_contract_dao.go
  */
 package dao
 
@@ -66,6 +66,22 @@ func (d *TreeContractDao) GetAll() []models.CmTreeContracts {
 	}
 }
 
+// 获得项目下的项目节
+func (d *TreeContractDao) GetDepth() []models.CmTreeContracts {
+
+	datalist := make([]models.CmTreeContracts, 0)
+	err := d.engine.
+		Where("depth <=? ", 1).
+		Asc("id").
+		Limit(5000, 0).
+		Find(&datalist)
+	if err != nil {
+		return datalist
+	} else {
+		return datalist
+	}
+}
+
 // 获得项目下的项目节不包含合同
 func (d *TreeContractDao) GetAllNotContract(bidsectionId int, projectId int, treeType int) []models.CmTreeContracts {
 

+ 8 - 2
services/contract_section_tree_service.go

@@ -16,8 +16,14 @@ import (
 )
 
 // 获得合同项目节
-func (s *contractService) GetSecionTree() *viewmodels.TreeSectionContract {
-	dataList := s.treeContractDao.GetAll()
+func (s *contractService) GetSecionTree(operation string) *viewmodels.TreeSectionContract {
+	dataList := make([]models.CmTreeContracts, 0)
+	if operation == "1" {
+		dataList = s.treeContractDao.GetDepth()
+	} else {
+		dataList = s.treeContractDao.GetAll()
+	}
+
 	sectionList := s.makeSectionTreeView(dataList)
 
 	// Node := sectionRoot //父节点

+ 1 - 1
services/contract_service.go

@@ -31,7 +31,7 @@ type ContractService interface {
 	ValidRuleSerial(ctx iris.Context) (*viewmodels.TreeSectionContract, error)
 
 	// 项目节
-	GetSecionTree() *viewmodels.TreeSectionContract
+	GetSecionTree(operation string) *viewmodels.TreeSectionContract
 	SetSection() error
 	GetSection(id int) *viewmodels.TreeSectionDetail
 	SectionAdd(sectionData *viewmodels.TreeSectionContract) (*models.CmTreeContracts, error)

+ 3 - 2
web/api/contract_api.go

@@ -2,7 +2,7 @@
  * @description: 合同管理 相关API
  * @Author: CP
  * @Date: 2020-10-26 15:27:04
- * @FilePath: \construction_management\web\api\contract_api.go
+ * @FilePath: \design_quantity\web\api\contract_api.go
  */
 package api
 
@@ -27,6 +27,7 @@ type ContractApi struct {
 // @Description 未设置合同项目节 返回项目节模板信息
 // @Accept  json
 // @Produce  json
+// @Param   operation     body    string     true        "操作名称"  1
 // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,data:viewmodels.TreeSectionContract,msg:错误信息}"
 // @Router /api/section/all [get]
 func (c *ContractApi) GetSectionAll() {
@@ -55,7 +56,7 @@ func (c *ContractApi) GetSectionAll() {
 	// }
 
 	//获得合同项目节
-	sectionTree := c.ServiceContract.GetSecionTree()
+	sectionTree := c.ServiceContract.GetSecionTree(sectionData.Operation)
 
 	c.Ctx.JSON(iris.Map{
 		"code":   0,