package gen import ( "html/template" "path/filepath" "strings" "management/internal/erpserver/model/dto" ) func Button() map[string]any { res := make(map[string]any, 3) res["genBtn"] = func(buttons []*dto.OwnerMenuDto, actionNames ...string) template.HTML { if len(buttons) == 0 { return "" } var res string for _, action := range actionNames { for _, btn := range buttons { btn.Style = strings.ReplaceAll(btn.Style, "pear", "layui") base := filepath.Base(btn.Url) if base == action { res += `` } } } return template.HTML(res) } res["genLink"] = func(buttons []*dto.OwnerMenuDto, actionNames ...string) template.HTML { if len(buttons) == 0 { return "" } var res string for _, action := range actionNames { for _, btn := range buttons { btn.Style = strings.ReplaceAll(btn.Style, "pear", "layui") base := filepath.Base(btn.Url) if base == action { res += `` } } } return template.HTML(res) } res["previewPicture"] = func(name string) template.HTML { var res string res += `` return template.HTML(res) } res["submitBtn"] = func(buttons []*dto.OwnerMenuDto, actionNames ...string) template.HTML { if len(buttons) == 0 { return "" } var res string for _, action := range actionNames { for _, btn := range buttons { btn.Style = strings.ReplaceAll(btn.Style, "pear", "layui") base := filepath.Base(btn.Url) if base == action { res += `` } } } return template.HTML(res) } return res } func firstLower(s string) string { if len(s) == 0 { return s } return strings.ToLower(s[:1]) + s[1:] }