mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-26 16:46:14 +08:00
代码生成 使用优化
表单组件是下拉框,但是没有选择字段前端就会报错 status默认值置为1,不然表单添加的时候没有默认值 单选按钮组件在table也使用tag渲染 选择了字典类型后可清空 删除代码生成的时间
This commit is contained in:
@@ -70,7 +70,11 @@ func (l *gCurd) generateWebEditFormItem(ctx context.Context, in *CurdPreviewInpu
|
||||
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-checkbox-group v-model:value=\"params.%s\">\n <n-space>\n <n-checkbox\n v-for=\"item in options.%s\"\n :key=\"item.value\"\n :value=\"item.value\"\n :label=\"item.label\"\n />\n </n-space>\n </n-checkbox-group>\n </n-form-item>", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName])
|
||||
|
||||
case FormModeSelect:
|
||||
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-select v-model:value=\"params.%s\" :options=\"options.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName])
|
||||
if in.options.dictMap[field.TsName] != nil {
|
||||
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-select v-model:value=\"params.%s\" :options=\"options.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName])
|
||||
} else {
|
||||
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-select v-model:value=\"params.%s\" options=\"\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName)
|
||||
}
|
||||
|
||||
case FormModeSelectMultiple:
|
||||
component = fmt.Sprintf("<n-form-item label=\"%s\" path=\"%s\">\n <n-select multiple v-model:value=\"params.%s\" :options=\"options.%s\" />\n </n-form-item>", field.Dc, field.TsName, field.TsName, in.options.dictMap[field.TsName])
|
||||
|
@@ -53,6 +53,9 @@ func (l *gCurd) generateWebModelDefaultState(ctx context.Context, in *CurdPrevie
|
||||
if value == "" {
|
||||
value = "''"
|
||||
}
|
||||
if field.Name == "status" {
|
||||
value = 1
|
||||
}
|
||||
buffer.WriteString(fmt.Sprintf(" %s: %v,\n", field.TsName, value))
|
||||
}
|
||||
buffer.WriteString("};")
|
||||
@@ -261,6 +264,8 @@ func (l *gCurd) generateWebModelColumnsEach(buffer *bytes.Buffer, in *CurdPrevie
|
||||
case FormModeDate:
|
||||
component = fmt.Sprintf(" {\n title: '%s',\n key: '%s',\n render(row) {\n return formatToDate(row.%s);\n },\n },\n", field.Dc, field.TsName, field.TsName)
|
||||
|
||||
case FormModeRadio:
|
||||
fallthrough
|
||||
case FormModeSelect:
|
||||
if g.IsEmpty(in.options.dictMap[field.TsName]) {
|
||||
err = gerror.Newf("设置单选下拉框选项时,必须选择字典类型,字段名称:%v", field.Name)
|
||||
|
Reference in New Issue
Block a user