作者 tangxvhui

版本 15改动

... ... @@ -15,7 +15,7 @@ type AuditForm struct {
SortNum int `orm:"column(sort_num)" description:"排序"`
Label string `orm:"column(label);size(100)" description:"标题"`
InputType string `orm:"column(input_type);size(50)" description:"输入类型 text"`
ValueList string `orm:"column(value_list);size(255)" description:"可选值列表"`
ValueList string `orm:"column(value_list);size(255)" description:"可选值列表json结构字符串"`
Required int8 `orm:"column(required)" description:"是否必填:【0:否】【1:是】"`
CurrentValue string `orm:"column(current_value);size(255)" description:"实际填写的值"`
Disable int8 `orm:"column(disable);null" description:"显示隐藏:【0:显示】【1:隐藏】"`
... ... @@ -34,6 +34,12 @@ func init() {
orm.RegisterModel(new(AuditForm))
}
//AuditFormValueList 表audit_form中字段value_list的结构
type AuditFormValueList struct {
Value string `json:"value"`
Type string `json:"type"` //输入的数据内容类型
}
var (
DeleteAuditFormBy = `delete FROM audit_form where audit_template_id=? and company_id=?`
)
... ...
... ... @@ -25,6 +25,7 @@ type AuditTemplate struct {
UpdateAt time.Time `orm:"column(update_at);type(timestamp)" description:"更新时间"`
Example string `orm:"column(example);null" description:"示例"`
Videos string `orm:"column(videos);null" description:"示例"`
SelfCheckNeed int8 `orm:"column(self_check_need)" description:"是否需要自查内容"`
}
const (
... ... @@ -37,6 +38,12 @@ const (
VisibleObject_Department = 1
)
// SelfCheckNeed 是否需要自查内容
const (
AuditSelfCheckNeedYes int8 = 1 //需要
AuditSelfCheckNeedNo int8 = 2 //不需要
)
func (t *AuditTemplate) TableName() string {
return "audit_template"
}
... ...
... ... @@ -85,7 +85,7 @@ func (t *Department) GetManages() []protocol.DepartmentManager {
return managesdata
}
func (t *Department) GetMembers() []protocol.DepartmentMember {
func (t *Department) GetMembers() []User {
ids, err := GetUserDepartmentIds(int(t.CompanyId), int(t.Id))
if err != nil {
log.Error(err.Error())
... ... @@ -96,14 +96,7 @@ func (t *Department) GetMembers() []protocol.DepartmentMember {
log.Error("GetUserNameByIds err :%s", err)
return nil
}
managesdata := []protocol.DepartmentMember{}
for _, v := range users {
m := protocol.DepartmentMember{
Id: v.Id, Name: v.NickName,
}
managesdata = append(managesdata, m)
}
return managesdata
return users
}
func (t *Department) IsTopDepartment() bool {
... ...
... ... @@ -6,23 +6,54 @@ import (
//输入框类型
const (
inputTypeCheck string = "check-box" //多选宽
inputTypeText string = "text" //单行文本宽
InputTypeRedio string = "redio" //单选框
InputTypeText string = "text" //单行文本宽
InputTypeRadio string = "radio" //单选框
InputImageVedio string = "image/vedio" // 图片或视频输入
)
//输入框输入的数据类型
const (
InputDataTypeText string = "text" //单纯文本
InputDataTypeImage string = "image" //图片的文件url
InputDataTypeVedio string = "vedio" //视频的文件url
)
var (
InputDataTypeMap map[string]bool = map[string]bool{
InputDataTypeText: true,
InputDataTypeImage: true,
InputDataTypeVedio: true,
}
InputTypeMap map[string]bool = map[string]bool{
InputTypeText: true,
InputTypeRadio: true,
InputImageVedio: true,
}
)
type InputElementData struct {
Value string `json:"value"` //输入框填写的值
Type string `json:"type"` //输入数据内容的类型
Path string `json:"path,omitempy"`
Cover map[string]interface{} `json:"cover,omitempy"`
}
type InputElementValueList struct {
Value string `json:"value"`
Type string `json:"type"` //输入的数据内容类型
}
//InputElement 自定义表单项
type InputElement struct {
Id int `json:"id"`
Sort int `json:"sort"` //排序
Label string `json:"label"` //标题
InputType string `json:"inputType"` //输入类型
Required int `json:"required"` //是否必填
CurrentValue string `json:"value"` //"当前填写的值"
SectionType int8 `json:"sectionType"`
// ValueList string `json:"-"` //输入候选值 value_list
// Placeholder string `json:"-"` //帮助用户填写输入字段的提示 Placeholder
// Disable bool `json:"-"` //"显示隐藏",
Id int `json:"id"`
Sort int `json:"sort"` //排序
Label string `json:"label"` //标题
InputType string `json:"inputType"` //输入类型
Required int `json:"required"` //是否必填
CurrentValue string `json:"value"` //"当前填写的值"
SectionType int8 `json:"sectionType"`
ValueList []InputElementValueList `json:"valueList,omitempy"` //输入候选值 value_list
Data []InputElementData `json:"data,omitempy"`
}
//自定义表单
... ... @@ -39,44 +70,6 @@ func (a CustomForm) Less(i, j int) bool {
return a[i].Sort < a[j].Sort
}
//IValidateInput 自定义输入项校验接口
type IValidateInput interface {
ValidateInput() error //校验当前输入值
ValidateConfig() error //校验自定义的输入项设置
}
type ValidateInputText struct {
InputElement
}
var (
_ IValidateInput = ValidateInputText{}
)
func (input ValidateInputText) ValidateInput() error {
return nil
}
func (input ValidateInputText) ValidateConfig() error {
return nil
}
//ValidateInputRedio 单选项校验
type ValidateInputRedio struct {
InputElement
}
var (
_ IValidateInput = ValidateInputRedio{}
)
func (input ValidateInputRedio) ValidateInput() error {
return nil
}
func (input ValidateInputRedio) ValidateConfig() error {
return nil
}
/***********审核模板管理**********/
/*TemplateAdd */
... ... @@ -111,6 +104,7 @@ type Template struct {
type AuditFlowConfig struct {
NoApprover int `json:"noApprover" valid:"Required;"` //审核人为空【1:自动通过】【2:转交给管理员】
ProcessConfig []ProcessConfig `json:"processConfig"` //创建时 0
SelfCheckNeed int `json:"self_check_need"` //是否需要自查内容【1:需要】【2:不需要】
}
type ProcessConfig struct {
ApproveType int `json:"approveType"` //1.部门长 2 指定成员 3.指定角色
... ...
... ... @@ -73,6 +73,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs
{
for i := range request.Template.InputList {
input := request.Template.InputList[i]
valueList, _ := json.Marshal(input.ValueList)
auditForm = &models.AuditForm{
CompanyId: int(companyId),
AuditTemplateId: int(templateId),
... ... @@ -83,6 +84,7 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs
Required: int8(input.Required),
CreateAt: time.Now(),
EnableStatus: 1,
ValueList: string(valueList),
}
if _, err = orm.Insert(auditForm); err != nil {
log.Error(err.Error())
... ... @@ -489,11 +491,14 @@ func TemplateUpdate(uid, companyId int64, request *protocol.TemplateUpdateReques
}
//更新 或 插入表单
//TODO 检查表单项类型是否被篡改
func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input *protocol.InputElement) (err error) {
var (
auditForm *models.AuditForm
)
valueList, _ := json.Marshal(input.ValueList)
if input.Id == 0 {
auditForm = &models.AuditForm{
CompanyId: int(companyId),
AuditTemplateId: int(templateId),
... ... @@ -504,6 +509,7 @@ func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input
Required: int8(input.Required),
CreateAt: time.Now(),
EnableStatus: 1,
ValueList: string(valueList),
}
if _, err = orm.Insert(auditForm); err != nil {
log.Error(err.Error())
... ... @@ -522,6 +528,7 @@ func insertOrUpdateInput(orm orm2.Ormer, companyId int64, templateId int, input
"InputType": input.InputType,
"Required": int8(input.Required),
"SortNum": input.Sort,
"ValueList": string(valueList),
}
if err = utils.UpdateTableByMapWithOrmer(orm, auditForm, updateMap); err != nil {
return
... ... @@ -701,14 +708,24 @@ func TemplateGet(uid, companyId int64, request *protocol.TemplateGetRequest) (rs
rsp.Template.InputList = make([]*protocol.InputElement, 0)
for i := range auditForm {
input := auditForm[i]
rsp.Template.InputList = append(rsp.Template.InputList, &protocol.InputElement{
var valuelist []models.AuditFormValueList
json.Unmarshal([]byte(input.ValueList), &valuelist)
inElement := &protocol.InputElement{
Id: input.Id,
Sort: input.SortNum,
Label: input.Label,
Required: int(input.Required),
SectionType: input.Section,
InputType: input.InputType,
})
}
for _, inputValue := range valuelist {
inElement.ValueList = append(inElement.ValueList, protocol.InputElementValueList{
Value: inputValue.Value,
Type: inputValue.Type,
})
}
rsp.Template.InputList = append(rsp.Template.InputList, inElement)
}
if configs, err = models.GetAuditFlowConfig(template.Id); err != nil {
log.Error("template:%v %v", template.Id, err.Error())
... ...
... ... @@ -118,13 +118,12 @@ func SelectorPosition(companyid int64) []protocol.PositionBase {
func SelectorUserAndDepartment(departid int64, companyId int64) (*protocol.DepartAndUser, error) {
var (
mDepart *models.Department
departsUser protocol.DepartAndUser
departbase []protocol.DepartmentBase
departMember []protocol.DepartmentMember
err error
where string
cond []interface{}
mDepart *models.Department
departsUser protocol.DepartAndUser
departbase []protocol.DepartmentBase
err error
where string
cond []interface{}
)
if departid > 0 {
mDepart, err = models.GetDepartmentById(departid)
... ... @@ -136,8 +135,13 @@ func SelectorUserAndDepartment(departid int64, companyId int64) (*protocol.Depar
log.Error("companyid err")
return nil, protocol.NewErrWithMessage("1")
}
departMember = mDepart.GetMembers()
departsUser.Members = departMember
departMember := mDepart.GetMembers()
for _, v := range departMember {
m := protocol.DepartmentMember{
Id: v.Id, Name: v.NickName,
}
departsUser.Members = append(departsUser.Members, m)
}
}
datasql0 := `SELECT id, company_id,name,parent_id ` +
` FROM department WHERE company_id = ? AND delete_at = 0 `
... ...
... ... @@ -361,7 +361,6 @@ func DepartmentListAll(companyId int64) ([]protocol.ResponseDepartmentInfo, erro
var manage []protocol.DepartmentManager
manage = v.GetManages()
depart.Manages = manage
// depart.Members = v.GetMembers()
departs = append(departs, depart)
}
... ...
... ... @@ -212,7 +212,6 @@ func RoleMenuEdit(companyid int64, roleId int64, menuids []int64) error {
//机会管理高级设置
func UpdateSetOpportunity(param OptionOpportunity, roleid int64, companyid int64) error {
var (
//code = M_SYSTEM_OPPORTUNITY
rolemenu *models.RoleMenu
roleInfo *models.Role
err error
... ...
... ... @@ -85,6 +85,7 @@ type CheckDeparment struct {
Wait int `json:"wait"`
OpenAll int `json:"open_all"`
OpenDepart int `json:"open_depart"`
NotPass int `json:"not_pass"`
}
//CheckOpp 特殊的查看条件设定
... ... @@ -111,6 +112,7 @@ type OptionOpportunity struct {
2:仅查看自己部门和公开机会:查看对自己所在部门公开的机会+公司公开的机会
3:特定部门的机会:选定部门提交的公司公开、部门公开的机会;>只选择部门
4:查看所有机会:查看所有部门的公开机会及部门公开机会;
5:查看指定部门的未通过的机会
*/
const (
OpportunityCheckLv1 int = 1
... ...