优化:没有需要查询的字段则隐藏搜索表单

This commit is contained in:
maxbad 2023-05-12 15:34:11 +08:00
parent e32201ea6b
commit df70f8ec06
2 changed files with 26 additions and 1 deletions

View File

@ -8,6 +8,7 @@ package views
import (
"context"
"fmt"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/text/gstr"
)
@ -60,5 +61,28 @@ func (l *gCurd) webIndexTplData(ctx context.Context, in *CurdPreviewInput) (g.Ma
data["iconsImport"] = fmt.Sprintf(IndexIconsImport, gstr.Implode(",", iconsImport))
}
// 没有需要查询的字段则隐藏搜索表单
isSearchForm := false
for _, field := range in.masterFields {
if field.IsQuery == true {
isSearchForm = true
break
}
}
if isSearchForm == false {
if len(in.options.Join) > 0 {
LoopOut:
for _, v := range in.options.Join {
for _, column := range v.Columns {
if column.IsQuery == true {
isSearchForm = true
break LoopOut
}
}
}
}
}
data["isSearchForm"] = isSearchForm
return data, nil
}

View File

@ -6,6 +6,7 @@
<!-- 这是系统自动生成的CURD表格你可以将此行注释改为表格的描述 -->
</n-card>
</div>
@{ if eq .isSearchForm true }
<BasicForm
@register="register"
@submit="reloadTable"
@ -16,7 +17,7 @@
<template #statusSlot="{ model, field }">
<n-input v-model:value="model[field]" />
</template>
</BasicForm>
</BasicForm>@{end}
<BasicTable
:openChecked="@{.options.Step.HasCheck}"