diff --git a/code/makecode.go b/code/makecode.go index af94b97..9ab1827 100644 --- a/code/makecode.go +++ b/code/makecode.go @@ -234,26 +234,34 @@ func (that *MakeCode) Db2JSON(name string, path string, db db.HoTimeDB) { coloum["sortable"] = true } - //如果是select类型需要设置options - if coloum.GetString("type") == "select" { - - options := Slice{} - comments := strings.Split(info.GetString("label"), " ") - if len(comments) >= 2 { - optionComment := strings.Split(comments[1], ",") - for _, v := range optionComment { - optionSlice := strings.Split(v, "-") - if len(optionSlice) >= 2 { - options = append(options, Map{"name": optionSlice[1], "value": optionSlice[0]}) - } - } - } - coloum["options"] = options - } - if !coloum.GetBool("notUse") { that.TableConfig.GetMap(v.GetString("name"))["columns"] = append(that.TableConfig.GetMap(v.GetString("name")).GetSlice("columns"), coloum) } + //如果是select类型需要设置options + //if coloum.GetString("type") == "select" { + + options := Slice{} + comments := strings.Split(info.GetString("label"), " ") + if len(comments) >= 2 { + optionComment := strings.Split(comments[1], ",") + for _, v := range optionComment { + optionSlice := strings.Split(v, "-") + if len(optionSlice) >= 2 { + options = append(options, Map{"name": optionSlice[1], "value": optionSlice[0]}) + } + } + } + + if coloum.GetString("type") == "select" { + coloum["must"] = true + coloum["options"] = options + } else if len(options) > 0 { + coloum["must"] = true + coloum["options"] = options + coloum["type"] = "select" + + } + //} } //else {