@ -630,13 +630,19 @@ func (a *ApiMethod) GainTableField(c *gin.Context) {
}
masterTable , err := GainFormTableField ( customerFormMaster . TableKey )
if err != nil {
publicmethod . Result ( 1 , err , c , "未知表单!无法获取字段!" )
return
}
sendTableList := publicmethod . MapOut [ string ] ( )
sendTableList [ "masterTableName" ] = customerFormMaster . Name
sendTableList [ "masterTable" ] = masterTable
if err != nil {
if customerFormMaster . MastesForm != "" {
publicmethod . Result ( 0 , sendTableList , c )
} else {
publicmethod . Result ( 1 , err , c , "未知表单!无法获取字段!" )
}
return
}
if customerFormMaster . TableStructure != "" { //判断是否有主体子表单
var sunTable map [ string ] interface { }
err = json . Unmarshal ( [ ] byte ( customerFormMaster . TableStructure ) , & sunTable )
@ -683,17 +689,42 @@ func (a *ApiMethod) GainFormTableField(c *gin.Context) {
return
}
var customerFormMaster modelAppPlatform . CustomerFormView
err = customerFormMaster . GetCont ( map [ string ] interface { } { "`cfid`" : requestData . Id , "`status`" : 1 } , "`tablekey`" , "`table_structure`" , "`mastesform`" , "`mastesformjson`" )
err = customerFormMaster . GetCont ( map [ string ] interface { } { "`cfid`" : requestData . Id , "`status`" : 1 } , "`tablekey`" , "`table_structure`" , "`mastesform`" , "`mastesformjson`" , "`listjson`" )
if err != nil {
publicmethod . Result ( 1 , err , c , "未知表单!无法获取字段!" )
return
}
masterTable , err := GainFormTableField ( customerFormMaster . TableKey )
var masterTable [ ] Result
var listFieldsMap ListPageFields
if customerFormMaster . ListJson != "" {
json . Unmarshal ( [ ] byte ( customerFormMaster . ListJson ) , & listFieldsMap )
fmt . Printf ( "判断结果%v" , JhudgeIsTitle ( listFieldsMap ) )
if JhudgeIsTitle ( listFieldsMap ) {
var myKeyWord Result
myKeyWord . Field = "_lableTitle"
myKeyWord . Type = "varchar(255)"
myKeyWord . Attribute = ""
myKeyWord . Collation = "utf8mb4_bin"
myKeyWord . Null = "YES"
myKeyWord . Key = ""
myKeyWord . Default = ""
myKeyWord . Extra = ""
myKeyWord . Privileges = "select,insert,update,references"
myKeyWord . Comment = "标题"
myKeyWord . Pattern = "varchar"
myKeyWord . Classify = ""
masterTable = append ( masterTable , myKeyWord )
}
}
masterTableAll , err := GainFormTableField ( customerFormMaster . TableKey )
masterTable = append ( masterTable , masterTableAll ... )
if err != nil {
publicmethod . Result ( 1 , err , c , "未知表单!无法获取字段!" )
return
}
// jhjs, _ := json.Marshal(masterTable)
// fmt.Printf("jhjs--------------->\n%v\n", string(jhjs))
var unitCont map [ string ] interface { }
json . Unmarshal ( [ ] byte ( customerFormMaster . MastesFormJson ) , & unitCont )
@ -709,6 +740,7 @@ func (a *ApiMethod) GainFormTableField(c *gin.Context) {
if len ( formFieldAry . MasterInfo ) > 0 {
sendTableList [ "masterTable" ] = TableFieldCompare ( masterTable , formFieldAry . MasterInfo )
} else {
sendTableList [ "masterTable" ] = masterTable
}
@ -739,16 +771,11 @@ func (a *ApiMethod) GainFormTableField(c *gin.Context) {
publicmethod . Result ( 0 , sendTableList , c )
}
// 获取子表表单数据
func GainSunFormTableField ( tableName string , SunFormInfo [ ] SunFormFieldInfoList ) ( fieldList [ ] FormFieldInfo ) {
return
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2024 - 03 - 25 0 9 : 01 : 12
@ 功能 : 表单数据对照
@ 时间 : 2024 - 07 - 25 0 9 : 46 : 13
@ 功能 : 判断是否有标题
@ 参数
#
@ -761,116 +788,184 @@ func GainSunFormTableField(tableName string, SunFormInfo []SunFormFieldInfoList)
#
* /
func TableFieldCompare ( tableFieldList [ ] Result , jsonFieldList [ ] FormFieldInfo ) ( fieldList [ ] FormFieldInfo ) {
if len ( tableFieldList ) > 0 {
if len ( jsonFieldList ) > 0 {
var writeTableField [ ] string
for _ , tv := range tableFieldList {
for _ , jv := range jsonFieldList {
if tv . Field == jv . Id {
if ! publicmethod . IsInTrue [ string ] ( tv . Field , writeTableField ) {
writeTableField = append ( writeTableField , tv . Field )
}
var fieldInfo FormFieldInfo
fieldInfo . Id = jv . Id
if tv . Comment == "" {
fieldInfo . Label = jv . Label
} else {
fieldInfo . Label = tv . Comment
}
func JhudgeIsTitle ( listFieldsMap ListPageFields ) bool {
fieldInfo . Field = tv . Field //field"`
if listView , isOk := listFieldsMap . View [ "list" ] ; isOk {
fmt . Printf ( "判断是否有标题--->%v--->%v\n" , listView , len ( listView . Form . Title ) )
if len ( listView . Form . Title ) > 0 {
return true
}
}
return false
}
attFiled := strings . Split ( tv . Type , " " )
fmt . Printf ( "attFiled---->%v=========>%v\n" , tv . Type , attFiled )
if len ( attFiled ) > 0 {
fieldInfo . Types = attFiled [ 0 ]
}
if len ( attFiled ) >= 2 {
fieldInfo . Attribute = attFiled [ 1 ]
}
// 获取子表表单数据
func GainSunFormTableField ( tableName string , SunFormInfo [ ] SunFormFieldInfoList ) ( fieldList [ ] FormFieldInfo ) {
return
}
patternInfo := strings . Split ( tv . Type , "(" )
if len ( patternInfo ) >= 1 {
fieldInfo . Pattern = patternInfo [ 0 ]
}
/ *
*
@ 作者 : 秦东
@ 时间 : 2024 - 03 - 25 0 9 : 01 : 12
@ 功能 : 表单数据对照
@ 参数
fieldInfo . FieldClass = jv . FieldClass //fieldClass"`
fieldInfo . ActiveValue = jv . ActiveValue //activeValue"`
fieldInfo . InactiveValue = jv . InactiveValue //inactiveValue"`
fieldInfo . Options = jv . Options //options"`
fieldInfo . Control = jv . Control //control"`
fieldInfo . Config = jv . Config //config"`
fieldList = append ( fieldList , fieldInfo )
}
}
}
if len ( writeTableField ) > 0 {
for _ , tv := range tableFieldList {
if ! publicmethod . IsInTrue [ string ] ( tv . Field , writeTableField ) {
var fieldInfo FormFieldInfo
fieldInfo . Id = tv . Field
if tv . Comment == "" {
fieldInfo . Label = tv . Field
} else {
fieldInfo . Label = tv . Comment
}
#
fieldInfo . Field = tv . Field //field"`
@ 返回值
attFiled := strings . Split ( tv . Type , " " )
if len ( attFiled ) > 0 {
fieldInfo . Types = attFiled [ 0 ]
}
if len ( attFiled ) >= 2 {
fieldInfo . Attribute = attFiled [ 1 ]
#
}
patternInfo := strings . Split ( tv . Type , "(" )
if len ( patternInfo ) >= 1 {
fieldInfo . Pattern = patternInfo [ 0 ]
}
@ 方法原型
fieldInfo . FieldClass = tv . Field //fieldClass"`
// fieldInfo.ActiveValue = v. //activeValue"`
// fieldInfo.InactiveValue = v. //inactiveValue"`
// fieldInfo.Options = v. //options"`
#
* /
func TableFieldCompare ( tableFieldList [ ] Result , jsonFieldList [ ] FormFieldInfo ) ( fieldList [ ] FormFieldInfo ) {
fieldList = append ( fieldList , fieldInfo )
}
}
for _ , jv := range jsonFieldList {
if ! publicmethod . IsInTrue [ string ] ( jv . Id , writeTableField ) {
fieldList = append ( fieldList , jv )
}
}
}
} else {
for _ , v := range tableFieldList {
var fieldInfo FormFieldInfo
fieldInfo . Id = v . Field
fieldInfo . Label = v . Comment
fieldInfo . Field = v . Field //field"`
tableFieldListsdf , _ := json . Marshal ( tableFieldList )
jsonFieldListsdf , _ := json . Marshal ( jsonFieldList )
fmt . Printf ( "\n=====================================================\n" )
fmt . Printf ( "tableFieldListsdf:%v\n" , string ( tableFieldListsdf ) )
fmt . Printf ( "jsonFieldListsdf:%v\n" , string ( jsonFieldListsdf ) )
fmt . Printf ( "\n=====================================================\n" )
if len ( tableFieldList ) > 0 {
for _ , v := range tableFieldList {
if v . Field == "_lableTitle" {
var titleInfo FormFieldInfo
titleInfo . Id = v . Field
titleInfo . Label = v . Comment
titleInfo . Field = v . Field
attFiled := strings . Split ( v . Type , " " )
// fmt.Printf("attFiled---->%v=========>%v\n", v.Type, attFiled)
if len ( attFiled ) > 0 {
titleInfo . Types = attFiled [ 0 ]
}
if len ( attFiled ) >= 2 {
fieldInfo . Attribute = attFiled [ 1 ]
fieldInfo . Types = attFiled [ 0 ]
titleInfo . Attribute = attFiled [ 1 ]
}
patternInfo := strings . Split ( v . Type , "(" )
if len ( patternInfo ) >= 1 {
field Info. Pattern = patternInfo [ 0 ]
title Info. Pattern = patternInfo [ 0 ]
}
// fieldInfo.FieldClass = v. //fieldClass"`
// fieldInfo.ActiveValue = v. //activeValue"`
// fieldInfo.InactiveValue = v. //inactiveValue"`
// fieldInfo.Options = v. //options"`
fieldList = append ( fieldList , fieldInfo )
titleInfo . FieldClass = v . Field
titleInfo . ActiveValue = ""
titleInfo . InactiveValue = ""
fieldList = append ( fieldList , titleInfo )
} else {
fieldList = append ( fieldList , TableFormAttribute ( v , jsonFieldList ) )
}
}
// if len(jsonFieldList) > 0 {
// var writeTableField []string
// for _, tv := range tableFieldList {
// for _, jv := range jsonFieldList {
// if tv.Field == jv.Id {
// if !publicmethod.IsInTrue[string](tv.Field, writeTableField) {
// writeTableField = append(writeTableField, tv.Field)
// }
// var fieldInfo FormFieldInfo
// fieldInfo.Id = jv.Id
// if tv.Comment == "" {
// fieldInfo.Label = jv.Label
// } else {
// fieldInfo.Label = tv.Comment
// }
// fieldInfo.Field = tv.Field //field"`
// attFiled := strings.Split(tv.Type, " ")
// // fmt.Printf("attFiled---->%v=========>%v\n", tv.Type, jv.Auxiliary)
// if len(attFiled) > 0 {
// fieldInfo.Types = attFiled[0]
// }
// if len(attFiled) >= 2 {
// fieldInfo.Attribute = attFiled[1]
// }
// patternInfo := strings.Split(tv.Type, "(")
// if len(patternInfo) >= 1 {
// fieldInfo.Pattern = patternInfo[0]
// }
// fieldInfo.Auxiliary = jv.Auxiliary
// fieldInfo.FieldClass = jv.FieldClass //fieldClass"`
// fieldInfo.ActiveValue = jv.ActiveValue //activeValue"`
// fieldInfo.InactiveValue = jv.InactiveValue //inactiveValue"`
// fieldInfo.Options = jv.Options //options"`
// fieldInfo.Control = jv.Control //control"`
// fieldInfo.Config = jv.Config //config"`
// fieldList = append(fieldList, fieldInfo)
// }
// }
// }
// if len(writeTableField) > 0 {
// for _, tv := range tableFieldList {
// if !publicmethod.IsInTrue[string](tv.Field, writeTableField) {
// var fieldInfo FormFieldInfo
// fieldInfo.Id = tv.Field
// if tv.Comment == "" {
// fieldInfo.Label = tv.Field
// } else {
// fieldInfo.Label = tv.Comment
// }
// fieldInfo.Field = tv.Field //field"`
// attFiled := strings.Split(tv.Type, " ")
// if len(attFiled) > 0 {
// fieldInfo.Types = attFiled[0]
// }
// if len(attFiled) >= 2 {
// fieldInfo.Attribute = attFiled[1]
// }
// patternInfo := strings.Split(tv.Type, "(")
// if len(patternInfo) >= 1 {
// fieldInfo.Pattern = patternInfo[0]
// }
// fieldInfo.FieldClass = tv.Field //fieldClass"`
// // fieldInfo.ActiveValue = v. //activeValue"`
// // fieldInfo.InactiveValue = v. //inactiveValue"`
// // fieldInfo.Options = v. //options"`
// fieldList = append(fieldList, fieldInfo)
// }
// }
// for _, jv := range jsonFieldList {
// if !publicmethod.IsInTrue[string](jv.Id, writeTableField) {
// fieldList = append(fieldList, jv)
// }
// }
// }
// } else {
// for _, v := range tableFieldList {
// var fieldInfo FormFieldInfo
// fieldInfo.Id = v.Field
// fieldInfo.Label = v.Comment
// fieldInfo.Field = v.Field //field"`
// attFiled := strings.Split(v.Type, " ")
// if len(attFiled) >= 2 {
// fieldInfo.Attribute = attFiled[1]
// fieldInfo.Types = attFiled[0]
// }
// patternInfo := strings.Split(v.Type, "(")
// if len(patternInfo) >= 1 {
// fieldInfo.Pattern = patternInfo[0]
// }
// // fieldInfo.FieldClass = v. //fieldClass"`
// // fieldInfo.ActiveValue = v. //activeValue"`
// // fieldInfo.InactiveValue = v. //inactiveValue"`
// // fieldInfo.Options = v. //options"`
// fieldList = append(fieldList, fieldInfo)
// }
// }
} else {
fieldList = jsonFieldList
}
@ -987,10 +1082,13 @@ func (f *FormJsonFieldInfo) AnalyzingFormJson(tableName string, unitList []inter
if unitTypeStr , ok := unitType . ( string ) ; ok {
unitInfo . FieldClass = unitTypeStr
}
// fmt.Printf("unitList---->%T====>%v\n", listInfo["control"] , listInfo["control"])
// fmt.Printf("unitListt---->%v---->%T====>%v\n",unitType , listInfo["control"])
if controlVal , ok := listInfo [ "control" ] ; ok {
// fmt.Printf("unitList--123-->%T====>%v\n", controlVal, controlVal)
if controlMap , ok := controlVal . ( map [ string ] interface { } ) ; ok {
// fmt.Printf("unitList--450-->%T====>%v\n", controlMap["type"], controlMap["type"])
if activeVal , ok := controlMap [ "activeValue" ] ; ok {
if activeValStr , ok := activeVal . ( string ) ; ok {
unitInfo . ActiveValue = activeValStr
@ -1001,7 +1099,12 @@ func (f *FormJsonFieldInfo) AnalyzingFormJson(tableName string, unitList []inter
unitInfo . InactiveValue = InactiveValStr
}
}
if typeVal , ok := controlMap [ "type" ] ; ok {
if typeValStr , ok := typeVal . ( string ) ; ok {
unitInfo . Auxiliary = typeValStr
// fmt.Printf("unitList--450-->%T====>%v\n", typeValStr, typeValStr)
}
}
// fmt.Printf("unitList--5656-->%T====>%v\n", controlMap["optionsValue3Formid"], controlMap["optionsValue3Formid"])
// fmt.Printf("unitList--7788-->%T====>%v\n", controlMap["optionsValue3Field"], controlMap["optionsValue3Field"])
@ -1031,7 +1134,7 @@ func (f *FormJsonFieldInfo) AnalyzingFormJson(tableName string, unitList []inter
if configVal , ok := listInfo [ "config" ] ; ok {
if configMap , ok := configVal . ( map [ string ] interface { } ) ; ok {
if configMApVal , ok := configMap [ "optionsType" ] ; ok {
fmt . Printf ( "optvMap---->%T====>%v\n" , configMApVal , configMApVal )
// fmt.Printf("optvMap---->%T====>%v\n", configMApVal, configMApVal)
if configMApValStr , ok := configMApVal . ( float64 ) ; ok {
unitInfo . Config . OptionsType = configMApValStr
}
@ -1062,8 +1165,8 @@ func (f *FormJsonFieldInfo) AnalyzingFormJson(tableName string, unitList []inter
}
}
fieldInfo = append ( fieldInfo , unitInfo )
fmt . Printf ( "unitInfo--1->:%v\n" , unitInfo )
fmt . Printf ( "fieldInfo-2->:%v\n" , fieldInfo )
// fmt.Printf("unitInfo--1->:%v\n", unitInfo)
// fmt.Printf("fieldInfo-2->:%v\n", fieldInfo)
}
}
}
@ -1273,27 +1376,31 @@ func (a *ApiMethod) GainFormPageListCont(c *gin.Context) {
formList [ i ] [ "isRetract" ] = false
if mastrKey , ok := v [ "runFlowId" ] ; ok {
// fmt.Printf("masters_key----------->%v\n", v["masters_key"])
var runFlowInfo customerForm . RunWorkflow
runFlowInfo . GetCont ( map [ string ] interface { } { "`id`" : mastrKey } , "`id`" , "`current_step`" , "`next_step`" )
formList [ i ] [ "runFlowInfo" ] = runFlowInfo . Id
// fmt.Printf("runFlowInfo----------->%v--------->%v\n", runFlowInfo, v["taskStatus"])
if stateVal , ok := v [ "taskStatus" ] ; ok {
// fmt.Printf("NextStep----------->%T----------->%v--------->%v--------->%v\n", stateVal, stateVal, runFlowInfo.NextStep, runFlowInfo.CurrentStep)
if stauval , ok := stateVal . ( string ) ; ok {
if stauval == "3" && runFlowInfo . NextStep != 0 {
if runFlowInfo . CurrentStep == 1 {
if createrName , ok := formList [ i ] [ "creater" ] . ( string ) ; ok {
if createrName == userCont . Name {
formList [ i ] [ "isRetract" ] = true
mastrKeyInt , _ := publicmethod . StringToInt64 ( mastrKey )
if mastrKeyInt != 0 {
var runFlowInfo customerForm . RunWorkflow
runFlowInfo . GetCont ( map [ string ] interface { } { "`id`" : mastrKey } , "`id`" , "`current_step`" , "`next_step`" )
formList [ i ] [ "runFlowInfo" ] = runFlowInfo . Id
// fmt.Printf("runFlowInfo----------->%v--------->%v\n", runFlowInfo, v["taskStatus"])
if stateVal , ok := v [ "taskStatus" ] ; ok {
// fmt.Printf("NextStep----------->%T----------->%v--------->%v--------->%v\n", stateVal, stateVal, runFlowInfo.NextStep, runFlowInfo.CurrentStep)
if stauval , ok := stateVal . ( string ) ; ok {
if stauval == "3" && runFlowInfo . NextStep != 0 {
if runFlowInfo . CurrentStep == 1 {
if createrName , ok := formList [ i ] [ "creater" ] . ( string ) ; ok {
if createrName == userCont . Name {
formList [ i ] [ "isRetract" ] = true
}
}
}
}
}
}
}
}
}
}
if mastrKeyVal , ok := v [ "masters_key" ] ; ok {
// fmt.Printf("mastrKeyVal----------->%T----------->%v\n", mastrKeyVal, mastrKeyVal)
@ -1318,7 +1425,7 @@ func (l *ListPageFields) DevelopSpecificationsSend(listData []map[string]interfa
for _ , v := range listData {
sendInfo := publicmethod . MapOut [ string ] ( )
for mi , mv := range v {
fmt . Printf ( "%v = %v\n" , mi , mv )
switch mi {
case "creater" :
var myInfo modelshr . PersonArchives
@ -1334,6 +1441,135 @@ func (l *ListPageFields) DevelopSpecificationsSend(listData []map[string]interfa
sendInfo [ mi ] = l . BaseTableAttrField ( mi , mv )
// sendInfo[mi] = publicmethod.TypeToInterface(mv)
}
for _ , lv := range l . TableData . Columns {
if lv . FieldClass != "-" && lv . FieldClass != "_lableTitle" && lv . FieldClass != "__control" {
if lv . Id == mi {
switch lv . FieldClass {
case "radio" :
for _ , ov := range lv . Options {
// fmt.Printf("%T = %v\n", mv, mv)
radioId := publicmethod . TypeToInterface ( mv )
if radioId == ov . Value {
sendInfo [ mi ] = ov . Label
}
// if radioId, isOk := mv.(int64); isOk {
// radioIdStr := strconv.FormatInt(radioId, 10)
// if radioIdStr == ov.Value {
// sendInfo[mi] = ov.Label
// }
// }
// if radioId, isOk := mv.(string); isOk {
// if radioId == ov.Value {
// sendInfo[mi] = ov.Label
// }
// }
}
case "datePicker" :
var beginTime string
timeVal , _ := publicmethod . StringToInt64 ( mv )
// if isOk == nil {
// beginTime = timeVal
// sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 14)
// }
switch lv . Auxiliary {
case "year" :
sendInfo [ mi ] = publicmethod . UnixTimeToDay ( timeVal / 1000 , 16 )
case "month" :
sendInfo [ mi ] = publicmethod . UnixTimeToDay ( timeVal / 1000 , 15 )
case "datetime" :
sendInfo [ mi ] = publicmethod . UnixTimeToDay ( timeVal / 1000 , 11 )
case "week" :
sendInfo [ mi ] = publicmethod . UnixTimeToDay ( timeVal / 1000 , 41 )
case "datetimerange" :
beginTime = publicmethod . UnixTimeToDay ( timeVal / 1000 , 11 )
sendInfo [ mi ] = beginTime
endKey := fmt . Sprintf ( "%v_end" , mi )
if v [ endKey ] != nil {
endTimeVal , _ := publicmethod . StringToInt64 ( v [ endKey ] )
sendInfo [ mi ] = fmt . Sprintf ( "%v - %v" , beginTime , publicmethod . UnixTimeToDay ( int64 ( endTimeVal ) / 1000 , 11 ) )
}
case "daterange" :
beginTime = publicmethod . UnixTimeToDay ( timeVal / 1000 , 14 )
sendInfo [ mi ] = beginTime
endKey := fmt . Sprintf ( "%v_end" , mi )
if v [ endKey ] != nil {
endTimeVal , _ := publicmethod . StringToInt64 ( v [ endKey ] )
sendInfo [ mi ] = fmt . Sprintf ( "%v - %v" , beginTime , publicmethod . UnixTimeToDay ( int64 ( endTimeVal ) / 1000 , 14 ) )
}
case "monthrange" :
beginTime = publicmethod . UnixTimeToDay ( timeVal / 1000 , 15 )
sendInfo [ mi ] = beginTime
endKey := fmt . Sprintf ( "%v_end" , mi )
if v [ endKey ] != nil {
endTimeVal , _ := publicmethod . StringToInt64 ( v [ endKey ] )
sendInfo [ mi ] = fmt . Sprintf ( "%v - %v" , beginTime , publicmethod . UnixTimeToDay ( int64 ( endTimeVal ) / 1000 , 15 ) )
}
default :
beginTime = publicmethod . UnixTimeToDay ( timeVal / 1000 , 14 )
sendInfo [ mi ] = beginTime
endKey := fmt . Sprintf ( "%v_end" , mi )
if v [ endKey ] != nil {
endTimeVal , _ := publicmethod . StringToInt64 ( v [ endKey ] )
sendInfo [ mi ] = fmt . Sprintf ( "%v - %v" , beginTime , publicmethod . UnixTimeToDay ( int64 ( endTimeVal ) / 1000 , 14 ) )
}
}
case "timePicker" :
if timeVal , isOk := mv . ( int64 ) ; isOk {
sendInfo [ mi ] = publicmethod . UnixTimeToDay ( timeVal / 1000 , 6 )
}
case "deptOrg" :
var orgCont modelshr . AdministrativeOrganization
orgCont . GetCont ( map [ string ] interface { } { "`id`" : mv } , "`name`" )
sendInfo [ mi ] = orgCont . Name
case "owner" :
var userInfo modelshr . PersonArchives
userInfo . GetCont ( map [ string ] interface { } { "`key`" : mv } , "`name`" , "`number`" )
sendInfo [ mi ] = fmt . Sprintf ( "%v(%v)" , userInfo . Name , userInfo . Number )
case "expand-user" :
var userAry [ ] string
jsonStr := publicmethod . TypeToInterface ( mv )
json . Unmarshal ( [ ] byte ( jsonStr ) , & userAry )
sendInfo [ mi ] = strings . Join ( userAry , " , " )
case "select" :
var sendInfp [ ] string
if mv != nil {
fmt . Printf ( "Step1:\n" )
valStr := publicmethod . TypeToInterface ( mv )
var valAry [ ] int64
json . Unmarshal ( [ ] byte ( valStr ) , & valAry )
if len ( valAry ) > 0 {
for _ , vv := range valAry {
for _ , v := range lv . Options {
vvStr := strconv . FormatInt ( vv , 10 )
if v . Value == vvStr {
fmt . Printf ( "Step2:\n" )
sendInfp = append ( sendInfp , v . Label )
}
}
}
} else {
fmt . Printf ( "Step3:\n" )
for _ , v := range lv . Options {
if v . Value == valStr {
fmt . Printf ( "Step4:\n" )
sendInfp = append ( sendInfp , v . Label )
}
}
}
sendInfo [ mi ] = strings . Join ( sendInfp , " , " )
}
default :
}
}
}
}
}
// fmt.Printf("================================\n")
sendList = append ( sendList , sendInfo )
@ -1389,6 +1625,38 @@ func (l *ListPageFields) BaseTableAttrField(key string, val interface{}) interfa
if len ( mapAry ) > 0 {
return mapAry [ 0 ]
}
case "select" :
var sendInfp [ ] string
if val != nil {
valStr := publicmethod . TypeToInterface ( val )
var valAry [ ] int64
json . Unmarshal ( [ ] byte ( valStr ) , & valAry )
if len ( valAry ) > 0 {
for _ , vv := range valAry {
for _ , v := range v . Options {
vvStr := strconv . FormatInt ( vv , 10 )
if v . Value == vvStr {
sendInfp = append ( sendInfp , v . Label )
}
}
}
} else {
for _ , v := range v . Options {
if v . Value == valStr {
sendInfp = append ( sendInfp , v . Label )
}
}
}
selectVal := strings . Join ( sendInfp , " , " )
return selectVal
}
default :
return publicmethod . TypeToInterface ( val )
}
@ -1445,17 +1713,96 @@ func AnalysisSerachTermSql(why string, gormDb *gorm.DB) *gorm.DB {
}
for _ , v := range listField {
if v . Values != nil && v . Values != "" && v . Values != "" {
switch v . Pattern {
case "int" :
likeSql := fmt . Sprintf ( "f.`%v` = %v" , v . Field , v . Values )
gormDb = gormDb . Where ( likeSql )
case "bigint" :
likeSql := fmt . Sprintf ( "f.`%v` = %v" , v . Field , v . Values )
gormDb = gormDb . Where ( likeSql )
default :
likeSql := fmt . Sprintf ( "f.%v LIKE %v%v%v" , v . Field , "'%" , v . Values , "%'" )
if v . FieldClass == "datePicker" {
switch v . Auxiliary {
case "year" :
mvInt , _ := publicmethod . StringToInt64 ( v . Values )
likeSql := fmt . Sprintf ( "f.`%v` = %v" , v . Field , mvInt )
gormDb = gormDb . Where ( likeSql )
case "month" :
mvInt , _ := publicmethod . StringToInt64 ( v . Values )
likeSql := fmt . Sprintf ( "f.`%v` = %v" , v . Field , mvInt )
gormDb = gormDb . Where ( likeSql )
case "date" :
mvInt , _ := publicmethod . StringToInt64 ( v . Values )
likeSql := fmt . Sprintf ( "f.`%v` = %v" , v . Field , mvInt )
gormDb = gormDb . Where ( likeSql )
case "datetime" :
mvInt , _ := publicmethod . StringToInt64 ( v . Values )
likeSql := fmt . Sprintf ( "f.`%v` = %v" , v . Field , mvInt )
gormDb = gormDb . Where ( likeSql )
case "week" :
mvInt , _ := publicmethod . StringToInt64 ( v . Values )
likeSql := fmt . Sprintf ( "f.`%v` = %v" , v . Field , mvInt )
gormDb = gormDb . Where ( likeSql )
case "datetimerange" :
if val , isOk := v . Values . ( [ ] interface { } ) ; isOk {
if len ( val ) >= 2 {
starVal , _ := publicmethod . StringToInt64 ( val [ 0 ] )
endVal , _ := publicmethod . StringToInt64 ( val [ len ( val ) - 1 ] )
likeSql := fmt . Sprintf ( "f.`%v` >= %v AND f.`%v_end` <= %v" , v . Field , starVal , v . Field , endVal )
gormDb = gormDb . Where ( likeSql )
}
}
// likeSql := fmt.Sprintf("f.`%v` >= %v AND f.`%v_end` <= %v", v.Field, v.Values, v.Field, v.Values)
// gormDb = gormDb.Where(likeSql)
case "daterange" :
// likeSql := fmt.Sprintf("f.`%v` >= %v AND f.`%v_end` <= %v", v.Field, v.Values, v.Field, v.Values)
// gormDb = gormDb.Where(likeSql)
if val , isOk := v . Values . ( [ ] interface { } ) ; isOk {
if len ( val ) >= 2 {
starVal , _ := publicmethod . StringToInt64 ( val [ 0 ] )
endVal , _ := publicmethod . StringToInt64 ( val [ len ( val ) - 1 ] )
likeSql := fmt . Sprintf ( "f.`%v` >= %v AND f.`%v_end` <= %v" , v . Field , starVal , v . Field , endVal )
gormDb = gormDb . Where ( likeSql )
}
}
case "monthrange" :
// likeSql := fmt.Sprintf("f.`%v` >= %v AND f.`%v_end` <= %v", v.Field, v.Values, v.Field, v.Values)
// gormDb = gormDb.Where(likeSql)
if val , isOk := v . Values . ( [ ] interface { } ) ; isOk {
if len ( val ) >= 2 {
starVal , _ := publicmethod . StringToInt64 ( val [ 0 ] )
endVal , _ := publicmethod . StringToInt64 ( val [ len ( val ) - 1 ] )
likeSql := fmt . Sprintf ( "f.`%v` >= %v AND f.`%v_end` <= %v" , v . Field , starVal , v . Field , endVal )
gormDb = gormDb . Where ( likeSql )
}
}
default :
}
} else if v . FieldClass == "timePicker" {
mvInt , _ := publicmethod . StringToInt64 ( v . Values )
likeSql := fmt . Sprintf ( "f.`%v` = %v" , v . Field , mvInt )
gormDb = gormDb . Where ( likeSql )
} else if v . FieldClass == "_lableTitle" {
} else {
isWrint := true
if val , isOk := v . Values . ( [ ] interface { } ) ; isOk {
isWrint = false
if len ( val ) > 0 {
likeSql := fmt . Sprintf ( "f.`%v` IN %v" , v . Field , val )
gormDb = gormDb . Where ( likeSql )
}
}
if isWrint {
switch v . Pattern {
case "int" :
likeSql := fmt . Sprintf ( "f.`%v` = %v" , v . Field , v . Values )
gormDb = gormDb . Where ( likeSql )
case "bigint" :
likeSql := fmt . Sprintf ( "f.`%v` = %v" , v . Field , v . Values )
gormDb = gormDb . Where ( likeSql )
default :
likeSql := fmt . Sprintf ( "f.%v LIKE %v%v%v" , v . Field , "'%" , v . Values , "%'" )
gormDb = gormDb . Where ( likeSql )
}
}
}
}
}
return gormDb