mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-27 14:40:42 +08:00
fix 代码生成switch
This commit is contained in:
@@ -232,6 +232,15 @@ func HasColumn(masterFields []*sysin.GenCodesColumnListModel, column string) boo
|
||||
return false
|
||||
}
|
||||
|
||||
func HasColumnWithFormMode(masterFields []*sysin.GenCodesColumnListModel, column string) bool {
|
||||
for _, field := range masterFields {
|
||||
if field.FormMode == column {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func HasMaxSort(masterFields []*sysin.GenCodesColumnListModel) bool {
|
||||
return HasColumn(masterFields, "Sort")
|
||||
}
|
||||
@@ -247,5 +256,5 @@ func HasSwitch(headOps []string, masterFields []*sysin.GenCodesColumnListModel)
|
||||
if !gstr.InArray(headOps, "switch") {
|
||||
return false
|
||||
}
|
||||
return HasColumn(masterFields, "Switch")
|
||||
return HasColumnWithFormMode(masterFields, "Switch")
|
||||
}
|
||||
|
@@ -67,7 +67,11 @@ func (l *gCurd) generateLogicSwitchUpdate(ctx context.Context, in *CurdPreviewIn
|
||||
func (l *gCurd) generateLogicSwitchFields(ctx context.Context, in *CurdPreviewInput) string {
|
||||
buffer := bytes.NewBuffer(nil)
|
||||
if in.options.Step.HasSwitch {
|
||||
buffer.WriteString("\t\tdao." + in.In.DaoName + ".Columns().Switch,\n")
|
||||
for _, field := range in.masterFields {
|
||||
if field.FormMode == "Switch" {
|
||||
buffer.WriteString("\t\tdao." + in.In.DaoName + ".Columns()." + field.GoName + ",\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
return buffer.String()
|
||||
}
|
||||
|
@@ -140,9 +140,9 @@ func (l *gCurd) generateWebModelRules(ctx context.Context, in *CurdPreviewInput)
|
||||
}
|
||||
|
||||
if field.FormRole == "" || field.FormRole == FormRoleNone {
|
||||
buffer.WriteString(fmt.Sprintf(" %s: {\n required: %v,\n trigger: ['blur', 'input'],\n message: '请输入%s',\n },\n", field.TsName, field.Required, field.Dc))
|
||||
buffer.WriteString(fmt.Sprintf(" %s: {\n required: %v,\n trigger: ['blur', 'input'],\n type: '%s',\n message: '请输入%s',\n },\n", field.TsName, field.Required, field.TsType, field.Dc))
|
||||
} else {
|
||||
buffer.WriteString(fmt.Sprintf(" %s: {\n required: %v,\n trigger: ['blur', 'input'],\n message: '请输入%s',\n validator: validate.%v,\n },\n", field.TsName, field.Required, field.Dc, field.FormRole))
|
||||
buffer.WriteString(fmt.Sprintf(" %s: {\n required: %v,\n trigger: ['blur', 'input'],\n type: '%s',\n message: '请输入%s',\n validator: validate.%v,\n },\n", field.TsName, field.Required, field.TsType, field.Dc, field.FormRole))
|
||||
}
|
||||
}
|
||||
buffer.WriteString("};\n")
|
||||
|
@@ -3,7 +3,7 @@ import { NAvatar, NImage, NTag, NSwitch, NRate } from 'naive-ui';
|
||||
import { cloneDeep } from 'lodash-es';
|
||||
import { FormSchema } from '@/components/Form';
|
||||
import { Dicts } from '@/api/dict/dict';
|
||||
@{ if eq .options.Step.HasSwitch true }import { Switch } from '@/api/@{.varName | LcFirst}';@{end}
|
||||
@{ if eq .options.Step.HasSwitch true }import { Switch } from '@{.importWebApi}';@{end}
|
||||
import { isArray, isNullObject } from '@/utils/is';
|
||||
import { getFileExt } from '@/utils/urlUtils';
|
||||
import { defRangeShortcuts, defShortcuts, formatToDate } from '@/utils/dateUtil';
|
||||
|
Reference in New Issue
Block a user