lanjianrong 4 yıl önce
ebeveyn
işleme
765d5dbe67

+ 1 - 1
conf/project.go

@@ -25,7 +25,7 @@ const OssHost string = "http://measuresaas.oss-cn-shenzhen.aliyuncs.com"
 const CallbackUrl string = "http://88.88.88.88:8888"
 
 // 用户上传文件时指定的前缀。 --user-dir-prefix/
-const Upload_dir string = "xinxihua/"
+const Upload_dir string = "shuliangshejibiao/"
 const Expire_time int64 = 60
 
 // 中国时区

+ 1 - 1
dao/tree_contract_dao.go

@@ -503,7 +503,7 @@ func (d *TreeContractDao) Delete(section *models.CmTreeContracts) error {
 	// 孩子们的归属
 	attribution := fmt.Sprintf("%s%d-", section.Attribution, section.Serial)
 	// 2. 删除项目节孩子们
-	_, err = session.Exec("DELETE FROM `cm_tree_contracts` WHERE attribution like ? and project_id=? and bidsection_id=? and tree_type=? ", attribution+"%", section.ProjectId, section.BidsectionId, section.TreeType)
+	_, err = session.Exec("DELETE FROM `cm_tree_contracts` WHERE attribution like ? ", attribution+"%")
 	if err != nil {
 		session.Rollback()
 		return errors.New("删除失败")

+ 8 - 43
services/contract_section_tree_service.go

@@ -45,16 +45,16 @@ func (s *contractService) GetSectionTreeContract(attribution string) []*viewmode
 }
 
 // 设置合同项目节初始数据-根据模板导入
-func (s *contractService) SetSection(templateNumber int) error {
+func (s *contractService) SetSection() error {
 	// 获得模板数据
 	templateTree := make([]*lib.ItemSectionTemplateTree, 0)
-	if templateNumber == 1 {
-		templateTree = lib.NewItemSectionData().TemplateList1
-	} else if templateNumber == 2 {
-		templateTree = lib.NewItemSectionData().TemplateList2
-	} else {
-		return errors.New("找不到合同项目节模板")
-	}
+	templateTree = lib.NewItemSectionData().TemplateList1
+	// if templateNumber == 1 {
+	// } else if templateNumber == 2 {
+	// 	templateTree = lib.NewItemSectionData().TemplateList2
+	// } else {
+	// 	return errors.New("找不到合同项目节模板")
+	// }
 
 	// 1.组合数据-写入库中
 	sectionTreeList := make([]*models.CmTreeContracts, 0)
@@ -62,8 +62,6 @@ func (s *contractService) SetSection(templateNumber int) error {
 		section := &models.CmTreeContracts{}
 		section.TreeId = item.Id
 		section.ParentId = item.ParentId
-		section.ProjectId = 1
-		section.BidsectionId = 1
 		section.Name = item.Name
 		section.Depth = item.Depth
 		section.Serial = item.Serial
@@ -234,39 +232,6 @@ func (s *contractService) SectionSave(sectionData *viewmodels.TreeSectionContrac
 	return nil
 }
 
-// 保存编号
-func (s *contractService) SectionCode(sectionData *viewmodels.TreeSectionContract, bidsectionId int, projectId int, treeType int) error {
-	// 1.验证项目节ID
-	treeId, err := utils.GetDecryptId(sectionData.Id)
-	if err != nil {
-		return err
-	}
-	section := s.treeContractDao.Get(treeId, bidsectionId, projectId, treeType)
-	if section.Id == 0 {
-		return errors.New("未找到合同项目节")
-	}
-
-	if section.Code == sectionData.Code {
-		return nil
-	}
-
-	// 1-1 深度为>=2才能新增项目节
-	// if section.Depth < 2 {
-	// 	return errors.New("请在项目节第三层开始编辑")
-	// }
-
-	// 2.保存
-	sectionCM := &models.CmTreeContracts{}
-	sectionCM.Code = sectionData.Code
-	sectionCM.Id = section.Id
-
-	err = s.treeContractDao.Save(sectionCM, []string{"Code"})
-	if err != nil {
-		return errors.New("保存失败")
-	}
-	return nil
-}
-
 // 更新序号
 func (s *contractService) UpdateSerial(sectionData *viewmodels.TreeSectionContract) error {
 	// 1.验证项目节ID

+ 1 - 1
services/contract_service.go

@@ -31,7 +31,7 @@ type ContractService interface {
 
 	// 项目节
 	GetSecionTree() *viewmodels.TreeSectionContract
-	SetSection(templateNumber int) error
+	SetSection() error
 	SectionAdd(sectionData *viewmodels.TreeSectionContract) (*models.CmTreeContracts, error)
 	SectionSave(sectionData *viewmodels.TreeSectionContract) error
 	UpdateSerial(sectionData *viewmodels.TreeSectionContract) error

+ 24 - 30
web/api/contract_section_tree_api.go

@@ -20,8 +20,6 @@ import (
 // @Produce  json
 // @Security ApiKeyAuth
 // @Param   id     body    string     true        "项目节ID"
-// @Param   bidsectionId     body    string     true        "标段ID"
-// @Param   treeType     body    string     true        "项目节类型(0收入1支出) 不传为0" default(0)
 // @Param   operation     body    string     true        "操作名称"  default(upDepth)
 // @Success 200 {string} string	"{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
 // @Router /api/contract/section/depth [post]
@@ -74,8 +72,6 @@ func (c *ContractApi) PostSectionDepth() {
 // @Produce  json
 // @Security ApiKeyAuth
 // @Param   id     body    string     true        "项目节ID"
-// @Param   bidsectionId     body    string     true        "标段ID"
-// @Param   treeType     body    string     true        "项目节类型(0收入1支出) 不传为0" default(0)
 // @Param   operation     body    string     true        "操作名称"  default(upSerial)
 // @Success 200 {string} string	"{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
 // @Router /api/contract/section/serial [post]
@@ -129,8 +125,6 @@ func (c *ContractApi) PostSectionSerial() {
 // @Produce  json
 // @Security ApiKeyAuth
 // @Param   id     body    string     true        "项目节ID"
-// @Param   bidsectionId     body    string     true        "标段ID"
-// @Param   treeType     body    string     true        "项目节类型(0收入1支出) 不传为0" default(0)
 // @Param   serial     body    int     true        "操作名称"
 // @Success 200 {string} string	"{code:0成功,-1参数类错误,-2服务端内部错误,msg:错误信息}"
 // @Router /api/contract/section/serial/update [post]
@@ -189,11 +183,11 @@ func (c *ContractApi) PostSectionSerialUpdate() {
 func (c *ContractApi) PostSectionTemplate() {
 
 	// 获得模板号
-	sectionData, err := c.ServiceContract.ValidRuleTemplate(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "解析参数出错"})
-		return
-	}
+	// sectionData, err := c.ServiceContract.ValidRuleTemplate(c.Ctx)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": "解析参数出错"})
+	// 	return
+	// }
 
 	// 项目ID
 	// projectIdInt, err := utils.GetProjectId(c.Ctx)
@@ -216,7 +210,7 @@ func (c *ContractApi) PostSectionTemplate() {
 	//获得合同项目节
 	// sectionTree := c.ServiceContract.GetSecionTree(bidsectionId, projectIdInt, sectionData.TreeType)
 
-	err = c.ServiceContract.SetSection(sectionData.TemplateNumber)
+	err := c.ServiceContract.SetSection()
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
@@ -350,24 +344,24 @@ func (c *ContractApi) PostSectionCode() {
 	}
 
 	// 项目ID
-	projectIdInt, err := utils.GetProjectId(c.Ctx)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
+	// projectIdInt, err := utils.GetProjectId(c.Ctx)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
+	// 	return
+	// }
 	// 标段ID
-	bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
-	if err != nil {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
-		return
-	}
+	// bidsectionId, err := utils.GetDecryptId(sectionData.BidsectionId)
+	// if err != nil {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
+	// 	return
+	// }
 
-	if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
-		c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
-		return
-	}
+	// if !(sectionData.TreeType == 0 || sectionData.TreeType == 1) {
+	// 	c.Ctx.JSON(iris.Map{"code": -1, "msg": "合同项目节类型只能是0或者1"})
+	// 	return
+	// }
 
-	err = c.ServiceContract.SectionSave(sectionData, bidsectionId, projectIdInt, sectionData.TreeType)
+	err = c.ServiceContract.SectionSave(sectionData)
 	if err != nil {
 		c.Ctx.JSON(iris.Map{"code": -1, "msg": fmt.Sprintf("%s", err)})
 		return
@@ -375,10 +369,10 @@ func (c *ContractApi) PostSectionCode() {
 
 	//2.请求当前项目信息
 	// 1.验证项目节ID
-	treeId, _ := utils.GetDecryptId(sectionData.Id)
-	sectionDetail := c.ServiceContract.Get(treeId, bidsectionId, projectIdInt, sectionData.TreeType)
+	// treeId, _ := utils.GetDecryptId(sectionData.Id)
+	// sectionDetail := c.ServiceContract.Get(treeId)
 
-	c.Ctx.JSON(iris.Map{"code": 0, "msg": "修改成功", "section": sectionDetail})
+	c.Ctx.JSON(iris.Map{"code": 0, "msg": "修改成功"})
 }
 
 // @Summary 删除 合同项目节

+ 7 - 8
web/viewmodels/tree_section_contract.go

@@ -37,10 +37,10 @@ type TreeSectionContract struct {
 	CreateTime string                 `form:"createTime" json:"createTime"`
 	Children   []*TreeSectionContract `json:"children"`
 
-	TemplateNumber int    `form:"templateNumber" json:"templateNumber"`
-	Operation      string `form:"operation" json:"operation"`
-	ElderBrother   bool   `form:"elderBrother" json:"elderBrother"`
-	IsEnd          bool   `form:"isEnd" json:"isEnd"`
+	// TemplateNumber int    `form:"templateNumber" json:"templateNumber"`
+	Operation    string `form:"operation" json:"operation"`
+	ElderBrother bool   `form:"elderBrother" json:"elderBrother"`
+	IsEnd        bool   `form:"isEnd" json:"isEnd"`
 }
 
 func (l TreeSectionContract) ValidateDepth() error {
@@ -58,10 +58,9 @@ func (l TreeSectionContract) ValidateSectionNot() error {
 }
 
 func (l TreeSectionContract) ValidateTemplate() error {
-	return validation.ValidateStruct(&l,
-		validation.Field(&l.TemplateNumber, validation.Required.Error("模板号不能为空"), validation.In(1, 2).Error("未找到相关模板")),
-		// validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
-	)
+	return validation.ValidateStruct(&l) // validation.Field(&l.TemplateNumber, validation.Required.Error("模板号不能为空"), validation.In(1, 2).Error("未找到相关模板")),
+	// validation.Field(&l.BidsectionId, validation.Required.Error("标段ID不能为空")),
+
 }
 
 func (l TreeSectionContract) ValidateSectionAdd() error {