|
@@ -11,6 +11,7 @@ import (
|
|
|
"github.com/GoAdminGroup/go-admin/template/types"
|
|
"github.com/GoAdminGroup/go-admin/template/types"
|
|
|
"github.com/GoAdminGroup/go-admin/template/types/action"
|
|
"github.com/GoAdminGroup/go-admin/template/types/action"
|
|
|
"github.com/GoAdminGroup/go-admin/template/types/form"
|
|
"github.com/GoAdminGroup/go-admin/template/types/form"
|
|
|
|
|
+ selection "github.com/GoAdminGroup/go-admin/template/types/form/select"
|
|
|
editType "github.com/GoAdminGroup/go-admin/template/types/table"
|
|
editType "github.com/GoAdminGroup/go-admin/template/types/table"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -87,7 +88,59 @@ func GetUserTable(ctx *context.Context) (userTable table.Table) {
|
|
|
{Text: "women", Value: "1"},
|
|
{Text: "women", Value: "1"},
|
|
|
}).FieldDefault("0")
|
|
}).FieldDefault("0")
|
|
|
formList.AddField("Phone", "phone", db.Varchar, form.Text)
|
|
formList.AddField("Phone", "phone", db.Varchar, form.Text)
|
|
|
- formList.AddField("City", "city", db.Varchar, form.Text)
|
|
|
|
|
|
|
+ formList.AddField("Country", "country", db.Tinyint, form.SelectSingle).
|
|
|
|
|
+ FieldOptions(types.FieldOptions{
|
|
|
|
|
+ {Text: "China", Value: "0"},
|
|
|
|
|
+ {Text: "America", Value: "1"},
|
|
|
|
|
+ {Text: "England", Value: "2"},
|
|
|
|
|
+ {Text: "Canada", Value: "3"},
|
|
|
|
|
+ }).FieldDefault("0").FieldOnChooseAjax("city", "/choose/country",
|
|
|
|
|
+ func(ctx *context.Context) (bool, string, interface{}) {
|
|
|
|
|
+ country := ctx.FormValue("value")
|
|
|
|
|
+ var data = make(selection.Options, 0)
|
|
|
|
|
+ switch country {
|
|
|
|
|
+ case "0":
|
|
|
|
|
+ data = selection.Options{
|
|
|
|
|
+ {Text: "Beijing", ID: "beijing"},
|
|
|
|
|
+ {Text: "ShangHai", ID: "shangHai"},
|
|
|
|
|
+ {Text: "GuangZhou", ID: "guangZhou"},
|
|
|
|
|
+ {Text: "ShenZhen", ID: "shenZhen"},
|
|
|
|
|
+ }
|
|
|
|
|
+ case "1":
|
|
|
|
|
+ data = selection.Options{
|
|
|
|
|
+ {Text: "Los Angeles", ID: "los angeles"},
|
|
|
|
|
+ {Text: "Washington, dc", ID: "washington, dc"},
|
|
|
|
|
+ {Text: "New York", ID: "new york"},
|
|
|
|
|
+ {Text: "Las Vegas", ID: "las vegas"},
|
|
|
|
|
+ }
|
|
|
|
|
+ case "2":
|
|
|
|
|
+ data = selection.Options{
|
|
|
|
|
+ {Text: "London", ID: "london"},
|
|
|
|
|
+ {Text: "Cambridge", ID: "cambridge"},
|
|
|
|
|
+ {Text: "Manchester", ID: "manchester"},
|
|
|
|
|
+ {Text: "Liverpool", ID: "liverpool"},
|
|
|
|
|
+ }
|
|
|
|
|
+ case "3":
|
|
|
|
|
+ data = selection.Options{
|
|
|
|
|
+ {Text: "Vancouver", ID: "vancouver"},
|
|
|
|
|
+ {Text: "Toronto", ID: "toronto"},
|
|
|
|
|
+ }
|
|
|
|
|
+ default:
|
|
|
|
|
+ data = selection.Options{
|
|
|
|
|
+ {Text: "Beijing", ID: "beijing"},
|
|
|
|
|
+ {Text: "ShangHai", ID: "shangHai"},
|
|
|
|
|
+ {Text: "GuangZhou", ID: "guangZhou"},
|
|
|
|
|
+ {Text: "ShenZhen", ID: "shenZhen"},
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return true, "ok", data
|
|
|
|
|
+ })
|
|
|
|
|
+ formList.AddField("City", "city", db.Varchar, form.SelectSingle).
|
|
|
|
|
+ FieldOptionInitFn(func(val types.FieldModel) types.FieldOptions {
|
|
|
|
|
+ return types.FieldOptions{
|
|
|
|
|
+ {Value: val.Value, Text: val.Value, Selected: true},
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
formList.AddField("Custom Field", "role", db.Varchar, form.Text).
|
|
formList.AddField("Custom Field", "role", db.Varchar, form.Text).
|
|
|
FieldPostFilterFn(func(value types.PostFieldModel) interface{} {
|
|
FieldPostFilterFn(func(value types.PostFieldModel) interface{} {
|
|
|
fmt.Println("user custom field", value)
|
|
fmt.Println("user custom field", value)
|
|
@@ -98,7 +151,7 @@ func GetUserTable(ctx *context.Context) (userTable table.Table) {
|
|
|
formList.AddField("CreatedAt", "created_at", db.Timestamp, form.Default).FieldNotAllowAdd()
|
|
formList.AddField("CreatedAt", "created_at", db.Timestamp, form.Default).FieldNotAllowAdd()
|
|
|
|
|
|
|
|
userTable.GetForm().SetTabGroups(types.
|
|
userTable.GetForm().SetTabGroups(types.
|
|
|
- NewTabGroups("id", "ip", "name", "gender", "city").
|
|
|
|
|
|
|
+ NewTabGroups("id", "ip", "name", "gender", "country", "city").
|
|
|
AddGroup("phone", "role", "created_at", "updated_at")).
|
|
AddGroup("phone", "role", "created_at", "updated_at")).
|
|
|
SetTabHeaders("profile1", "profile2")
|
|
SetTabHeaders("profile1", "profile2")
|
|
|
|
|
|