|
@@ -3,14 +3,19 @@ package seal
|
|
|
import (
|
|
|
"encoding/json"
|
|
|
"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"
|
|
|
+ sealModels "hongze/hz_crm_api/models/seal"
|
|
|
"hongze/hz_crm_api/models/seal/request"
|
|
|
"hongze/hz_crm_api/models/seal/response"
|
|
|
"hongze/hz_crm_api/services/seal"
|
|
|
"hongze/hz_crm_api/utils"
|
|
|
+ "os"
|
|
|
+ "path/filepath"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
// 用印审批管理
|
|
@@ -30,6 +35,7 @@ type SealApprovalController struct {
|
|
|
// @Param EndTime query string false "提交结束时间"
|
|
|
// @Param Keyword query string false "搜索关键词(客户名称/社会信用码)"
|
|
|
// @Param IsExport query bool false "是否导出excel,默认是false"
|
|
|
+// @Param AffiliatedCompany query string false "归属公司"
|
|
|
// @Success 200 {object} response.SealApprovalListResp
|
|
|
// @router /getApprovalPageList [get]
|
|
|
func (this *SealApprovalController) List() {
|
|
@@ -160,9 +166,16 @@ func (this *SealApprovalController) List() {
|
|
|
pars = append(pars, keywords, keywords, keywords)
|
|
|
}
|
|
|
|
|
|
+ // 归属公司
|
|
|
+ affiliatedCompany := this.GetString("AffiliatedCompany")
|
|
|
+ if affiliatedCompany != "" {
|
|
|
+ condition += ` AND c.affiliated_company = ?`
|
|
|
+ pars = append(pars, affiliatedCompany)
|
|
|
+ }
|
|
|
+
|
|
|
//导出excel
|
|
|
if isExport {
|
|
|
- //TripListExport(this, condition, joinCondition, pars)
|
|
|
+ ApprovalListExport(this, condition, joinCondition, pars, br)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -184,6 +197,131 @@ func (this *SealApprovalController) List() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// ApprovalListExport 审批列表导出
|
|
|
+func ApprovalListExport(this *SealApprovalController, condition, joinCondition string, pars []interface{}, br *models.BaseResponse) {
|
|
|
+ list, err := sealModels.GetSealApprovalList(condition, joinCondition, pars)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "审批列表获取失败!"
|
|
|
+ br.ErrMsg = "审批列表获取失败!" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ ////超级管理员和权益管理员、权益研究员可以下载所有客户,销售组长能下载本组客户,销售只能下载本人名下客户
|
|
|
+ //resp := new(cygx.CanDownload)
|
|
|
+ //adminInfo, errAdmin := system.GetSysUserById(sysUser.AdminId)
|
|
|
+ //if errAdmin != nil {
|
|
|
+ // br.Msg = "获取失败"
|
|
|
+ // br.ErrMsg = "获取失败,Err:" + errAdmin.Error()
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ //if adminInfo.Role == "admin" || adminInfo.Role == "researcher" {
|
|
|
+ // resp.IsCanDownload = true
|
|
|
+ //}
|
|
|
+
|
|
|
+ //创建excel
|
|
|
+ dir, err := os.Executable()
|
|
|
+ exPath := filepath.Dir(dir)
|
|
|
+ downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
|
|
|
+ xlsxFile := xlsx.NewFile()
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "生成文件失败"
|
|
|
+ br.ErrMsg = "生成文件失败"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ style := xlsx.NewStyle()
|
|
|
+ alignment := xlsx.Alignment{
|
|
|
+ Horizontal: "center",
|
|
|
+ Vertical: "center",
|
|
|
+ WrapText: true,
|
|
|
+ }
|
|
|
+ style.Alignment = alignment
|
|
|
+ style.ApplyAlignment = true
|
|
|
+
|
|
|
+ sheetName := "审批列表"
|
|
|
+ sheet, err := xlsxFile.AddSheet(sheetName)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "新增Sheet失败"
|
|
|
+ br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //标头
|
|
|
+ rowTitle := sheet.AddRow()
|
|
|
+ cellA := rowTitle.AddCell()
|
|
|
+ cellA.Value = "归属公司"
|
|
|
+ cellB := rowTitle.AddCell()
|
|
|
+ cellB.Value = "客户名称"
|
|
|
+ cellC := rowTitle.AddCell()
|
|
|
+ cellC.Value = "社会信用码"
|
|
|
+ cellD := rowTitle.AddCell()
|
|
|
+ cellD.Value = "用印用途"
|
|
|
+ cellE := rowTitle.AddCell()
|
|
|
+ cellE.Value = "合同编号"
|
|
|
+ cellF := rowTitle.AddCell()
|
|
|
+ cellF.Value = "合同类型"
|
|
|
+ cellG := rowTitle.AddCell()
|
|
|
+ cellG.Value = "加盖印章"
|
|
|
+ cellH := rowTitle.AddCell()
|
|
|
+ cellH.Value = "所属销售"
|
|
|
+ cellI := rowTitle.AddCell()
|
|
|
+ cellI.Value = "提交时间"
|
|
|
+ cellJ := rowTitle.AddCell()
|
|
|
+ cellJ.Value = "用印状态"
|
|
|
+ cellK := rowTitle.AddCell()
|
|
|
+ cellK.Value = "一级审批人"
|
|
|
+ cellL := rowTitle.AddCell()
|
|
|
+ cellL.Value = "一级抄送人"
|
|
|
+ cellM := rowTitle.AddCell()
|
|
|
+ cellM.Value = "二级审批人"
|
|
|
+ cellN := rowTitle.AddCell()
|
|
|
+ cellN.Value = "二级抄送人"
|
|
|
+
|
|
|
+ for _, v := range list {
|
|
|
+ row := sheet.AddRow()
|
|
|
+ cellA := row.AddCell()
|
|
|
+ cellA.Value = v.AffiliatedCompany
|
|
|
+ cellB := row.AddCell()
|
|
|
+ cellB.Value = v.CompanyName
|
|
|
+ cellC := row.AddCell()
|
|
|
+ cellC.Value = v.CreditCode
|
|
|
+ cellD := row.AddCell()
|
|
|
+ cellD.Value = v.Use
|
|
|
+ cellE := rowTitle.AddCell()
|
|
|
+ cellE.Value = v.ContractCode
|
|
|
+ cellF := rowTitle.AddCell()
|
|
|
+ cellF.Value = v.ContractType
|
|
|
+ cellG := rowTitle.AddCell()
|
|
|
+ cellG.Value = v.SealType
|
|
|
+ cellH := rowTitle.AddCell()
|
|
|
+ cellH.Value = v.ApplyUserName
|
|
|
+ cellI := rowTitle.AddCell()
|
|
|
+ cellI.Value = v.CreateTimeStr
|
|
|
+ cellJ := rowTitle.AddCell()
|
|
|
+ cellJ.Value = v.Status
|
|
|
+ cellK := rowTitle.AddCell()
|
|
|
+ cellK.Value = "一级审批人"
|
|
|
+ cellL := rowTitle.AddCell()
|
|
|
+ cellL.Value = "一级抄送人"
|
|
|
+ cellM := rowTitle.AddCell()
|
|
|
+ cellM.Value = "二级审批人"
|
|
|
+ cellN := rowTitle.AddCell()
|
|
|
+ cellN.Value = "二级抄送人"
|
|
|
+ }
|
|
|
+
|
|
|
+ err = xlsxFile.Save(downLoadnFilePath)
|
|
|
+ if err != nil {
|
|
|
+ br.Msg = "保存文件失败"
|
|
|
+ br.ErrMsg = "保存文件失败"
|
|
|
+ return
|
|
|
+ }
|
|
|
+ downloadFileName := "审批列表" + ".xlsx"
|
|
|
+ this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
|
|
|
+ defer func() {
|
|
|
+ os.Remove(downLoadnFilePath)
|
|
|
+ }()
|
|
|
+ br.Success = true
|
|
|
+ br.Ret = 200
|
|
|
+ br.IsAddLog = true
|
|
|
+}
|
|
|
+
|
|
|
// 用印申请
|
|
|
// @Title 用印申请
|
|
|
// @Description 用印申请
|