|
|
|
|
package customerform
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
datacenter "appPlatform/api/version1/dataCenter"
|
|
|
|
|
"appPlatform/middleware/grocerystore"
|
|
|
|
|
"appPlatform/models/customerForm"
|
|
|
|
|
"appPlatform/models/modelAppPlatform"
|
|
|
|
|
"appPlatform/models/modelshr"
|
|
|
|
|
"appPlatform/models/modelssystempermission"
|
|
|
|
|
"appPlatform/overall"
|
|
|
|
|
"appPlatform/overall/publicmethod"
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2023-09-30 14:37:11
|
|
|
|
|
@ 功能: 分析表格组件转换值类型
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func AnalysisFormUnitClass(subUnit MasterStruct) (fieldCont AnalysisFormSubUnitClass) {
|
|
|
|
|
fieldCont.UnitName = subUnit.Type
|
|
|
|
|
fieldCont.WordName = subUnit.Name
|
|
|
|
|
fieldCont.Describe = subUnit.Item.Label
|
|
|
|
|
fieldCont.MinVal = 0
|
|
|
|
|
switch subUnit.Type {
|
|
|
|
|
case "input", "password": //单行文本
|
|
|
|
|
if len(subUnit.CustomRules) > 0 {
|
|
|
|
|
var fieldType []string
|
|
|
|
|
var valType []fieldStruct
|
|
|
|
|
for _, v := range subUnit.CustomRules {
|
|
|
|
|
switch v.Trigger {
|
|
|
|
|
case "mobile", "tel", "phone", "card":
|
|
|
|
|
if !publicmethod.IsInTrue[string]("varchar", fieldType) {
|
|
|
|
|
fieldType = append(fieldType, "varchar")
|
|
|
|
|
valType = append(valType, fieldStruct{Types: "varchar", MaxVal: 50})
|
|
|
|
|
} else {
|
|
|
|
|
for i := 0; i < len(valType); i++ {
|
|
|
|
|
if valType[i].Types == "varchar" {
|
|
|
|
|
valType[i].MaxVal = 50
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case "email", "url", "numberLetter":
|
|
|
|
|
if !publicmethod.IsInTrue[string]("varchar", fieldType) {
|
|
|
|
|
fieldType = append(fieldType, "varchar")
|
|
|
|
|
valType = append(valType, fieldStruct{Types: "varchar", MaxVal: 255})
|
|
|
|
|
} else {
|
|
|
|
|
for i := 0; i < len(valType); i++ {
|
|
|
|
|
if valType[i].Types == "varchar" {
|
|
|
|
|
valType[i].MaxVal = 255
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case "cn":
|
|
|
|
|
if !publicmethod.IsInTrue[string]("mediumtext", fieldType) {
|
|
|
|
|
fieldType = append(fieldType, "mediumtext")
|
|
|
|
|
valType = append(valType, fieldStruct{Types: "mediumtext", MaxVal: 0})
|
|
|
|
|
}
|
|
|
|
|
case "longitude", "latitude":
|
|
|
|
|
if !publicmethod.IsInTrue[string]("float", fieldType) {
|
|
|
|
|
fieldType = append(fieldType, "float")
|
|
|
|
|
valType = append(valType, fieldStruct{Types: "float", MaxVal: 20, MinVal: 20})
|
|
|
|
|
} else {
|
|
|
|
|
for i := 0; i < len(valType); i++ {
|
|
|
|
|
if valType[i].Types == "float" {
|
|
|
|
|
valType[i].MaxVal = 20
|
|
|
|
|
valType[i].MinVal = 20
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case "money":
|
|
|
|
|
if !publicmethod.IsInTrue[string]("decimal", fieldType) {
|
|
|
|
|
fieldType = append(fieldType, "decimal")
|
|
|
|
|
valType = append(valType, fieldStruct{Types: "decimal", MaxVal: 20, MinVal: 4})
|
|
|
|
|
} else {
|
|
|
|
|
for i := 0; i < len(valType); i++ {
|
|
|
|
|
if valType[i].Types == "decimal" {
|
|
|
|
|
valType[i].MaxVal = 20
|
|
|
|
|
valType[i].MinVal = 4
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case "int":
|
|
|
|
|
if !publicmethod.IsInTrue[string]("bigint", fieldType) {
|
|
|
|
|
fieldType = append(fieldType, "bigint")
|
|
|
|
|
valType = append(valType, fieldStruct{Types: "bigint", MaxVal: 20, Signed: true})
|
|
|
|
|
} else {
|
|
|
|
|
for i := 0; i < len(valType); i++ {
|
|
|
|
|
if valType[i].Types == "bigint" {
|
|
|
|
|
valType[i].MaxVal = 20
|
|
|
|
|
valType[i].Signed = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case "number":
|
|
|
|
|
if !publicmethod.IsInTrue[string]("bigint", fieldType) {
|
|
|
|
|
fieldType = append(fieldType, "bigint")
|
|
|
|
|
valType = append(valType, fieldStruct{Types: "bigint", MaxVal: 20})
|
|
|
|
|
} else {
|
|
|
|
|
for i := 0; i < len(valType); i++ {
|
|
|
|
|
if valType[i].Types == "bigint" {
|
|
|
|
|
valType[i].MaxVal = 20
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
if len(valType) > 0 {
|
|
|
|
|
for _, v := range valType {
|
|
|
|
|
if v.Types == "mediumtext" {
|
|
|
|
|
fieldCont.FieldType = "mediumtext"
|
|
|
|
|
} else if v.Types == "varchar" {
|
|
|
|
|
fieldCont.FieldType = "varchar"
|
|
|
|
|
fieldCont.MaxVal = v.MaxVal
|
|
|
|
|
} else if v.Types == "float" {
|
|
|
|
|
fieldCont.FieldType = "float"
|
|
|
|
|
fieldCont.MaxVal = v.MaxVal
|
|
|
|
|
fieldCont.MinVal = v.MinVal
|
|
|
|
|
} else if v.Types == "decimal" {
|
|
|
|
|
fieldCont.FieldType = "decimal"
|
|
|
|
|
fieldCont.MaxVal = v.MaxVal
|
|
|
|
|
fieldCont.MinVal = v.MinVal
|
|
|
|
|
} else if v.Types == "bigint" {
|
|
|
|
|
fieldCont.FieldType = "bigint"
|
|
|
|
|
fieldCont.MaxVal = v.MaxVal
|
|
|
|
|
fieldCont.Signed = v.Signed
|
|
|
|
|
} else {
|
|
|
|
|
fieldCont.FieldType = "varchar"
|
|
|
|
|
fieldCont.MaxVal = 255
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
fieldCont.FieldType = "varchar"
|
|
|
|
|
fieldCont.MaxVal = 255
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
fieldCont.FieldType = "varchar"
|
|
|
|
|
fieldCont.MaxVal = 255
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "textarea", "tinymce": //多行文本,富文本
|
|
|
|
|
fieldCont.FieldType = "mediumtext"
|
|
|
|
|
case "signaturemap", "lowcodeTransfer":
|
|
|
|
|
fieldCont.FieldType = "longtext"
|
|
|
|
|
case "radio": //单选框组
|
|
|
|
|
if subUnit.Config.TransformData == "number" || subUnit.Config.TransformData == "" {
|
|
|
|
|
var fieldVal string
|
|
|
|
|
if len(subUnit.Options) > 0 {
|
|
|
|
|
for _, ov := range subUnit.Options {
|
|
|
|
|
if len(fieldVal) < len(ov.Value) {
|
|
|
|
|
fieldVal = ov.Value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
size, fieldType := CalculateCharacterLength("int", fieldVal)
|
|
|
|
|
fieldCont.FieldType = fieldType
|
|
|
|
|
fieldCont.MaxVal = size
|
|
|
|
|
fieldCont.Signed = true
|
|
|
|
|
} else {
|
|
|
|
|
fieldCont.FieldType = "varchar"
|
|
|
|
|
fieldCont.MaxVal = 50
|
|
|
|
|
}
|
|
|
|
|
case "checkbox", "cascader", "treeSelect", "upload", "expand-user": //checkbox,级联选择器,树形控件,图片/文件: ,选择用户
|
|
|
|
|
fieldCont.FieldType = "mediumtext"
|
|
|
|
|
fieldCont.ValIsAry = true
|
|
|
|
|
case "select": //下拉选择框
|
|
|
|
|
if subUnit.Control.Multiple {
|
|
|
|
|
fieldCont.FieldType = "mediumtext"
|
|
|
|
|
fieldCont.ValIsAry = true
|
|
|
|
|
} else {
|
|
|
|
|
if subUnit.Config.TransformData == "number" {
|
|
|
|
|
var fieldVal string
|
|
|
|
|
if len(subUnit.Options) > 0 {
|
|
|
|
|
for _, ov := range subUnit.Options {
|
|
|
|
|
if len(fieldVal) < len(ov.Value) {
|
|
|
|
|
fieldVal = ov.Value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
size, fieldType := CalculateCharacterLength("int", fieldVal)
|
|
|
|
|
fieldCont.FieldType = fieldType
|
|
|
|
|
fieldCont.MaxVal = size
|
|
|
|
|
fieldCont.Signed = true
|
|
|
|
|
} else {
|
|
|
|
|
fieldCont.FieldType = "varchar"
|
|
|
|
|
fieldCont.MaxVal = 50
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case "datePicker": //日期选择器
|
|
|
|
|
fieldCont.UnitType = subUnit.Control.Type
|
|
|
|
|
switch subUnit.Control.Type {
|
|
|
|
|
case "year", "month", "date", "datetime", "week":
|
|
|
|
|
fieldCont.FieldType = "bigint"
|
|
|
|
|
fieldCont.MaxVal = 20
|
|
|
|
|
case "datetimerange", "daterange", "monthrange":
|
|
|
|
|
fieldCont.FieldType = "bigint"
|
|
|
|
|
fieldCont.MaxVal = 20
|
|
|
|
|
fieldCont.ValIsAry = true
|
|
|
|
|
default:
|
|
|
|
|
fieldCont.FieldType = "bigint"
|
|
|
|
|
fieldCont.MaxVal = 20
|
|
|
|
|
}
|
|
|
|
|
case "timePicker", "inputNumber": //时间选择器,计数器
|
|
|
|
|
fieldCont.FieldType = "bigint"
|
|
|
|
|
fieldCont.MaxVal = 20
|
|
|
|
|
case "colorPicker": //取色器
|
|
|
|
|
fieldCont.FieldType = "varchar"
|
|
|
|
|
fieldCont.MaxVal = 50
|
|
|
|
|
case "switch": //开关
|
|
|
|
|
var fieldVal string
|
|
|
|
|
if len(subUnit.Options) > 0 {
|
|
|
|
|
for _, ov := range subUnit.Options {
|
|
|
|
|
if len(fieldVal) < len(ov.Value) {
|
|
|
|
|
fieldVal = ov.Value
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
size, fieldType := CalculateCharacterLength("int", fieldVal)
|
|
|
|
|
fieldCont.FieldType = fieldType
|
|
|
|
|
fieldCont.MaxVal = size
|
|
|
|
|
fieldCont.Signed = true
|
|
|
|
|
case "rate", "slider": //评分,滑块
|
|
|
|
|
fieldVal := strconv.Itoa(subUnit.Control.Max)
|
|
|
|
|
size, fieldType := CalculateCharacterLength("int", fieldVal)
|
|
|
|
|
fieldCont.FieldType = fieldType
|
|
|
|
|
fieldCont.MaxVal = size
|
|
|
|
|
fieldCont.Signed = true
|
|
|
|
|
case "txt", "button", "title", "table", "grid", "tabs", "card", "flex", "divider", "div": //文本,按钮,标题,表格,格栅,标签,卡片布局,弹性布局,分割线,容器
|
|
|
|
|
case "component": //自定义组件 (格式待定)
|
|
|
|
|
default:
|
|
|
|
|
fieldCont.FieldType = "varchar"
|
|
|
|
|
fieldCont.MaxVal = 255
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2023-09-30 14:10:21
|
|
|
|
|
@ 功能: 自定义表格生成数据表
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (c *CustomerFormMaster) CreateFormTable() (relevance string, err error) {
|
|
|
|
|
// for _, v := range c.List {
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
tableFieldList, _ := GainFormTableField(c.Form.Name)
|
|
|
|
|
|
|
|
|
|
var tableFormSqlAry FormTableSql
|
|
|
|
|
tableFormSqlAry.TableSubUnitAnalysis(c.Form.Name, c.List, true, tableFieldList)
|
|
|
|
|
jsonStr, _ := json.Marshal(tableFieldList)
|
|
|
|
|
fmt.Printf("数据表-----》%v\n", string(jsonStr))
|
|
|
|
|
isSunForm := false
|
|
|
|
|
if len(tableFormSqlAry.MasterSql) <= 0 {
|
|
|
|
|
err = errors.New("没有主表!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if len(tableFormSqlAry.SunSql) > 0 {
|
|
|
|
|
isSunForm = true
|
|
|
|
|
err = CreateForm(c.Form.Name, c.Form.FormName, "InnoDB", true)
|
|
|
|
|
} else {
|
|
|
|
|
err = CreateForm(c.Form.Name, c.Form.FormName, "MyISAM", true)
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("数据表--1---》%v\n", tableFormSqlAry.MasterSql)
|
|
|
|
|
CreateFormFiled(c.Form.Name, c.Form.FormName, true, tableFormSqlAry.MasterSql) //添加主表字段
|
|
|
|
|
sunFormNameAry := make(map[string]string)
|
|
|
|
|
var sunTableNameAry []string
|
|
|
|
|
if isSunForm {
|
|
|
|
|
for _, v := range tableFormSqlAry.SunSql {
|
|
|
|
|
if len(v.SqlAry) > 0 {
|
|
|
|
|
sunFormTableName := v.TableName
|
|
|
|
|
if !publicmethod.IsInTrue[string](sunFormTableName, sunTableNameAry) {
|
|
|
|
|
sunTableNameAry = append(sunTableNameAry, sunFormTableName)
|
|
|
|
|
sunFormNameAry[v.TableName] = sunFormTableName
|
|
|
|
|
} else {
|
|
|
|
|
sunFormTableName = fmt.Sprintf("%v%v", v.TableName, publicmethod.GetUUid(1))
|
|
|
|
|
sunTableNameAry = append(sunTableNameAry, sunFormTableName)
|
|
|
|
|
sunFormNameAry[v.TableName] = sunFormTableName
|
|
|
|
|
}
|
|
|
|
|
err = CreateForm(sunFormTableName, fmt.Sprintf("%v(%v)子表", c.Form.FormName, c.Form.Name), "InnoDB", false)
|
|
|
|
|
// fmt.Printf("%v------->%v------->%v\n", sunFormTableName, err, v.SqlAry)
|
|
|
|
|
if err == nil {
|
|
|
|
|
CreateFormFiled(sunFormTableName, fmt.Sprintf("%v(%v)子表", c.Form.FormName, c.Form.Name), false, v.SqlAry)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if len(sunFormNameAry) > 0 {
|
|
|
|
|
relevanceByte, _ := json.Marshal(sunFormNameAry)
|
|
|
|
|
relevance = string(relevanceByte)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2023-09-30 14:12:51
|
|
|
|
|
@ 功能: 表格组件拆分
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (f *FormTableSql) TableSubUnitAnalysis(tablename string, subUnitAry []MasterStruct, isMaster bool, fieldList []Result) {
|
|
|
|
|
if len(subUnitAry) > 0 {
|
|
|
|
|
var sqlAllAry []string
|
|
|
|
|
fmt.Printf("tablename--->%v===>%v\n", tablename, isMaster)
|
|
|
|
|
|
|
|
|
|
oldTable := []string{"id", "masters_key", "creater", "createrOrg", "creater_time", "edit_time", "flow_id", "states", "flowIsOpen"}
|
|
|
|
|
var alreadyExists []string
|
|
|
|
|
|
|
|
|
|
for _, v := range subUnitAry {
|
|
|
|
|
wordClass := AnalysisFormUnitClass(v)
|
|
|
|
|
wordClassJson, _ := json.Marshal(wordClass)
|
|
|
|
|
fmt.Printf("wordClass--->%T===>%v\n", wordClass, string(wordClassJson))
|
|
|
|
|
switch wordClass.UnitName {
|
|
|
|
|
case "flex", "table":
|
|
|
|
|
if len(v.List) > 0 {
|
|
|
|
|
f.TableSubUnitAnalysis(v.Name, v.List, false, fieldList)
|
|
|
|
|
}
|
|
|
|
|
case "grid", "tabs":
|
|
|
|
|
if len(v.Columns) > 0 {
|
|
|
|
|
for _, mv := range v.Columns {
|
|
|
|
|
f.TableSubUnitAnalysis(tablename, mv.List, isMaster, fieldList)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case "card", "div":
|
|
|
|
|
if len(v.List) > 0 {
|
|
|
|
|
f.TableSubUnitAnalysis(tablename, v.List, isMaster, fieldList)
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
if isMaster {
|
|
|
|
|
masterSql := MakeSql(tablename, wordClass, fieldList)
|
|
|
|
|
sqlAllAry = append(sqlAllAry, masterSql...)
|
|
|
|
|
} else {
|
|
|
|
|
fieldList, _ := GainFormTableField(tablename)
|
|
|
|
|
masterSql := MakeSql(tablename, wordClass, fieldList)
|
|
|
|
|
sqlAllAry = append(sqlAllAry, masterSql...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if len(masterSql) > 0 {
|
|
|
|
|
// if isMaster {
|
|
|
|
|
// f.MasterSql = append(f.MasterSql, masterSql...)
|
|
|
|
|
// } else {
|
|
|
|
|
// sunSqlAry := publicmethod.MapOut[string]()
|
|
|
|
|
// sunSqlAry[tablename] = masterSql
|
|
|
|
|
// f.SunSql = sunSqlAry
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !publicmethod.IsInTrue[string](wordClass.WordName, oldTable) {
|
|
|
|
|
alreadyExists = append(alreadyExists, wordClass.WordName)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, v := range fieldList {
|
|
|
|
|
if !publicmethod.IsInTrue[string](v.Field, oldTable) {
|
|
|
|
|
alreadyExists = append(alreadyExists, v.Field)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buConfSql := newFieldOld(tablename, oldTable, alreadyExists)
|
|
|
|
|
if len(buConfSql) > 0 {
|
|
|
|
|
sqlAllAry = append(sqlAllAry, buConfSql...)
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("tablename--->%v===>%v===>%v\n", tablename, isMaster, sqlAllAry)
|
|
|
|
|
if len(sqlAllAry) > 0 {
|
|
|
|
|
if isMaster {
|
|
|
|
|
f.MasterSql = append(f.MasterSql, sqlAllAry...)
|
|
|
|
|
} else {
|
|
|
|
|
if len(f.SunSql) > 0 {
|
|
|
|
|
isWrite := true
|
|
|
|
|
for sk, s := range f.SunSql {
|
|
|
|
|
if s.TableName == tablename {
|
|
|
|
|
f.SunSql[sk].SqlAry = append(f.SunSql[sk].SqlAry, sqlAllAry...)
|
|
|
|
|
isWrite = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if isWrite {
|
|
|
|
|
var sunSqlInfo SunSqlCont
|
|
|
|
|
sunSqlInfo.TableName = tablename
|
|
|
|
|
sunSqlInfo.SqlAry = sqlAllAry
|
|
|
|
|
f.SunSql = append(f.SunSql, sunSqlInfo)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
var sunSqlInfo SunSqlCont
|
|
|
|
|
sunSqlInfo.TableName = tablename
|
|
|
|
|
sunSqlInfo.SqlAry = sqlAllAry
|
|
|
|
|
f.SunSql = append(f.SunSql, sunSqlInfo)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2025-01-03 13:38:30
|
|
|
|
|
@ 功能: 生成数据源没有的字段语句
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#tablename 数据表
|
|
|
|
|
#oldTable 表默认字段
|
|
|
|
|
#alreadyExists 已有字段
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#oldTable := []string{"id", "masters_key", "creater", "creater_time", "edit_time", "flow_id", "states", "flowIsOpen"}
|
|
|
|
|
*/
|
|
|
|
|
func newFieldOld(tablename string, oldTable, alreadyExists []string) (sql []string) {
|
|
|
|
|
for _, v := range oldTable {
|
|
|
|
|
if !publicmethod.IsInTrue[string](v, alreadyExists) {
|
|
|
|
|
switch v {
|
|
|
|
|
case "id":
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN %v bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'Id';", tablename, v))
|
|
|
|
|
case "masters_key":
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN %v bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '主表标识';", tablename, v))
|
|
|
|
|
case "creater":
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN %v bigint(20) unsigned DEFAULT '0' COMMENT '创建人';", tablename, v))
|
|
|
|
|
case "creater_time":
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN %v bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间';", tablename, v))
|
|
|
|
|
case "edit_time":
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN %v bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '编辑时间';", tablename, v))
|
|
|
|
|
case "flow_id":
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN %v bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '流程识别标识';", tablename, v))
|
|
|
|
|
case "states":
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN %v int(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态(1:启用,2:禁用;3:删除)';", tablename, v))
|
|
|
|
|
case "flowIsOpen":
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN %v int(1) unsigned NOT NULL DEFAULT '2' COMMENT '是否开启工作流';", tablename, v))
|
|
|
|
|
case "createrOrg":
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN %v int(1) unsigned NOT NULL DEFAULT '2' COMMENT '创建人行政组织';", tablename, v))
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2023-10-01 08:22:23
|
|
|
|
|
@ 功能: 组装sql语句
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func MakeSql(tablename string, fieldCont AnalysisFormSubUnitClass, fieldList []Result) (sql []string) {
|
|
|
|
|
if tablename == "" || fieldCont.WordName == "" {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
unsigned := ""
|
|
|
|
|
if !fieldCont.Signed {
|
|
|
|
|
unsigned = "unsigned"
|
|
|
|
|
}
|
|
|
|
|
isNew := true
|
|
|
|
|
if len(fieldList) > 0 {
|
|
|
|
|
for _, v := range fieldList {
|
|
|
|
|
if v.Field == fieldCont.WordName {
|
|
|
|
|
isNew = false
|
|
|
|
|
if fieldCont.FieldType == "bigint" {
|
|
|
|
|
if fieldCont.ValIsAry {
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v) %v NOT NULL DEFAULT %v COMMENT '%v';", tablename, fieldCont.WordName, fieldCont.FieldType, fieldCont.MaxVal, unsigned, fieldCont.MinVal, "开始日期"))
|
|
|
|
|
endField := fmt.Sprintf("%v_end", fieldCont.WordName)
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v) %v NOT NULL DEFAULT %v COMMENT '%v';", tablename, endField, fieldCont.FieldType, fieldCont.MaxVal, unsigned, fieldCont.MinVal, "结束日期"))
|
|
|
|
|
} else {
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v) %v NOT NULL DEFAULT %v COMMENT '%v';", tablename, fieldCont.WordName, fieldCont.FieldType, fieldCont.MaxVal, unsigned, fieldCont.MinVal, fieldCont.Describe))
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` MODIFY COLUMN %v %v COMMENT '%v';", tablename, fieldCont.WordName, v.Type, fieldCont.Describe))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isNew = true
|
|
|
|
|
}
|
|
|
|
|
if isNew {
|
|
|
|
|
switch fieldCont.FieldType {
|
|
|
|
|
case "int":
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v) %v NOT NULL DEFAULT %v COMMENT '%v';", tablename, fieldCont.WordName, fieldCont.FieldType, fieldCont.MaxVal, unsigned, fieldCont.MinVal, fieldCont.Describe))
|
|
|
|
|
case "bigint":
|
|
|
|
|
|
|
|
|
|
if fieldCont.ValIsAry {
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v) %v NOT NULL DEFAULT %v COMMENT '%v';", tablename, fieldCont.WordName, fieldCont.FieldType, fieldCont.MaxVal, unsigned, fieldCont.MinVal, "开始日期"))
|
|
|
|
|
endField := fmt.Sprintf("%v_end", fieldCont.WordName)
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v) %v NOT NULL DEFAULT %v COMMENT '%v';", tablename, endField, fieldCont.FieldType, fieldCont.MaxVal, unsigned, fieldCont.MinVal, "结束日期"))
|
|
|
|
|
} else {
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v) %v NOT NULL DEFAULT %v COMMENT '%v';", tablename, fieldCont.WordName, fieldCont.FieldType, fieldCont.MaxVal, unsigned, fieldCont.MinVal, fieldCont.Describe))
|
|
|
|
|
}
|
|
|
|
|
case "float":
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v,%v) %v NOT NULL DEFAULT 0 COMMENT '%v';", tablename, fieldCont.WordName, fieldCont.FieldType, fieldCont.MaxVal, fieldCont.MinVal, unsigned, fieldCont.Describe))
|
|
|
|
|
case "decimal":
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v,%v) %v NOT NULL DEFAULT 0 COMMENT '%v';", tablename, fieldCont.WordName, fieldCont.FieldType, fieldCont.MaxVal, fieldCont.MinVal, unsigned, fieldCont.Describe))
|
|
|
|
|
case "mediumtext", "longtext":
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v COMMENT '%v';", tablename, fieldCont.WordName, fieldCont.FieldType, fieldCont.Describe))
|
|
|
|
|
case "varchar":
|
|
|
|
|
sql = append(sql, fmt.Sprintf("ALTER TABLE `%v` ADD COLUMN `%v` %v(%v) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '%v';", tablename, fieldCont.WordName, fieldCont.FieldType, fieldCont.MaxVal, fieldCont.Describe))
|
|
|
|
|
default:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// fmt.Printf("%v------->%v------->%v\n", fieldCont.WordName, fieldCont.FieldType, fieldCont.ValIsAry)
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2023-10-07 14:18:23
|
|
|
|
|
@ 功能: 获取主表及子表相关组件
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#tablename 当前表明
|
|
|
|
|
#subUnitAry 组件列表
|
|
|
|
|
#isMaster true:主表;false:子表
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (f *FormUnitInfo) GainMasterAndSunFormUnit(tablename string, subUnitAry []MasterStruct, isMaster bool) {
|
|
|
|
|
if len(subUnitAry) > 0 {
|
|
|
|
|
unitAry := make(map[string]MasterStruct)
|
|
|
|
|
for _, v := range subUnitAry {
|
|
|
|
|
wordClass := AnalysisFormUnitClass(v)
|
|
|
|
|
switch wordClass.UnitName {
|
|
|
|
|
case "flex", "table":
|
|
|
|
|
if len(v.List) > 0 {
|
|
|
|
|
f.GainMasterAndSunFormUnit(v.Name, v.List, false)
|
|
|
|
|
}
|
|
|
|
|
case "grid", "tabs":
|
|
|
|
|
if len(v.Columns) > 0 {
|
|
|
|
|
for _, mv := range v.Columns {
|
|
|
|
|
f.GainMasterAndSunFormUnit(tablename, mv.List, isMaster)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case "card", "div":
|
|
|
|
|
if len(v.List) > 0 {
|
|
|
|
|
f.GainMasterAndSunFormUnit(tablename, v.List, isMaster)
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
// unitAry = append(unitAry, v)
|
|
|
|
|
if v.Name != "" {
|
|
|
|
|
unitAry[v.Name] = v
|
|
|
|
|
if isMaster {
|
|
|
|
|
f.MasterInfo = append(f.MasterInfo, v)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if len(unitAry) > 0 {
|
|
|
|
|
if isMaster {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if len(f.SunFormInfo) > 0 {
|
|
|
|
|
isWrite := true
|
|
|
|
|
for sk, s := range f.SunFormInfo {
|
|
|
|
|
if s.TableName == tablename {
|
|
|
|
|
f.SunFormInfo[sk].UbitInfo = unitAry
|
|
|
|
|
isWrite = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if isWrite {
|
|
|
|
|
var sunTableCont SunFormInfoList
|
|
|
|
|
sunTableCont.TableName = tablename
|
|
|
|
|
sunTableCont.UbitInfo = unitAry
|
|
|
|
|
f.SunFormInfo = append(f.SunFormInfo, sunTableCont)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
var sunTableCont SunFormInfoList
|
|
|
|
|
sunTableCont.TableName = tablename
|
|
|
|
|
sunTableCont.UbitInfo = unitAry
|
|
|
|
|
f.SunFormInfo = append(f.SunFormInfo, sunTableCont)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2023-12-02 11:07:48
|
|
|
|
|
@ 功能: 组件名与关键字对照
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (f *FormUnitInfo) GainMasterAndSunFormUnitNameKey() (mastNameKey map[string]string, suanNameKey map[string]map[string]string) {
|
|
|
|
|
mastNameKeyInfo := make(map[string]string)
|
|
|
|
|
for _, v := range f.MasterInfo {
|
|
|
|
|
mastNameKeyInfo[v.Name] = v.Item.Label
|
|
|
|
|
}
|
|
|
|
|
mastNameKey = mastNameKeyInfo
|
|
|
|
|
|
|
|
|
|
sunTypeAry := make(map[string]map[string]string)
|
|
|
|
|
for _, v := range f.SunFormInfo {
|
|
|
|
|
sunUnitNameKey := make(map[string]string)
|
|
|
|
|
for _, uv := range v.UbitInfo {
|
|
|
|
|
|
|
|
|
|
sunUnitNameKey[uv.Name] = uv.Item.Label
|
|
|
|
|
}
|
|
|
|
|
sunTypeAry[v.TableName] = sunUnitNameKey
|
|
|
|
|
// sunTypeAry[v.TableName] = v.UbitInfo
|
|
|
|
|
// fmt.Printf("自定义表单结果值!tableName:%v---->%T---->%v\n", v.TableName, v.UbitInfo, v.UbitInfo)
|
|
|
|
|
}
|
|
|
|
|
suanNameKey = sunTypeAry
|
|
|
|
|
// fmt.Printf("自定义表单结果值!tableName:%v---->%T\n", sunTypeAry, sunTypeAry)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-03-26 13:46:27
|
|
|
|
|
@ 功能: 获取数据库表字段
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (a *ApiMethod) GainTableField(c *gin.Context) {
|
|
|
|
|
var requestData publicmethod.PublicId
|
|
|
|
|
err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(100, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var customerFormMaster modelAppPlatform.CustomerFormView
|
|
|
|
|
err = customerFormMaster.GetCont(map[string]interface{}{"`cfid`": requestData.Id, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`name`")
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
masterTable, err := GainFormTableField(customerFormMaster.TableKey)
|
|
|
|
|
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)
|
|
|
|
|
if err == nil {
|
|
|
|
|
sunTableMap := publicmethod.MapOut[string]()
|
|
|
|
|
for _, v := range sunTable { //遍历子表单名称
|
|
|
|
|
if vStr, ok := v.(string); ok {
|
|
|
|
|
sunTableMap[vStr], err = GainFormTableField(vStr)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sendTableList["sunTable"] = sunTableMap
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
publicmethod.Result(0, sendTableList, c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-03-20 15:09:59
|
|
|
|
|
@ 功能: 获取表格字段
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (a *ApiMethod) GainFormTableField(c *gin.Context) {
|
|
|
|
|
var requestData publicmethod.PublicId
|
|
|
|
|
err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(100, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var customerFormMaster modelAppPlatform.CustomerFormView
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
var formJsonCont CustomerFormMaster
|
|
|
|
|
json.Unmarshal([]byte(customerFormMaster.MastesFormJson), &formJsonCont)
|
|
|
|
|
if formJsonCont.Form.DataSource == "yes" {
|
|
|
|
|
var sqlDb datacenter.DataBastType
|
|
|
|
|
sqlDb.Type = formJsonCont.Form.DataSourceConfig.DSN.SqlType
|
|
|
|
|
sqlDb.Ip = formJsonCont.Form.DataSourceConfig.DSN.Ip
|
|
|
|
|
sqlDb.DataBaseName = formJsonCont.Form.DataSourceConfig.DSN.DataBaseName
|
|
|
|
|
sqlDb.Port = formJsonCont.Form.DataSourceConfig.DSN.Port
|
|
|
|
|
sqlDb.UserName = formJsonCont.Form.DataSourceConfig.DSN.UserName
|
|
|
|
|
sqlDb.Pwd = formJsonCont.Form.DataSourceConfig.DSN.Password
|
|
|
|
|
sqlDborm, err := sqlDb.StartDataBast()
|
|
|
|
|
if err != nil {
|
|
|
|
|
sqlDborm, err = datacenter.GainDataStorce(formJsonCont.Form.DataSourceConfig.Id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(0, sqlDb, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
masterTableAll, err := GainFormAllFieldList(sqlDborm, formJsonCont.Form.DataSourceConfig.TableKey)
|
|
|
|
|
if err == nil {
|
|
|
|
|
masterTable = append(masterTable, masterTableAll...)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
masterTableAll, err := GainFormTableField(customerFormMaster.TableKey)
|
|
|
|
|
if err == nil {
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
var formFieldAry FormJsonFieldInfo
|
|
|
|
|
if list, ok := unitCont["list"]; ok {
|
|
|
|
|
|
|
|
|
|
if listAry, ok := list.([]interface{}); ok {
|
|
|
|
|
formFieldAry.AnalyzingFormJson("", listAry)
|
|
|
|
|
// publicmethod.Result(0, listAry, c)
|
|
|
|
|
// return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendTableList := publicmethod.MapOut[string]()
|
|
|
|
|
if len(formFieldAry.MasterInfo) > 0 {
|
|
|
|
|
sendTableList["masterTable"] = TableFieldCompare(masterTable, formFieldAry.MasterInfo)
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
sendTableList["masterTable"] = masterTable
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if customerFormMaster.TableStructure != "" { //判断是否有主体子表单
|
|
|
|
|
var sunTable map[string]interface{}
|
|
|
|
|
err = json.Unmarshal([]byte(customerFormMaster.TableStructure), &sunTable)
|
|
|
|
|
if err == nil {
|
|
|
|
|
sunTableMap := publicmethod.MapOut[string]()
|
|
|
|
|
sunTableNameMap := publicmethod.MapOut[string]()
|
|
|
|
|
var sunFormList []SunTableInfo
|
|
|
|
|
for _, v := range sunTable { //遍历子表单名称
|
|
|
|
|
if vStr, ok := v.(string); ok {
|
|
|
|
|
var sunFormInfo SunTableInfo
|
|
|
|
|
sunFormInfo.FieldKey = vStr
|
|
|
|
|
sunFormInfo.Name = gainSunTableName(vStr, formJsonCont)
|
|
|
|
|
sunField := GainSunFormTableField(vStr, formFieldAry.SunFormInfo)
|
|
|
|
|
if len(sunField) > 0 {
|
|
|
|
|
sunTableForm, formErr := GainFormTableField(vStr)
|
|
|
|
|
if formErr == nil {
|
|
|
|
|
fields := TableFieldCompare(sunTableForm, sunField)
|
|
|
|
|
sunTableMap[vStr] = fields
|
|
|
|
|
sunFormInfo.Fields = fields
|
|
|
|
|
} else {
|
|
|
|
|
fields, _ := GainFormTableField(vStr)
|
|
|
|
|
sunTableMap[vStr] = TableFieldCompare(fields, sunField) //获取表单字段
|
|
|
|
|
sunFormInfo.Fields = TableFieldCompare(fields, sunField)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
sunTableForm, _ := GainFormTableField(vStr)
|
|
|
|
|
fields := TableFieldCompare(sunTableForm, sunField)
|
|
|
|
|
sunTableMap[vStr] = fields //获取表单字段
|
|
|
|
|
sunFormInfo.Fields = fields
|
|
|
|
|
}
|
|
|
|
|
sunTableNameMap[vStr] = gainSunTableName(vStr, formJsonCont)
|
|
|
|
|
sunFormList = append(sunFormList, sunFormInfo)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sendTableList["sunTable"] = sunTableMap
|
|
|
|
|
sendTableList["sunTableName"] = sunTableNameMap
|
|
|
|
|
sendTableList["sunFormList"] = sunFormList
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
publicmethod.Result(0, sendTableList, c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取子表单名称
|
|
|
|
|
func gainSunTableName(tableKey string, formJsonCont CustomerFormMaster) (sunTableName string) {
|
|
|
|
|
if len(formJsonCont.List) > 0 {
|
|
|
|
|
for _, v := range formJsonCont.List {
|
|
|
|
|
if v.Type == "table" && v.Name == tableKey {
|
|
|
|
|
sunTableName = v.Item.Label
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-07-25 09:46:13
|
|
|
|
|
@ 功能: 判断是否有标题
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func JhudgeIsTitle(listFieldsMap ListPageFields) bool {
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取子表表单数据
|
|
|
|
|
func GainSunFormTableField(tableName string, SunFormInfo []SunFormFieldInfoList) (fieldList []FormFieldInfo) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-03-25 09:01:12
|
|
|
|
|
@ 功能: 表单数据对照
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func TableFieldCompare(tableFieldList []Result, jsonFieldList []FormFieldInfo) (fieldList []FormFieldInfo) {
|
|
|
|
|
|
|
|
|
|
// 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 {
|
|
|
|
|
titleInfo.Attribute = attFiled[1]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
patternInfo := strings.Split(v.Type, "(")
|
|
|
|
|
if len(patternInfo) >= 1 {
|
|
|
|
|
titleInfo.Pattern = patternInfo[0]
|
|
|
|
|
}
|
|
|
|
|
titleInfo.FieldClass = v.Field
|
|
|
|
|
titleInfo.ActiveValue = ""
|
|
|
|
|
titleInfo.InactiveValue = ""
|
|
|
|
|
fieldList = append(fieldList, titleInfo)
|
|
|
|
|
} else {
|
|
|
|
|
tableKey, isOk := TableFormAttribute(v, jsonFieldList)
|
|
|
|
|
if isOk {
|
|
|
|
|
fieldList = append(fieldList, tableKey)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
fieldList = jsonFieldList
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-03-22 09:00:27
|
|
|
|
|
@ 功能: 获取表单字段
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func GainFormTableField(formTableName string) (fieldList []Result, err error) {
|
|
|
|
|
gormDb := overall.CONSTANT_DB_CustomerForm
|
|
|
|
|
sqlStr := fmt.Sprintf("SHOW FULL COLUMNS FROM `%v`", formTableName)
|
|
|
|
|
err = gormDb.Raw(sqlStr).Scan(&fieldList).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
for i, v := range fieldList {
|
|
|
|
|
attFiled := strings.Split(v.Type, " ")
|
|
|
|
|
if len(attFiled) >= 2 {
|
|
|
|
|
fieldList[i].Attribute = attFiled[1]
|
|
|
|
|
fieldList[i].Type = attFiled[0]
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if v.Field == "id" {
|
|
|
|
|
fieldList[i].Comment = "Id"
|
|
|
|
|
}
|
|
|
|
|
patternInfo := strings.Split(v.Type, "(")
|
|
|
|
|
if len(patternInfo) >= 1 {
|
|
|
|
|
fieldList[i].Pattern = patternInfo[0]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-03-23 15:15:17
|
|
|
|
|
@ 功能: 解析表单字段
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (f *FormJsonFieldInfo) AnalyzingFormJson(tableName string, unitList []interface{}) {
|
|
|
|
|
|
|
|
|
|
if len(unitList) > 0 {
|
|
|
|
|
var fieldInfo []FormFieldInfo
|
|
|
|
|
for _, listVal := range unitList {
|
|
|
|
|
// fmt.Printf("listVal------------------>%v\n", listVal)
|
|
|
|
|
if listInfo, ok := listVal.(map[string]interface{}); ok {
|
|
|
|
|
if unitType, ok := listInfo["type"]; ok {
|
|
|
|
|
var unitInfo FormFieldInfo
|
|
|
|
|
if unitName, ok := listInfo["name"]; ok {
|
|
|
|
|
if unitNameStr, ok := unitName.(string); ok {
|
|
|
|
|
unitInfo.Id = unitNameStr
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if itemVal, ok := listInfo["item"]; ok {
|
|
|
|
|
if itemInfo, ok := itemVal.(map[string]interface{}); ok {
|
|
|
|
|
if itemName, ok := itemInfo["label"]; ok {
|
|
|
|
|
if itemNameStr, ok := itemName.(string); ok {
|
|
|
|
|
unitInfo.Label = itemNameStr
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch unitType {
|
|
|
|
|
case "flex", "table":
|
|
|
|
|
if list, ok := listInfo["list"]; ok {
|
|
|
|
|
if listAry, ok := list.([]interface{}); ok {
|
|
|
|
|
f.AnalyzingFormJson(unitInfo.Id, listAry)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case "grid", "tabs":
|
|
|
|
|
if list, ok := listInfo["columns"]; ok {
|
|
|
|
|
if listAry, ok := list.([]interface{}); ok {
|
|
|
|
|
for _, colVal := range listAry {
|
|
|
|
|
if colList, ok := colVal.(map[string]interface{}); ok {
|
|
|
|
|
if listMap, ok := colList["list"]; ok {
|
|
|
|
|
if colListAry, ok := listMap.([]interface{}); ok {
|
|
|
|
|
f.AnalyzingFormJson(unitInfo.Id, colListAry)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case "card", "div":
|
|
|
|
|
case "title", "txt", "button":
|
|
|
|
|
default:
|
|
|
|
|
if unitTypeStr, ok := unitType.(string); ok {
|
|
|
|
|
unitInfo.FieldClass = unitTypeStr
|
|
|
|
|
}
|
|
|
|
|
// 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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if InactiveVal, ok := controlMap["inactiveValue"]; ok {
|
|
|
|
|
if InactiveValStr, ok := InactiveVal.(string); ok {
|
|
|
|
|
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"])
|
|
|
|
|
|
|
|
|
|
if optValId, ok := controlMap["optionsValue3Formid"]; ok {
|
|
|
|
|
// fmt.Printf("optValId:%v\n", optValId)
|
|
|
|
|
// fmt.Printf("optValId--5656-->%T====>%v\n", optValId, optValId)
|
|
|
|
|
if optValIdStr, ok := optValId.(string); ok {
|
|
|
|
|
unitInfo.Control.OptionsValue3Formid = optValIdStr
|
|
|
|
|
}
|
|
|
|
|
// unitInfo.Control.OptionsValue3Formid = optValId
|
|
|
|
|
// controlMap["optionsValue3Formid"] = optValId
|
|
|
|
|
}
|
|
|
|
|
if optValField, ok := controlMap["optionsValue3Field"]; ok {
|
|
|
|
|
// fmt.Printf("optValField:%v\n", optValField)
|
|
|
|
|
// fmt.Printf("optValField--5656-->%T====>%v\n", optValField, optValField)
|
|
|
|
|
if optValFieldStr, ok := optValField.(string); ok {
|
|
|
|
|
unitInfo.Control.OptionsValue3Field = optValFieldStr
|
|
|
|
|
}
|
|
|
|
|
// controlMap["optionsValue3Field"] = optValField
|
|
|
|
|
// unitInfo.Control.OptionsValue3Field = optValField
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// unitInfo.Control.OptionsValue3Field = "254f6sdf46"
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
if configMApValStr, ok := configMApVal.(float64); ok {
|
|
|
|
|
unitInfo.Config.OptionsType = configMApValStr
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if optionsVal, ok := listInfo["options"]; ok {
|
|
|
|
|
if optionsMap, ok := optionsVal.([]interface{}); ok {
|
|
|
|
|
for _, optv := range optionsMap {
|
|
|
|
|
|
|
|
|
|
if optvMap, ok := optv.(map[string]interface{}); ok {
|
|
|
|
|
var optInfo OptionsInfo
|
|
|
|
|
// fmt.Printf("optvMap---->%T====>%v\n", optvMap["label"], optvMap["label"])
|
|
|
|
|
if labelVal, ok := optvMap["label"]; ok {
|
|
|
|
|
if labelValStr, ok := labelVal.(string); ok {
|
|
|
|
|
optInfo.Label = labelValStr
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if valueVal, ok := optvMap["value"]; ok {
|
|
|
|
|
optInfo.Value = valueVal
|
|
|
|
|
// if valueValStr, ok := valueVal.(string); ok {
|
|
|
|
|
// optInfo.Value = valueValStr
|
|
|
|
|
// } else {
|
|
|
|
|
// intVal, _ := publicmethod.StringToInt64(valueVal)
|
|
|
|
|
// optInfo.Value = intVal
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
if chiVal, ok := optvMap["children"]; ok {
|
|
|
|
|
// fmt.Printf("unitInfo--3->:%v---->%T\n", chiVal, chiVal)
|
|
|
|
|
optInfo.Children = chiVal
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
unitInfo.Options = append(unitInfo.Options, optInfo)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fieldInfo = append(fieldInfo, unitInfo)
|
|
|
|
|
// fmt.Printf("unitInfo--1->:%v\n", unitInfo)
|
|
|
|
|
// fmt.Printf("fieldInfo-2->:%v\n", fieldInfo)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if len(fieldInfo) > 0 {
|
|
|
|
|
if tableName != "" {
|
|
|
|
|
if len(f.SunFormInfo) > 0 {
|
|
|
|
|
isNewData := true
|
|
|
|
|
for i, v := range f.SunFormInfo {
|
|
|
|
|
if v.TableName == tableName {
|
|
|
|
|
f.SunFormInfo[i].UbitInfo = append(f.SunFormInfo[i].UbitInfo, fieldInfo...)
|
|
|
|
|
isNewData = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if isNewData {
|
|
|
|
|
var sunFormInfo SunFormFieldInfoList
|
|
|
|
|
sunFormInfo.TableName = tableName
|
|
|
|
|
sunFormInfo.UbitInfo = fieldInfo
|
|
|
|
|
f.SunFormInfo = append(f.SunFormInfo, sunFormInfo)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
var sunFormInfo SunFormFieldInfoList
|
|
|
|
|
sunFormInfo.TableName = tableName
|
|
|
|
|
sunFormInfo.UbitInfo = fieldInfo
|
|
|
|
|
f.SunFormInfo = append(f.SunFormInfo, sunFormInfo)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
f.MasterInfo = append(f.MasterInfo, fieldInfo...)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-03-29 16:43:17
|
|
|
|
|
@ 功能: 编辑自定义表单列表数据
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (a *ApiMethod) EditCustomerFormList(c *gin.Context) {
|
|
|
|
|
var requestData EditCustFormList
|
|
|
|
|
err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(100, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!2")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.Data == "" {
|
|
|
|
|
publicmethod.Result(1, err, c, "未知列表数据!无法获取字段!1")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var customerFormInfo modelAppPlatform.CustomerForm
|
|
|
|
|
err = customerFormInfo.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`listjson`")
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!3")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
editInfo := publicmethod.MapOut[string]()
|
|
|
|
|
editInfo["listjson"] = requestData.Data
|
|
|
|
|
editInfo["edit_time"] = time.Now().Unix()
|
|
|
|
|
err = customerFormInfo.EiteCont(map[string]interface{}{"`id`": requestData.Id}, editInfo)
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(1, err, c, "编辑失败!请重新提交!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
publicmethod.Result(0, err, c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-04-01 08:34:08
|
|
|
|
|
@ 功能: 获取表单列表数据
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (a *ApiMethod) GainFormListCont(c *gin.Context) {
|
|
|
|
|
var requestData publicmethod.PublicId
|
|
|
|
|
err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(100, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!2")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var customerFormInfo modelAppPlatform.CustomerForm
|
|
|
|
|
err = customerFormInfo.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!3")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
publicmethod.Result(0, customerFormInfo, c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-04-01 16:03:50
|
|
|
|
|
@ 功能:获取表单列表翻页数据
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (a *ApiMethod) GainFormPageListCont(c *gin.Context) {
|
|
|
|
|
var requestData FormPageListAttr
|
|
|
|
|
err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(100, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.FormId == "" {
|
|
|
|
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!2")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.Page == 0 {
|
|
|
|
|
requestData.Page = 1
|
|
|
|
|
}
|
|
|
|
|
if requestData.PageSize == 0 {
|
|
|
|
|
requestData.Page = 20
|
|
|
|
|
}
|
|
|
|
|
context, _ := c.Get(overall.MyContJwt)
|
|
|
|
|
var userCont modelshr.ManCont
|
|
|
|
|
userCont.GetLoginCont(context) //当前操作人
|
|
|
|
|
|
|
|
|
|
userKeyMap, isTrue := GainRolePower(userCont)
|
|
|
|
|
|
|
|
|
|
// fmt.Printf()
|
|
|
|
|
|
|
|
|
|
var formInfo modelAppPlatform.CustomerFormView
|
|
|
|
|
err = formInfo.GetCont(map[string]interface{}{"`cfid`": requestData.FormId, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`listjson`", "`flowIsOpen`", "`flowkey`")
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var formJsonCont CustomerFormMaster
|
|
|
|
|
json.Unmarshal([]byte(formInfo.MastesFormJson), &formJsonCont)
|
|
|
|
|
|
|
|
|
|
var sunMap map[string]string
|
|
|
|
|
json.Unmarshal([]byte(formInfo.TableStructure), &sunMap)
|
|
|
|
|
|
|
|
|
|
if formJsonCont.Form.DataSource == "yes" {
|
|
|
|
|
var sqlDb datacenter.DataBastType
|
|
|
|
|
sqlDb.Type = formJsonCont.Form.DataSourceConfig.DSN.SqlType
|
|
|
|
|
sqlDb.Ip = formJsonCont.Form.DataSourceConfig.DSN.Ip
|
|
|
|
|
sqlDb.DataBaseName = formJsonCont.Form.DataSourceConfig.DSN.DataBaseName
|
|
|
|
|
sqlDb.Port = formJsonCont.Form.DataSourceConfig.DSN.Port
|
|
|
|
|
sqlDb.UserName = formJsonCont.Form.DataSourceConfig.DSN.UserName
|
|
|
|
|
sqlDb.Pwd = formJsonCont.Form.DataSourceConfig.DSN.Password
|
|
|
|
|
sqlDborm, err := sqlDb.StartDataBast()
|
|
|
|
|
if err != nil {
|
|
|
|
|
sqlDborm, err = datacenter.GainDataStorce(formJsonCont.Form.DataSourceConfig.Id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(0, sqlDb, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gormDb := sqlDborm.Table(formJsonCont.Form.DataSourceConfig.TableKey)
|
|
|
|
|
gormDb = gormDb.Where("`states` BETWEEN ? AND ?", 1, 2)
|
|
|
|
|
if !isTrue {
|
|
|
|
|
if len(userKeyMap) > 0 {
|
|
|
|
|
gormDb = gormDb.Where("`creater` IN ? ", userKeyMap)
|
|
|
|
|
} else {
|
|
|
|
|
gormDb = gormDb.Where("`creater` = ? ", userCont.Key)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gormDb = AnalysisSerachTermSql(requestData.SearchData, gormDb)
|
|
|
|
|
var total int64
|
|
|
|
|
totalErr := gormDb.Count(&total).Error
|
|
|
|
|
if totalErr != nil {
|
|
|
|
|
total = 0
|
|
|
|
|
}
|
|
|
|
|
var formList []map[string]interface{}
|
|
|
|
|
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
|
|
|
|
|
err = gormDb.Order("`id` DESC").Find(&formList).Error
|
|
|
|
|
if err != nil && len(formList) < 1 {
|
|
|
|
|
publicmethod.Result(0, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var listFieldsMap ListPageFields
|
|
|
|
|
// sqlDborm.Table(formJsonCont.Form.DataSourceConfig.TableKey).Find(&formList)
|
|
|
|
|
// fmt.Printf("%T----------->%v----------->%v\n", formList, err, formList)
|
|
|
|
|
if formInfo.ListJson != "" {
|
|
|
|
|
|
|
|
|
|
err = json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap)
|
|
|
|
|
// fmt.Printf("%T----------->%v----------->%v\n", listFieldsMap, err, listFieldsMap)
|
|
|
|
|
if err == nil {
|
|
|
|
|
// fmt.Printf("%T----------->%v\n", listFieldsMap, listFieldsMap)
|
|
|
|
|
formList = listFieldsMap.DevelopSpecificationsSend(formList, formJsonCont)
|
|
|
|
|
// formList = DevelopSpecificationsSend(formList, listFieldsMap)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取任务状态
|
|
|
|
|
for i, v := range formList {
|
|
|
|
|
formList[i]["isRetract"] = false
|
|
|
|
|
var masterKey int64
|
|
|
|
|
if mastrKeyVal, isOk := v["masters_key"]; isOk {
|
|
|
|
|
masterKey, _ = publicmethod.StringToInt64(mastrKeyVal)
|
|
|
|
|
if mastrKeyUint64, ok := mastrKeyVal.(uint64); ok {
|
|
|
|
|
formList[i]["masters_key"] = strconv.FormatUint(mastrKeyUint64, 10)
|
|
|
|
|
}
|
|
|
|
|
masterKeyVal := publicmethod.TypeToInterface(masterKey)
|
|
|
|
|
redisKey := fmt.Sprintf("SendMsg:Work_WeChat_%v", masterKeyVal)
|
|
|
|
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3)
|
|
|
|
|
formList[i]["retract_true"], _ = redisClient.Get(redisKey)
|
|
|
|
|
|
|
|
|
|
var taskInfo customerForm.TaskRecord
|
|
|
|
|
overall.CONSTANT_DB_CustomerForm.Where("`masters_key` = ?", mastrKeyVal).First(&taskInfo)
|
|
|
|
|
formList[i]["runFlowId"] = strconv.FormatInt(taskInfo.RunFlowId, 10)
|
|
|
|
|
if mastrKey, ok := formList[i]["runFlowId"]; ok {
|
|
|
|
|
// fmt.Printf("masters_key----------->%v\n", v["masters_key"])
|
|
|
|
|
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"] = strconv.FormatInt(runFlowInfo.Id, 10)
|
|
|
|
|
// fmt.Printf("runFlowInfo----------->%v--------->%v\n", runFlowInfo, v["taskStatus"])
|
|
|
|
|
if taskInfo.Status == 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 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)
|
|
|
|
|
// if mastrKeyUint64, ok := mastrKeyVal.(uint64); ok {
|
|
|
|
|
// formList[i]["masters_key"] = strconv.FormatUint(mastrKeyUint64, 10)
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
for _, sv := range sunMap {
|
|
|
|
|
formList[i][sv] = gainMasterSunList(sv, masterKey, formJsonCont, sqlDborm)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// publicmethod.Result(100, formList, c)
|
|
|
|
|
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(formList)), formList, c)
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
// why, err := AnalysisSerachTerm(requestData.SearchData)
|
|
|
|
|
// fmt.Printf("why---->%v\n", why)
|
|
|
|
|
var formList []map[string]interface{}
|
|
|
|
|
// gormDb := overall.CONSTANT_DB_CustomerForm.Table(formInfo.TableKey)
|
|
|
|
|
tableName := fmt.Sprintf("`%v` as f", formInfo.TableKey)
|
|
|
|
|
gormDb := overall.CONSTANT_DB_CustomerForm.Table(tableName).Select("f.*,t.status as taskStatus,t.runFlowId")
|
|
|
|
|
// if err == nil {
|
|
|
|
|
// gormDb = gormDb.Where(why)
|
|
|
|
|
// }
|
|
|
|
|
gormDb = gormDb.Joins("LEFT JOIN `taskrecord` as t ON f.masters_key = t.masters_key")
|
|
|
|
|
// gormDb = gormDb.Where("f.`creater` = ? ", userCont.Key)
|
|
|
|
|
if !isTrue {
|
|
|
|
|
if len(userKeyMap) > 0 {
|
|
|
|
|
gormDb = gormDb.Where("f.`creater` IN ? ", userKeyMap)
|
|
|
|
|
} else {
|
|
|
|
|
gormDb = gormDb.Where("f.`creater` = ? ", userCont.Key)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
gormDb = gormDb.Where("f.`states` BETWEEN ? AND ?", 1, 2)
|
|
|
|
|
|
|
|
|
|
gormDb = AnalysisSerachTermSql(requestData.SearchData, gormDb)
|
|
|
|
|
var total int64
|
|
|
|
|
totalErr := gormDb.Count(&total).Error
|
|
|
|
|
if totalErr != nil {
|
|
|
|
|
total = 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gormDb = publicmethod.PageTurningSettings(gormDb, requestData.Page, requestData.PageSize)
|
|
|
|
|
err = gormDb.Order("f.`id` DESC").Find(&formList).Error
|
|
|
|
|
if err != nil && len(formList) < 1 {
|
|
|
|
|
publicmethod.Result(0, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// for i, _ := range formList {
|
|
|
|
|
// // formList[i]["flowIsOpen"] = formInfo.FlowIsOpen
|
|
|
|
|
// formList[i]["flowkey"] = strconv.FormatInt(formInfo.Flowkey, 10)
|
|
|
|
|
// }
|
|
|
|
|
var listFieldsMap ListPageFields
|
|
|
|
|
if formInfo.ListJson != "" {
|
|
|
|
|
|
|
|
|
|
err = json.Unmarshal([]byte(formInfo.ListJson), &listFieldsMap)
|
|
|
|
|
// fmt.Printf("%T----------->%v----------->%v\n", listFieldsMap, err, listFieldsMap)
|
|
|
|
|
if err == nil {
|
|
|
|
|
// fmt.Printf("%T----------->%v\n", listFieldsMap, listFieldsMap)
|
|
|
|
|
formList = listFieldsMap.DevelopSpecificationsSend(formList, formJsonCont)
|
|
|
|
|
// formList = DevelopSpecificationsSend(formList, listFieldsMap)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取任务状态
|
|
|
|
|
for i, v := range formList {
|
|
|
|
|
formList[i]["isRetract"] = false
|
|
|
|
|
if mastrKey, ok := v["runFlowId"]; ok {
|
|
|
|
|
fmt.Printf("runFlowId------wrewrwerwerwerwe----->%v\n", v["runFlowId"])
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var masterKey int64
|
|
|
|
|
if mastrKeyVal, ok := v["masters_key"]; ok {
|
|
|
|
|
masterKey, _ = publicmethod.StringToInt64(mastrKeyVal)
|
|
|
|
|
// fmt.Printf("mastrKeyVal----------->%T----------->%v\n", mastrKeyVal, mastrKeyVal)
|
|
|
|
|
if mastrKeyUint64, ok := mastrKeyVal.(uint64); ok {
|
|
|
|
|
|
|
|
|
|
formList[i]["masters_key"] = strconv.FormatUint(mastrKeyUint64, 10)
|
|
|
|
|
}
|
|
|
|
|
masterKeyVal := publicmethod.TypeToInterface(masterKey)
|
|
|
|
|
redisKey := fmt.Sprintf("SendMsg:Work_WeChat_%v", masterKeyVal)
|
|
|
|
|
redisClient := grocerystore.RunRedis(overall.CONSTANT_REDIS3)
|
|
|
|
|
formList[i]["retract_true"], _ = redisClient.Get(redisKey)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("mastrKeyVal----------->%T----------->%v\n", v["table_structure"], v["table_structure"])
|
|
|
|
|
for _, sv := range sunMap {
|
|
|
|
|
formList[i][sv] = gainMasterSunList(sv, masterKey, formJsonCont, overall.CONSTANT_DB_CustomerForm)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// publicmethod.Result(100, formList, c)
|
|
|
|
|
publicmethod.ResultList(0, requestData.Page, requestData.PageSize, total, int64(len(formList)), formList, c)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2025-03-14 08:59:27
|
|
|
|
|
@ 功能: 获取每条数据得子数据列表
|
|
|
|
|
*/
|
|
|
|
|
func gainMasterSunList(tableName string, masterKey int64, formJsonCont CustomerFormMaster, gormDbConfig *gorm.DB) (list []map[string]interface{}) {
|
|
|
|
|
// fmt.Printf(" 获取每条数据得子数据列表------->%v\n------->%v\n------->%v\n", tableName, masterKey, gormDbConfig)
|
|
|
|
|
gormDbConfig.Table(tableName).Where("`masters_key` = ? and `states` = 1", masterKey).Find(&list)
|
|
|
|
|
if len(list) > 0 {
|
|
|
|
|
var listFieldsMap ListPageFields
|
|
|
|
|
var sunTable MasterStruct
|
|
|
|
|
for _, v := range formJsonCont.List {
|
|
|
|
|
if v.Type == "table" && v.Name == tableName {
|
|
|
|
|
sunTable = v
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
list = listFieldsMap.SunTableForm(list, masterKey, sunTable)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// fmt.Printf(" 获取每条数据得子数据列表------->%v\n------->%v\n------->%v\n", err, err, err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2025-03-14 11:20:00
|
|
|
|
|
@ 功能: 数值结果类型转换
|
|
|
|
|
*/
|
|
|
|
|
func (l *ListPageFields) SunTableForm(listData []map[string]interface{}, masterKey int64, sunTable MasterStruct) []map[string]interface{} {
|
|
|
|
|
var sendList []map[string]interface{}
|
|
|
|
|
for _, v := range listData {
|
|
|
|
|
sendInfo := publicmethod.MapOut[string]()
|
|
|
|
|
for mi, mv := range v {
|
|
|
|
|
switch mi {
|
|
|
|
|
case "creater":
|
|
|
|
|
mvInt, _ := publicmethod.StringToInt64(mv)
|
|
|
|
|
if mvInt != 0 {
|
|
|
|
|
var myInfo modelshr.PersonArchives
|
|
|
|
|
myInfo.GetCont(map[string]interface{}{"`key`": mvInt}, "`name`")
|
|
|
|
|
sendInfo[mi] = myInfo.Name
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "creater_time":
|
|
|
|
|
timeInt, _ := publicmethod.StringToInt64(mv)
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27)
|
|
|
|
|
case "edit_time":
|
|
|
|
|
timeInt, _ := publicmethod.StringToInt64(mv)
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27)
|
|
|
|
|
default:
|
|
|
|
|
sendInfo[mi] = l.BaseSunTableAttrField(mi, mv, sunTable)
|
|
|
|
|
// 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 {
|
|
|
|
|
|
|
|
|
|
radioId := publicmethod.TypeToInterface(mv)
|
|
|
|
|
if radioId == ov.Value {
|
|
|
|
|
sendInfo[mi] = ov.Label
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case "datePicker":
|
|
|
|
|
var beginTime string
|
|
|
|
|
timeVal, _ := publicmethod.StringToInt64(mv)
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
case "daterange":
|
|
|
|
|
beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 14)
|
|
|
|
|
sendInfo[mi] = beginTime
|
|
|
|
|
case "monthrange":
|
|
|
|
|
beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 15)
|
|
|
|
|
sendInfo[mi] = beginTime
|
|
|
|
|
default:
|
|
|
|
|
beginTime = publicmethod.UnixTimeToDay(timeVal/1000, 14)
|
|
|
|
|
sendInfo[mi] = beginTime
|
|
|
|
|
}
|
|
|
|
|
case "timePicker":
|
|
|
|
|
timeVal, _ := publicmethod.StringToInt64(mv)
|
|
|
|
|
if timeVal != 0 {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 5)
|
|
|
|
|
} else {
|
|
|
|
|
sendInfo[mi] = ""
|
|
|
|
|
}
|
|
|
|
|
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:
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sendList = append(sendList, sendInfo)
|
|
|
|
|
}
|
|
|
|
|
return sendList
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2025-03-14 11:23:55
|
|
|
|
|
@ 功能: 根据字段显示格式处理数据
|
|
|
|
|
*/
|
|
|
|
|
func (l *ListPageFields) BaseSunTableAttrField(key string, val interface{}, sunTable MasterStruct) interface{} {
|
|
|
|
|
if len(l.TableData.Columns) < 0 {
|
|
|
|
|
return val
|
|
|
|
|
}
|
|
|
|
|
for _, v := range l.TableData.Columns {
|
|
|
|
|
if v.Id == key {
|
|
|
|
|
fmt.Printf("组件类型---->\n\n%v\n\n", v.FieldClass)
|
|
|
|
|
switch v.FieldClass {
|
|
|
|
|
case "checkbox":
|
|
|
|
|
if val != nil {
|
|
|
|
|
var checkboxStrAry []interface{}
|
|
|
|
|
var checkboxAry []string
|
|
|
|
|
if valStr, ok := val.(string); ok {
|
|
|
|
|
err := json.Unmarshal([]byte(valStr), &checkboxStrAry)
|
|
|
|
|
if err == nil {
|
|
|
|
|
for _, v := range checkboxStrAry {
|
|
|
|
|
checkboxAry = append(checkboxAry, publicmethod.TypeToInterface(v))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(checkboxAry) > 0 {
|
|
|
|
|
var jieGuo []string
|
|
|
|
|
for _, ov := range v.Options {
|
|
|
|
|
intVal, _ := publicmethod.StringToInt64(ov.Value)
|
|
|
|
|
intValStr := strconv.FormatInt(intVal, 10)
|
|
|
|
|
if publicmethod.IsInTrue[string](intValStr, checkboxAry) {
|
|
|
|
|
jieGuo = append(jieGuo, ov.Label)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
val = strings.Join(jieGuo, ",")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case "orgCentent":
|
|
|
|
|
var orgCont modelshr.AdministrativeOrganization
|
|
|
|
|
orgCont.GetCont(map[string]interface{}{"`id`": val}, "name")
|
|
|
|
|
return orgCont.Name
|
|
|
|
|
case "baidumap":
|
|
|
|
|
var mapAry []string
|
|
|
|
|
if valStr, ok := val.(string); ok {
|
|
|
|
|
mapAry = strings.Split(valStr, "|*@*|")
|
|
|
|
|
}
|
|
|
|
|
if len(mapAry) > 0 {
|
|
|
|
|
return mapAry[0]
|
|
|
|
|
}
|
|
|
|
|
case "treeSelect":
|
|
|
|
|
// jsonStr, _ := json.Marshal(v)
|
|
|
|
|
// fmt.Printf("树形菜单结构----》\n%v\n", string(jsonStr))
|
|
|
|
|
// formJsonCont.GetUnitVal(v.Id)
|
|
|
|
|
hjakshdk := GetSunUnitVal(v.Id, val, sunTable)
|
|
|
|
|
// fmt.Printf("树形菜单结构----》\n%v\n", hjakshdk)
|
|
|
|
|
return hjakshdk
|
|
|
|
|
case "pickrole":
|
|
|
|
|
return 112
|
|
|
|
|
case "pickpost":
|
|
|
|
|
return 250
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return publicmethod.TypeToInterface(val)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetSunUnitVal(key string, val interface{}, formJsonCont MasterStruct) (rutVal string) {
|
|
|
|
|
|
|
|
|
|
if len(formJsonCont.List) > 0 {
|
|
|
|
|
for _, v := range formJsonCont.List {
|
|
|
|
|
if v.Name == key {
|
|
|
|
|
if datList, isOk := v.Control.Data.([]interface{}); isOk {
|
|
|
|
|
|
|
|
|
|
rutVal = diGuiShu(val, datList)
|
|
|
|
|
// fmt.Printf("已经是结果了:%v\n", rutVal)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-04-02 08:14:10
|
|
|
|
|
@ 功能: 按照制定列表字段输出
|
|
|
|
|
*/
|
|
|
|
|
func (l *ListPageFields) DevelopSpecificationsSend(listData []map[string]interface{}, formJsonCont CustomerFormMaster) []map[string]interface{} {
|
|
|
|
|
var sendList []map[string]interface{}
|
|
|
|
|
for _, v := range listData {
|
|
|
|
|
sendInfo := publicmethod.MapOut[string]()
|
|
|
|
|
for mi, mv := range v {
|
|
|
|
|
|
|
|
|
|
switch mi {
|
|
|
|
|
case "creater":
|
|
|
|
|
mvInt, _ := publicmethod.StringToInt64(mv)
|
|
|
|
|
if mvInt != 0 {
|
|
|
|
|
var myInfo modelshr.PersonArchives
|
|
|
|
|
myInfo.GetCont(map[string]interface{}{"`key`": mvInt}, "`name`")
|
|
|
|
|
sendInfo[mi] = myInfo.Name
|
|
|
|
|
sendInfo["createrKey"] = mv
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "creater_time":
|
|
|
|
|
timeInt, _ := publicmethod.StringToInt64(mv)
|
|
|
|
|
|
|
|
|
|
if publicmethod.GetIntLength(timeInt) == 13 {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt/1000, 27)
|
|
|
|
|
} else {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27)
|
|
|
|
|
}
|
|
|
|
|
sendInfo["createrTimeVal"] = mv
|
|
|
|
|
case "edit_time":
|
|
|
|
|
timeInt, _ := publicmethod.StringToInt64(mv)
|
|
|
|
|
if publicmethod.GetIntLength(timeInt) == 13 {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt/1000, 27)
|
|
|
|
|
} else {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeInt, 27)
|
|
|
|
|
}
|
|
|
|
|
sendInfo["editTimeVal"] = mv
|
|
|
|
|
case "states":
|
|
|
|
|
mvInt, _ := publicmethod.StringToInt64(mv)
|
|
|
|
|
switch mvInt {
|
|
|
|
|
case 1:
|
|
|
|
|
sendInfo[mi] = "启用"
|
|
|
|
|
sendInfo["statess"] = 1
|
|
|
|
|
case 2:
|
|
|
|
|
sendInfo[mi] = "禁用"
|
|
|
|
|
sendInfo["statess"] = 2
|
|
|
|
|
case 3:
|
|
|
|
|
sendInfo[mi] = "删除"
|
|
|
|
|
sendInfo["statess"] = 3
|
|
|
|
|
default:
|
|
|
|
|
sendInfo[mi] = "未知"
|
|
|
|
|
sendInfo["statess"] = 4
|
|
|
|
|
}
|
|
|
|
|
case "flowIsOpen":
|
|
|
|
|
mvInt, _ := publicmethod.StringToInt64(mv)
|
|
|
|
|
switch mvInt {
|
|
|
|
|
case 1:
|
|
|
|
|
sendInfo[mi] = "开启"
|
|
|
|
|
sendInfo["flowIsOpens"] = 1
|
|
|
|
|
case 2:
|
|
|
|
|
sendInfo[mi] = "关闭"
|
|
|
|
|
sendInfo["flowIsOpens"] = 2
|
|
|
|
|
case 3:
|
|
|
|
|
sendInfo[mi] = "删除"
|
|
|
|
|
sendInfo["flowIsOpens"] = 3
|
|
|
|
|
default:
|
|
|
|
|
sendInfo[mi] = "未知"
|
|
|
|
|
sendInfo["flowIsOpens"] = 4
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
sendInfo[mi] = l.BaseTableAttrField(mi, mv, formJsonCont)
|
|
|
|
|
// sendInfo[mi] = publicmethod.TypeToInterface(mv)
|
|
|
|
|
}
|
|
|
|
|
for _, lv := range l.TableData.Columns {
|
|
|
|
|
if lv.FieldClass != "-" && lv.FieldClass != "_lableTitle" && lv.FieldClass != "__control" {
|
|
|
|
|
if lv.Id == mi {
|
|
|
|
|
// fmt.Printf("%T = %v\n", lv.FieldClass, lv.FieldClass)
|
|
|
|
|
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":
|
|
|
|
|
if publicmethod.GetIntLength(timeVal) == 13 {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 16)
|
|
|
|
|
} else {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 16)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "month":
|
|
|
|
|
if publicmethod.GetIntLength(timeVal) == 13 {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 15)
|
|
|
|
|
} else {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 15)
|
|
|
|
|
}
|
|
|
|
|
case "datetime":
|
|
|
|
|
if publicmethod.GetIntLength(timeVal) == 13 {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 11)
|
|
|
|
|
} else {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 11)
|
|
|
|
|
}
|
|
|
|
|
case "week":
|
|
|
|
|
if publicmethod.GetIntLength(timeVal) == 13 {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 41)
|
|
|
|
|
} else {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 41)
|
|
|
|
|
}
|
|
|
|
|
case "datetimerange":
|
|
|
|
|
if publicmethod.GetIntLength(timeVal) == 13 {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 11)
|
|
|
|
|
} else {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 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":
|
|
|
|
|
if publicmethod.GetIntLength(timeVal) == 13 {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 14)
|
|
|
|
|
} else {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 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":
|
|
|
|
|
if publicmethod.GetIntLength(timeVal) == 13 {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 15)
|
|
|
|
|
} else {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 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:
|
|
|
|
|
if publicmethod.GetIntLength(timeVal) == 13 {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 14)
|
|
|
|
|
} else {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 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))
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("\n\n\n\n时间--------->%v--------->%v--------->%v\n\n\n\n", publicmethod.GetIntLength(timeVal), timeVal, beginTime)
|
|
|
|
|
case "timePicker":
|
|
|
|
|
timeVal, _ := publicmethod.StringToInt64(mv)
|
|
|
|
|
if timeVal != 0 {
|
|
|
|
|
if publicmethod.GetIntLength(timeVal) == 13 {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 5)
|
|
|
|
|
} else {
|
|
|
|
|
sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal, 5)
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
sendInfo[mi] = ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if timeVal, isOk := mv.(int64); isOk {
|
|
|
|
|
// sendInfo[mi] = publicmethod.UnixTimeToDay(timeVal/1000, 6)
|
|
|
|
|
// }
|
|
|
|
|
// fmt.Printf("时间显示器:%T====》%v\n", mv, mv)
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
return sendList
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-04-02 11:42:20
|
|
|
|
|
@ 功能: 根据字段显示格式处理数据
|
|
|
|
|
*/
|
|
|
|
|
func (l *ListPageFields) BaseTableAttrField(key string, val interface{}, formJsonCont CustomerFormMaster) interface{} {
|
|
|
|
|
if len(l.TableData.Columns) < 0 {
|
|
|
|
|
return val
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// jsonStrl, _ := json.Marshal(formJsonCont)
|
|
|
|
|
// fmt.Printf("树形菜单结构--1--》\n\n\n\n%v\n\n\n\n", string(jsonStrl))
|
|
|
|
|
|
|
|
|
|
for _, v := range l.TableData.Columns {
|
|
|
|
|
if v.Id == key {
|
|
|
|
|
switch v.FieldClass {
|
|
|
|
|
case "checkbox":
|
|
|
|
|
if val != nil {
|
|
|
|
|
var checkboxStrAry []interface{}
|
|
|
|
|
var checkboxAry []string
|
|
|
|
|
if valStr, ok := val.(string); ok {
|
|
|
|
|
err := json.Unmarshal([]byte(valStr), &checkboxStrAry)
|
|
|
|
|
if err == nil {
|
|
|
|
|
for _, v := range checkboxStrAry {
|
|
|
|
|
checkboxAry = append(checkboxAry, publicmethod.TypeToInterface(v))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(checkboxAry) > 0 {
|
|
|
|
|
var jieGuo []string
|
|
|
|
|
for _, ov := range v.Options {
|
|
|
|
|
intVal, _ := publicmethod.StringToInt64(ov.Value)
|
|
|
|
|
intValStr := strconv.FormatInt(intVal, 10)
|
|
|
|
|
if publicmethod.IsInTrue[string](intValStr, checkboxAry) {
|
|
|
|
|
jieGuo = append(jieGuo, ov.Label)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
val = strings.Join(jieGuo, ",")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case "orgCentent":
|
|
|
|
|
var orgCont modelshr.AdministrativeOrganization
|
|
|
|
|
orgCont.GetCont(map[string]interface{}{"`id`": val}, "name")
|
|
|
|
|
return orgCont.Name
|
|
|
|
|
case "baidumap":
|
|
|
|
|
var mapAry []string
|
|
|
|
|
if valStr, ok := val.(string); ok {
|
|
|
|
|
mapAry = strings.Split(valStr, "|*@*|")
|
|
|
|
|
}
|
|
|
|
|
if len(mapAry) > 0 {
|
|
|
|
|
return mapAry[0]
|
|
|
|
|
}
|
|
|
|
|
case "treeSelect":
|
|
|
|
|
// jsonStr, _ := json.Marshal(v)
|
|
|
|
|
// fmt.Printf("树形菜单结构----》\n%v\n", string(jsonStr))
|
|
|
|
|
// formJsonCont.GetUnitVal(v.Id)
|
|
|
|
|
hjakshdk := GetUnitVal(v.Id, val, formJsonCont)
|
|
|
|
|
// fmt.Printf("树形菜单结构----》\n%v\n", hjakshdk)
|
|
|
|
|
return hjakshdk
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
case "pickrole":
|
|
|
|
|
valInt := publicmethod.TypeToInterface(val)
|
|
|
|
|
if valInt != "" && valInt != "0" {
|
|
|
|
|
var roleMode modelssystempermission.SystemRole
|
|
|
|
|
roleMode.GetCont(map[string]interface{}{"`id`": val})
|
|
|
|
|
return roleMode.Name
|
|
|
|
|
} else {
|
|
|
|
|
return val
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "pickpost":
|
|
|
|
|
valString := publicmethod.TypeToInterface(val)
|
|
|
|
|
if valString != "" {
|
|
|
|
|
mapAry := strings.Split(valString, "#@#")
|
|
|
|
|
if len(mapAry) >= 2 {
|
|
|
|
|
var orgInfo modelshr.AdministrativeOrganization
|
|
|
|
|
orgInfo.GetCont(map[string]interface{}{"`id`": mapAry[0]}, "`name`")
|
|
|
|
|
var postInfo modelshr.Position
|
|
|
|
|
postInfo.GetCont(map[string]interface{}{"`id`": mapAry[len(mapAry)-1]}, "`name`")
|
|
|
|
|
return fmt.Sprintf("%v - %v", orgInfo.Name, postInfo.Name)
|
|
|
|
|
} else if len(mapAry) == 1 {
|
|
|
|
|
var orgInfo modelshr.AdministrativeOrganization
|
|
|
|
|
orgInfo.GetCont(map[string]interface{}{"`id`": mapAry[0]}, "`name`")
|
|
|
|
|
return orgInfo.Name
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return val
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return publicmethod.TypeToInterface(val)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return publicmethod.TypeToInterface(val)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetUnitVal(key string, val interface{}, formJsonCont CustomerFormMaster) (rutVal string) {
|
|
|
|
|
|
|
|
|
|
if len(formJsonCont.List) > 0 {
|
|
|
|
|
for _, v := range formJsonCont.List {
|
|
|
|
|
if v.Name == key {
|
|
|
|
|
if datList, isOk := v.Control.Data.([]interface{}); isOk {
|
|
|
|
|
|
|
|
|
|
rutVal = diGuiShu(val, datList)
|
|
|
|
|
// fmt.Printf("已经是结果了:%v\n", rutVal)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2025-02-28 15:43:27
|
|
|
|
|
@ 功能: 递归查值
|
|
|
|
|
*/
|
|
|
|
|
func diGuiShu(key interface{}, val []interface{}) string {
|
|
|
|
|
jieguo := ""
|
|
|
|
|
|
|
|
|
|
for _, v := range val {
|
|
|
|
|
|
|
|
|
|
if mapVal, isOk := v.(map[string]interface{}); isOk {
|
|
|
|
|
// fmt.Printf("结果是---111-->%v---111-->%v---111-->%v\n", mapVal["value"], key, publicmethod.TypeToInterface(mapVal["value"]) == publicmethod.TypeToInterface(key))
|
|
|
|
|
publicmethod.TypeToInterface(mapVal["value"])
|
|
|
|
|
if publicmethod.TypeToInterface(mapVal["value"]) == publicmethod.TypeToInterface(key) {
|
|
|
|
|
// fmt.Printf("结果是---label-->%v\n", publicmethod.TypeToInterface(mapVal["label"]))
|
|
|
|
|
jieguo = publicmethod.TypeToInterface(mapVal["label"])
|
|
|
|
|
// return jieguo
|
|
|
|
|
} else {
|
|
|
|
|
if childVal, isok := mapVal["children"]; isok {
|
|
|
|
|
// fmt.Printf("\n\n组件清苦--->>%T------>%v\n\n", childVal, childVal)
|
|
|
|
|
if vhiList, ok := childVal.([]interface{}); ok {
|
|
|
|
|
jieguo = diGuiShu(key, vhiList)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if jieguo != "" {
|
|
|
|
|
return jieguo
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// fmt.Printf("结果是-1--label--1>%v\n", jieguo)
|
|
|
|
|
return jieguo
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-04-01 16:16:28
|
|
|
|
|
@ 功能: 拆析查询条件
|
|
|
|
|
*/
|
|
|
|
|
func AnalysisSerachTerm(why string) (whereMap map[string]interface{}, err error) {
|
|
|
|
|
err = nil
|
|
|
|
|
if why == "" {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var listField []SearchButtonInfo
|
|
|
|
|
err = json.Unmarshal([]byte(why), &listField)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
whyMap := publicmethod.MapOut[string]()
|
|
|
|
|
for _, v := range listField {
|
|
|
|
|
// fmt.Printf("%v: %v\n", v.Field, v.Values)
|
|
|
|
|
if v.Values != nil && v.Values != "" {
|
|
|
|
|
whyMap[v.Field] = v.Values
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if len(whyMap) < 1 {
|
|
|
|
|
err = errors.New("没有要查询的内容!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
whereMap = whyMap
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-04-02 13:26:45
|
|
|
|
|
@ 功能: 查询条件
|
|
|
|
|
*/
|
|
|
|
|
func AnalysisSerachTermSql(why string, gormDb *gorm.DB) *gorm.DB {
|
|
|
|
|
if why == "" {
|
|
|
|
|
return gormDb
|
|
|
|
|
}
|
|
|
|
|
var listField []SearchButtonInfo
|
|
|
|
|
err := json.Unmarshal([]byte(why), &listField)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return gormDb
|
|
|
|
|
}
|
|
|
|
|
for _, v := range listField {
|
|
|
|
|
if v.Values != nil && v.Values != "" && 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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-07-06 13:42:03
|
|
|
|
|
@ 功能: 列表展示需要字段
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (a *ApiMethod) GainListTableField(c *gin.Context) {
|
|
|
|
|
var requestData publicmethod.PublicId
|
|
|
|
|
err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(100, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var customerFormMaster modelAppPlatform.CustomerFormView
|
|
|
|
|
err = customerFormMaster.GetCont(map[string]interface{}{"`cfid`": requestData.Id, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`name`")
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var masterTable []Result
|
|
|
|
|
var formJsonCont CustomerFormMaster
|
|
|
|
|
json.Unmarshal([]byte(customerFormMaster.MastesFormJson), &formJsonCont)
|
|
|
|
|
if formJsonCont.Form.DataSource == "yes" {
|
|
|
|
|
var sqlDb datacenter.DataBastType
|
|
|
|
|
sqlDb.Type = formJsonCont.Form.DataSourceConfig.DSN.SqlType
|
|
|
|
|
sqlDb.Ip = formJsonCont.Form.DataSourceConfig.DSN.Ip
|
|
|
|
|
sqlDb.DataBaseName = formJsonCont.Form.DataSourceConfig.DSN.DataBaseName
|
|
|
|
|
sqlDb.Port = formJsonCont.Form.DataSourceConfig.DSN.Port
|
|
|
|
|
sqlDb.UserName = formJsonCont.Form.DataSourceConfig.DSN.UserName
|
|
|
|
|
sqlDb.Pwd = formJsonCont.Form.DataSourceConfig.DSN.Password
|
|
|
|
|
sqlDborm, err := sqlDb.StartDataBast()
|
|
|
|
|
if err != nil {
|
|
|
|
|
sqlDborm, err = datacenter.GainDataStorce(formJsonCont.Form.DataSourceConfig.Id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(0, sqlDb, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
masterTable, err = GainFormAllFieldList(sqlDborm, formJsonCont.Form.DataSourceConfig.TableKey)
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
masterTable, err = GainFormTableField(customerFormMaster.TableKey)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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 customerFormMaster.TableStructure != "" { //判断是否有主体子表单
|
|
|
|
|
var sunTable map[string]interface{}
|
|
|
|
|
err = json.Unmarshal([]byte(customerFormMaster.TableStructure), &sunTable)
|
|
|
|
|
if err == nil {
|
|
|
|
|
sunTableMap := publicmethod.MapOut[string]()
|
|
|
|
|
for _, v := range sunTable { //遍历子表单名称
|
|
|
|
|
if vStr, ok := v.(string); ok {
|
|
|
|
|
sunTableMap[vStr], err = GainFormTableField(vStr)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// sendTableList["sunTable"] = sunTableMap
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var unitCont map[string]interface{}
|
|
|
|
|
json.Unmarshal([]byte(customerFormMaster.MastesFormJson), &unitCont)
|
|
|
|
|
|
|
|
|
|
var formFieldAry FormJsonFieldInfo
|
|
|
|
|
if list, ok := unitCont["list"]; ok {
|
|
|
|
|
|
|
|
|
|
if listAry, ok := list.([]interface{}); ok {
|
|
|
|
|
formFieldAry.AnalyzingFormJson("", listAry)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var allKeyWords []ViewListMode
|
|
|
|
|
var mapKeyWords []ViewListMode
|
|
|
|
|
var cardKeyWords []ViewListMode
|
|
|
|
|
var timeKeyWords []ViewListMode
|
|
|
|
|
sendTableList["isMap"] = false
|
|
|
|
|
sendTableList["isCard"] = false
|
|
|
|
|
for _, v := range masterTable {
|
|
|
|
|
var keyWords ViewListMode
|
|
|
|
|
keyWords.Label = v.Comment
|
|
|
|
|
if v.Field == "id" {
|
|
|
|
|
keyWords.Label = "Id"
|
|
|
|
|
}
|
|
|
|
|
keyWords.Value = v.Field
|
|
|
|
|
allKeyWords = append(allKeyWords, keyWords)
|
|
|
|
|
if v.Field == "creater_time" || v.Field == "edit_time" {
|
|
|
|
|
timeKeyWords = append(timeKeyWords, keyWords)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for _, fv := range formFieldAry.MasterInfo {
|
|
|
|
|
if publicmethod.IsInTrue(fv.FieldClass, []string{"datePicker", "timePicker"}) {
|
|
|
|
|
var keyWordsTime ViewListMode
|
|
|
|
|
keyWordsTime.Label = fv.Label
|
|
|
|
|
keyWordsTime.Value = fv.Id
|
|
|
|
|
timeKeyWords = append(timeKeyWords, keyWordsTime)
|
|
|
|
|
}
|
|
|
|
|
if publicmethod.IsInTrue(fv.FieldClass, []string{"baidumap"}) {
|
|
|
|
|
var keyWordsMap ViewListMode
|
|
|
|
|
keyWordsMap.Label = fv.Label
|
|
|
|
|
keyWordsMap.Value = fv.Id
|
|
|
|
|
mapKeyWords = append(mapKeyWords, keyWordsMap)
|
|
|
|
|
sendTableList["isMap"] = true
|
|
|
|
|
}
|
|
|
|
|
if publicmethod.IsInTrue(fv.FieldClass, []string{"lowcodeImage"}) {
|
|
|
|
|
var keyWordsMap ViewListMode
|
|
|
|
|
keyWordsMap.Label = fv.Label
|
|
|
|
|
keyWordsMap.Value = fv.Id
|
|
|
|
|
cardKeyWords = append(cardKeyWords, keyWordsMap)
|
|
|
|
|
sendTableList["isCard"] = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sendTableList["allKeyWords"] = allKeyWords
|
|
|
|
|
sendTableList["mapKeyWords"] = mapKeyWords
|
|
|
|
|
sendTableList["timeKeyWords"] = timeKeyWords
|
|
|
|
|
sendTableList["cardKeyWords"] = cardKeyWords
|
|
|
|
|
|
|
|
|
|
publicmethod.Result(0, sendTableList, c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-07-06 13:42:03
|
|
|
|
|
@ 功能: 列表展示需要字段(带标题组件)
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (a *ApiMethod) GainListTableFieldTitle(c *gin.Context) {
|
|
|
|
|
var requestData publicmethod.PublicId
|
|
|
|
|
err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(100, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
publicmethod.Result(103, err, c, "未知表单!无法获取字段!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var customerFormMaster modelAppPlatform.CustomerFormView
|
|
|
|
|
err = customerFormMaster.GetCont(map[string]interface{}{"`cfid`": requestData.Id, "`status`": 1}, "`tablekey`", "`table_structure`", "`mastesform`", "`mastesformjson`", "`name`")
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(100, err, c, "未知表单!无法获取字段!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var masterTable []Result
|
|
|
|
|
var formJsonCont CustomerFormMaster
|
|
|
|
|
json.Unmarshal([]byte(customerFormMaster.MastesFormJson), &formJsonCont)
|
|
|
|
|
if formJsonCont.Form.DataSource == "yes" {
|
|
|
|
|
var sqlDb datacenter.DataBastType
|
|
|
|
|
sqlDb.Type = formJsonCont.Form.DataSourceConfig.DSN.SqlType
|
|
|
|
|
sqlDb.Ip = formJsonCont.Form.DataSourceConfig.DSN.Ip
|
|
|
|
|
sqlDb.DataBaseName = formJsonCont.Form.DataSourceConfig.DSN.DataBaseName
|
|
|
|
|
sqlDb.Port = formJsonCont.Form.DataSourceConfig.DSN.Port
|
|
|
|
|
sqlDb.UserName = formJsonCont.Form.DataSourceConfig.DSN.UserName
|
|
|
|
|
sqlDb.Pwd = formJsonCont.Form.DataSourceConfig.DSN.Password
|
|
|
|
|
sqlDborm, err := sqlDb.StartDataBast()
|
|
|
|
|
if err != nil {
|
|
|
|
|
sqlDborm, err = datacenter.GainDataStorce(formJsonCont.Form.DataSourceConfig.Id)
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(0, sqlDb, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
masterTable, err = GainFormAllFieldList(sqlDborm, formJsonCont.Form.DataSourceConfig.TableKey)
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
masterTable, err = GainFormTableField(customerFormMaster.TableKey)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// masterTable, err := GainFormTableField(customerFormMaster.TableKey)
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(101, err, c, "未知表单!无法获取字段!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
sendTableList := publicmethod.MapOut[string]()
|
|
|
|
|
// sendTableList["masterTableName"] = customerFormMaster.Name
|
|
|
|
|
// sendTableList["masterTable"] = masterTable
|
|
|
|
|
if customerFormMaster.TableStructure != "" { //判断是否有主体子表单
|
|
|
|
|
var sunTable map[string]interface{}
|
|
|
|
|
err = json.Unmarshal([]byte(customerFormMaster.TableStructure), &sunTable)
|
|
|
|
|
if err == nil {
|
|
|
|
|
sunTableMap := publicmethod.MapOut[string]()
|
|
|
|
|
for _, v := range sunTable { //遍历子表单名称
|
|
|
|
|
if vStr, ok := v.(string); ok {
|
|
|
|
|
sunTableMap[vStr], err = GainFormTableField(vStr)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// sendTableList["sunTable"] = sunTableMap
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var unitCont map[string]interface{}
|
|
|
|
|
json.Unmarshal([]byte(customerFormMaster.MastesFormJson), &unitCont)
|
|
|
|
|
|
|
|
|
|
var formFieldAry FormJsonFieldInfo
|
|
|
|
|
if list, ok := unitCont["list"]; ok {
|
|
|
|
|
|
|
|
|
|
if listAry, ok := list.([]interface{}); ok {
|
|
|
|
|
formFieldAry.AnalyzingFormJson("", listAry)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var allKeyWords []ViewListMode
|
|
|
|
|
var mapKeyWords []ViewListMode
|
|
|
|
|
var cardKeyWords []ViewListMode
|
|
|
|
|
var timeKeyWords []ViewListMode
|
|
|
|
|
sendTableList["isMap"] = false
|
|
|
|
|
sendTableList["isCard"] = false
|
|
|
|
|
for _, v := range masterTable {
|
|
|
|
|
var keyWords ViewListMode
|
|
|
|
|
keyWords.Label = v.Comment
|
|
|
|
|
if v.Field == "id" {
|
|
|
|
|
keyWords.Label = "Id"
|
|
|
|
|
}
|
|
|
|
|
keyWords.Value = v.Field
|
|
|
|
|
allKeyWords = append(allKeyWords, keyWords)
|
|
|
|
|
if v.Field == "creater_time" || v.Field == "edit_time" {
|
|
|
|
|
timeKeyWords = append(timeKeyWords, keyWords)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for _, fv := range formFieldAry.MasterInfo {
|
|
|
|
|
if publicmethod.IsInTrue(fv.FieldClass, []string{"datePicker", "timePicker"}) {
|
|
|
|
|
var keyWordsTime ViewListMode
|
|
|
|
|
keyWordsTime.Label = fv.Label
|
|
|
|
|
keyWordsTime.Value = fv.Id
|
|
|
|
|
timeKeyWords = append(timeKeyWords, keyWordsTime)
|
|
|
|
|
}
|
|
|
|
|
if publicmethod.IsInTrue(fv.FieldClass, []string{"baidumap"}) {
|
|
|
|
|
var keyWordsMap ViewListMode
|
|
|
|
|
keyWordsMap.Label = fv.Label
|
|
|
|
|
keyWordsMap.Value = fv.Id
|
|
|
|
|
mapKeyWords = append(mapKeyWords, keyWordsMap)
|
|
|
|
|
sendTableList["isMap"] = true
|
|
|
|
|
}
|
|
|
|
|
if publicmethod.IsInTrue(fv.FieldClass, []string{"lowcodeImage"}) {
|
|
|
|
|
var keyWordsMap ViewListMode
|
|
|
|
|
keyWordsMap.Label = fv.Label
|
|
|
|
|
keyWordsMap.Value = fv.Id
|
|
|
|
|
cardKeyWords = append(cardKeyWords, keyWordsMap)
|
|
|
|
|
sendTableList["isCard"] = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
allKeyWords = append(allKeyWords, JudgeUnitTitle(formJsonCont.List)...)
|
|
|
|
|
sendTableList["allKeyWords"] = allKeyWords
|
|
|
|
|
sendTableList["mapKeyWords"] = mapKeyWords
|
|
|
|
|
sendTableList["timeKeyWords"] = timeKeyWords
|
|
|
|
|
sendTableList["cardKeyWords"] = cardKeyWords
|
|
|
|
|
|
|
|
|
|
publicmethod.Result(0, sendTableList, c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2025-05-31 15:09:44
|
|
|
|
|
@ 功能: 标题组件解析
|
|
|
|
|
*/
|
|
|
|
|
func JudgeUnitTitle(List []MasterStruct) (keyValAry []ViewListMode) {
|
|
|
|
|
fmt.Printf("标题组件解析------------》%v\n\n\n\n\n", List)
|
|
|
|
|
for _, v := range List {
|
|
|
|
|
if v.Type == "title" {
|
|
|
|
|
if v.Control.ModelValue != "" {
|
|
|
|
|
// title := publicmethod.TypeToClass(v.Control.ModelValue, 10)
|
|
|
|
|
var keyVal ViewListMode
|
|
|
|
|
keyVal.Label = publicmethod.TypeToClass(v.Control.ModelValue, 10)
|
|
|
|
|
keyVal.Value = fmt.Sprintf("%v|#|%v", v.Control.ModelValue, "title")
|
|
|
|
|
keyValAry = append(keyValAry, keyVal)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-09-13 14:18:47
|
|
|
|
|
@ 功能: 根据版本Id获取相应的表单结构
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func (a *ApiMethod) GainTableVersionField(c *gin.Context) {
|
|
|
|
|
var requestData publicmethod.PublicId
|
|
|
|
|
err := c.ShouldBindJSON(&requestData)
|
|
|
|
|
if err != nil {
|
|
|
|
|
publicmethod.Result(100, err, c)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if requestData.Id == "" {
|
|
|
|
|
publicmethod.Result(1, err, c, "未知表单!无法获取字段!")
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
var version modelAppPlatform.CustomerFormVersion
|
|
|
|
|
version.GetCont(map[string]interface{}{"`id`": requestData.Id})
|
|
|
|
|
sendTableList := publicmethod.MapOut[string]()
|
|
|
|
|
var tableMaster modelAppPlatform.CustomerForm
|
|
|
|
|
tableMaster.GetCont(map[string]interface{}{"`tablename`": version.TableKey}, "`name`")
|
|
|
|
|
sendTableList["masterTableName"] = tableMaster.Name
|
|
|
|
|
masterTable, _ := GainFormTableField(version.TableKey)
|
|
|
|
|
|
|
|
|
|
if version.MastesFormJson != "" {
|
|
|
|
|
var unitCont map[string]interface{}
|
|
|
|
|
json.Unmarshal([]byte(version.MastesFormJson), &unitCont)
|
|
|
|
|
|
|
|
|
|
var formFieldAry FormJsonFieldInfo
|
|
|
|
|
if list, ok := unitCont["list"]; ok {
|
|
|
|
|
|
|
|
|
|
if listAry, ok := list.([]interface{}); ok {
|
|
|
|
|
formFieldAry.AnalyzingFormJson("", listAry)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if len(formFieldAry.MasterInfo) > 0 {
|
|
|
|
|
sendTableList["masterTable"] = TableFieldCompareForm(masterTable, formFieldAry.MasterInfo)
|
|
|
|
|
} else {
|
|
|
|
|
sendTableList["masterTable"] = masterTable
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
sendTableList["masterTable"] = masterTable
|
|
|
|
|
}
|
|
|
|
|
if version.TableStructure != "" {
|
|
|
|
|
var sunTable map[string]interface{}
|
|
|
|
|
err = json.Unmarshal([]byte(version.TableStructure), &sunTable)
|
|
|
|
|
if err == nil {
|
|
|
|
|
sunTableMap := publicmethod.MapOut[string]()
|
|
|
|
|
for _, v := range sunTable { //遍历子表单名称
|
|
|
|
|
if vStr, ok := v.(string); ok {
|
|
|
|
|
sunTableMap[vStr], err = GainFormTableField(vStr)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sendTableList["sunTable"] = sunTableMap
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
publicmethod.Result(0, sendTableList, c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
@ 作者: 秦东
|
|
|
|
|
@ 时间: 2024-03-25 09:01:12
|
|
|
|
|
@ 功能: 表单数据对照
|
|
|
|
|
@ 参数
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 返回值
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
@ 方法原型
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
*/
|
|
|
|
|
func TableFieldCompareForm(tableFieldList []Result, jsonFieldList []FormFieldInfo) (fieldList []Result) {
|
|
|
|
|
|
|
|
|
|
tableFieldListsdf, _ := json.Marshal(tableFieldList)
|
|
|
|
|
jsonFieldListsdf, _ := json.Marshal(jsonFieldList)
|
|
|
|
|
fmt.Printf("\n======================1===============================\n")
|
|
|
|
|
fmt.Printf("tableFieldListsdf:%v\n", string(tableFieldListsdf))
|
|
|
|
|
fmt.Printf("jsonFieldListsdf:%v\n", string(jsonFieldListsdf))
|
|
|
|
|
fmt.Printf("\n======================1===============================\n")
|
|
|
|
|
|
|
|
|
|
if len(tableFieldList) > 0 {
|
|
|
|
|
for _, v := range tableFieldList {
|
|
|
|
|
// if v.Field == "_lableTitle" {
|
|
|
|
|
|
|
|
|
|
// fieldList = append(fieldList, v)
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
switch v.Field {
|
|
|
|
|
case "_lableTitle":
|
|
|
|
|
fieldList = append(fieldList, v)
|
|
|
|
|
case "id":
|
|
|
|
|
fieldList = append(fieldList, v)
|
|
|
|
|
case "masters_key":
|
|
|
|
|
fieldList = append(fieldList, v)
|
|
|
|
|
case "creater":
|
|
|
|
|
fieldList = append(fieldList, v)
|
|
|
|
|
case "creater_time":
|
|
|
|
|
fieldList = append(fieldList, v)
|
|
|
|
|
case "edit_time":
|
|
|
|
|
fieldList = append(fieldList, v)
|
|
|
|
|
case "flow_id":
|
|
|
|
|
fieldList = append(fieldList, v)
|
|
|
|
|
case "states":
|
|
|
|
|
fieldList = append(fieldList, v)
|
|
|
|
|
case "flowIsOpen":
|
|
|
|
|
fieldList = append(fieldList, v)
|
|
|
|
|
default:
|
|
|
|
|
formKey := TableFormAttributeForm(v, jsonFieldList)
|
|
|
|
|
if formKey.Field != "" {
|
|
|
|
|
fieldList = append(fieldList, formKey)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
fieldList = tableFieldList
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
func TableFormAttributeForm(formField Result, tableFieldList []FormFieldInfo) (fieldInfo Result) {
|
|
|
|
|
fmt.Printf("formField.Field--->%v\n", formField.Field)
|
|
|
|
|
for _, v := range tableFieldList {
|
|
|
|
|
fmt.Printf("v.Field--->%v\n", v.Id)
|
|
|
|
|
if v.Id == formField.Field {
|
|
|
|
|
fieldInfo = formField
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|