diff --git a/server/internal/consts/gencodes.go b/server/internal/consts/gencodes.go index 5f87aaa..c8a1a18 100644 --- a/server/internal/consts/gencodes.go +++ b/server/internal/consts/gencodes.go @@ -3,7 +3,6 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package consts // 生成代码类型 @@ -79,3 +78,18 @@ const ( GenCodesIndexPK = "PRI" // 主键索引 GenCodesIndexUNI = "UNI" // 唯一索引 ) + +// 表格字段显示位置 +const ( + ListShowHide = 1 + ListShowLeft = 2 + ListShowCenter = 3 + ListShowRight = 4 +) + +var ListShowMap = map[int]string{ + ListShowHide: "不显示", + ListShowLeft: "居左显示", + ListShowCenter: "居中显示", + ListShowRight: "居右显示", +} diff --git a/server/internal/library/hggen/hggen.go b/server/internal/library/hggen/hggen.go index 1ae1543..01b3682 100644 --- a/server/internal/library/hggen/hggen.go +++ b/server/internal/library/hggen/hggen.go @@ -6,13 +6,16 @@ package hggen import ( - _ "hotgo/internal/library/hggen/internal/cmd/gendao" + "context" + "sort" _ "unsafe" - "context" + _ "hotgo/internal/library/hggen/internal/cmd/gendao" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/util/gconv" + "hotgo/internal/consts" "hotgo/internal/library/addons" "hotgo/internal/library/hggen/internal/cmd" @@ -23,7 +26,6 @@ import ( "hotgo/internal/model/input/form" "hotgo/internal/model/input/sysin" "hotgo/internal/service" - "sort" ) //go:linkname doGenDaoForArray hotgo/internal/library/hggen/internal/cmd/gendao.doGenDaoForArray @@ -130,6 +132,15 @@ func TableSelects(ctx context.Context, in *sysin.GenCodesSelectsInp) (res *sysin }) } + for k, v := range consts.ListShowMap { + res.ListShow = append(res.ListShow, &form.Select{ + Value: k, + Name: v, + Label: v, + }) + } + sort.Sort(res.ListShow) + res.Addons = addons.ModuleSelect() return } diff --git a/server/internal/library/hggen/views/column.go b/server/internal/library/hggen/views/column.go index e8f8a09..1dfbfc7 100644 --- a/server/internal/library/hggen/views/column.go +++ b/server/internal/library/hggen/views/column.go @@ -8,14 +8,16 @@ package views import ( "context" "fmt" + "strings" + + "hotgo/internal/library/hggen/internal/cmd/gendao" + "hotgo/internal/model/input/sysin" + "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" - "hotgo/internal/library/hggen/internal/cmd/gendao" - "hotgo/internal/model/input/sysin" - "strings" ) // DoTableColumns 获取指定表生成字段列表 @@ -40,6 +42,8 @@ func DoTableColumns(ctx context.Context, in *sysin.GenCodesColumnListInp, config } else { CustomAttributes(ctx, field, config) } + field.Width = 80 + field.ListShow = 1 } return } diff --git a/server/internal/library/hggen/views/column_map.go b/server/internal/library/hggen/views/column_map.go index f5e49b0..4a1d4e4 100644 --- a/server/internal/library/hggen/views/column_map.go +++ b/server/internal/library/hggen/views/column_map.go @@ -3,11 +3,11 @@ // @Copyright Copyright (c) 2023 HotGo CLI // @Author Ms <133814250@qq.com> // @License https://github.com/bufanyun/hotgo/blob/master/LICENSE -// package views import ( "github.com/gogf/gf/v2/text/gstr" + "hotgo/internal/model/input/sysin" ) @@ -258,3 +258,12 @@ func HasSwitch(headOps []string, masterFields []*sysin.GenCodesColumnListModel) } return HasColumnWithFormMode(masterFields, "Switch") } + +// HasTableSort 是否包含表排序字段 +func HasTableSort(masterFields []*sysin.GenCodesColumnListModel) bool { + for _, field := range masterFields { + return gstr.InArray(field.Attribute, "sort") + } + + return false +} diff --git a/server/internal/library/hggen/views/curd.go b/server/internal/library/hggen/views/curd.go index d1f1607..baacde1 100644 --- a/server/internal/library/hggen/views/curd.go +++ b/server/internal/library/hggen/views/curd.go @@ -7,12 +7,16 @@ package views import ( "context" + "runtime" + "strings" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/os/gview" "github.com/gogf/gf/v2/text/gstr" + "hotgo/internal/consts" "hotgo/internal/library/hggen/internal/cmd/gendao" "hotgo/internal/library/hggen/internal/utility/utils" @@ -20,8 +24,6 @@ import ( "hotgo/internal/model/input/sysin" "hotgo/utility/convert" "hotgo/utility/file" - "runtime" - "strings" ) var Curd = gCurd{} @@ -41,6 +43,7 @@ type CurdStep struct { HasSwitch bool `json:"hasSwitch"` HasCheck bool `json:"hasCheck"` HasMenu bool `json:"hasMenu"` + HasSort bool `json:"hasSort"` } type CurdOptionsJoin struct { @@ -152,6 +155,7 @@ func initStep(in *CurdPreviewInput) { in.options.Step.HasSwitch = HasSwitch(in.options.ColumnOps, in.masterFields) in.options.Step.HasCheck = gstr.InArray(in.options.ColumnOps, "check") in.options.Step.HasMenu = gstr.InArray(in.options.AutoOps, "genMenuPermissions") + in.options.Step.HasSort = HasTableSort(in.masterFields) } func (l *gCurd) loadView(ctx context.Context, in *CurdPreviewInput) (err error) { diff --git a/server/internal/model/gen_codes.go b/server/internal/model/gen_codes.go index 881f1e1..9529edc 100644 --- a/server/internal/model/gen_codes.go +++ b/server/internal/model/gen_codes.go @@ -20,19 +20,24 @@ type GenCodesColumn struct { Extra string `json:"extra" dc:"额外选项"` // 自定义生成属性 // Alias string `json:"alias" dc:"字段别名"` - GoName string `json:"goName" dc:"Go属性"` - GoType string `json:"goType" dc:"Go类型"` - TsName string `json:"tsName" dc:"Ts属性"` - TsType string `json:"tsType" dc:"Ts类型"` - IsList bool `json:"isList" dc:"列表"` - IsExport bool `json:"isExport" dc:"导出"` - IsSort bool `json:"isSort" dc:"排序"` - IsQuery bool `json:"isQuery" dc:"查询"` - QueryWhere string `json:"queryWhere" dc:"查询条件"` - IsEdit bool `json:"isEdit" dc:"编辑"` - Required bool `json:"required" dc:"必填"` - Unique bool `json:"unique" dc:"唯一性"` - FormMode string `json:"formMode" dc:"表单组件"` - FormRole string `json:"formRole" dc:"表单验证"` - DictType int64 `json:"dictType" dc:"字典类型ID"` + GoName string `json:"goName" dc:"Go属性"` + GoType string `json:"goType" dc:"Go类型"` + TsName string `json:"tsName" dc:"Ts属性"` + TsType string `json:"tsType" dc:"Ts类型"` + IsList bool `json:"isList" dc:"列表"` + IsExport bool `json:"isExport" dc:"导出"` + IsSort bool `json:"isSort" dc:"排序"` + IsQuery bool `json:"isQuery" dc:"查询"` + QueryWhere string `json:"queryWhere" dc:"查询条件"` + IsEdit bool `json:"isEdit" dc:"编辑"` + Required bool `json:"required" dc:"必填"` + Unique bool `json:"unique" dc:"唯一性"` + FormMode string `json:"formMode" dc:"表单组件"` + FormRole string `json:"formRole" dc:"表单验证"` + DictType int64 `json:"dictType" dc:"字典类型ID"` + ListShow int64 `json:"listShow" dc:"显示状态"` + Width int64 `json:"width" dc:"单元格宽度"` + Placeholder string `json:"placeholder" dc:"占位符"` + ShowCondition string `json:"showCondition" dc:"显示条件"` + Attribute []string `json:"attribute" dc:"其他属性"` } diff --git a/server/internal/model/input/sysin/gen_codes.go b/server/internal/model/input/sysin/gen_codes.go index 4b79187..e6c1afb 100644 --- a/server/internal/model/input/sysin/gen_codes.go +++ b/server/internal/model/input/sysin/gen_codes.go @@ -7,9 +7,11 @@ package sysin import ( "context" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/util/gconv" + "hotgo/internal/consts" "hotgo/internal/model" "hotgo/internal/model/entity" @@ -89,6 +91,7 @@ type GenCodesSelectsModel struct { FormRole form.Selects `json:"formRole" dc:"表单验证"` DictMode []*DictTypeTree `json:"dictMode" dc:"字典类型"` WhereMode form.Selects `json:"whereMode" dc:"查询条件"` + ListShow form.Selects `json:"listShow" dc:"显示位置"` Addons form.Selects `json:"addons" dc:"插件选项"` } diff --git a/server/resource/generate/default/curd/input.go.template b/server/resource/generate/default/curd/input.go.template index 33fe824..858edce 100644 --- a/server/resource/generate/default/curd/input.go.template +++ b/server/resource/generate/default/curd/input.go.template @@ -71,6 +71,7 @@ type @{.varName}ViewModel struct { // @{.varName}ListInp 获取@{.tableComment}列表 type @{.varName}ListInp struct { form.PageReq +@{ if eq .options.Step.HasSort true} form.Sorters@{end} @{.listInpColumns} } diff --git a/server/resource/generate/default/curd/web.index.vue.template b/server/resource/generate/default/curd/web.index.vue.template index 8fc6782..e522ee3 100644 --- a/server/resource/generate/default/curd/web.index.vue.template +++ b/server/resource/generate/default/curd/web.index.vue.template @@ -28,6 +28,7 @@ :actionColumn="actionColumn" :checked-row-keys="checkedIds" @update:checked-row-keys="onCheckedRow" +@{ if eq .options.Step.HasSort true} @update:sorter="handleUpdateSorter"@{end} :scroll-x="1090" :resizeHeightOffset="-10000" size="small" @@ -91,6 +92,7 @@ import { BasicTable, TableAction } from '@/components/Table'; import { BasicForm, useForm } from '@/components/Form/index'; import { usePermission } from '@/hooks/web/usePermission'; +@{ if eq .options.Step.HasSort true} import { useSorter } from '@/hooks/common';@{end} @{.apiImport} import { State, columns, schemas, options, newState } from './model'; @{.iconsImport} @@ -107,6 +109,7 @@ const checkedIds = ref([]); const showModal = ref(false); const formParams = ref(); +@{ if eq .options.Step.HasSort true} const { updateSorter: handleUpdateSorter, sortStatesRef: sortStatesRef } = useSorter(reloadTable);@{end} const actionColumn = reactive({ width: 300, @@ -167,7 +170,11 @@ }); const loadDataTable = async (res) => { - return await List({ ...searchFormRef.value?.formModel, ...res }); + return await List({ + ...searchFormRef.value?.formModel, +@{ if eq .options.Step.HasSort true} ...{ sorters: sortStatesRef.value },@{end} + ...res, + }); }; @{ if eq .options.Step.HasAdd true } function addTable() { diff --git a/web/src/views/curdDemo/view.vue b/web/src/views/curdDemo/view.vue index 7d58052..536cb49 100644 --- a/web/src/views/curdDemo/view.vue +++ b/web/src/views/curdDemo/view.vue @@ -68,6 +68,11 @@ > + + + {{ formValue.updatedAt }} + + diff --git a/web/src/views/develop/code/components/EditField.vue b/web/src/views/develop/code/components/EditField.vue new file mode 100644 index 0000000..0424053 --- /dev/null +++ b/web/src/views/develop/code/components/EditField.vue @@ -0,0 +1,263 @@ + + + + + diff --git a/web/src/views/develop/code/components/EditMasterCell.vue b/web/src/views/develop/code/components/EditMasterCell.vue index 5466683..a64300d 100644 --- a/web/src/views/develop/code/components/EditMasterCell.vue +++ b/web/src/views/develop/code/components/EditMasterCell.vue @@ -14,8 +14,8 @@ ref="actionRef" :canResize="true" :pagination="false" - :scroll-x="3000" :scroll-y="720" + :actionColumn="actionColumn" >