panel

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const StaticPath = "/static/application/server/resource"

StaticPath 静态文件路由地址

Variables

View Source
var ValidatorList = map[string]map[ActionType]map[string][]ValidatorItem{}

ValidatorList 待验证数据集合 表:操作类型:字段:[]规则

Functions

func ConvertModeToMap

func ConvertModeToMap(data any) map[string]any

ConvertModeToMap 转换model 为map格式

func InitializeTemplateFun

func InitializeTemplateFun() template.FuncMap

InitializeTemplateFun 定义模板方法

Types

type ActionType

type ActionType int

ActionType 操作类型

const (
	DataAdd ActionType = iota
	DataEdit
)

type EditSourceDataFun

type EditSourceDataFun func(map[string]any) map[string]any

EditSourceDataFun 自定义编辑元数据修改方法

type Field

type Field struct {
	Field   string
	Row     map[string]any
	Value   any
	Display FieldDisplayFun
	Label   bool
	Icon    bool
	Image   bool
	Array   []string
}

Field 显示字段信息

func (*Field) Show

func (f *Field) Show() any

Show 数据显现

type FieldDisplayFun

type FieldDisplayFun func(model FieldModel) any

FieldDisplayFun table展示自定义方法

type FieldList

type FieldList []TableField

type FieldModel

type FieldModel struct {
	ID    any
	Value any
	Row   map[string]any
}

FieldModel display 元素

type Form

type Form struct {
	// contains filtered or unexported fields
}

Form Form表单

func NewForm

func NewForm(context *gin.Context, actionType ActionType) *Form

NewForm 新表单定义

func (*Form) AddField

func (f *Form) AddField(fieldName string, field string, formType Type) *Form

AddField 添加字段

func (*Form) Default

func (f *Form) Default(defaultValue any) *Form

Default 默认值

func (*Form) DefaultValueTow

func (f *Form) DefaultValueTow(defaultValue any) *Form

DefaultValueTow 默认值

func (*Form) Disable

func (f *Form) Disable() *Form

Disable 不可编辑

func (*Form) EditForm

func (f *Form) EditForm() *Form

EditForm 编辑的表单

func (*Form) Editable

func (f *Form) Editable() *Form

Editable 可编辑

func (*Form) GetField

func (f *Form) GetField() FormFieldList

GetField 获取form表单元素--template使用

func (*Form) GetForm

func (f *Form) GetForm(data any) *Form

GetForm 获取当前表单

func (*Form) HelpMsg

func (f *Form) HelpMsg(msg string) *Form

HelpMsg 提示信息

func (*Form) HideBackButton

func (f *Form) HideBackButton(hideBackButton bool) *Form

HideBackButton 隐藏返回按钮

func (*Form) NotAllowEdit

func (f *Form) NotAllowEdit(notAllowEdit bool) *Form

NotAllowEdit 不允许编辑

func (*Form) OptionGroup

func (f *Form) OptionGroup(optionGroups []OptionGroup) *Form

OptionGroup 设置select标记的options数据

func (*Form) Options

func (f *Form) Options(options []SelectOption) *Form

Options 设置select标记的options数据

func (*Form) ParseForm

func (f *Form) ParseForm() *Form

ParseForm 解析当前form定义

func (*Form) Placeholder

func (f *Form) Placeholder(label string) *Form

Placeholder 添加字段input输入提示

func (*Form) Readonly

func (f *Form) Readonly() *Form

Readonly 可编辑

func (*Form) Require

func (f *Form) Require() *Form

Require 当前字段必填 -ok

func (*Form) SetAction

func (f *Form) SetAction(actionType ActionType) *Form

func (*Form) SetEditSourceDataFun

func (f *Form) SetEditSourceDataFun(fun EditSourceDataFun) *Form

SetEditSourceDataFun 增加当前字段编辑器修改方法

func (*Form) SetModel

func (f *Form) SetModel(model handler.ModelAction) *Form

func (*Form) SetSelectedLabel

func (f *Form) SetSelectedLabel(labels template.HTML) *Form

SetSelectedLabel 设置select选择项

func (*Form) Unique

func (f *Form) Unique() *Form

Require 当前字段唯一

type FormField

type FormField struct {
	Field          string
	Value          any
	Value2         any
	FormType       Type
	FieldName      string
	FieldClass     string
	Placeholder    string
	Must           bool
	HelpMsg        string
	NotAllowEdit   bool
	HideBackButton bool
	Editable       bool
	NoIcon         bool
	Readonly       bool

	Validator []ValidatorItem

	OptionGroups  []OptionGroup
	Options       []SelectOption
	SelectedLabel template.HTML
	OptionExt     template.JS
	OptionExt2    template.JS
	ValueArr      []string
	Label         string
	Display       FieldDisplayFun

	CustomContent any
	CustomJs      template.JS
	CustomCss     template.CSS
}

FormField form表单原数据定义

type FormFieldList

type FormFieldList []FormField

FormFieldList form 表单数据列表

type Grid

type Grid struct {
	PageData handler.PageData

	SearchFields []SearchField
	// 页面提示
	Tips       string
	DeleteAble bool
	EditAble   bool
	DetailAble bool

	// ===============================
	Export     bool
	DataAdd    bool
	HasSearch  bool
	InitSearch InitSearch
	// contains filtered or unexported fields
}

Grid 当前显示数据表格

func NewGrid

func NewGrid(context *gin.Context) *Grid

NewGrid 新对象

func (*Grid) AddField

func (t *Grid) AddField(head string, field string) *Grid

AddField 添加字段显示

func (*Grid) BaseUrl

func (t *Grid) BaseUrl() string

BaseUrl 获取当前请求的基本uril,搜索用

func (*Grid) CurrentUrl

func (t *Grid) CurrentUrl(params ...any) string

CurrentUrl 获取当前url 页面分页用

func (*Grid) DisableAddData

func (t *Grid) DisableAddData() *Grid

DisableAddData 禁用添加按钮

func (*Grid) DisableDelete

func (t *Grid) DisableDelete() *Grid

DisableDelete 禁用删除

func (*Grid) DisableDetail

func (t *Grid) DisableDetail() *Grid

DisableDetail 禁用详情

func (*Grid) DisableEdit

func (t *Grid) DisableEdit() *Grid

DisableEdit 禁用编辑

func (*Grid) Display

func (t *Grid) Display(displayFun FieldDisplayFun) *Grid

Display 自定义当中数据展示

func (*Grid) EnableDelete

func (t *Grid) EnableDelete() *Grid

EnableDelete 允许删除

func (*Grid) EnableDetail

func (t *Grid) EnableDetail() *Grid

EnableDetail 允许详情

func (*Grid) EnableEdit

func (t *Grid) EnableEdit() *Grid

EnableEdit 允许编辑

func (*Grid) FieldSortable

func (t *Grid) FieldSortable() *Grid

FieldSortable 当前字段可排序

func (*Grid) GetField

func (t *Grid) GetField() FieldList

GetField 获取字段

func (*Grid) GetSelectWhere

func (t *Grid) GetSelectWhere() WhereClosure

GetSelectWhere 获取当前数据查询条件

func (*Grid) GetTable

func (t *Grid) GetTable(pageData handler.PageData) *Grid

GetTable 获取显现的table对象

func (*Grid) Icon

func (t *Grid) Icon() *Grid

Icon 以icon展示数据

func (*Grid) Image

func (t *Grid) Image() *Grid

Image 以图片展示数据

func (*Grid) Label

func (t *Grid) Label() *Grid

Label 以标签形式展示数据

func (*Grid) Search

func (t *Grid) Search(searchFields ...SearchField) *Grid

Search 设置当前字段可搜素

func (*Grid) SearchValue

func (t *Grid) SearchValue(params any) any

SearchValue 当前搜索的字段信息,页面回显用

func (*Grid) SetInitSearch

func (t *Grid) SetInitSearch(optionGroups []OptionGroup, defaultValue string) *Grid

SetInitSearch 设置提示

func (*Grid) SetSelectWhere

func (t *Grid) SetSelectWhere(where WhereClosure) *Grid

SetSelectWhere 设置当前数据查询条件

func (*Grid) SetTips

func (t *Grid) SetTips(tips string) *Grid

SetTips 设置提示

type Info

type Info struct {
	// contains filtered or unexported fields
}

Info 显示结构体

func NewInfo

func NewInfo(context *gin.Context) *Info

func (*Info) AddField

func (s *Info) AddField(fieldName string, field string, formType ...Type) *Info

AddField 添加字段

func (*Info) Display

func (s *Info) Display(fun FieldDisplayFun) *Info

Display 格式化输出数据

func (*Info) GetField

func (s *Info) GetField() FormFieldList

GetField 获取显示的字段,模板调用

func (*Info) GetInfo

func (s *Info) GetInfo(data any) *Info

GetInfo 获取显示模板对象

func (*Info) HelpMsg

func (s *Info) HelpMsg(msg string) *Info

HelpMsg 帮助信息

func (*Info) HideBackButton

func (s *Info) HideBackButton(hideBackButton bool) *Info

HideBackButton 隐藏返回按钮

func (*Info) Options

func (s *Info) Options(options []SelectOption) *Info

Options 设置select 选项

func (*Info) SetSelectedLabel

func (s *Info) SetSelectedLabel(labels template.HTML) *Info

SetSelectedLabel 设置selected label

type InitSearch

type InitSearch struct {
	OptionGroups []OptionGroup
	DefaultValue string
}

type OptionGroup

type OptionGroup struct {
	Group   string         `json:"group"`
	Options []SelectOption `json:"options"`
}

type SearchField

type SearchField struct {
	Field    string
	ShowName string
	Notice   string
	Type     string
}

SearchField 搜索字段定义

type SelectOption

type SelectOption struct {
	Text          string            `json:"text"`
	Value         string            `json:"value"`
	TextHTML      template.HTML     `json:"-"`
	Selected      bool              `json:"-"`
	SelectedLabel template.HTML     `json:"-"`
	Extra         map[string]string `json:"-"`
}

SelectOption 下来框元数据

type TableField

type TableField struct {
	Field    string
	ShowName string
	Sortable bool
	Display  FieldDisplayFun
	Export   bool
}

TableField table 元数据

type Type

type Type uint8

Type 组件类型

const (
	Default Type = iota
	Text
	Hidden
	SelectSingle
	SelectSingleGroup
	Select
	IconPicker
	SelectBox
	File
	Password
	RichText
	Datetime
	DatetimeRange
	Radio
	Checkbox
	CheckboxStacked
	CheckboxSingle
	Email
	Date
	DateRange
	Url
	Ip
	Color
	Array
	Currency
	Rate
	Number
	NumberRange
	TextArea
	Custom
	Switch
	Code
	Slider
	Image
)

组件类型定义

func (Type) String

func (t Type) String() string

获取类型对应元素

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

func NewValidator

func NewValidator(model handler.ModelAction) *Validator

func (*Validator) AddValidator

func (v *Validator) AddValidator(actionType ActionType, formField FormField, validatorItem []ValidatorItem)

AddValidator 添加验证规则--内部方法

func (*Validator) DataValidator

func (v *Validator) DataValidator(actionType ActionType, params map[string]string) error

DataValidator 添加验证方法 --内部

func (*Validator) SetBaseModel

func (v *Validator) SetBaseModel(model *handler.CommonModel) *Validator

SetBaseModel 设置基础model

type ValidatorItem

type ValidatorItem struct {
	ValidatorType ValidatorType
	ValidatorMsg  string
}

ValidatorItem Validator 数据验证体定义

type ValidatorType

type ValidatorType int

ValidatorType 验证类型

const (
	ValidatorRequire ValidatorType = iota
	ValidatorUnique
)

验证类型定义

type WhereClosure

type WhereClosure func(*gorm.DB) *gorm.DB

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL