Skip to content

Commit 1a6bc84

Browse files
committed
fix: 修复弹窗表单bug
1 parent e9362c7 commit 1a6bc84

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

template/admin/resource/resolves_actions.go

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -584,31 +584,39 @@ func (p *Template) BuildActionApi(ctx *quark.Context, params []string, uriKey st
584584
func (p *Template) BuildFormInitApi(ctx *quark.Context, params []string, uriKey string) string {
585585
var (
586586
paramsUri = ""
587-
api = ""
587+
api = ctx.Path()
588588
)
589589

590590
for _, v := range params {
591591
paramsUri = paramsUri + v + "=${" + v + "}&"
592592
}
593593

594-
// 列表页接口
595-
if ctx.IsIndex() {
596-
api = strings.Replace(ctx.Path(), "/index", "/action/"+uriKey+"/values", -1)
597-
}
594+
// 获取api路径
595+
apiPaths := strings.Split(api, "/")
598596

599-
// 创建页接口
600-
if ctx.IsCreating() {
601-
api = strings.Replace(ctx.Path(), "/create", "/action/"+uriKey+"/values", -1)
597+
// 错误路径,直接返回
598+
if len(apiPaths) <= 2 {
599+
return ""
602600
}
603601

604-
// 编辑页接口
605-
if ctx.IsEditing() {
602+
// 解析数据
603+
switch apiPaths[len(apiPaths)-1] {
604+
case "index":
605+
// 列表页接口
606+
api = strings.Replace(api, "/index", "/action/"+uriKey+"/values", -1)
607+
case "create":
608+
// 创建页接口
609+
api = strings.Replace(api, "/create", "/action/"+uriKey+"/values", -1)
610+
case "edit":
611+
// 编辑页接口
606612
api = strings.Replace(api, "/edit", "/action/"+uriKey+"/values", -1)
607-
}
608-
609-
// 详情页接口
610-
if ctx.IsDetail() {
613+
case "detail":
614+
// 详情页接口
611615
api = strings.Replace(api, "/detail", "/action/"+uriKey+"/values", -1)
616+
case "form":
617+
// 表单页接口
618+
lastPath := apiPaths[len(apiPaths)-2]
619+
api = strings.Replace(api, lastPath+"/form", "action/"+uriKey+"/values", -1)
612620
}
613621

614622
// 追加参数

0 commit comments

Comments
 (0)