Exemplo n.º 1
0
func transPurchaseMap(oldMap orm.Params) t.ItemMap {
	var retMap = make(t.ItemMap, 0)
	for key, value := range oldMap {
		retMap[strings.ToLower(key)] = value
	}
	if userName, ok := oldMap["user_name"]; ok {
		retMap["buyer"] = userName
	}
	category, _ := retMap[s.Category].(string)
	retMap[s.Category] = lang.GetLabel(category)
	if supplierSn, ok := retMap[s.Supplier]; ok && !u.IsNullStr(supplierSn) {
		if supplierMap, sok := supplierMgr.Get(supplierSn.(string)); sok {
			retMap[s.Supplier+s.EName] = u.GetStringValue(supplierMap, s.Name)
			retMap[s.Supplier+s.EKey] = u.GetStringValue(supplierMap, s.Keyword)
		}
	}
	return retMap
}
Exemplo n.º 2
0
func BuildSelectOptions(valueMaps []map[string]interface{}, defaultValue interface{}, valueField string, labelField string, addFields ...string) string {
	options := ""
	for _, valueMap := range valueMaps {
		optionValue, ok := valueMap[valueField]
		if !ok {
			continue
		}
		optionValueStr := u.ToStr(optionValue)
		optionLabel, _ := valueMap[labelField]

		optionDatas := ""
		for _, addField := range addFields {
			addData := u.GetStringValue(valueMap, addField)
			optionDatas = optionDatas + fmt.Sprintf(`data-wb-a-%s = "%s" `, addField, addData)
		}

		if optionValue == defaultValue {
			options = options + fmt.Sprintf(`<option value="%s" %s selected>%s</option>`, optionValueStr, optionDatas, optionLabel)
			continue
		}
		options = options + fmt.Sprintf(`<option value="%s" %s>%s</option>`, optionValueStr, optionDatas, optionLabel)
	}
	return options
}