作者 yangfu

导出修改

@@ -112,7 +112,7 @@ func (this *BaseController) Valid(obj interface{}) (result bool, msg *protocol.R @@ -112,7 +112,7 @@ func (this *BaseController) Valid(obj interface{}) (result bool, msg *protocol.R
112 func (this *BaseController) ResponseExcelByFile(ctx *context.Context, excelMaker *exceltool.ExcelMaker) error { 112 func (this *BaseController) ResponseExcelByFile(ctx *context.Context, excelMaker *exceltool.ExcelMaker) error {
113 ctx.Output.Header("Content-Disposition", "attachment; filename="+excelMaker.FileName) 113 ctx.Output.Header("Content-Disposition", "attachment; filename="+excelMaker.FileName)
114 ctx.Output.Header("Content-Description", "File Transfer") 114 ctx.Output.Header("Content-Description", "File Transfer")
115 - ctx.Output.Header("Content-Type", "application/octet-stream") 115 + ctx.Output.Header("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
116 ctx.Output.Header("Content-Transfer-Encoding", "binary") 116 ctx.Output.Header("Content-Transfer-Encoding", "binary")
117 ctx.Output.Header("Expires", "0") 117 ctx.Output.Header("Expires", "0")
118 ctx.Output.Header("Cache-Control", "must-revalidate") 118 ctx.Output.Header("Cache-Control", "must-revalidate")
@@ -83,6 +83,10 @@ var errmessge ErrorMap = map[string]string{ @@ -83,6 +83,10 @@ var errmessge ErrorMap = map[string]string{
83 "10277": "最多一个小数", 83 "10277": "最多一个小数",
84 "10278": "公告标题大于30个字符", 84 "10278": "公告标题大于30个字符",
85 "10279": "该子分类名称已存在", 85 "10279": "该子分类名称已存在",
  86 + "10280": "请为您选择的特殊人员设置审批流程",
  87 + "10281": "请您选择的审批人员",
  88 + "10282": "请您选择的审批角色",
  89 + "10283": "特殊审批流程被审批人不可重复",
86 90
87 "10170": "请选择指定成员", 91 "10170": "请选择指定成员",
88 "10171": "请选择审批人类别", 92 "10171": "请选择审批人类别",
@@ -682,3 +682,90 @@ func CategoryEditSort(uid, companyId int64, request *protocol.CategoryEditSortRe @@ -682,3 +682,90 @@ func CategoryEditSort(uid, companyId int64, request *protocol.CategoryEditSortRe
682 rsp = &protocol.CategoryEditSortResponse{} 682 rsp = &protocol.CategoryEditSortResponse{}
683 return 683 return
684 } 684 }
  685 +
  686 +//验证模板配置
  687 +func ValidAuditFlowConfig(flowConfig protocol.AuditFlowConfig) (msg *protocol.ResponseMessage) {
  688 + var (
  689 + count int
  690 + specailUser map[int]int
  691 + )
  692 + msg = protocol.NewMessage("0")
  693 + for i := range flowConfig.ProcessConfig {
  694 + config := flowConfig.ProcessConfig[i]
  695 + if !(config.ApproveType == models.AuditByDepartmentor || config.ApproveType == models.AuditByUser || config.ApproveType == models.AuditByRole) {
  696 + msg = protocol.BadRequestParam("10171")
  697 + return
  698 + }
  699 + if !(config.AcitonType == models.ActionTypeOr || config.AcitonType == models.ActionTypeAnd) {
  700 + msg = protocol.BadRequestParam("10172")
  701 + return
  702 + }
  703 + if config.ApproveType == models.AuditByUser {
  704 + if len(config.ToUser) == 0 {
  705 + msg = protocol.BadRequestParam("10170")
  706 + return
  707 + }
  708 + if len(config.ToUser) > 10 {
  709 + msg = protocol.BadRequestParam("10174")
  710 + return
  711 + }
  712 + }
  713 + if config.ApproveType == models.AuditByRole {
  714 + if len(config.ToRole) == 0 {
  715 + msg = protocol.BadRequestParam("10173")
  716 + return
  717 + }
  718 + if len(config.ToRole) > 1 {
  719 + msg = protocol.BadRequestParam("10175")
  720 + return
  721 + }
  722 + }
  723 + if config.ProcessType == models.FlowTypeNormal {
  724 + count++
  725 + if count > 1 {
  726 + msg = protocol.BadRequestParam("10176")
  727 + return
  728 + }
  729 + }
  730 + if config.ProcessType == models.FlowTypeSpecail {
  731 + if len(config.FromSpecialUser) == 0 { //特殊人为空
  732 + msg = protocol.BadRequestParam("10281")
  733 + return
  734 + }
  735 + msg = ValidProcessConfig(&config)
  736 + if msg.Errno != 0 {
  737 + return
  738 + }
  739 + for i := range config.ToUser {
  740 + u := config.ToUser[i]
  741 + if _, ok := specailUser[u.Id]; ok {
  742 + msg = protocol.BadRequestParam("10283")
  743 + return
  744 + }
  745 + }
  746 + }
  747 + }
  748 + return
  749 +}
  750 +
  751 +//检验审核配置
  752 +func ValidProcessConfig(config *protocol.ProcessConfig) (msg *protocol.ResponseMessage) {
  753 + msg = &protocol.ResponseMessage{}
  754 + switch config.ApproveType {
  755 + case models.AuditByDepartmentor:
  756 + break
  757 + case models.AuditByUser:
  758 + if len(config.ToUser) == 0 {
  759 + msg = protocol.BadRequestParam("10281")
  760 + return
  761 + }
  762 + break
  763 + case models.AuditByRole:
  764 + if len(config.ToRole) == 0 {
  765 + msg = protocol.BadRequestParam("10282")
  766 + return
  767 + }
  768 + break
  769 + }
  770 + return
  771 +}