caipin 4 éve
szülő
commit
12d2bb5197
1 módosított fájl, 32 hozzáadás és 26 törlés
  1. 32 26
      web/api/contract_api.go

+ 32 - 26
web/api/contract_api.go

@@ -69,17 +69,16 @@ func (c *ContractApi) GetFolder() {
 	})
 }
 
-// @Summary 获得标段收入-项目节信息(除去合同项目节)
-// @Tags 合同管理-收入合同(除去合同项目节)
+// @Summary 获得标段收入-项目节信息
+// @Tags 合同管理-收入合同
 // @Description 未设置合同项目节 返回项目节模板信息
 // @Accept  json
 // @Produce  json
 // @Security ApiKeyAuth
 // @Param   bidsectionId     path    string     true        "标段ID"
-// @Param   treeType     path    int     true        "项目节类型(0收入,1支出)不传为收入"
 // @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,data:viewmodels.TreeSectionContract,msg:错误信息}"
-// @Router /api/contract/income/section/nocontract [get]
-func (c *ContractApi) GetSectionNocontract() {
+// @Router /api/contract/income/section/all [get]
+func (c *ContractApi) GetIncomeSectionAll() {
 
 	sectionData := viewmodels.TreeSectionContract{}
 	err := c.Ctx.ReadForm(&sectionData)
@@ -105,27 +104,34 @@ func (c *ContractApi) GetSectionNocontract() {
 	}
 
 	//获得合同项目节
-	sectionTree := c.ServiceContract.GetSecionTree(bidsectionId, projectIdInt, sectionData.TreeType)
-
-	// 2.已设置项目节
-	c.Ctx.JSON(iris.Map{
-		"code":        0,
-		"msg":         "",
-		"sectionTree": sectionTree,
-	})
-}
-
-// @Summary 获得标段收入-项目节信息
-// @Tags 合同管理-收入合同
-// @Description 未设置合同项目节 返回项目节模板信息
-// @Accept  json
-// @Produce  json
-// @Security ApiKeyAuth
-// @Param   bidsectionId     path    string     true        "标段ID"
-// @Success 200 {object} viewmodels.TreeSectionContract "{code:0成功,-1参数类错误,data:viewmodels.TreeSectionContract,msg:错误信息}"
-// @Router /api/contract/income/section/all [get]
-func (c *ContractApi) GetIncomeSectionAll() {
-
+	sectionTree := c.ServiceContract.GetSecionTree(bidsectionId, projectIdInt, 0)
+
+	// 1.未设置了项目节
+	if len(sectionTree.Children) == 0 {
+		// 返回项目节2个基础模板
+		templateTree1 := lib.NewItemSection().TemplateTree1
+		templateTree2 := lib.NewItemSection().TemplateTree2
+
+		c.Ctx.JSON(iris.Map{
+			"code":             0,
+			"msg":              "",
+			"isTemplate":       1,
+			"sectionTemplate1": templateTree1,
+			"sectionTemplate2": templateTree2,
+		})
+		return
+		//2.项目节已设置
+	} else {
+		// 2.已设置项目节
+		c.Ctx.JSON(iris.Map{
+			"code":        0,
+			"msg":         "",
+			"isTemplate":  0,
+			"sectionTree": sectionTree,
+		})
+		return
+		// 返回项目相关所有信息
+	}
 }
 
 // @Summary 单个合同和项目节