作者 tangxvhui

版本 15改动

@@ -15,7 +15,7 @@ type AuditForm struct { @@ -15,7 +15,7 @@ type AuditForm struct {
15 SortNum int `orm:"column(sort_num)" description:"排序"` 15 SortNum int `orm:"column(sort_num)" description:"排序"`
16 Label string `orm:"column(label);size(100)" description:"标题"` 16 Label string `orm:"column(label);size(100)" description:"标题"`
17 InputType string `orm:"column(input_type);size(50)" description:"输入类型 text"` 17 InputType string `orm:"column(input_type);size(50)" description:"输入类型 text"`
18 - ValueList string `orm:"column(value_list);size(255)" description:"可选值列表"` 18 + ValueList string `orm:"column(value_list);size(255)" description:"可选值列表json结构字符串"`
19 Required int8 `orm:"column(required)" description:"是否必填:【0:否】【1:是】"` 19 Required int8 `orm:"column(required)" description:"是否必填:【0:否】【1:是】"`
20 CurrentValue string `orm:"column(current_value);size(255)" description:"实际填写的值"` 20 CurrentValue string `orm:"column(current_value);size(255)" description:"实际填写的值"`
21 Disable int8 `orm:"column(disable);null" description:"显示隐藏:【0:显示】【1:隐藏】"` 21 Disable int8 `orm:"column(disable);null" description:"显示隐藏:【0:显示】【1:隐藏】"`
@@ -34,6 +34,12 @@ func init() { @@ -34,6 +34,12 @@ func init() {
34 orm.RegisterModel(new(AuditForm)) 34 orm.RegisterModel(new(AuditForm))
35 } 35 }
36 36
  37 +//AuditFormValueList 表audit_form中字段value_list的结构
  38 +type AuditFormValueList struct {
  39 + Value string `json:"value"`
  40 + Type string `json:"type"` //输入的数据内容类型
  41 +}
  42 +
37 var ( 43 var (
38 DeleteAuditFormBy = `delete FROM audit_form where audit_template_id=? and company_id=?` 44 DeleteAuditFormBy = `delete FROM audit_form where audit_template_id=? and company_id=?`
39 ) 45 )
@@ -25,6 +25,7 @@ type AuditTemplate struct { @@ -25,6 +25,7 @@ type AuditTemplate struct {
25 UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"` 25 UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
26 Example string `orm:"column(example);null" description:"示例"` 26 Example string `orm:"column(example);null" description:"示例"`
27 Videos string `orm:"column(videos);null" description:"示例"` 27 Videos string `orm:"column(videos);null" description:"示例"`
  28 + SelfCheckNeed int8 `orm:"column(self_check_need)" description:"是否需要自查内容"`
28 } 29 }
29 30
30 const ( 31 const (
@@ -37,6 +38,12 @@ const ( @@ -37,6 +38,12 @@ const (
37 VisibleObject_Department = 1 38 VisibleObject_Department = 1
38 ) 39 )
39 40
  41 +// SelfCheckNeed 是否需要自查内容
  42 +const (
  43 + AuditSelfCheckNeedYes int8 = 1 //需要
  44 + AuditSelfCheckNeedNo int8 = 2 //不需要
  45 +)
  46 +
40 func (t *AuditTemplate) TableName() string { 47 func (t *AuditTemplate) TableName() string {
41 return "audit_template" 48 return "audit_template"
42 } 49 }
@@ -85,7 +85,7 @@ func (t *Department) GetManages() []protocol.DepartmentManager { @@ -85,7 +85,7 @@ func (t *Department) GetManages() []protocol.DepartmentManager {
85 return managesdata 85 return managesdata
86 } 86 }
87 87
88 -func (t *Department) GetMembers() []protocol.DepartmentMember { 88 +func (t *Department) GetMembers() []User {
89 ids, err := GetUserDepartmentIds(int(t.CompanyId), int(t.Id)) 89 ids, err := GetUserDepartmentIds(int(t.CompanyId), int(t.Id))
90 if err != nil { 90 if err != nil {
91 log.Error(err.Error()) 91 log.Error(err.Error())
@@ -96,14 +96,7 @@ func (t *Department) GetMembers() []protocol.DepartmentMember { @@ -96,14 +96,7 @@ func (t *Department) GetMembers() []protocol.DepartmentMember {
96 log.Error("GetUserNameByIds err :%s", err) 96 log.Error("GetUserNameByIds err :%s", err)
97 return nil 97 return nil
98 } 98 }
99 - managesdata := []protocol.DepartmentMember{}  
100 - for _, v := range users {  
101 - m := protocol.DepartmentMember{  
102 - Id: v.Id, Name: v.NickName,  
103 - }  
104 - managesdata = append(managesdata, m)  
105 - }  
106 - return managesdata 99 + return users
107 } 100 }
108 101
109 func (t *Department) IsTopDepartment() bool { 102 func (t *Department) IsTopDepartment() bool {
@@ -6,11 +6,43 @@ import ( @@ -6,11 +6,43 @@ import (
6 6
7 //输入框类型 7 //输入框类型
8 const ( 8 const (
9 - inputTypeCheck string = "check-box" //多选宽  
10 - inputTypeText string = "text" //单行文本宽  
11 - InputTypeRedio string = "redio" //单选框 9 + InputTypeText string = "text" //单行文本宽
  10 + InputTypeRadio string = "radio" //单选框
  11 + InputImageVedio string = "image/vedio" // 图片或视频输入
12 ) 12 )
13 13
  14 +//输入框输入的数据类型
  15 +const (
  16 + InputDataTypeText string = "text" //单纯文本
  17 + InputDataTypeImage string = "image" //图片的文件url
  18 + InputDataTypeVedio string = "vedio" //视频的文件url
  19 +)
  20 +
  21 +var (
  22 + InputDataTypeMap map[string]bool = map[string]bool{
  23 + InputDataTypeText: true,
  24 + InputDataTypeImage: true,
  25 + InputDataTypeVedio: true,
  26 + }
  27 + InputTypeMap map[string]bool = map[string]bool{
  28 + InputTypeText: true,
  29 + InputTypeRadio: true,
  30 + InputImageVedio: true,
  31 + }
  32 +)
  33 +
  34 +type InputElementData struct {
  35 + Value string `json:"value"` //输入框填写的值
  36 + Type string `json:"type"` //输入数据内容的类型
  37 + Path string `json:"path,omitempy"`
  38 + Cover map[string]interface{} `json:"cover,omitempy"`
  39 +}
  40 +
  41 +type InputElementValueList struct {
  42 + Value string `json:"value"`
  43 + Type string `json:"type"` //输入的数据内容类型
  44 +}
  45 +
14 //InputElement 自定义表单项 46 //InputElement 自定义表单项
15 type InputElement struct { 47 type InputElement struct {
16 Id int `json:"id"` 48 Id int `json:"id"`
@@ -20,9 +52,8 @@ type InputElement struct { @@ -20,9 +52,8 @@ type InputElement struct {
20 Required int `json:"required"` //是否必填 52 Required int `json:"required"` //是否必填
21 CurrentValue string `json:"value"` //"当前填写的值" 53 CurrentValue string `json:"value"` //"当前填写的值"
22 SectionType int8 `json:"sectionType"` 54 SectionType int8 `json:"sectionType"`
23 - // ValueList string `json:"-"` //输入候选值 value_list  
24 - // Placeholder string `json:"-"` //帮助用户填写输入字段的提示 Placeholder  
25 - // Disable bool `json:"-"` //"显示隐藏", 55 + ValueList []InputElementValueList `json:"valueList,omitempy"` //输入候选值 value_list
  56 + Data []InputElementData `json:"data,omitempy"`
26 } 57 }
27 58
28 //自定义表单 59 //自定义表单
@@ -39,44 +70,6 @@ func (a CustomForm) Less(i, j int) bool { @@ -39,44 +70,6 @@ func (a CustomForm) Less(i, j int) bool {
39 return a[i].Sort < a[j].Sort 70 return a[i].Sort < a[j].Sort
40 } 71 }
41 72
42 -//IValidateInput 自定义输入项校验接口  
43 -type IValidateInput interface {  
44 - ValidateInput() error //校验当前输入值  
45 - ValidateConfig() error //校验自定义的输入项设置  
46 -}  
47 -  
48 -type ValidateInputText struct {  
49 - InputElement  
50 -}  
51 -  
52 -var (  
53 - _ IValidateInput = ValidateInputText{}  
54 -)  
55 -  
56 -func (input ValidateInputText) ValidateInput() error {  
57 - return nil  
58 -}  
59 -func (input ValidateInputText) ValidateConfig() error {  
60 - return nil  
61 -}  
62 -  
63 -//ValidateInputRedio 单选项校验  
64 -type ValidateInputRedio struct {  
65 - InputElement  
66 -}  
67 -  
68 -var (  
69 - _ IValidateInput = ValidateInputRedio{}  
70 -)  
71 -  
72 -func (input ValidateInputRedio) ValidateInput() error {  
73 - return nil  
74 -}  
75 -  
76 -func (input ValidateInputRedio) ValidateConfig() error {  
77 - return nil  
78 -}  
79 -  
80 /***********审核模板管理**********/ 73 /***********审核模板管理**********/
81 /*TemplateAdd */ 74 /*TemplateAdd */
82 75
@@ -111,6 +104,7 @@ type Template struct { @@ -111,6 +104,7 @@ type Template struct {
111 type AuditFlowConfig struct { 104 type AuditFlowConfig struct {
112 NoApprover int `json:"noApprover" valid:"Required;"` //审核人为空【1:自动通过】【2:转交给管理员】 105 NoApprover int `json:"noApprover" valid:"Required;"` //审核人为空【1:自动通过】【2:转交给管理员】
113 ProcessConfig []ProcessConfig `json:"processConfig"` //创建时 0 106 ProcessConfig []ProcessConfig `json:"processConfig"` //创建时 0
  107 + SelfCheckNeed int `json:"self_check_need"` //是否需要自查内容【1:需要】【2:不需要】
114 } 108 }
115 type ProcessConfig struct { 109 type ProcessConfig struct {
116 ApproveType int `json:"approveType"` //1.部门长 2 指定成员 3.指定角色 110 ApproveType int `json:"approveType"` //1.部门长 2 指定成员 3.指定角色
@@ -73,6 +73,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs @@ -73,6 +73,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs
73 { 73 {
74 for i := range request.Template.InputList { 74 for i := range request.Template.InputList {
75 input := request.Template.InputList[i] 75 input := request.Template.InputList[i]
  76 + valueList, _ := json.Marshal(input.ValueList)
76 auditForm = &models.AuditForm{ 77 auditForm = &models.AuditForm{
77 CompanyId: int(companyId), 78 CompanyId: int(companyId),
78 AuditTemplateId: int(templateId), 79 AuditTemplateId: int(templateId),
@@ -83,6 +84,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs @@ -83,6 +84,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs
83 Required: int8(input.Required), 84 Required: int8(input.Required),
84 CreateAt: time.Now(), 85 CreateAt: time.Now(),
85 EnableStatus: 1, 86 EnableStatus: 1,
  87 + ValueList: string(valueList),
86 } 88 }
87 if _, err = orm.Insert(auditForm); err != nil { 89 if _, err = orm.Insert(auditForm); err != nil {
88 log.Error(err.Error()) 90 log.Error(err.Error())
@@ -489,11 +491,14 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques @@ -489,11 +491,14 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques
489 } 491 }
490 492
491 //更新 或 插入表单 493 //更新 或 插入表单
  494 +//TODO 检查表单项类型是否被篡改
492 func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input *protocol.InputElement) (err error) { 495 func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input *protocol.InputElement) (err error) {
493 var ( 496 var (
494 auditForm *models.AuditForm 497 auditForm *models.AuditForm
495 ) 498 )
  499 + valueList, _ := json.Marshal(input.ValueList)
496 if input.Id == 0 { 500 if input.Id == 0 {
  501 +
497 auditForm = &models.AuditForm{ 502 auditForm = &models.AuditForm{
498 CompanyId: int(companyId), 503 CompanyId: int(companyId),
499 AuditTemplateId: int(templateId), 504 AuditTemplateId: int(templateId),
@@ -504,6 +509,7 @@ func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input @@ -504,6 +509,7 @@ func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input
504 Required: int8(input.Required), 509 Required: int8(input.Required),
505 CreateAt: time.Now(), 510 CreateAt: time.Now(),
506 EnableStatus: 1, 511 EnableStatus: 1,
  512 + ValueList: string(valueList),
507 } 513 }
508 if _, err = orm.Insert(auditForm); err != nil { 514 if _, err = orm.Insert(auditForm); err != nil {
509 log.Error(err.Error()) 515 log.Error(err.Error())
@@ -522,6 +528,7 @@ func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input @@ -522,6 +528,7 @@ func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input
522 "InputType": input.InputType, 528 "InputType": input.InputType,
523 "Required": int8(input.Required), 529 "Required": int8(input.Required),
524 "SortNum": input.Sort, 530 "SortNum": input.Sort,
  531 + "ValueList": string(valueList),
525 } 532 }
526 if err = utils.UpdateTableByMapWithOrmer(orm, auditForm, updateMap); err != nil { 533 if err = utils.UpdateTableByMapWithOrmer(orm, auditForm, updateMap); err != nil {
527 return 534 return
@@ -701,15 +708,25 @@ func TemplateGet(uid, companyId int64, request *protocol.TemplateGetRequest) (rs @@ -701,15 +708,25 @@ func TemplateGet(uid, companyId int64, request *protocol.TemplateGetRequest) (rs
701 rsp.Template.InputList = make([]*protocol.InputElement, 0) 708 rsp.Template.InputList = make([]*protocol.InputElement, 0)
702 for i := range auditForm { 709 for i := range auditForm {
703 input := auditForm[i] 710 input := auditForm[i]
704 - rsp.Template.InputList = append(rsp.Template.InputList, &protocol.InputElement{ 711 + var valuelist []models.AuditFormValueList
  712 + json.Unmarshal([]byte(input.ValueList), &valuelist)
  713 + inElement := &protocol.InputElement{
705 Id: input.Id, 714 Id: input.Id,
706 Sort: input.SortNum, 715 Sort: input.SortNum,
707 Label: input.Label, 716 Label: input.Label,
708 Required: int(input.Required), 717 Required: int(input.Required),
709 SectionType: input.Section, 718 SectionType: input.Section,
710 InputType: input.InputType, 719 InputType: input.InputType,
  720 + }
  721 + for _, inputValue := range valuelist {
  722 + inElement.ValueList = append(inElement.ValueList, protocol.InputElementValueList{
  723 + Value: inputValue.Value,
  724 + Type: inputValue.Type,
711 }) 725 })
712 } 726 }
  727 + rsp.Template.InputList = append(rsp.Template.InputList, inElement)
  728 +
  729 + }
713 if configs, err = models.GetAuditFlowConfig(template.Id); err != nil { 730 if configs, err = models.GetAuditFlowConfig(template.Id); err != nil {
714 log.Error("template:%v %v", template.Id, err.Error()) 731 log.Error("template:%v %v", template.Id, err.Error())
715 err = nil 732 err = nil
@@ -121,7 +121,6 @@ func SelectorUserAndDepartment(departid int64, companyId int64) (*protocol.Depar @@ -121,7 +121,6 @@ func SelectorUserAndDepartment(departid int64, companyId int64) (*protocol.Depar
121 mDepart *models.Department 121 mDepart *models.Department
122 departsUser protocol.DepartAndUser 122 departsUser protocol.DepartAndUser
123 departbase []protocol.DepartmentBase 123 departbase []protocol.DepartmentBase
124 - departMember []protocol.DepartmentMember  
125 err error 124 err error
126 where string 125 where string
127 cond []interface{} 126 cond []interface{}
@@ -136,8 +135,13 @@ func SelectorUserAndDepartment(departid int64, companyId int64) (*protocol.Depar @@ -136,8 +135,13 @@ func SelectorUserAndDepartment(departid int64, companyId int64) (*protocol.Depar
136 log.Error("companyid err") 135 log.Error("companyid err")
137 return nil, protocol.NewErrWithMessage("1") 136 return nil, protocol.NewErrWithMessage("1")
138 } 137 }
139 - departMember = mDepart.GetMembers()  
140 - departsUser.Members = departMember 138 + departMember := mDepart.GetMembers()
  139 + for _, v := range departMember {
  140 + m := protocol.DepartmentMember{
  141 + Id: v.Id, Name: v.NickName,
  142 + }
  143 + departsUser.Members = append(departsUser.Members, m)
  144 + }
141 } 145 }
142 datasql0 := `SELECT id, company_id,name,parent_id ` + 146 datasql0 := `SELECT id, company_id,name,parent_id ` +
143 ` FROM department WHERE company_id = ? AND delete_at = 0 ` 147 ` FROM department WHERE company_id = ? AND delete_at = 0 `
@@ -361,7 +361,6 @@ func DepartmentListAll(companyId int64) ([]protocol.ResponseDepartmentInfo, erro @@ -361,7 +361,6 @@ func DepartmentListAll(companyId int64) ([]protocol.ResponseDepartmentInfo, erro
361 var manage []protocol.DepartmentManager 361 var manage []protocol.DepartmentManager
362 manage = v.GetManages() 362 manage = v.GetManages()
363 depart.Manages = manage 363 depart.Manages = manage
364 - // depart.Members = v.GetMembers()  
365 departs = append(departs, depart) 364 departs = append(departs, depart)
366 } 365 }
367 366
@@ -212,7 +212,6 @@ func RoleMenuEdit(companyid int64, roleId int64, menuids []int64) error { @@ -212,7 +212,6 @@ func RoleMenuEdit(companyid int64, roleId int64, menuids []int64) error {
212 //机会管理高级设置 212 //机会管理高级设置
213 func UpdateSetOpportunity(param OptionOpportunity, roleid int64, companyid int64) error { 213 func UpdateSetOpportunity(param OptionOpportunity, roleid int64, companyid int64) error {
214 var ( 214 var (
215 - //code = M_SYSTEM_OPPORTUNITY  
216 rolemenu *models.RoleMenu 215 rolemenu *models.RoleMenu
217 roleInfo *models.Role 216 roleInfo *models.Role
218 err error 217 err error
@@ -85,6 +85,7 @@ type CheckDeparment struct { @@ -85,6 +85,7 @@ type CheckDeparment struct {
85 Wait int `json:"wait"` 85 Wait int `json:"wait"`
86 OpenAll int `json:"open_all"` 86 OpenAll int `json:"open_all"`
87 OpenDepart int `json:"open_depart"` 87 OpenDepart int `json:"open_depart"`
  88 + NotPass int `json:"not_pass"`
88 } 89 }
89 90
90 //CheckOpp 特殊的查看条件设定 91 //CheckOpp 特殊的查看条件设定
@@ -111,6 +112,7 @@ type OptionOpportunity struct { @@ -111,6 +112,7 @@ type OptionOpportunity struct {
111 2:仅查看自己部门和公开机会:查看对自己所在部门公开的机会+公司公开的机会 112 2:仅查看自己部门和公开机会:查看对自己所在部门公开的机会+公司公开的机会
112 3:特定部门的机会:选定部门提交的公司公开、部门公开的机会;>只选择部门 113 3:特定部门的机会:选定部门提交的公司公开、部门公开的机会;>只选择部门
113 4:查看所有机会:查看所有部门的公开机会及部门公开机会; 114 4:查看所有机会:查看所有部门的公开机会及部门公开机会;
  115 +5:查看指定部门的未通过的机会
114 */ 116 */
115 const ( 117 const (
116 OpportunityCheckLv1 int = 1 118 OpportunityCheckLv1 int = 1