diff --git a/server/resource/template/fe/table.vue.tpl b/server/resource/template/fe/table.vue.tpl index 367d1207..c6fedf49 100644 --- a/server/resource/template/fe/table.vue.tpl +++ b/server/resource/template/fe/table.vue.tpl @@ -4,9 +4,32 @@ {{- range .Fields}} {{- if .FieldSearchType}} + {{- if eq .FieldType "bool" }} + + + + + + + + + + + + + {{- else }} + {{ end }} {{ end }} {{ end }} @@ -108,6 +131,10 @@ export default { onSubmit() { this.page = 1 this.pageSize = 10 + {{- range .Fields}} {{- if eq .FieldType "bool" }} + if (this.searchInfo.{{.FieldJson}}==""){ + this.searchInfo.{{.FieldJson}}=null + } {{ end }} {{ end }} this.getTableData() }, async update{{.StructName}}(row) { diff --git a/server/resource/template/te/model.go.tpl b/server/resource/template/te/model.go.tpl index 873d5787..0a51ad59 100644 --- a/server/resource/template/te/model.go.tpl +++ b/server/resource/template/te/model.go.tpl @@ -7,6 +7,11 @@ import ( // 如果含有time.Time 请自行import time包 type {{.StructName}} struct { - gorm.Model {{range .Fields}} - {{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:'{{.Comment}}'"`{{ end }} + gorm.Model {{- range .Fields}} + {{- if eq .FieldType "bool" }} + {{.FieldName}} *{{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:'{{.Comment}}'"` + {{- else }} + {{.FieldName}} {{.FieldType}} `json:"{{.FieldJson}}" form:"{{.FieldJson}}" gorm:"column:{{.ColumnName}};comment:'{{.Comment}}'"` + {{- end }} {{- end }} +} } diff --git a/server/resource/template/te/service.go.tpl b/server/resource/template/te/service.go.tpl index 5ba589c3..16546c27 100644 --- a/server/resource/template/te/service.go.tpl +++ b/server/resource/template/te/service.go.tpl @@ -71,7 +71,7 @@ func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error, db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+ {{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }}) } {{- else if eq .FieldType "bool" }} - if info.{{.FieldName}} != 0 { + if info.{{.FieldName}} != nil { db = db.Where("{{.ColumnName}} {{.FieldSearchType}} ?",{{if eq .FieldSearchType "LIKE"}}"%"+{{ end }}info.{{.FieldName}}{{if eq .FieldSearchType "LIKE"}}+"%"{{ end }}) } {{- else if eq .FieldType "int" }}