mirror of
https://github.com/quarkcloudio/quark-go.git
synced 2025-09-26 20:11:11 +08:00
feat: 表格搜索增加button style的单选组件
This commit is contained in:
@@ -174,6 +174,10 @@ func (p *Menu) Searches(ctx *builder.Context) []interface{} {
|
||||
return []interface{}{
|
||||
searches.Input("name", "名称"),
|
||||
searches.Input("path", "路由"),
|
||||
searches.Radio("show", "显示", []*radio.Option{{
|
||||
Label: "是",
|
||||
Value: 1,
|
||||
}}),
|
||||
searches.Status(),
|
||||
}
|
||||
}
|
||||
|
33
pkg/app/admin/service/searches/radio.go
Normal file
33
pkg/app/admin/service/searches/radio.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package searches
|
||||
|
||||
import (
|
||||
"github.com/quarkcloudio/quark-go/v2/pkg/app/admin/component/form/fields/radio"
|
||||
"github.com/quarkcloudio/quark-go/v2/pkg/app/admin/template/resource/searches"
|
||||
"github.com/quarkcloudio/quark-go/v2/pkg/builder"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type RadioField struct {
|
||||
searches.Radio
|
||||
}
|
||||
|
||||
// 下拉框
|
||||
func Radio(column string, name string, options []*radio.Option) *RadioField {
|
||||
field := &RadioField{}
|
||||
|
||||
field.Column = column
|
||||
field.Name = name
|
||||
field.RadioOptions = options
|
||||
|
||||
return field
|
||||
}
|
||||
|
||||
// 执行查询
|
||||
func (p *RadioField) Apply(ctx *builder.Context, query *gorm.DB, value interface{}) *gorm.DB {
|
||||
return query.Where(p.Column+" = ?", value)
|
||||
}
|
||||
|
||||
// 属性
|
||||
func (p *RadioField) Options(ctx *builder.Context) interface{} {
|
||||
return p.RadioOptions
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
package resource
|
||||
|
||||
import (
|
||||
"github.com/quarkcloudio/quark-go/v2/pkg/app/admin/component/form/fields/radio"
|
||||
"strings"
|
||||
|
||||
"github.com/quarkcloudio/quark-go/v2/pkg/app/admin/component/form/fields/cascader"
|
||||
@@ -73,6 +74,12 @@ func (p *Template) IndexSearches(ctx *builder.Context) interface{} {
|
||||
Select(name, label).
|
||||
SetWidth(nil).
|
||||
SetOptions(options.([]*selectfield.Option))
|
||||
case "radioField":
|
||||
item = field.
|
||||
Radio(name, label).
|
||||
SetOptions(options.([]*radio.Option)).
|
||||
SetOptionType("button").
|
||||
SetButtonStyle("solid")
|
||||
case "multipleSelectField":
|
||||
item = field.
|
||||
Select(name, label).
|
||||
|
26
pkg/app/admin/template/resource/searches/radio.go
Normal file
26
pkg/app/admin/template/resource/searches/radio.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package searches
|
||||
|
||||
import (
|
||||
"github.com/quarkcloudio/quark-go/v2/pkg/app/admin/component/form/fields/radio"
|
||||
"github.com/quarkcloudio/quark-go/v2/pkg/builder"
|
||||
)
|
||||
|
||||
type Radio struct {
|
||||
Search
|
||||
RadioOptions []*radio.Option
|
||||
}
|
||||
|
||||
// 初始化模板
|
||||
func (p *Radio) TemplateInit(ctx *builder.Context) interface{} {
|
||||
p.Component = "radioField"
|
||||
return p
|
||||
}
|
||||
|
||||
// 设置Option
|
||||
func (p *Radio) Option(value interface{}, label string) *radio.Option {
|
||||
|
||||
return &radio.Option{
|
||||
Value: value,
|
||||
Label: label,
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user