|
@@ -2,11 +2,14 @@ package seal
|
|
|
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
+ "errors"
|
|
|
+ "fmt"
|
|
|
"github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"github.com/tealeg/xlsx"
|
|
|
"hongze/hz_crm_api/controllers"
|
|
|
"hongze/hz_crm_api/models"
|
|
|
"hongze/hz_crm_api/models/company"
|
|
|
+ "hongze/hz_crm_api/models/contract"
|
|
|
sealModels "hongze/hz_crm_api/models/seal"
|
|
|
"hongze/hz_crm_api/models/seal/request"
|
|
|
"hongze/hz_crm_api/models/seal/response"
|
|
@@ -14,6 +17,7 @@ import (
|
|
|
"hongze/hz_crm_api/utils"
|
|
|
"os"
|
|
|
"path/filepath"
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
@@ -217,6 +221,36 @@ func ApprovalListExport(this *SealApprovalController, condition, joinCondition s
|
|
|
// resp.IsCanDownload = true
|
|
|
//}
|
|
|
|
|
|
+ if len(list) > 0 {
|
|
|
+ // 取出所有列表的关联合同id
|
|
|
+ contractIdSlice := make([]string, 0)
|
|
|
+ for i := 0; i < len(list); i++ {
|
|
|
+ contractIdSlice = append(contractIdSlice, strconv.Itoa(list[i].ContractId))
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取所有关联的合同列表
|
|
|
+ selfContractMap := make(map[int]*contract.ContractList)
|
|
|
+ {
|
|
|
+ if len(contractIdSlice) > 0 {
|
|
|
+ contractIdStr := strings.Join(contractIdSlice, ",")
|
|
|
+ contractList, tempErr := contract.GetContractListByContractIds(contractIdStr)
|
|
|
+ if tempErr != nil {
|
|
|
+ err = errors.New(fmt.Sprint("获取合同失败,Err:"+tempErr.Error(), err))
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for i := 0; i < len(contractList); i++ {
|
|
|
+ selfContractMap[contractList[i].ContractId] = contractList[i]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for i, v := range list {
|
|
|
+ // 合同编码
|
|
|
+ if selfContract, has := selfContractMap[v.ContractId]; has {
|
|
|
+ list[i].ContractCode = selfContract.ContractCode
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//创建excel
|
|
|
dir, err := os.Executable()
|
|
|
exPath := filepath.Dir(dir)
|