瀏覽代碼

fix:合同模板调整

Roc 2 年之前
父節點
當前提交
7557fffea5
共有 2 個文件被更改,包括 22 次插入15 次删除
  1. 1 0
      models/tables/contract_template/contract_template.go
  2. 21 15
      services/word.go

+ 1 - 0
models/tables/contract_template/contract_template.go

@@ -13,6 +13,7 @@ type ContractTemplate struct {
 	Html               string    `description:"html模板"`
 	PdfHtml            string    `description:"生成pdf的html模板"`
 	WordConfig         string    `description:"生成word的json配置"`
+	ContentConfig      string    `description:"合同中一些特定区域的文字展示配置;json格式"`
 	CreateTime         time.Time `description:"创建时间"`
 }
 

+ 21 - 15
services/word.go

@@ -641,16 +641,20 @@ func GetHtmlByContractDetail(contractDetail *contract.ContractDetail, htmlType s
 	}
 	contractHtml = buf.String()
 
+	// 初始化合同中一些特定区域的文字展示配置
+	contentConfigMap := make(map[string]string)
+	err = json.Unmarshal([]byte(contractTemplate.ContentConfig), &contentConfigMap)
+	if err != nil {
+		return
+	}
 	//服务内容
 	{
 		tableStr := ""
 		tableDataSlice := make([]TableData, 0)
 		tableTitleSlice := make([]string, 0)
-		title := ""
-		if contractDetail.ProductId == 1 {
-			title = "依照《【弘则研究】FICC客户服务列表2022》中 "
-		} else {
-			title = "依照《【弘则研究】私募客户服务列表2022》中 "
+		title := ``
+		if tmpTitle, ok := contentConfigMap["title1"]; ok {
+			title = tmpTitle
 		}
 		for i := 0; i < len(contractDetail.Service); i++ {
 			//表格数据
@@ -1101,6 +1105,12 @@ func GenerateWordV2(contractDetail *contract.ContractDetail, wordPath string) (e
 		fmt.Println("json字符串解析失败,ERR:", err)
 		return
 	}
+	// 初始化合同中一些特定区域的文字展示配置
+	contentConfigMap := make(map[string]string)
+	err = json.Unmarshal([]byte(contractTemplate.ContentConfig), &contentConfigMap)
+	if err != nil {
+		return
+	}
 
 	doc := document.New()
 
@@ -1126,11 +1136,9 @@ func GenerateWordV2(contractDetail *contract.ContractDetail, wordPath string) (e
 		printContent := ``
 		if data.ElementName == "services" {
 			tableTitleSlice := make([]string, 0)
-			title := ""
-			if contractDetail.ProductId == 1 {
-				title = "依照《【弘则研究】FICC客户服务列表2022》中"
-			} else {
-				title = "依照《【弘则研究】私募客户服务列表2022》中"
+			title := ``
+			if tmpTitle, ok := contentConfigMap["title1"]; ok {
+				title = tmpTitle
 			}
 			TableDataListSlice := make([]TableData, 0)
 			//for i := len(contractServiceAndDetailList) - 1; i >= 0; i-- {
@@ -1317,11 +1325,9 @@ func GenerateWordV2(contractDetail *contract.ContractDetail, wordPath string) (e
 		for _, text := range data.ElementList {
 			if text.ElementName == "services" {
 				tableTitleSlice := make([]string, 0)
-				title := ""
-				if contractDetail.ProductId == 1 {
-					title = "依照《【弘则研究】FICC客户服务列表2022》中 "
-				} else {
-					title = "依照《【弘则研究】私募客户服务列表2022》中 "
+				title := ``
+				if tmpTitle, ok := contentConfigMap["title1"]; ok {
+					title = tmpTitle
 				}
 				TableDataListSlice := make([]TableData, 0)
 				for i := len(contractServiceAndDetailList) - 1; i >= 0; i-- {