Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/opp into dev
正在显示
1 个修改的文件
包含
74 行增加
和
0 行删除
protocol/audit.go
0 → 100644
| 1 | +package protocol | ||
| 2 | + | ||
| 3 | +import "sort" | ||
| 4 | + | ||
| 5 | +//输入框类型 | ||
| 6 | +const ( | ||
| 7 | + inputTypeCheck string = "check-box" //多选宽 | ||
| 8 | + inputTypeText string = "text" //单行文本宽 | ||
| 9 | + InputTypeRedio string = "redio" //单选框 | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +//InputElement 自定义表单项 | ||
| 13 | +type InputElement struct { | ||
| 14 | + Sort int `json:"sort"` //排序 | ||
| 15 | + Lable string `json:"lable"` //标题 | ||
| 16 | + InputType string `json:"input_type"` //输入类型 | ||
| 17 | + ValueList string `json:"value_list"` //输入候选值 | ||
| 18 | + Required bool `json:"required"` //是否必填 | ||
| 19 | + Placeholder string `json:"Placeholder"` //帮助用户填写输入字段的提示 | ||
| 20 | + Disable bool `json:"disable ` //"显示隐藏", | ||
| 21 | + CurrentValue string `json:"current_value"` //"当前填写的值" | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +//自定义表单 | ||
| 25 | +type CustomForm []InputElement | ||
| 26 | + | ||
| 27 | +var ( | ||
| 28 | + _ sort.Interface = new(CustomForm) | ||
| 29 | +) | ||
| 30 | + | ||
| 31 | +//实现排序接口 | ||
| 32 | +func (a CustomForm) Len() int { return len(a) } | ||
| 33 | +func (a CustomForm) Swap(i, j int) { a[i], a[j] = a[j], a[i] } | ||
| 34 | +func (a CustomForm) Less(i, j int) bool { | ||
| 35 | + return a[i].Sort < a[j].Sort | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +//IValidateInput 自定义输入项校验接口 | ||
| 39 | +type IValidateInput interface { | ||
| 40 | + ValidateInput() error //校验当前输入值 | ||
| 41 | + ValidateConfig() error //校验自定义的输入项设置 | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | +type ValidateInputText struct { | ||
| 45 | + InputElement | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +var ( | ||
| 49 | + _ IValidateInput = ValidateInputText{} | ||
| 50 | +) | ||
| 51 | + | ||
| 52 | +func (input ValidateInputText) ValidateInput() error { | ||
| 53 | + return nil | ||
| 54 | +} | ||
| 55 | +func (input ValidateInputText) ValidateConfig() error { | ||
| 56 | + return nil | ||
| 57 | +} | ||
| 58 | + | ||
| 59 | +//ValidateInputRedio 单选项校验 | ||
| 60 | +type ValidateInputRedio struct { | ||
| 61 | + InputElement | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +var ( | ||
| 65 | + _ IValidateInput = ValidateInputRedio{} | ||
| 66 | +) | ||
| 67 | + | ||
| 68 | +func (input ValidateInputRedio) ValidateInput() error { | ||
| 69 | + return nil | ||
| 70 | +} | ||
| 71 | + | ||
| 72 | +func (input ValidateInputRedio) ValidateConfig() error { | ||
| 73 | + return nil | ||
| 74 | +} |
-
请 注册 或 登录 后发表评论