Squashed commit : 机会版本 v0.14.0
commit abd918ea Author: yangfu <785409885@qq.com> Date: Thu Jun 4 18:23:25 2020 +0800 机会池权限修改 commit 4037796f Author: yangfu <785409885@qq.com> Date: Wed Jun 3 21:20:33 2020 +0800 机会审核修改 commit eb95837a Author: yangfu <785409885@qq.com> Date: Wed Jun 3 15:35:04 2020 +0800 搜索修改 commit 350b3e1c Author: yangfu <785409885@qq.com> Date: Wed Jun 3 11:34:39 2020 +0800 机会详情修改 commit b689b20f Author: yangfu <785409885@qq.com> Date: Wed Jun 3 11:33:26 2020 +0800 机会详情修改 commit cc0930c0 Author: yangfu <785409885@qq.com> Date: Wed Jun 3 10:23:24 2020 +0800 机会补充修改 commit 846b0ea0 Author: yangfu <785409885@qq.com> Date: Mon Jun 1 10:04:07 2020 +0800 机会池修改 commit d8e7e218 Author: yangfu <785409885@qq.com> Date: Sun May 31 13:45:41 2020 +0800 草稿箱修改 commit 35c458d9 Author: yangfu <785409885@qq.com> Date: Sat May 30 22:22:14 2020 +0800 草稿箱修改 commit ab49d03a Author: yangfu <785409885@qq.com> Date: Fri May 29 15:08:10 2020 +0800 修改模板列表,单选表单赋值 commit 01cca9d6 Author: yangfu <785409885@qq.com> Date: Fri May 29 13:53:04 2020 +0800 列表过滤 commit c46f5ca1 Author: yangfu <785409885@qq.com> Date: Fri May 29 11:36:02 2020 +0800 fix error commit bab101df Author: yangfu <785409885@qq.com> Date: Thu May 28 17:12:39 2020 +0800 1.修改机会变更详情 commit 73419bbf Author: yangfu <785409885@qq.com> Date: Tue May 26 17:33:06 2020 +0800 1.机会搜索 2.审核是否需要提交自查 commit ba285a34 Merge: d833d2d4 2a22d230 Author: yangfu <785409885@qq.com> Date: Tue May 26 10:35:50 2020 +0800 Merge remote-tracking branch 'origin/test' into dev commit d833d2d4 Author: yangfu <785409885@qq.com> Date: Mon May 18 14:12:16 2020 +0800 修改权限过期时间 commit d72f9c03 Author: yangfu <785409885@qq.com> Date: Mon May 18 14:00:10 2020 +0800 修改权限过期时间 commit de50130d Author: yangfu <785409885@qq.com> Date: Mon May 18 11:14:08 2020 +0800 修改权限过期时间
正在显示
15 个修改的文件
包含
444 行增加
和
115 行删除
@@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
6 | "opp/controllers" | 6 | "opp/controllers" |
7 | "opp/protocol" | 7 | "opp/protocol" |
8 | + "opp/services/agg" | ||
8 | "opp/services/chance" | 9 | "opp/services/chance" |
9 | "strings" | 10 | "strings" |
10 | ) | 11 | ) |
@@ -292,6 +293,7 @@ func (this *ChanceController) ChanceSubmit() { | @@ -292,6 +293,7 @@ func (this *ChanceController) ChanceSubmit() { | ||
292 | msg = protocol.NewReturnResponse(nil, e) | 293 | msg = protocol.NewReturnResponse(nil, e) |
293 | return | 294 | return |
294 | } | 295 | } |
296 | + agg.SetFormDefaultValue(request.FormList, agg.SetRadioFormValue) | ||
295 | header := controllers.GetRequestHeader(this.Ctx) | 297 | header := controllers.GetRequestHeader(this.Ctx) |
296 | msg = protocol.NewReturnResponse(chance.ChanceSubmit(header, request)) | 298 | msg = protocol.NewReturnResponse(chance.ChanceSubmit(header, request)) |
297 | } | 299 | } |
@@ -318,6 +320,7 @@ func (this *ChanceController) ChanceUpdate() { | @@ -318,6 +320,7 @@ func (this *ChanceController) ChanceUpdate() { | ||
318 | msg = protocol.NewReturnResponse(nil, e) | 320 | msg = protocol.NewReturnResponse(nil, e) |
319 | return | 321 | return |
320 | } | 322 | } |
323 | + agg.SetFormDefaultValue(request.FormList, agg.SetRadioFormValue) | ||
321 | header := controllers.GetRequestHeader(this.Ctx) | 324 | header := controllers.GetRequestHeader(this.Ctx) |
322 | msg = protocol.NewReturnResponse(chance.ChanceUpdate(header, request)) | 325 | msg = protocol.NewReturnResponse(chance.ChanceUpdate(header, request)) |
323 | } | 326 | } |
@@ -671,6 +674,31 @@ func (this *ChanceController) ChanceReservePool() { | @@ -671,6 +674,31 @@ func (this *ChanceController) ChanceReservePool() { | ||
671 | msg = protocol.NewReturnResponse(chance.ChancePool(header, request)) | 674 | msg = protocol.NewReturnResponse(chance.ChancePool(header, request)) |
672 | } | 675 | } |
673 | 676 | ||
677 | +//SearchChance 搜索 | ||
678 | +//@router /search [post] | ||
679 | +func (this *ChanceController) SearchChance() { | ||
680 | + var msg *protocol.ResponseMessage | ||
681 | + defer func() { | ||
682 | + this.Resp(msg) | ||
683 | + }() | ||
684 | + var request *protocol.ChancePoolRequest | ||
685 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
686 | + log.Error(err) | ||
687 | + msg = protocol.BadRequestParam(1) | ||
688 | + return | ||
689 | + } | ||
690 | + if b, m := this.Valid(request); !b { | ||
691 | + msg = m | ||
692 | + return | ||
693 | + } | ||
694 | + if len(strings.TrimSpace(request.KeyWord)) == 0 { | ||
695 | + msg = protocol.BadRequestParamWithMessage(2, "请输入机会内容、员工姓名") | ||
696 | + return | ||
697 | + } | ||
698 | + header := controllers.GetRequestHeader(this.Ctx) | ||
699 | + msg = protocol.NewReturnResponse(chance.ChancePool(header, request)) | ||
700 | +} | ||
701 | + | ||
674 | //ChanceReviseDetail 机会补充详情 | 702 | //ChanceReviseDetail 机会补充详情 |
675 | //@router /chanceReviseDetail [post] | 703 | //@router /chanceReviseDetail [post] |
676 | func (this *ChanceController) ChanceReviseDetail() { | 704 | func (this *ChanceController) ChanceReviseDetail() { |
@@ -841,6 +869,7 @@ func (this *ChanceController) DraftSaveChance() { | @@ -841,6 +869,7 @@ func (this *ChanceController) DraftSaveChance() { | ||
841 | } | 869 | } |
842 | header := controllers.GetRequestHeader(this.Ctx) | 870 | header := controllers.GetRequestHeader(this.Ctx) |
843 | request.SelfChecks.SetSelfChecksLevel1ByRule() | 871 | request.SelfChecks.SetSelfChecksLevel1ByRule() |
872 | + agg.SetFormDefaultValue(request.FormList, agg.SetRadioFormValue) | ||
844 | msg = protocol.NewReturnResponse(chance.DraftSaveChance(header, request)) | 873 | msg = protocol.NewReturnResponse(chance.DraftSaveChance(header, request)) |
845 | } | 874 | } |
846 | 875 |
@@ -17,6 +17,7 @@ type AuditTemplate struct { | @@ -17,6 +17,7 @@ type AuditTemplate struct { | ||
17 | Code string `orm:"column(code);size(50);null" description:" 编码"` | 17 | Code string `orm:"column(code);size(50);null" description:" 编码"` |
18 | NoticeType int8 `orm:"column(notice_type)" description:"通知方式"` | 18 | NoticeType int8 `orm:"column(notice_type)" description:"通知方式"` |
19 | NoApprover int8 `orm:"column(no_approver)" description:"审核人空时:【1:自动通过】【2:转交给管理员】"` | 19 | NoApprover int8 `orm:"column(no_approver)" description:"审核人空时:【1:自动通过】【2:转交给管理员】"` |
20 | + SelfCheckNeed int8 `orm:"column(self_check_need)" description:"是否需要自查内容 【1:需要自查内容】【2:不需要】"` | ||
20 | SortNum int `orm:"column(sort_num)" description:"自定义排序编号"` | 21 | SortNum int `orm:"column(sort_num)" description:"自定义排序编号"` |
21 | VisibleType int8 `orm:"column(visible_type)" description:"可见范围 0:所有人 1:指定部门 "` | 22 | VisibleType int8 `orm:"column(visible_type)" description:"可见范围 0:所有人 1:指定部门 "` |
22 | VisibleObject string `orm:"column(visible_object);size(1000);null" description:"可见的对象 部门 指定人 json"` | 23 | VisibleObject string `orm:"column(visible_object);size(1000);null" description:"可见的对象 部门 指定人 json"` |
@@ -55,10 +55,12 @@ const ( | @@ -55,10 +55,12 @@ const ( | ||
55 | ) | 55 | ) |
56 | 56 | ||
57 | type ChancePoolOption struct { | 57 | type ChancePoolOption struct { |
58 | - ChanceTypeId int //机会类型编号 | ||
59 | - DIds []int //部门编号列表 | ||
60 | - Type int8 //机会类型 | ||
61 | - ReserveTypeId int //机会储备类型编号 | 58 | + ChanceTypeId int //机会类型编号 |
59 | + DIds []int //部门编号列表 | ||
60 | + Type int8 //机会类型 | ||
61 | + ReserveTypeId int //机会储备类型编号 | ||
62 | + KeyWord string //搜索特定内容的机会 (基础/附加) | ||
63 | + InUsers []int64 //搜索特定User的机会 | ||
62 | } | 64 | } |
63 | 65 | ||
64 | //机会池查询选项 | 66 | //机会池查询选项 |
@@ -74,6 +76,17 @@ func NewChancePoolOption(chanceTypeId int, deps []int, t int8, rt int) *ChancePo | @@ -74,6 +76,17 @@ func NewChancePoolOption(chanceTypeId int, deps []int, t int8, rt int) *ChancePo | ||
74 | ReserveTypeId: rt, | 76 | ReserveTypeId: rt, |
75 | } | 77 | } |
76 | } | 78 | } |
79 | +func (o *ChancePoolOption) SetKeyWord(keyWord string) *ChancePoolOption { | ||
80 | + o.KeyWord = keyWord | ||
81 | + return o | ||
82 | +} | ||
83 | +func (o *ChancePoolOption) SetInUsers(inUsers []int64) *ChancePoolOption { | ||
84 | + if len(inUsers) == 0 { | ||
85 | + return o | ||
86 | + } | ||
87 | + o.InUsers = inUsers | ||
88 | + return o | ||
89 | +} | ||
77 | 90 | ||
78 | var ( | 91 | var ( |
79 | SqlGetChanceSelfChecks = `select user_id,review_status,self_checks from chance where id =?` //机会自查数据 | 92 | SqlGetChanceSelfChecks = `select user_id,review_status,self_checks from chance where id =?` //机会自查数据 |
@@ -569,6 +582,11 @@ func getFilterSql(option *ChancePoolOption) string { | @@ -569,6 +582,11 @@ func getFilterSql(option *ChancePoolOption) string { | ||
569 | if option.ReserveTypeId > 0 { | 582 | if option.ReserveTypeId > 0 { |
570 | rsp.WriteString(fmt.Sprintf(" and reserve_type_id =%v ", option.ReserveTypeId)) | 583 | rsp.WriteString(fmt.Sprintf(" and reserve_type_id =%v ", option.ReserveTypeId)) |
571 | } | 584 | } |
585 | + if len(option.KeyWord) > 0 && len(option.InUsers) > 0 { | ||
586 | + rsp.WriteString(fmt.Sprintf(" and (user_id in (%v) or source_content like '%%%v%%' )", utils.JoinInt64s(option.InUsers, ","), option.KeyWord)) | ||
587 | + } else if len(option.KeyWord) > 0 { | ||
588 | + rsp.WriteString(fmt.Sprintf(" and source_content like '%%%v%%' ", option.KeyWord)) | ||
589 | + } | ||
572 | return rsp.String() | 590 | return rsp.String() |
573 | } | 591 | } |
574 | 592 |
@@ -129,3 +129,20 @@ func GetUserAllCompany(uid int64) (v []*UserCompany, err error) { | @@ -129,3 +129,20 @@ func GetUserAllCompany(uid int64) (v []*UserCompany, err error) { | ||
129 | } | 129 | } |
130 | return nil, err | 130 | return nil, err |
131 | } | 131 | } |
132 | + | ||
133 | +//获取用户Id列表 | ||
134 | +//@key CompanyId NickName | ||
135 | +func GetUserCompanyIdAllBy(options map[string]interface{}) (v []int64, err error) { | ||
136 | + o := orm.NewOrm() | ||
137 | + sql := "select id from user_company where 1=1 " | ||
138 | + if _, ok := options["CompanyId"]; ok { | ||
139 | + sql += fmt.Sprintf(" and company_id=%v ", options["CompanyId"]) | ||
140 | + } | ||
141 | + if _, ok := options["NickName"]; ok { | ||
142 | + sql += fmt.Sprintf(" and nick_name like '%%%v%%' ", options["NickName"]) | ||
143 | + } | ||
144 | + if _, err = o.Raw(sql).QueryRows(&v); err == nil { | ||
145 | + return v, nil | ||
146 | + } | ||
147 | + return nil, err | ||
148 | +} |
@@ -203,8 +203,9 @@ type ChancePoolRequest struct { | @@ -203,8 +203,9 @@ type ChancePoolRequest struct { | ||
203 | ChanceTypeId int `json:"chanceTypeId"` //0:所有机会 编号:对应机会类型编号的机会 | 203 | ChanceTypeId int `json:"chanceTypeId"` //0:所有机会 编号:对应机会类型编号的机会 |
204 | DepartmentId int `json:"departmentId"` //部门编号 | 204 | DepartmentId int `json:"departmentId"` //部门编号 |
205 | IncludeSubDepartment bool | 205 | IncludeSubDepartment bool |
206 | - Type int8 `json:"type"` //0:机会池 1:储备池 | ||
207 | - ReserveTypeId int `json:"reserveTypeId"` //储备类型编号 | 206 | + Type int8 `json:"type"` //0:机会池 1:储备池 |
207 | + ReserveTypeId int `json:"reserveTypeId"` //储备类型编号 | ||
208 | + KeyWord string `json:"keyWord"` //搜索特定内容的机会 | ||
208 | } | 209 | } |
209 | type ChancePoolResponse struct { | 210 | type ChancePoolResponse struct { |
210 | List []CommonListItem `json:"list"` | 211 | List []CommonListItem `json:"list"` |
@@ -508,12 +509,28 @@ type Template struct { | @@ -508,12 +509,28 @@ type Template struct { | ||
508 | 509 | ||
509 | //表单 | 510 | //表单 |
510 | type Form struct { | 511 | type Form struct { |
511 | - Id int `json:"id"` | ||
512 | - Label string `json:"label"` | ||
513 | - InputType string `json:"inputType"` | ||
514 | - SectionType int8 `json:"sectionType"` | ||
515 | - Value string `json:"value"` | ||
516 | - Required int8 `json:"required"` | 512 | + Id int `json:"id"` |
513 | + Label string `json:"label"` | ||
514 | + InputType string `json:"inputType"` | ||
515 | + SectionType int8 `json:"sectionType"` | ||
516 | + Required int8 `json:"required"` | ||
517 | + Value string `json:"value"` | ||
518 | + ValueList []*ValueListItem `json:"valueList"` | ||
519 | + Data []*FormDataItem `json:"data"` | ||
520 | +} | ||
521 | + | ||
522 | +type ValueListItem struct { | ||
523 | + Type string `json:"type"` | ||
524 | + Value string `json:"value"` | ||
525 | +} | ||
526 | + | ||
527 | +type FormDataItem struct { | ||
528 | + Type string `json:"type"` | ||
529 | + Value string `json:"value"` | ||
530 | + Path string `json:"path,omitempty"` | ||
531 | + Cover *Cover `json:"cover,omitempty"` | ||
532 | + Duration int `json:"duration,omitempty"` | ||
533 | + Remark string `json:"remark,omitempty"` | ||
517 | } | 534 | } |
518 | 535 | ||
519 | //清楚未填写的表单数据 | 536 | //清楚未填写的表单数据 |
@@ -541,9 +558,9 @@ type Speech struct { | @@ -541,9 +558,9 @@ type Speech struct { | ||
541 | //图片 | 558 | //图片 |
542 | type Picture struct { | 559 | type Picture struct { |
543 | Path string `json:"path"` | 560 | Path string `json:"path"` |
544 | - W int `json:"-"` //w | ||
545 | - H int `json:"-"` //h | ||
546 | - ImageId string `json:"imageId"` //imageId | 561 | + W int `json:"-"` //w |
562 | + H int `json:"-"` //h | ||
563 | + ImageId string `json:"imageId,omitempty"` //imageId | ||
547 | PathBak string `json:"-"` | 564 | PathBak string `json:"-"` |
548 | //JobId string `json:"job_id"` | 565 | //JobId string `json:"job_id"` |
549 | } | 566 | } |
@@ -563,7 +580,18 @@ type Video struct { | @@ -563,7 +580,18 @@ type Video struct { | ||
563 | 580 | ||
564 | //审批配置 | 581 | //审批配置 |
565 | type AuditConfig struct { | 582 | type AuditConfig struct { |
566 | - NoApprover int8 `json:"no_approver"` //审核人空时:【1:自动通过】【2:转交给管理员】 | 583 | + NoApprover int8 `json:"no_approver"` //审核人空时:【1:自动通过】【2:转交给管理员】 |
584 | + SelfCheckNeed int8 `json:"self_check_need"` //审核人是否需要提交自查 1:需要 0:不需要 | ||
585 | +} | ||
586 | + | ||
587 | +func (c AuditConfig) GetSelfCheckNeed() int { | ||
588 | + if c.SelfCheckNeed == 1 { | ||
589 | + return 1 | ||
590 | + } | ||
591 | + if c.SelfCheckNeed == 2 { | ||
592 | + return 0 | ||
593 | + } | ||
594 | + return 1 | ||
567 | } | 595 | } |
568 | 596 | ||
569 | //机会池 - 统计 | 597 | //机会池 - 统计 |
@@ -700,7 +728,11 @@ type ChanceReviseLog struct { | @@ -700,7 +728,11 @@ type ChanceReviseLog struct { | ||
700 | } | 728 | } |
701 | 729 | ||
702 | type ReviseContent struct { | 730 | type ReviseContent struct { |
703 | - Content string `json:"content"` | 731 | + InputType string `json:"inputType"` |
732 | + Label string `json:"label"` | ||
733 | + Content string `json:"content"` | ||
734 | + Data []*FormDataItem `json:"data"` | ||
735 | + RemoveAllPhotoVideo bool `json:"removeAllPhotoVideo"` //是否移除所有媒体数据 | ||
704 | } | 736 | } |
705 | 737 | ||
706 | /*ChanceReviseDetail 机会补充详情*/ | 738 | /*ChanceReviseDetail 机会补充详情*/ |
@@ -50,9 +50,10 @@ type Approve struct { | @@ -50,9 +50,10 @@ type Approve struct { | ||
50 | 50 | ||
51 | //审核操作权限 | 51 | //审核操作权限 |
52 | type ApproveAccess struct { | 52 | type ApproveAccess struct { |
53 | - ProcessId int64 `json:"processId"` | ||
54 | - AllowApprove int `json:"allowApprove"` | ||
55 | - AllowReject int `json:"allowReject"` | 53 | + ProcessId int64 `json:"processId"` |
54 | + AllowApprove int `json:"allowApprove"` | ||
55 | + AllowReject int `json:"allowReject"` | ||
56 | + SelfCheckNeed int `json:"selfCheckNeed"` //是否需要提交自查 | ||
56 | } | 57 | } |
57 | 58 | ||
58 | //审核数据 审核通过 | 59 | //审核数据 审核通过 |
@@ -44,6 +44,16 @@ const ( | @@ -44,6 +44,16 @@ const ( | ||
44 | MyGraspAchievement //我把握的成果 | 44 | MyGraspAchievement //我把握的成果 |
45 | ) | 45 | ) |
46 | 46 | ||
47 | +//输入类型 | ||
48 | +const ( | ||
49 | + InputRadio = "radio" | ||
50 | + InputFiles = "files" | ||
51 | + InputCheckbox = "checkbox" | ||
52 | + InputText = "text" | ||
53 | + InputImage = "image" | ||
54 | + InputVideo = "video" | ||
55 | +) | ||
56 | + | ||
47 | var MapStaticName map[int64]string | 57 | var MapStaticName map[int64]string |
48 | 58 | ||
49 | func init() { | 59 | func init() { |
@@ -178,7 +178,7 @@ type Cover struct { | @@ -178,7 +178,7 @@ type Cover struct { | ||
178 | Path string `json:"path" valid:"Required"` | 178 | Path string `json:"path" valid:"Required"` |
179 | H int `json:"-"` | 179 | H int `json:"-"` |
180 | W int `json:"-"` | 180 | W int `json:"-"` |
181 | - ImageId string `json:"imageId"` | 181 | + ImageId string `json:"-"` |
182 | } | 182 | } |
183 | 183 | ||
184 | /*公告列表 BulletinList */ | 184 | /*公告列表 BulletinList */ |
@@ -305,6 +305,14 @@ func init() { | @@ -305,6 +305,14 @@ func init() { | ||
305 | 305 | ||
306 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | 306 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], |
307 | beego.ControllerComments{ | 307 | beego.ControllerComments{ |
308 | + Method: "SearchChance", | ||
309 | + Router: `/search`, | ||
310 | + AllowHTTPMethods: []string{"post"}, | ||
311 | + MethodParams: param.Make(), | ||
312 | + Params: nil}) | ||
313 | + | ||
314 | + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | ||
315 | + beego.ControllerComments{ | ||
308 | Method: "SiftingPool", | 316 | Method: "SiftingPool", |
309 | Router: `/siftingPool`, | 317 | Router: `/siftingPool`, |
310 | AllowHTTPMethods: []string{"post"}, | 318 | AllowHTTPMethods: []string{"post"}, |
@@ -249,16 +249,119 @@ func GetIncrementSqlBatch(table string, column string, incre int, ids ...int64) | @@ -249,16 +249,119 @@ func GetIncrementSqlBatch(table string, column string, incre int, ids ...int64) | ||
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | -//清楚未填写的表单数据 | ||
253 | -func ClearEmptyForm(inputFormList []*protocol.Form) (FormList []*protocol.Form) { | 252 | +type Filters func(inputFormList []*protocol.Form) (forms []*protocol.Form) |
253 | + | ||
254 | +type SetFormValue func(form *protocol.Form) | ||
255 | + | ||
256 | +func SetRadioFormValue(form *protocol.Form) { | ||
257 | + if form.InputType != protocol.InputRadio { | ||
258 | + return | ||
259 | + } | ||
260 | + if len(form.Data) > 0 && form.Data[0].Type == protocol.InputText { | ||
261 | + form.Value = form.Data[0].Value | ||
262 | + } | ||
263 | +} | ||
264 | + | ||
265 | +func SetFormDefaultValue(inputFormList []*protocol.Form, funcSetForm ...SetFormValue) { | ||
266 | + if len(inputFormList) == 0 { | ||
267 | + return | ||
268 | + } | ||
269 | + for i := range inputFormList { | ||
270 | + for j := range funcSetForm { | ||
271 | + funcSetForm[j](inputFormList[i]) | ||
272 | + } | ||
273 | + } | ||
274 | +} | ||
275 | + | ||
276 | +//清除未填写的表单数据 | ||
277 | +func ClearEmptyForm(inputFormList []*protocol.Form) (forms []*protocol.Form) { | ||
254 | if len(inputFormList) == 0 { | 278 | if len(inputFormList) == 0 { |
255 | return | 279 | return |
256 | } | 280 | } |
257 | for i := range inputFormList { | 281 | for i := range inputFormList { |
258 | item := inputFormList[i] | 282 | item := inputFormList[i] |
283 | + if len(item.Data) == 0 { | ||
284 | + item.Data = make([]*protocol.FormDataItem, 0) | ||
285 | + } | ||
286 | + if len(item.ValueList) == 0 { | ||
287 | + item.ValueList = make([]*protocol.ValueListItem, 0) | ||
288 | + } | ||
259 | if len(item.Value) > 0 { | 289 | if len(item.Value) > 0 { |
260 | - FormList = append(FormList, item) | 290 | + forms = append(forms, item) |
291 | + } | ||
292 | + } | ||
293 | + return | ||
294 | +} | ||
295 | + | ||
296 | +//清楚文件表单数据 | ||
297 | +func ClearFilesForm(inputFormList []*protocol.Form) (forms []*protocol.Form) { | ||
298 | + if len(inputFormList) == 0 { | ||
299 | + return | ||
300 | + } | ||
301 | + for i := range inputFormList { | ||
302 | + item := inputFormList[i] | ||
303 | + if strings.EqualFold(strings.TrimSpace(item.InputType), protocol.InputFiles) { | ||
304 | + continue | ||
261 | } | 305 | } |
306 | + forms = append(forms, item) | ||
262 | } | 307 | } |
263 | return | 308 | return |
264 | } | 309 | } |
310 | + | ||
311 | +func FormFilter(inputFormList []*protocol.Form, fiters ...Filters) (forms []*protocol.Form) { | ||
312 | + for i := range fiters { | ||
313 | + inputFormList = fiters[i](inputFormList) | ||
314 | + } | ||
315 | + forms = inputFormList | ||
316 | + return | ||
317 | +} | ||
318 | + | ||
319 | +//表单所有媒体文件 | ||
320 | +func FormsAllFiles(inputFormList []*protocol.Form) ([]protocol.Picture, []protocol.Video) { | ||
321 | + var ( | ||
322 | + pictures []protocol.Picture = make([]protocol.Picture, 0) | ||
323 | + videos []protocol.Video = make([]protocol.Video, 0) | ||
324 | + ) | ||
325 | + for i := range inputFormList { | ||
326 | + item := inputFormList[i] | ||
327 | + if !strings.EqualFold(strings.TrimSpace(item.InputType), protocol.InputFiles) { | ||
328 | + continue | ||
329 | + } | ||
330 | + for j := range item.Data { | ||
331 | + var ( | ||
332 | + path string = item.Data[j].Path | ||
333 | + cover *protocol.Cover = &protocol.Cover{} | ||
334 | + duration int = item.Data[j].Duration | ||
335 | + ) | ||
336 | + if len(strings.TrimSpace(item.Data[j].Path)) == 0 { | ||
337 | + continue | ||
338 | + } | ||
339 | + switch item.Data[j].Type { | ||
340 | + case protocol.InputImage: | ||
341 | + pictures = append(pictures, protocol.Picture{ | ||
342 | + Path: path, | ||
343 | + }) | ||
344 | + break | ||
345 | + case protocol.InputVideo: | ||
346 | + if item.Data[j].Cover == nil { | ||
347 | + continue | ||
348 | + } | ||
349 | + cover = item.Data[j].Cover | ||
350 | + videos = append(videos, protocol.Video{ | ||
351 | + Path: path, | ||
352 | + Duration: duration, | ||
353 | + Cover: *cover, | ||
354 | + }) | ||
355 | + break | ||
356 | + } | ||
357 | + } | ||
358 | + } | ||
359 | + return pictures, videos | ||
360 | +} | ||
361 | + | ||
362 | +func CombineAllFiles(inputFormList []*protocol.Form, pics []protocol.Picture, vids []protocol.Video) ([]protocol.Picture, []protocol.Video) { | ||
363 | + formPics, formVids := FormsAllFiles(inputFormList) | ||
364 | + formPics = append(formPics, pics...) | ||
365 | + formVids = append(formVids, vids...) | ||
366 | + return formPics, formVids | ||
367 | +} |
@@ -53,3 +53,14 @@ func Test_GetTopPosition(t *testing.T) { | @@ -53,3 +53,14 @@ func Test_GetTopPosition(t *testing.T) { | ||
53 | t.Fatal("top department error") | 53 | t.Fatal("top department error") |
54 | } | 54 | } |
55 | } | 55 | } |
56 | + | ||
57 | +func TestSetFormValue(t *testing.T) { | ||
58 | + input := []*protocol.Form{ | ||
59 | + {Label: "1", InputType: "radio", Data: []*protocol.FormDataItem{{Type: protocol.InputText, Value: "选项A"}}}, | ||
60 | + } | ||
61 | + SetFormDefaultValue(input, SetRadioFormValue) | ||
62 | + t.Log(input[0].Value) | ||
63 | + if input[0].Value != "选项A" { | ||
64 | + t.Fatal("input:", input[0].Value, " except:", "选项A") | ||
65 | + } | ||
66 | +} |
@@ -56,6 +56,13 @@ func GetChancePool(uid, cid int64, o *models.ChancePoolOption, departmentId int, | @@ -56,6 +56,13 @@ func GetChancePool(uid, cid int64, o *models.ChancePoolOption, departmentId int, | ||
56 | } | 56 | } |
57 | log.Debug(fmt.Sprintf("user:%v check:%v is_amdin:%v", uid, check, user.Id == uid)) | 57 | log.Debug(fmt.Sprintf("user:%v check:%v is_amdin:%v", uid, check, user.Id == uid)) |
58 | option := models.NewChancePoolOption(chanceTypeId, dIds, o.Type, o.ReserveTypeId) | 58 | option := models.NewChancePoolOption(chanceTypeId, dIds, o.Type, o.ReserveTypeId) |
59 | + if len(o.KeyWord) > 0 { | ||
60 | + option.SetKeyWord(o.KeyWord) | ||
61 | + ids, _ := models.GetUserCompanyIdAllBy(map[string]interface{}{"CompanyId": cid, "NickName": o.KeyWord}) | ||
62 | + if len(ids) > 0 { | ||
63 | + option.SetInUsers(ids) | ||
64 | + } | ||
65 | + } | ||
59 | switch check { | 66 | switch check { |
60 | case OpportunityCheckLv1: | 67 | case OpportunityCheckLv1: |
61 | return models.GetChancePoolMyself(uid, cid, option, lastId, pageSize, v) | 68 | return models.GetChancePoolMyself(uid, cid, option, lastId, pageSize, v) |
@@ -76,6 +83,8 @@ func GetChancePool(uid, cid int64, o *models.ChancePoolOption, departmentId int, | @@ -76,6 +83,8 @@ func GetChancePool(uid, cid int64, o *models.ChancePoolOption, departmentId int, | ||
76 | return models.GetChancePoolSpecialDepartment(uid, cid, option, lastId, pageSize, v, specialDIds) | 83 | return models.GetChancePoolSpecialDepartment(uid, cid, option, lastId, pageSize, v, specialDIds) |
77 | case OpportunityCheckLv4: | 84 | case OpportunityCheckLv4: |
78 | return models.GetChancePoolAll(uid, cid, option, lastId, pageSize, v) | 85 | return models.GetChancePoolAll(uid, cid, option, lastId, pageSize, v) |
86 | + case OpportunityCheckLv5: | ||
87 | + return models.GetChancePoolMyself(uid, cid, option, lastId, pageSize, v) | ||
79 | default: | 88 | default: |
80 | return models.GetChancePoolAll(uid, cid, option, lastId, pageSize, v) | 89 | return models.GetChancePoolAll(uid, cid, option, lastId, pageSize, v) |
81 | } | 90 | } |
@@ -233,10 +242,11 @@ func SetChanceItem(header *protocol.RequestHeader, chance protocol.CommChanceIte | @@ -233,10 +242,11 @@ func SetChanceItem(header *protocol.RequestHeader, chance protocol.CommChanceIte | ||
233 | item.UpdateTime = 0 | 242 | item.UpdateTime = 0 |
234 | } | 243 | } |
235 | utils.JsonUnmarshal(chance.SourceContent, &item.FormList) | 244 | utils.JsonUnmarshal(chance.SourceContent, &item.FormList) |
236 | - item.FormList = ClearEmptyForm(item.FormList) | ||
237 | utils.JsonUnmarshal(chance.Images, &item.Pictures) | 245 | utils.JsonUnmarshal(chance.Images, &item.Pictures) |
238 | utils.JsonUnmarshal(chance.Voices, &item.Speechs) | 246 | utils.JsonUnmarshal(chance.Voices, &item.Speechs) |
239 | utils.JsonUnmarshal(chance.Videos, &item.Videos) | 247 | utils.JsonUnmarshal(chance.Videos, &item.Videos) |
248 | + item.Pictures, item.Videos = CombineAllFiles(item.FormList, item.Pictures, item.Videos) | ||
249 | + item.FormList = FormFilter(item.FormList, ClearEmptyForm, ClearFilesForm) | ||
240 | return item, chanceStatus | 250 | return item, chanceStatus |
241 | } | 251 | } |
242 | func SetMsgItem(header *protocol.RequestHeader, msg protocol.MsgItemOrm, commItem *protocol.MsgCommonListItem) { | 252 | func SetMsgItem(header *protocol.RequestHeader, msg protocol.MsgItemOrm, commItem *protocol.MsgCommonListItem) { |
@@ -151,13 +151,14 @@ type OptionOpportunity struct { | @@ -151,13 +151,14 @@ type OptionOpportunity struct { | ||
151 | 2:仅查看自己部门和公开机会:查看对自己部门公开的机会+公司公开的机会 -> 仅查看自己部门和公开机会:查看对自己所在部门公开的机会+公司公开的机会; | 151 | 2:仅查看自己部门和公开机会:查看对自己部门公开的机会+公司公开的机会 -> 仅查看自己部门和公开机会:查看对自己所在部门公开的机会+公司公开的机会; |
152 | 3:特定部门的机会:自由配置选定部门的待审核、公司公开、部门公开的机会+查看对自己部门公开的机会 -> 特定部门的公开机会:选定部门提交的公司公开、部门公开的机会;>只选择部门 | 152 | 3:特定部门的机会:自由配置选定部门的待审核、公司公开、部门公开的机会+查看对自己部门公开的机会 -> 特定部门的公开机会:选定部门提交的公司公开、部门公开的机会;>只选择部门 |
153 | 4:查看所有机会:查看所有部门的待审核机会、公开机会及部门公开机会 -> 查看所有公开机会:查看所有部门的公开机会及部门公开机会; | 153 | 4:查看所有机会:查看所有部门的待审核机会、公开机会及部门公开机会 -> 查看所有公开机会:查看所有部门的公开机会及部门公开机会; |
154 | -5. -> 特定部门的待审核机会:选定部门提交的待审核机会。>只选择部门(这条这期可以先不做) | 154 | +5:特定部门的待审核机会:选定部门提交的待审核机会。>只选择部门 (只配置该权限,则机会池查看权限是 1) |
155 | */ | 155 | */ |
156 | const ( | 156 | const ( |
157 | OpportunityCheckLv1 int = 1 | 157 | OpportunityCheckLv1 int = 1 |
158 | OpportunityCheckLv2 int = 2 | 158 | OpportunityCheckLv2 int = 2 |
159 | OpportunityCheckLv3 int = 3 | 159 | OpportunityCheckLv3 int = 3 |
160 | OpportunityCheckLv4 int = 4 | 160 | OpportunityCheckLv4 int = 4 |
161 | + OpportunityCheckLv5 int = 5 | ||
161 | ) | 162 | ) |
162 | 163 | ||
163 | var ( | 164 | var ( |
@@ -351,6 +352,15 @@ func getUserChancePermission(userCompanyid int64) (map[string]PermissionOptionOb | @@ -351,6 +352,15 @@ func getUserChancePermission(userCompanyid int64) (map[string]PermissionOptionOb | ||
351 | return getPermissionMap(list) | 352 | return getPermissionMap(list) |
352 | } | 353 | } |
353 | 354 | ||
355 | +//权限权重 值越大,权重越大 | ||
356 | +var PermissionWeight map[int]int = map[int]int{ | ||
357 | + OpportunityCheckLv1: 1, | ||
358 | + OpportunityCheckLv2: 2, | ||
359 | + OpportunityCheckLv3: 3, | ||
360 | + OpportunityCheckLv4: 4, | ||
361 | + OpportunityCheckLv5: 1, | ||
362 | +} | ||
363 | + | ||
354 | //获取机会权限map | 364 | //获取机会权限map |
355 | func getPermissionMap(list []OptionOpportunity) (map[string]PermissionOptionObject, error) { | 365 | func getPermissionMap(list []OptionOpportunity) (map[string]PermissionOptionObject, error) { |
356 | var ( | 366 | var ( |
@@ -371,7 +381,7 @@ func getPermissionMap(list []OptionOpportunity) (map[string]PermissionOptionObje | @@ -371,7 +381,7 @@ func getPermissionMap(list []OptionOpportunity) (map[string]PermissionOptionObje | ||
371 | specialDepIds := make(map[int64]CheckDeparment) //特定部门 | 381 | specialDepIds := make(map[int64]CheckDeparment) //特定部门 |
372 | for i := range list { | 382 | for i := range list { |
373 | tmp := list[i] | 383 | tmp := list[i] |
374 | - if tmp.Check > obj.Check { | 384 | + if tmp.Check > 0 && checkPermissionWeight(obj.Check, tmp.Check) { |
375 | obj.Check = tmp.Check | 385 | obj.Check = tmp.Check |
376 | } | 386 | } |
377 | if _, ok := obj.CheckMap[tmp.Check]; !ok { //所有的check都加进来 | 387 | if _, ok := obj.CheckMap[tmp.Check]; !ok { //所有的check都加进来 |
@@ -397,3 +407,15 @@ func getPermissionMap(list []OptionOpportunity) (map[string]PermissionOptionObje | @@ -397,3 +407,15 @@ func getPermissionMap(list []OptionOpportunity) (map[string]PermissionOptionObje | ||
397 | objMap[M_SYSTEM_OPPORTUNITY] = obj | 407 | objMap[M_SYSTEM_OPPORTUNITY] = obj |
398 | return objMap, nil | 408 | return objMap, nil |
399 | } | 409 | } |
410 | + | ||
411 | +//@return true:比当前权限更大 false:比当前权限小 | ||
412 | +func checkPermissionWeight(oldCheck, newCheck int) bool { | ||
413 | + var ow, nw int | ||
414 | + if v, ok := PermissionWeight[oldCheck]; ok { | ||
415 | + ow = v | ||
416 | + } | ||
417 | + if v, ok := PermissionWeight[newCheck]; ok { | ||
418 | + nw = v | ||
419 | + } | ||
420 | + return nw > ow | ||
421 | +} |
@@ -357,7 +357,9 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | @@ -357,7 +357,9 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | ||
357 | mapProcess["EnableStatus"] = int8(1) | 357 | mapProcess["EnableStatus"] = int8(1) |
358 | mapChance["Type"] = request.Type | 358 | mapChance["Type"] = request.Type |
359 | mapChance["ReserveTypeId"] = request.ReserveTypeId | 359 | mapChance["ReserveTypeId"] = request.ReserveTypeId |
360 | - mapChance["SelfChecks"] = common.AssertJson(request.SelfChecks) | 360 | + if len(request.SelfChecks) > 0 { |
361 | + mapChance["SelfChecks"] = common.AssertJson(request.SelfChecks) | ||
362 | + } | ||
361 | } | 363 | } |
362 | } | 364 | } |
363 | log.Info(fmt.Sprintf("用户:%v 提交审核 机会编号:%v 审批流编号:%v 审批状态:%v", header.UserId, chance.Id, process.Id, request.ReviewStatus)) | 365 | log.Info(fmt.Sprintf("用户:%v 提交审核 机会编号:%v 审批流编号:%v 审批状态:%v", header.UserId, chance.Id, process.Id, request.ReviewStatus)) |
@@ -538,7 +540,9 @@ func ConverTypeToReviewStaus(approveType int) (reviewStatus int) { | @@ -538,7 +540,9 @@ func ConverTypeToReviewStaus(approveType int) (reviewStatus int) { | ||
538 | func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance) (rsp *protocol.ChanceApproveProcessResponse, err error) { | 540 | func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance) (rsp *protocol.ChanceApproveProcessResponse, err error) { |
539 | var ( | 541 | var ( |
540 | processList []*models.AuditFlowProcess | 542 | processList []*models.AuditFlowProcess |
543 | + config *protocol.AuditConfig | ||
541 | ) | 544 | ) |
545 | + utils.JsonUnmarshal(chance.AuditTemplateConfig, &config) | ||
542 | if processList, err = models.GetAuditFlowProcessList(chance.Id); err != nil { | 546 | if processList, err = models.GetAuditFlowProcessList(chance.Id); err != nil { |
543 | log.Error(fmt.Sprintf("chance_id :%v 未查询到审核流信息", chance.Id), err) | 547 | log.Error(fmt.Sprintf("chance_id :%v 未查询到审核流信息", chance.Id), err) |
544 | if err == orm.ErrNoRows { | 548 | if err == orm.ErrNoRows { |
@@ -590,9 +594,10 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance) | @@ -590,9 +594,10 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance) | ||
590 | } | 594 | } |
591 | if process.ReviewStatus == protocol.ReviewStatusAuditging && process.Uid == header.UserId { | 595 | if process.ReviewStatus == protocol.ReviewStatusAuditging && process.Uid == header.UserId { |
592 | rsp.ApproveAccess = &protocol.ApproveAccess{ | 596 | rsp.ApproveAccess = &protocol.ApproveAccess{ |
593 | - AllowApprove: 1, | ||
594 | - AllowReject: 1, | ||
595 | - ProcessId: process.Id, | 597 | + AllowApprove: 1, |
598 | + AllowReject: 1, | ||
599 | + SelfCheckNeed: config.GetSelfCheckNeed(), | ||
600 | + ProcessId: process.Id, | ||
596 | } | 601 | } |
597 | } | 602 | } |
598 | } | 603 | } |
@@ -270,14 +270,20 @@ func Templates(header *protocol.RequestHeader, request *protocol.TemplatesReques | @@ -270,14 +270,20 @@ func Templates(header *protocol.RequestHeader, request *protocol.TemplatesReques | ||
270 | } | 270 | } |
271 | for j := range forms { | 271 | for j := range forms { |
272 | form := forms[j] | 272 | form := forms[j] |
273 | - template.FormList[j] = &protocol.Form{ | 273 | + formItem := &protocol.Form{ |
274 | Id: form.Id, | 274 | Id: form.Id, |
275 | Label: form.Label, | 275 | Label: form.Label, |
276 | Value: "", | 276 | Value: "", |
277 | InputType: form.InputType, | 277 | InputType: form.InputType, |
278 | SectionType: form.Section, | 278 | SectionType: form.Section, |
279 | Required: form.Required, | 279 | Required: form.Required, |
280 | + Data: make([]*protocol.FormDataItem, 0), | ||
281 | + ValueList: make([]*protocol.ValueListItem, 0), | ||
280 | } | 282 | } |
283 | + if len(form.ValueList) > 0 && form.InputType == protocol.InputRadio { | ||
284 | + utils.JsonUnmarshal(form.ValueList, &formItem.ValueList) | ||
285 | + } | ||
286 | + template.FormList[j] = formItem | ||
281 | } | 287 | } |
282 | rsp.Templates = append(rsp.Templates, template) | 288 | rsp.Templates = append(rsp.Templates, template) |
283 | } | 289 | } |
@@ -291,6 +297,7 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) | @@ -291,6 +297,7 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) | ||
291 | forms []*models.AuditForm | 297 | forms []*models.AuditForm |
292 | chance *models.Chance | 298 | chance *models.Chance |
293 | chanceDraft *models.ChanceDraft | 299 | chanceDraft *models.ChanceDraft |
300 | + formData []*protocol.Form | ||
294 | ) | 301 | ) |
295 | rsp = &protocol.TemplateResponse{} | 302 | rsp = &protocol.TemplateResponse{} |
296 | if templates, err = models.GetAuditTemplate(header.CompanyId, request.ChanceTypeId, request.TemplateId); err != nil { | 303 | if templates, err = models.GetAuditTemplate(header.CompanyId, request.ChanceTypeId, request.TemplateId); err != nil { |
@@ -331,9 +338,11 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) | @@ -331,9 +338,11 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) | ||
331 | if chanceDraft, err = models.GetChanceDraftById(request.ChanceId); err == nil { | 338 | if chanceDraft, err = models.GetChanceDraftById(request.ChanceId); err == nil { |
332 | var old []protocol.SelfCheck | 339 | var old []protocol.SelfCheck |
333 | utils.JsonUnmarshal(chanceDraft.SelfChecks, &old) | 340 | utils.JsonUnmarshal(chanceDraft.SelfChecks, &old) |
341 | + utils.JsonUnmarshal(chanceDraft.SourceContent, &formData) | ||
334 | template.Questions = GetNewestCheckQuestions(chanceDraft.AuditTemplateId, old) | 342 | template.Questions = GetNewestCheckQuestions(chanceDraft.AuditTemplateId, old) |
335 | } | 343 | } |
336 | } else { //正常机会 | 344 | } else { //正常机会 |
345 | + utils.JsonUnmarshal(chance.SourceContent, &formData) | ||
337 | if template.Questions, err = agg.GetCheckQuestionsByChanceId(header, request.ChanceId); err != nil { | 346 | if template.Questions, err = agg.GetCheckQuestionsByChanceId(header, request.ChanceId); err != nil { |
338 | log.Error(err) | 347 | log.Error(err) |
339 | return | 348 | return |
@@ -347,14 +356,33 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) | @@ -347,14 +356,33 @@ func Template(header *protocol.RequestHeader, request *protocol.TemplateRequest) | ||
347 | } | 356 | } |
348 | for j := range forms { | 357 | for j := range forms { |
349 | form := forms[j] | 358 | form := forms[j] |
350 | - template.FormList[j] = &protocol.Form{ | 359 | + formItem := &protocol.Form{ |
351 | Id: form.Id, | 360 | Id: form.Id, |
352 | Label: form.Label, | 361 | Label: form.Label, |
353 | Value: "", | 362 | Value: "", |
354 | InputType: form.InputType, | 363 | InputType: form.InputType, |
355 | SectionType: form.Section, | 364 | SectionType: form.Section, |
356 | Required: form.Required, | 365 | Required: form.Required, |
366 | + Data: make([]*protocol.FormDataItem, 0), | ||
367 | + ValueList: make([]*protocol.ValueListItem, 0), | ||
368 | + } | ||
369 | + if len(form.ValueList) > 0 && form.InputType == protocol.InputRadio { | ||
370 | + utils.JsonUnmarshal(form.ValueList, &formItem.ValueList) | ||
371 | + } | ||
372 | + //填充旧的表单数据 | ||
373 | + setOldForm := func() { | ||
374 | + for i := range formData { | ||
375 | + data := formData[i] | ||
376 | + if data.Id == formItem.Id && strings.EqualFold(data.Label, data.Label) { | ||
377 | + formItem.Value = data.Value | ||
378 | + formItem.Data = data.Data | ||
379 | + } | ||
380 | + } | ||
357 | } | 381 | } |
382 | + if request.ChanceId > 0 { | ||
383 | + setOldForm() | ||
384 | + } | ||
385 | + template.FormList[j] = formItem | ||
358 | } | 386 | } |
359 | rsp.Template = template | 387 | rsp.Template = template |
360 | return | 388 | return |
@@ -432,7 +460,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -432,7 +460,7 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
432 | err = protocol.NewErrWithMessage(5302) | 460 | err = protocol.NewErrWithMessage(5302) |
433 | return | 461 | return |
434 | } | 462 | } |
435 | - auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover} | 463 | + auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover, SelfCheckNeed: template.SelfCheckNeed} |
436 | orm := orm.NewOrm() | 464 | orm := orm.NewOrm() |
437 | orm.Begin() | 465 | orm.Begin() |
438 | //2.检查模板是否有权限 | 466 | //2.检查模板是否有权限 |
@@ -648,7 +676,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate | @@ -648,7 +676,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate | ||
648 | err = protocol.NewErrWithMessage(5301) | 676 | err = protocol.NewErrWithMessage(5301) |
649 | return | 677 | return |
650 | } | 678 | } |
651 | - auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover} | 679 | + auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover, SelfCheckNeed: template.SelfCheckNeed} |
652 | 680 | ||
653 | CheckChanceDifferent(header, chance, request) | 681 | CheckChanceDifferent(header, chance, request) |
654 | 682 | ||
@@ -791,11 +819,6 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate | @@ -791,11 +819,6 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceUpdate | ||
791 | 819 | ||
792 | //检查机会更新 | 820 | //检查机会更新 |
793 | func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, request *protocol.ChanceUpdateRequest) { | 821 | func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, request *protocol.ChanceUpdateRequest) { |
794 | - var ( | ||
795 | - isSaveLog bool = false | ||
796 | - chanceReviseLog *models.ChanceReviseLog | ||
797 | - message string | ||
798 | - ) | ||
799 | defer func() { | 822 | defer func() { |
800 | if p := recover(); p != nil { | 823 | if p := recover(); p != nil { |
801 | log.Error(p) | 824 | log.Error(p) |
@@ -804,52 +827,80 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, | @@ -804,52 +827,80 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, | ||
804 | if header.UserId == chance.UserId { | 827 | if header.UserId == chance.UserId { |
805 | return | 828 | return |
806 | } | 829 | } |
830 | + //机会是审核通过的才有编辑记录!! | ||
807 | if chance.ReviewStatus != protocol.ReviewStatusPass { | 831 | if chance.ReviewStatus != protocol.ReviewStatusPass { |
808 | return | 832 | return |
809 | } | 833 | } |
810 | - var modifyLog = protocol.ChanceReviseLog{ | ||
811 | - RemoveAllPhotoVideo: false, | ||
812 | - RemoveAllSpeech: false, | ||
813 | - } | ||
814 | - checkIsSaveLog := func() { | 834 | + |
835 | + var ( | ||
836 | + isSaveLog bool = false | ||
837 | + modifyLog = protocol.ChanceReviseLog{ | ||
838 | + RemoveAllPhotoVideo: false, | ||
839 | + RemoveAllSpeech: false, | ||
840 | + } | ||
841 | + ) | ||
842 | + funcCheckSave := func() { | ||
815 | if !isSaveLog { | 843 | if !isSaveLog { |
816 | isSaveLog = true | 844 | isSaveLog = true |
817 | } | 845 | } |
818 | } | 846 | } |
819 | - | ||
820 | - diffFormList := func(source string, dis []*protocol.Form) { | 847 | + funcDiffForms := func(source string, src []*protocol.Form) { |
821 | var ( | 848 | var ( |
822 | - src []*protocol.Form | ||
823 | - mapForm map[string]*protocol.Form = make(map[string]*protocol.Form) | 849 | + dst []*protocol.Form |
850 | + mapForm = make(map[string]*protocol.Form) | ||
824 | reviseContents []protocol.ReviseContent | 851 | reviseContents []protocol.ReviseContent |
825 | ) | 852 | ) |
826 | - jsonUnmarshal(source, &src) | ||
827 | - keyFunc := func(form *protocol.Form) string { | 853 | + utils.JsonUnmarshal(source, &dst) |
854 | + funcKey := func(form *protocol.Form) string { | ||
828 | return fmt.Sprintf("%v_%v", form.Label, form.SectionType) | 855 | return fmt.Sprintf("%v_%v", form.Label, form.SectionType) |
829 | } | 856 | } |
830 | - for i := range src { | ||
831 | - mapForm[keyFunc(src[i])] = src[i] | 857 | + for i := range dst { |
858 | + mapForm[funcKey(dst[i])] = dst[i] | ||
832 | } | 859 | } |
833 | - for i := range dis { | ||
834 | - isDiff := false | ||
835 | - srcValue := "" | ||
836 | - if v, ok := mapForm[keyFunc(dis[i])]; ok { | 860 | + for i := range src { |
861 | + var ( | ||
862 | + isDiff = false | ||
863 | + oldForm *protocol.Form | ||
864 | + srcValue = "" | ||
865 | + ) | ||
866 | + | ||
867 | + if v, ok := mapForm[funcKey(src[i])]; ok { | ||
837 | srcValue = v.Value | 868 | srcValue = v.Value |
838 | - if dis[i].Value != v.Value { | 869 | + if src[i].Value != v.Value { |
839 | isDiff = true | 870 | isDiff = true |
840 | } | 871 | } |
872 | + if len(src[i].Data) > 0 || len(v.Data) > 0 { | ||
873 | + if !reflect.DeepEqual(src[i].Data, v.Data) { | ||
874 | + isDiff = true | ||
875 | + } | ||
876 | + } | ||
877 | + oldForm = v | ||
841 | } else { | 878 | } else { |
842 | isDiff = true | 879 | isDiff = true |
843 | } | 880 | } |
881 | + | ||
844 | if isDiff { | 882 | if isDiff { |
845 | - reviseContents = append(reviseContents, protocol.ReviseContent{ | ||
846 | - Content: fmt.Sprintf("将“%v”由“%v”改为 “%v”", dis[i].Label, srcValue, dis[i].Value)}) | ||
847 | - checkIsSaveLog() | 883 | + c := protocol.ReviseContent{ |
884 | + Content: fmt.Sprintf("将“%v”由“%v”改为“%v”", src[i].Label, srcValue, src[i].Value), | ||
885 | + Label: src[i].Label, | ||
886 | + InputType: src[i].InputType, | ||
887 | + Data: src[i].Data, | ||
888 | + } | ||
889 | + | ||
890 | + //文件表单 | ||
891 | + if src[i].InputType == protocol.InputFiles { | ||
892 | + if oldForm != nil && len(oldForm.Data) > 0 && len(src[i].Data) == 0 { | ||
893 | + c.RemoveAllPhotoVideo = true | ||
894 | + } | ||
895 | + c.Content = fmt.Sprintf("将%v修改为:", src[i].Label) | ||
896 | + } | ||
897 | + reviseContents = append(reviseContents, c) | ||
898 | + funcCheckSave() | ||
848 | } | 899 | } |
849 | } | 900 | } |
850 | modifyLog.DiffContents = reviseContents | 901 | modifyLog.DiffContents = reviseContents |
851 | } | 902 | } |
852 | - diffChanceData := func() { | 903 | + funcDiffChanceData := func() { |
853 | var ( | 904 | var ( |
854 | speechs []protocol.Speech | 905 | speechs []protocol.Speech |
855 | pictures []protocol.Picture | 906 | pictures []protocol.Picture |
@@ -860,12 +911,12 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, | @@ -860,12 +911,12 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, | ||
860 | jsonUnmarshal(chanceData.Images, &pictures) | 911 | jsonUnmarshal(chanceData.Images, &pictures) |
861 | jsonUnmarshal(chanceData.Videos, &videos) | 912 | jsonUnmarshal(chanceData.Videos, &videos) |
862 | if !reflect.DeepEqual(request.Videos, videos) || !reflect.DeepEqual(request.Pictures, pictures) { | 913 | if !reflect.DeepEqual(request.Videos, videos) || !reflect.DeepEqual(request.Pictures, pictures) { |
863 | - checkIsSaveLog() | 914 | + funcCheckSave() |
864 | modifyLog.Videos = request.Videos | 915 | modifyLog.Videos = request.Videos |
865 | modifyLog.Pictures = request.Pictures | 916 | modifyLog.Pictures = request.Pictures |
866 | } | 917 | } |
867 | if !reflect.DeepEqual(request.Speechs, speechs) { | 918 | if !reflect.DeepEqual(request.Speechs, speechs) { |
868 | - checkIsSaveLog() | 919 | + funcCheckSave() |
869 | modifyLog.Speechs = request.Speechs | 920 | modifyLog.Speechs = request.Speechs |
870 | } | 921 | } |
871 | 922 | ||
@@ -882,16 +933,13 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, | @@ -882,16 +933,13 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, | ||
882 | modifyLog.RemoveAllSpeech = true | 933 | modifyLog.RemoveAllSpeech = true |
883 | } | 934 | } |
884 | } else { | 935 | } else { |
885 | - checkIsSaveLog() | 936 | + funcCheckSave() |
886 | modifyLog.Speechs = request.Speechs | 937 | modifyLog.Speechs = request.Speechs |
887 | modifyLog.Videos = request.Videos | 938 | modifyLog.Videos = request.Videos |
888 | modifyLog.Speechs = request.Speechs | 939 | modifyLog.Speechs = request.Speechs |
889 | } | 940 | } |
890 | } | 941 | } |
891 | - | ||
892 | - diffFormList(chance.SourceContent, request.FormList) | ||
893 | - diffChanceData() | ||
894 | - checkModifyLog := func() { | 942 | + funcFormatEmpty := func() { |
895 | if len(modifyLog.Speechs) == 0 { | 943 | if len(modifyLog.Speechs) == 0 { |
896 | modifyLog.Speechs = make([]protocol.Speech, 0) | 944 | modifyLog.Speechs = make([]protocol.Speech, 0) |
897 | } | 945 | } |
@@ -905,51 +953,64 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, | @@ -905,51 +953,64 @@ func CheckChanceDifferent(header *protocol.RequestHeader, chance *models.Chance, | ||
905 | modifyLog.DiffContents = make([]protocol.ReviseContent, 0) | 953 | modifyLog.DiffContents = make([]protocol.ReviseContent, 0) |
906 | } | 954 | } |
907 | } | 955 | } |
908 | - checkModifyLog() | ||
909 | - if isSaveLog { //&& changeCount > 0 | ||
910 | - orm := orm.NewOrm() | ||
911 | - orm.Begin() | ||
912 | - var logId int64 | ||
913 | - //发送日志 | ||
914 | - if id, err := agg.SaveApproveLogResult(orm, 10, header.UserId, chance.Id); err != nil { | ||
915 | - log.Error(err) | ||
916 | - orm.Rollback() | ||
917 | - return | ||
918 | - } else { | ||
919 | - logId = id | ||
920 | - } | ||
921 | - //保存修改详情 | ||
922 | - chanceReviseLog = &models.ChanceReviseLog{ | ||
923 | - Id: idgen.Next(), | ||
924 | - ChanceId: chance.Id, | ||
925 | - UserCompanyId: header.UserId, | ||
926 | - Data: common.AssertJson(modifyLog), | ||
927 | - CreateAt: time.Now(), | ||
928 | - AuditFlowLogId: logId, | ||
929 | - } | ||
930 | - if _, e := orm.Insert(chanceReviseLog); e != nil { | ||
931 | - log.Error(e) | ||
932 | - orm.Rollback() | ||
933 | - return | ||
934 | - } | ||
935 | - if chanceType, err := models.GetChanceTypeById(chance.ChanceTypeId); err != nil { | ||
936 | - log.Error(err) | ||
937 | - orm.Rollback() | ||
938 | - return | ||
939 | - } else { | ||
940 | - message = fmt.Sprintf(protocol.MessageChanceRevise, chanceType.Name) | ||
941 | - } | ||
942 | - //发送修改机会消息 | ||
943 | - if err := agg.SendMsgWithHeader(header, chance.UserId, "", chanceReviseLog.Id, protocol.SourceTypeChanceReviseLog, message, protocol.MsgTypeChanceRevise, chance.Id); err != nil { | ||
944 | - log.Error(err) | ||
945 | - orm.Rollback() | ||
946 | - return | ||
947 | - } | ||
948 | 956 | ||
949 | - orm.Commit() | 957 | + funcDiffForms(chance.SourceContent, request.FormList) //比对表单 |
958 | + funcDiffChanceData() //比对机会数据 | ||
959 | + funcFormatEmpty() //格式化变更日志 | ||
960 | + if isSaveLog { | ||
961 | + _ = SaveChanceReviseLog(header, chance, modifyLog) | ||
950 | } | 962 | } |
951 | } | 963 | } |
952 | 964 | ||
965 | +//保存机会变更日志 | ||
966 | +func SaveChanceReviseLog(header *protocol.RequestHeader, chance *models.Chance, modifyLog protocol.ChanceReviseLog) (err error) { | ||
967 | + var ( | ||
968 | + chanceReviseLog *models.ChanceReviseLog | ||
969 | + message string | ||
970 | + ) | ||
971 | + orm := orm.NewOrm() | ||
972 | + orm.Begin() | ||
973 | + var logId, id int64 | ||
974 | + //发送日志 | ||
975 | + if id, err = agg.SaveApproveLogResult(orm, 10, header.UserId, chance.Id); err != nil { | ||
976 | + log.Error(err) | ||
977 | + orm.Rollback() | ||
978 | + return | ||
979 | + } else { | ||
980 | + logId = id | ||
981 | + } | ||
982 | + //保存修改详情 | ||
983 | + chanceReviseLog = &models.ChanceReviseLog{ | ||
984 | + Id: idgen.Next(), | ||
985 | + ChanceId: chance.Id, | ||
986 | + UserCompanyId: header.UserId, | ||
987 | + Data: common.AssertJson(modifyLog), | ||
988 | + CreateAt: time.Now(), | ||
989 | + AuditFlowLogId: logId, | ||
990 | + } | ||
991 | + if _, e := orm.Insert(chanceReviseLog); e != nil { | ||
992 | + log.Error(e) | ||
993 | + orm.Rollback() | ||
994 | + return | ||
995 | + } | ||
996 | + if chanceType, e := models.GetChanceTypeById(chance.ChanceTypeId); e != nil { | ||
997 | + log.Error(e) | ||
998 | + err = e | ||
999 | + orm.Rollback() | ||
1000 | + return | ||
1001 | + } else { | ||
1002 | + message = fmt.Sprintf(protocol.MessageChanceRevise, chanceType.Name) | ||
1003 | + } | ||
1004 | + //发送修改机会消息 | ||
1005 | + if err = agg.SendMsgWithHeader(header, chance.UserId, "", chanceReviseLog.Id, protocol.SourceTypeChanceReviseLog, message, protocol.MsgTypeChanceRevise, chance.Id); err != nil { | ||
1006 | + log.Error(err) | ||
1007 | + orm.Rollback() | ||
1008 | + return | ||
1009 | + } | ||
1010 | + orm.Commit() | ||
1011 | + return | ||
1012 | +} | ||
1013 | + | ||
953 | //修改公开状态 | 1014 | //修改公开状态 |
954 | func ChanceChangePublish(header *protocol.RequestHeader, request *protocol.ChanceChangePublishRequest) (rsp *protocol.ChanceChangePublishResponse, err error) { | 1015 | func ChanceChangePublish(header *protocol.RequestHeader, request *protocol.ChanceChangePublishRequest) (rsp *protocol.ChanceChangePublishResponse, err error) { |
955 | var ( | 1016 | var ( |
@@ -1590,7 +1651,9 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ | @@ -1590,7 +1651,9 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ | ||
1590 | provider *protocol.BaseUserInfo | 1651 | provider *protocol.BaseUserInfo |
1591 | flag int | 1652 | flag int |
1592 | ) | 1653 | ) |
1593 | - if total, err = agg.GetChancePool(header.UserId, header.CompanyId, models.NewChancePoolOption(request.ChanceTypeId, []int{}, request.Type, request.ReserveTypeId), request.DepartmentId, request.IncludeSubDepartment, request.LastId, request.PageSize, &chanceItems); err != nil { | 1654 | + options := models.NewChancePoolOption(request.ChanceTypeId, []int{}, request.Type, request.ReserveTypeId) |
1655 | + options.SetKeyWord(request.KeyWord) | ||
1656 | + if total, err = agg.GetChancePool(header.UserId, header.CompanyId, options, request.DepartmentId, request.IncludeSubDepartment, request.LastId, request.PageSize, &chanceItems); err != nil { | ||
1594 | if err == orm.ErrNoRows { | 1657 | if err == orm.ErrNoRows { |
1595 | err = nil | 1658 | err = nil |
1596 | return | 1659 | return |
@@ -1615,10 +1678,11 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ | @@ -1615,10 +1678,11 @@ func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequ | ||
1615 | CreateTime: chance.CreateTime.Unix() * 1000, | 1678 | CreateTime: chance.CreateTime.Unix() * 1000, |
1616 | } | 1679 | } |
1617 | jsonUnmarshal(chance.SourceContent, &item.FormList) | 1680 | jsonUnmarshal(chance.SourceContent, &item.FormList) |
1618 | - item.FormList = clearEmptyForm(item.FormList) | ||
1619 | jsonUnmarshal(chance.Images, &item.Pictures) | 1681 | jsonUnmarshal(chance.Images, &item.Pictures) |
1620 | jsonUnmarshal(chance.Voices, &item.Speechs) | 1682 | jsonUnmarshal(chance.Voices, &item.Speechs) |
1621 | jsonUnmarshal(chance.Videos, &item.Videos) | 1683 | jsonUnmarshal(chance.Videos, &item.Videos) |
1684 | + item.Pictures, item.Videos = agg.CombineAllFiles(item.FormList, item.Pictures, item.Videos) | ||
1685 | + item.FormList = agg.FormFilter(item.FormList, agg.ClearEmptyForm, agg.ClearFilesForm) | ||
1622 | commItem.Chance = item | 1686 | commItem.Chance = item |
1623 | 1687 | ||
1624 | //点赞评论数据 | 1688 | //点赞评论数据 |
@@ -1953,7 +2017,7 @@ func clearEmptyForm(inputFormList []*protocol.Form) (FormList []*protocol.Form) | @@ -1953,7 +2017,7 @@ func clearEmptyForm(inputFormList []*protocol.Form) (FormList []*protocol.Form) | ||
1953 | } | 2017 | } |
1954 | for i := range inputFormList { | 2018 | for i := range inputFormList { |
1955 | item := inputFormList[i] | 2019 | item := inputFormList[i] |
1956 | - if len(item.Value) > 0 { | 2020 | + if len(item.Value) > 0 || len(item.Data) > 0 { |
1957 | FormList = append(FormList, item) | 2021 | FormList = append(FormList, item) |
1958 | } | 2022 | } |
1959 | } | 2023 | } |
@@ -2018,7 +2082,6 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail | @@ -2018,7 +2082,6 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail | ||
2018 | UpdateTime: chance.UpdateAt.Unix() * 1000, | 2082 | UpdateTime: chance.UpdateAt.Unix() * 1000, |
2019 | } | 2083 | } |
2020 | jsonUnmarshal(chance.SourceContent, &item.FormList) | 2084 | jsonUnmarshal(chance.SourceContent, &item.FormList) |
2021 | - //jsonUnmarshal(chance.SelfChecks, &item.SelfChecks) | ||
2022 | item.SelfChecks = agg.GetChanceSelfChecks(chance) | 2085 | item.SelfChecks = agg.GetChanceSelfChecks(chance) |
2023 | item.FormList = clearEmptyForm(item.FormList) | 2086 | item.FormList = clearEmptyForm(item.FormList) |
2024 | item.RelatedDepartmentId = chance.DepartmentId | 2087 | item.RelatedDepartmentId = chance.DepartmentId |
@@ -2102,7 +2165,6 @@ func ChanceDraftDetail(header *protocol.RequestHeader, request *protocol.ChanceD | @@ -2102,7 +2165,6 @@ func ChanceDraftDetail(header *protocol.RequestHeader, request *protocol.ChanceD | ||
2102 | item.RelatedDepartmentInfo = agg.GetDepartment(int(chance.DepartmentId)) | 2165 | item.RelatedDepartmentInfo = agg.GetDepartment(int(chance.DepartmentId)) |
2103 | jsonUnmarshal(chance.SourceContent, &item.FormList) | 2166 | jsonUnmarshal(chance.SourceContent, &item.FormList) |
2104 | jsonUnmarshal(chance.SelfChecks, &item.SelfChecks) | 2167 | jsonUnmarshal(chance.SelfChecks, &item.SelfChecks) |
2105 | - item.FormList = clearEmptyForm(item.FormList) | ||
2106 | 2168 | ||
2107 | if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil { | 2169 | if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil { |
2108 | if len(chanceData.Videos) > 0 { | 2170 | if len(chanceData.Videos) > 0 { |
-
请 注册 或 登录 后发表评论