package taskflow import ( "appPlatform/api/version1/customerform" "appPlatform/models/modelAppPlatform" "appPlatform/overall" "appPlatform/overall/publicmethod" "encoding/json" "fmt" "strconv" "github.com/gin-gonic/gin" ) /* * @ 作者: 秦东 @ 时间: 2023-10-10 13:44:07 @ 功能: 初始化工作流 @ 参数 # @ 返回值 # @ 方法原型 # */ func (a *ApiMethod) InitializeWorkFlow(c *gin.Context) { var requestData publicmethod.PublicName c.ShouldBindJSON(&requestData) var workFlowStruct FlowStructIng workFlowStruct.TableId = strconv.FormatInt(publicmethod.GetUUid(2), 10) if requestData.Name != "" { workFlowStruct.WorkFlowDef.Name = requestData.Name } else { workFlowStruct.WorkFlowDef.Name = "自定义工作流" } workFlowStruct.NodeConfig.NodeNumber = strconv.FormatInt(publicmethod.GetUUid(5), 10) workFlowStruct.NodeConfig.NodeName = "发起人" workFlowStruct.DirectorMaxLevel = 4 workFlowStruct.NodeConfig.Attribute = 0 // err := json.Unmarshal([]byte(jsonStrSmaill), &workFlowStruct) outData := publicmethod.MapOut[string]() outData["workFlowStruct"] = workFlowStruct // outData["err"] = err publicmethod.Result(0, workFlowStruct, c) } /* * @ 作者: 秦东 @ 时间: 2023-10-19 14:02:54 @ 功能: 获取工作流版本列表 @ 参数 # @ 返回值 # @ 方法原型 # */ func (a *ApiMethod) GainFlowVersionList(c *gin.Context) { var requestData publicmethod.CommonId[string] err := c.ShouldBindJSON(&requestData) if err != nil || requestData.Id == "" { publicmethod.Result(10001, err, c) return } var flowVersionList []modelAppPlatform.FlowVersion err = overall.CONSTANT_DB_AppPlatform.Where("`state` IN ? AND `formkey` = ?", []int{1, 2}, requestData.Id).Find(&flowVersionList).Error if err != nil || len(flowVersionList) < 1 { publicmethod.Result(10001, err, c) return } var sendList []SendSmaileFlowVersion for _, v := range flowVersionList { var sendCont SendSmaileFlowVersion sendCont.Id = strconv.FormatInt(v.Id, 10) sendCont.Version = v.Version sendCont.State = v.State sendCont.Key = strconv.FormatInt(v.Key, 10) sendList = append(sendList, sendCont) } publicmethod.Result(0, sendList, c) } /* * @ 作者: 秦东 @ 时间: 2023-10-19 16:18:36 @ 功能: 获取审批节点或条件节点 @ 参数 # @ 返回值 # @ 方法原型 # */ func (a *ApiMethod) GainNodeFactor(c *gin.Context) { var requestData GainNodeFactor err := c.ShouldBindJSON(&requestData) if err != nil || requestData.Id == "" { publicmethod.Result(100, err, c) return } var customerFormCont modelAppPlatform.CustomerForm err = customerFormCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`tablename`") if err != nil { publicmethod.Result(106, err, c) return } var customerFormVersionCont modelAppPlatform.CustomerFormVersion err = customerFormVersionCont.GetCont(map[string]interface{}{"`tablekey`": customerFormCont.TableNames, "`status`": 1}, "`mastesformjson`") if err != nil { publicmethod.Result(106, err, c) return } var sendList []SendFormNodeFactor if customerFormVersionCont.MastesFormJson != "" { var formJsonCont customerform.CustomerFormMaster json.Unmarshal([]byte(customerFormVersionCont.MastesFormJson), &formJsonCont) var unitList CustomerFormUnit unitList.GetFormUnit(formJsonCont.Form.Name, formJsonCont.List, true) sendData := publicmethod.MapOut[string]() // master, sunTable, jsonerr := taskmanagement.GainFormStruct(customerFormVersionCont.MastesFormJson) // if jsonerr != nil { // publicmethod.Result(104, err, c) // return // } if len(unitList.MasterInfo) > 0 { var masterUnit []customerform.MasterStruct for _, v := range unitList.MasterInfo { if v.IsMaster { masterUnit = v.Info } } for _, v := range masterUnit { var sendCont SendFormNodeFactor if requestData.Types == 1 && publicmethod.IsInTrue[string](v.Type, []string{"expand-user"}) { sendCont.Id = v.Name sendCont.Name = v.Name if v.Item.Label != "" { sendCont.Name = v.Item.Label } sendList = append(sendList, sendCont) } else if requestData.Types != 1 && publicmethod.IsInTrue[string](v.Type, []string{"radio", "checkbox", "select", "switch"}) { sendCont.Id = v.Name sendCont.Name = v.Name if v.Type == "switch" { jsonstr, _ := json.Marshal(v.Control) fmt.Printf("------>%v\n", string(jsonstr)) var optInfoOne customerform.OptionsStruct optInfoOne.Label = "是" optInfoOne.Value = v.Control.ActiveValue sendCont.Options = append(sendCont.Options, optInfoOne) var optInfoTwo customerform.OptionsStruct optInfoTwo.Label = "否" optInfoTwo.Value = v.Control.InactiveValue sendCont.Options = append(sendCont.Options, optInfoTwo) } else { sendCont.Options = v.Options } if v.Type == "checkbox" { sendCont.IsCheckbox = true } if v.Item.Label != "" { sendCont.Name = v.Item.Label } sendList = append(sendList, sendCont) } } } // sendData["master"] = master // sendData["sunTable"] = sunTable sendData["sendList"] = sendList sendData["unitList"] = unitList publicmethod.Result(0, sendList, c) } // publicmethod.Result(0, sendList, c) } // 获取表单组件 func (f *CustomerFormUnit) GetFormUnit(tablename string, subUnitAry []customerform.MasterStruct, isMaster bool) { if len(subUnitAry) > 0 { var sqlAllAry []customerform.MasterStruct for _, v := range subUnitAry { switch v.Type { case "flex", "table": if len(v.List) > 0 { f.GetFormUnit(v.Name, v.List, false) } case "grid", "tabs": if len(v.Columns) > 0 { for _, mv := range v.Columns { f.GetFormUnit(tablename, mv.List, isMaster) } } case "card", "div": if len(v.List) > 0 { f.GetFormUnit(tablename, v.List, isMaster) } default: sqlAllAry = append(sqlAllAry, v) } } if len(sqlAllAry) > 0 { if len(f.MasterInfo) > 0 { isWrite := true for sk, s := range f.MasterInfo { if s.UnitKey == tablename { f.MasterInfo[sk].Info = append(f.MasterInfo[sk].Info, sqlAllAry...) isWrite = false } } if isWrite { var sunSqlInfo SunFormUnit sunSqlInfo.UnitKey = tablename sunSqlInfo.IsMaster = isMaster sunSqlInfo.Info = sqlAllAry f.MasterInfo = append(f.MasterInfo, sunSqlInfo) } } else { var sunSqlInfo SunFormUnit sunSqlInfo.UnitKey = tablename sunSqlInfo.IsMaster = isMaster sunSqlInfo.Info = sqlAllAry f.MasterInfo = append(f.MasterInfo, sunSqlInfo) } } } }