From 992a07bd068f5caa66a4a3659ad98c0bedbc68e8 Mon Sep 17 00:00:00 2001 From: aaron <462826@qq.com> Date: Tue, 17 Nov 2020 09:40:26 +0800 Subject: [PATCH] fix a issue --- src/model/definition.go | 1 + src/service/list.go | 5 +++-- src/utils/const/const.go | 1 + src/utils/string/string.go | 6 +++++- ui/src/components/FieldRefer.vue | 2 +- users/zentao/customer.yaml | 18 ++++++++++++++++++ 6 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 users/zentao/customer.yaml diff --git a/src/model/definition.go b/src/model/definition.go index 9a28096c..c503cd87 100644 --- a/src/model/definition.go +++ b/src/model/definition.go @@ -100,6 +100,7 @@ type DefInfo struct { Title string `yaml:"title"` Desc string `yaml:"desc"` + Fields interface{} `yaml:"fields,omitempty"` // is yaml Range string `yaml:"range,omitempty"` // is config Ranges interface{} `yaml:"ranges,omitempty"` // is ranges Instances interface{} `yaml:"instances,omitempty"` // is instances diff --git a/src/service/list.go b/src/service/list.go index 14ef894d..4aeddf0c 100644 --- a/src/service/list.go +++ b/src/service/list.go @@ -73,8 +73,7 @@ func LoadRes(resType string) (res map[string][]model.ResFile, nameWidth, titleWi } } - if resType == "" || resType == item.ResType || - (resType == "yaml" && fileExt == ".yaml"){ + if resType == "" || resType == item.ResType { arr = append(arr, item) } } @@ -236,6 +235,8 @@ func GetYamlResType(def model.DefInfo) string { return constant.ResTypeRanges } else if def.Instances != nil { return constant.ResTypeInstances + } else if def.Fields != nil { + return constant.ResTypeYaml } return "" diff --git a/src/utils/const/const.go b/src/utils/const/const.go index ba47d68f..6e957037 100644 --- a/src/utils/const/const.go +++ b/src/utils/const/const.go @@ -71,6 +71,7 @@ var ( ResTypeConfig = "config" ResTypeRanges = "ranges" ResTypeInstances = "instances" + ResTypeYaml = "yaml" ResTypeExcel = "excel" ResTypeText = "text" ResTypes = []string{ResTypeConfig, ResTypeRanges, ResTypeInstances, ResTypeExcel, ResTypeText} diff --git a/src/utils/string/string.go b/src/utils/string/string.go index 459d83d1..b8a59181 100644 --- a/src/utils/string/string.go +++ b/src/utils/string/string.go @@ -66,6 +66,10 @@ func BoolToPass(b bool) string { } } +func FindInArrBool(str string, arr []string) bool { + found, _ := FindInArr(str, arr) + return found +} func FindInArr(str string, arr []string) (bool,int) { for index, s := range arr { if str == s { @@ -240,4 +244,4 @@ func UrlEncode(str string) (ret string) { ret = base64.URLEncoding.EncodeToString([]byte(str)) return -} \ No newline at end of file +} diff --git a/ui/src/components/FieldRefer.vue b/ui/src/components/FieldRefer.vue index fafe5f91..fb1a51ba 100644 --- a/ui/src/components/FieldRefer.vue +++ b/ui/src/components/FieldRefer.vue @@ -136,7 +136,7 @@ export default { }, onReferChanged(value) { console.log("onReferChanged") - this.refer.file = value + this.refer.file = value.split('-')[0] if (this.refer.type != 'yaml' && this.refer.type != 'text') { this.listDefFieldReferField() diff --git a/users/zentao/customer.yaml b/users/zentao/customer.yaml new file mode 100644 index 00000000..dd2c1e42 --- /dev/null +++ b/users/zentao/customer.yaml @@ -0,0 +1,18 @@ +title: YAML类型 +desc: +author: +version: 1.0 + +fields: + - field: t1 + range: a-z + postfix: "\t" + + - field: WC_SEX + range: sex.txt + #rand: true + postfix: "\t" + + - field: t2 + range: 1-9 + postfix: "\t" -- GitLab