You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
960 lines
25 KiB
960 lines
25 KiB
package taskflow
|
|
|
|
import (
|
|
"appPlatform/api/version1/customerform"
|
|
"appPlatform/models/modelAppPlatform"
|
|
"appPlatform/overall"
|
|
"appPlatform/overall/publicmethod"
|
|
"encoding/json"
|
|
"fmt"
|
|
"strconv"
|
|
"time"
|
|
|
|
"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
|
|
fmt.Printf("初始化流程---》%v\n", requestData)
|
|
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 {
|
|
fmt.Printf("组件类型---->%v\n", v.Type)
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-03-12 16:23:11
|
|
@ 功能: 判断是否已经存在工作流以及是否开启
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) JudgeFormFlowIsOpen(c *gin.Context) {
|
|
var requestData publicmethod.PublicId
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil || requestData.Id == "" {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
sendData := publicmethod.MapOut[string]()
|
|
var customerFormCont modelAppPlatform.CustomerForm
|
|
err = customerFormCont.GetCont(map[string]interface{}{"`id`": requestData.Id}, "`flowkey`", "`flowIsOpen`")
|
|
if err != nil {
|
|
sendData["isOpen"] = 2
|
|
sendData["flowKey"] = customerFormCont.FlowKey
|
|
publicmethod.Result(106, sendData, c)
|
|
return
|
|
}
|
|
sendData["flowKey"] = customerFormCont.FlowKey
|
|
sendData["isOpen"] = customerFormCont.FlowIsOpen
|
|
publicmethod.Result(0, sendData, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-03-12 16:27:46
|
|
@ 功能: 开启或关闭表单流程
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) OpenFormFlow(c *gin.Context) {
|
|
var requestData publicmethod.PublicStates
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil || requestData.Id == "" {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.Status == 0 {
|
|
requestData.Status = 2
|
|
}
|
|
editData := publicmethod.MapOut[string]()
|
|
editData["flowIsOpen"] = requestData.Status
|
|
editData["edit_time"] = time.Now().Unix()
|
|
var customerFormCont modelAppPlatform.CustomerForm
|
|
err = customerFormCont.EiteCont(map[string]interface{}{"`id`": requestData.Id}, editData)
|
|
if err != nil {
|
|
publicmethod.Result(106, err, c)
|
|
return
|
|
}
|
|
publicmethod.Result(0, err, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-03-13 09:28:40
|
|
@ 功能: 解析自定义表单组件
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) AnalysisForm(c *gin.Context) {
|
|
var requestData AnalysisNodesUnitPower
|
|
err := c.ShouldBindJSON(&requestData)
|
|
if err != nil {
|
|
publicmethod.Result(100, err, c)
|
|
return
|
|
}
|
|
if requestData.NodeKey == "" {
|
|
requestData.NodeKey = "begin"
|
|
}
|
|
// var unitAry map[string]interface{}
|
|
// json.Unmarshal([]byte(requestData.NodeJson), &unitAry)
|
|
// if list, ok := unitAry["list"]; ok {
|
|
// fmt.Printf("list:%T--->%v\n", list, list)
|
|
// if listAry, ok := list.([]interface{}); ok {
|
|
// for i, v := range listAry {
|
|
// fmt.Printf("%v:%T\n", i, v)
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
var unitCont TypesAnalysisNodesUnit
|
|
json.Unmarshal([]byte(requestData.NodeJson), &unitCont.UnitList)
|
|
// unitCont.AnalysisNodesUnit()
|
|
// var unitState []NodesUnitNameStatue
|
|
// json.Unmarshal([]byte(requestData.NodeJson), &unitState)
|
|
// var purview []map[string]interface{}
|
|
var recUnitAry RecursionFormUnit
|
|
recUnitAry.CurrentNodeName = requestData.NodeKey
|
|
// var nodePower []NodePowerInfo
|
|
if purviewList, ok := unitCont.UnitList["purview"]; ok {
|
|
if purviewAry, ok := purviewList.([]interface{}); ok {
|
|
// nodePower = SplitNodeUnitPurview(purviewAry)
|
|
recUnitAry.NodePower = SplitNodeUnitPurview(purviewAry)
|
|
}
|
|
}
|
|
|
|
// fmt.Printf("nodePower:%v\n", nodePower)
|
|
|
|
if list, ok := unitCont.UnitList["list"]; ok {
|
|
if listAry, ok := list.([]interface{}); ok {
|
|
recUnitAry.AllUnitNodesAll("", listAry)
|
|
}
|
|
|
|
}
|
|
if len(recUnitAry.UnitAllState) > 0 {
|
|
recUnitAry.UnitAllState = QuChongUnit(recUnitAry.UnitAllState)
|
|
}
|
|
sendData := publicmethod.MapOut[string]()
|
|
sendData["nodeKey"] = requestData.NodeKey
|
|
sendData["recUnitAry"] = recUnitAry
|
|
publicmethod.Result(0, sendData, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-03-14 08:38:32
|
|
@ 功能: 拆分节点已有得权限
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func SplitNodeUnitPurview(purviewAry []interface{}) (nodeUnitPowerAry []NodePowerInfo) {
|
|
jsonCont, jsonErr := json.Marshal(purviewAry)
|
|
// fmt.Printf("purviewList:%T--->%v--->%v\n", jsonCont, jsonErr, string(jsonCont))
|
|
if jsonErr == nil {
|
|
json.Unmarshal(jsonCont, &nodeUnitPowerAry)
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-03-13 15:40:43
|
|
@ 功能: 数组去重
|
|
*/
|
|
func QuChongUnit(unitList []NodesUnitNameStatue) []NodesUnitNameStatue {
|
|
var newAry []NodesUnitNameStatue
|
|
var unitKey []string
|
|
for _, v := range unitList {
|
|
if !publicmethod.IsInTrue[string](v.Id, unitKey) {
|
|
unitKey = append(unitKey, v.Id)
|
|
newAry = append(newAry, v)
|
|
}
|
|
}
|
|
return newAry
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-03-13 10:40:19
|
|
@ 功能: 自定义组件类型断言分解
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (t *TypesAnalysisNodesUnit) AnalysisNodesUnit() {
|
|
if list, ok := t.UnitList["list"]; ok {
|
|
// fmt.Printf("list:%T--->%v\n", list, list)
|
|
if listAry, ok := list.([]interface{}); ok {
|
|
if len(listAry) > 0 {
|
|
for _, listVal := range listAry {
|
|
if listInfo, ok := listVal.(map[string]interface{}); ok {
|
|
|
|
if unitType, ok := listInfo["type"]; ok {
|
|
var unitInfo NodesUnitNameStatue
|
|
if unitName, ok := listInfo["name"]; ok {
|
|
// fmt.Printf("unitName:%T--->%v\n", unitName, unitName)
|
|
if unitNameStr, ok := unitName.(string); ok {
|
|
unitInfo.Name = unitNameStr
|
|
}
|
|
}
|
|
|
|
switch unitType {
|
|
case "flex", "table":
|
|
fmt.Printf("list:%T--->%v\n", listInfo["list"], listInfo["list"])
|
|
case "grid", "tabs":
|
|
fmt.Printf("columns:%T--->%v\n", listInfo["columns"], listInfo["columns"])
|
|
case "card", "div":
|
|
case "title", "txt", "button":
|
|
default:
|
|
unitInfo.Status = 4
|
|
t.MasterUnitList = append(t.MasterUnitList, unitInfo)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-03-13 11:30:30
|
|
@ 功能: 递归解析所有组件
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (r *RecursionFormUnit) AllUnitNodes(tableName string, unitList []interface{}) {
|
|
if len(unitList) > 0 {
|
|
var unitIncoList []NodesUnitNameStatue
|
|
for _, listVal := range unitList {
|
|
if listInfo, ok := listVal.(map[string]interface{}); ok {
|
|
if unitType, ok := listInfo["type"]; ok {
|
|
var unitInfo NodesUnitNameStatue
|
|
if unitName, ok := listInfo["name"]; ok {
|
|
if unitNameStr, ok := unitName.(string); ok {
|
|
unitInfo.Id = unitNameStr
|
|
if !publicmethod.IsInTrue[string](unitNameStr, r.UnitAllKey) {
|
|
r.UnitAllKey = append(r.UnitAllKey, 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.Name = itemNameStr
|
|
}
|
|
}
|
|
}
|
|
fmt.Printf("list:%T--->%v\n", itemVal, itemVal)
|
|
}
|
|
// fmt.Printf("list:%T--->%v\n", unitName, unitName)
|
|
switch unitType {
|
|
case "flex", "table":
|
|
if list, ok := listInfo["list"]; ok {
|
|
if listAry, ok := list.([]interface{}); ok {
|
|
r.AllUnitNodes(unitInfo.Id, listAry)
|
|
}
|
|
}
|
|
// fmt.Printf("list:%T--->%v\n", listInfo["list"], listInfo["list"])
|
|
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 {
|
|
// fmt.Printf("list:%T--->%v\n", listMap, listMap)
|
|
if colListAry, ok := listMap.([]interface{}); ok {
|
|
r.AllUnitNodes(unitInfo.Id, colListAry)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//
|
|
// r.AllUnitNodes(unitInfo.Name, listAry)
|
|
}
|
|
}
|
|
// fmt.Printf("columns:%T--->%v\n", listInfo["columns"], listInfo["columns"])
|
|
case "card", "div":
|
|
if list, ok := listInfo["list"]; ok {
|
|
fmt.Printf("list:%T--->%v\n", list, list)
|
|
}
|
|
// if len(listInfo["list"]) > 0 {
|
|
// // f.TableSubUnitAnalysis(tablename, v.List, isMaster)
|
|
// }
|
|
case "title", "txt", "button":
|
|
default:
|
|
|
|
unitInfo.Status = 4
|
|
// t.MasterUnitList = append(t.MasterUnitList, unitInfo)
|
|
unitIncoList = append(unitIncoList, unitInfo)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(unitIncoList) > 0 {
|
|
r.UnitAllState = append(r.UnitAllState, unitIncoList...)
|
|
if tableName != "" {
|
|
if len(r.SunUnitList) > 0 {
|
|
isTrue := true
|
|
for si, sv := range r.SunUnitList {
|
|
if sv.Name == tableName {
|
|
r.SunUnitList[si].UnitList = append(r.SunUnitList[si].UnitList, unitIncoList...)
|
|
isTrue = false
|
|
}
|
|
}
|
|
if isTrue {
|
|
var sunUnitInfo SunNodesUnitNameStatue
|
|
sunUnitInfo.Name = tableName
|
|
sunUnitInfo.UnitList = unitIncoList
|
|
r.SunUnitList = append(r.SunUnitList, sunUnitInfo)
|
|
}
|
|
} else {
|
|
var sunUnitInfo SunNodesUnitNameStatue
|
|
sunUnitInfo.Name = tableName
|
|
sunUnitInfo.UnitList = unitIncoList
|
|
r.SunUnitList = append(r.SunUnitList, sunUnitInfo)
|
|
}
|
|
} else {
|
|
r.MasterUnitList = append(r.MasterUnitList, unitIncoList...)
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
// func (r *RecursionFormUnit) AllUnitNodesAll(tableName string, unitList []interface{}, UnitState []NodesUnitNameStatue) {
|
|
func (r *RecursionFormUnit) AllUnitNodesAll(tableName string, unitList []interface{}) {
|
|
if len(unitList) > 0 {
|
|
var unitIncoList []NodesUnitNameStatue
|
|
for _, listVal := range unitList {
|
|
if listInfo, ok := listVal.(map[string]interface{}); ok {
|
|
if unitType, ok := listInfo["type"]; ok {
|
|
var unitInfo NodesUnitNameStatue
|
|
if unitName, ok := listInfo["name"]; ok {
|
|
if unitNameStr, ok := unitName.(string); ok {
|
|
unitInfo.Id = unitNameStr
|
|
if !publicmethod.IsInTrue[string](unitNameStr, r.UnitAllKey) {
|
|
r.UnitAllKey = append(r.UnitAllKey, unitNameStr)
|
|
}
|
|
if len(r.NodePower) > 0 {
|
|
// fmt.Printf("判断权限-1->: %v\n", unitNameStr)
|
|
//func (r *RecursionFormUnit) CalculateNodePower(key string) (isLook, isErit bool)
|
|
unitInfo.IsLook, unitInfo.IsEdit = r.CalculateNodePower(unitNameStr)
|
|
// for _, uvs := range UnitState {
|
|
// if uvs.Id == unitNameStr {
|
|
// unitInfo.IsLook = uvs.IsLook
|
|
// unitInfo.IsEdit = uvs.IsEdit
|
|
// }
|
|
// }
|
|
} else {
|
|
// fmt.Printf("判断权限-3->: %v\n", unitNameStr)
|
|
unitInfo.IsLook = true
|
|
unitInfo.IsEdit = true
|
|
}
|
|
}
|
|
}
|
|
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.Name = itemNameStr
|
|
}
|
|
}
|
|
}
|
|
// fmt.Printf("list:%T--->%v\n", itemVal, itemVal)
|
|
}
|
|
// fmt.Printf("list:%T--->%v\n", unitName, unitName)
|
|
switch unitType {
|
|
case "flex", "table":
|
|
if list, ok := listInfo["list"]; ok {
|
|
if listAry, ok := list.([]interface{}); ok {
|
|
r.AllUnitNodesAll(unitInfo.Id, listAry)
|
|
}
|
|
}
|
|
// fmt.Printf("list:%T--->%v\n", listInfo["list"], listInfo["list"])
|
|
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 {
|
|
// fmt.Printf("list:%T--->%v\n", listMap, listMap)
|
|
if colListAry, ok := listMap.([]interface{}); ok {
|
|
r.AllUnitNodesAll(unitInfo.Id, colListAry)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//
|
|
// r.AllUnitNodes(unitInfo.Name, listAry)
|
|
}
|
|
}
|
|
// fmt.Printf("columns:%T--->%v\n", listInfo["columns"], listInfo["columns"])
|
|
case "card", "div":
|
|
if list, ok := listInfo["list"]; ok {
|
|
fmt.Printf("list:%T--->%v\n", list, list)
|
|
}
|
|
// if len(listInfo["list"]) > 0 {
|
|
// // f.TableSubUnitAnalysis(tablename, v.List, isMaster)
|
|
// }
|
|
case "title", "txt", "button":
|
|
default:
|
|
|
|
unitInfo.Status = 4
|
|
|
|
// t.MasterUnitList = append(t.MasterUnitList, unitInfo)
|
|
unitIncoList = append(unitIncoList, unitInfo)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if len(unitIncoList) > 0 {
|
|
r.UnitAllState = append(r.UnitAllState, unitIncoList...)
|
|
if tableName != "" {
|
|
if len(r.SunUnitList) > 0 {
|
|
isTrue := true
|
|
for si, sv := range r.SunUnitList {
|
|
if sv.Name == tableName {
|
|
r.SunUnitList[si].UnitList = append(r.SunUnitList[si].UnitList, unitIncoList...)
|
|
isTrue = false
|
|
}
|
|
}
|
|
if isTrue {
|
|
var sunUnitInfo SunNodesUnitNameStatue
|
|
sunUnitInfo.Name = tableName
|
|
sunUnitInfo.UnitList = unitIncoList
|
|
r.SunUnitList = append(r.SunUnitList, sunUnitInfo)
|
|
}
|
|
} else {
|
|
var sunUnitInfo SunNodesUnitNameStatue
|
|
sunUnitInfo.Name = tableName
|
|
sunUnitInfo.UnitList = unitIncoList
|
|
r.SunUnitList = append(r.SunUnitList, sunUnitInfo)
|
|
}
|
|
} else {
|
|
r.MasterUnitList = append(r.MasterUnitList, unitIncoList...)
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-03-14 09:20:29
|
|
@ 功能: 计算字段权限
|
|
@ 参数
|
|
|
|
#key 字段识别符
|
|
|
|
@ 返回值
|
|
|
|
#isLook 可见
|
|
#isErit 可编辑
|
|
|
|
@ 方法原型
|
|
|
|
#func (r *RecursionFormUnit) CalculateNodePower(key string) (isLook, isErit bool)
|
|
*/
|
|
func (r *RecursionFormUnit) CalculateNodePower(key string) (isLook, isErit bool) {
|
|
isLook = true
|
|
isErit = true
|
|
for _, v := range r.NodePower {
|
|
if v.NodeKey == r.CurrentNodeName {
|
|
for _, kv := range v.PowerAry {
|
|
if kv.Id == key {
|
|
isLook = kv.IsLook
|
|
isErit = kv.IsEdit
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2024-03-14 11:25:31
|
|
@ 功能: 设置工作流表单字段权限
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) SetFlowFormKeyPower(c *gin.Context) {
|
|
var requestData FlowFormPowerInfo
|
|
c.ShouldBindJSON(&requestData)
|
|
if requestData.FormKey == "" && requestData.FormVersion == "" {
|
|
publicmethod.Result(106, requestData, c)
|
|
return
|
|
}
|
|
if requestData.FormData == "" && requestData.FormPower == "" {
|
|
publicmethod.Result(106, requestData, c)
|
|
return
|
|
}
|
|
var customerFormInfo modelAppPlatform.CustomerForm
|
|
err := customerFormInfo.GetCont(map[string]interface{}{"`id`": requestData.FormKey}, "`tablename`")
|
|
if err != nil {
|
|
publicmethod.Result(106, err, c)
|
|
return
|
|
}
|
|
if requestData.FormVersion == "" {
|
|
var formVersionInfo modelAppPlatform.CustomerFormVersion
|
|
formVersionInfo.GetCont(map[string]interface{}{"`tablekey`": customerFormInfo.TableNames, "`status`": 1}, "`id`")
|
|
requestData.FormVersion = strconv.FormatInt(formVersionInfo.Id, 10)
|
|
}
|
|
var formVersion modelAppPlatform.CustomerFormVersion
|
|
err = formVersion.GetCont(map[string]interface{}{"`id`": requestData.FormVersion})
|
|
if err != nil {
|
|
publicmethod.Result(106, err, c)
|
|
return
|
|
}
|
|
saveData := publicmethod.MapOut[string]()
|
|
if requestData.FormData != "" {
|
|
saveData["`mastesformjson`"] = requestData.FormData
|
|
}
|
|
if requestData.FormPower != "" {
|
|
saveData["`powerstr`"] = requestData.FormPower
|
|
} else {
|
|
var nodePower map[string]interface{}
|
|
err = json.Unmarshal([]byte(requestData.FormData), &nodePower)
|
|
if err != nil {
|
|
publicmethod.Result(106, err, c)
|
|
return
|
|
}
|
|
|
|
if powerInf, ok := nodePower["purview"]; ok {
|
|
fmt.Printf("nodePower:%T------>%v\n", powerInf, powerInf)
|
|
powerJson, err := json.Marshal(powerInf)
|
|
if err == nil {
|
|
saveData["`powerstr`"] = string(powerJson)
|
|
}
|
|
}
|
|
}
|
|
if len(saveData) > 0 {
|
|
saveData["`edit_time`"] = time.Now().Unix()
|
|
formVersion.EiteCont(map[string]interface{}{"`id`": requestData.FormVersion}, saveData)
|
|
}
|
|
publicmethod.Result(0, requestData, c)
|
|
}
|
|
|
|
/*
|
|
*
|
|
@ 作者: 秦东
|
|
@ 时间: 2025-03-25 16:26:37
|
|
@ 功能: 获取行政组织几人员相关控件信息
|
|
@ 参数
|
|
|
|
#
|
|
|
|
@ 返回值
|
|
|
|
#
|
|
|
|
@ 方法原型
|
|
|
|
#
|
|
*/
|
|
func (a *ApiMethod) GainOrgOfPeopleNodeFactor(c *gin.Context) {
|
|
var requestData publicmethod.CommonId[string]
|
|
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 []SendRangField
|
|
var sendMapList []SendWorkMsgRangField
|
|
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 {
|
|
isWrite := true
|
|
jsonVal, _ := json.Marshal(v)
|
|
fmt.Printf("组件类型---->%v\n", string(jsonVal))
|
|
var sendCont SendRangField
|
|
sendCont.Lable = v.Item.Label
|
|
sendCont.Fields = v.Name
|
|
sendCont.Types = v.Type
|
|
|
|
var sendMapCont SendWorkMsgRangField
|
|
sendMapCont.Id = v.Name
|
|
sendMapCont.Name = v.Item.Label
|
|
sendMapCont.Types = v.Type
|
|
switch v.Type {
|
|
case "pickrole": //角色选择
|
|
sendMapCont.MultipleChoice = false
|
|
sendCont.MultipleChoice = false
|
|
isWrite = true
|
|
case "pickpost": //岗位选择
|
|
sendMapCont.MultipleChoice = false
|
|
sendCont.MultipleChoice = false
|
|
isWrite = true
|
|
case "deptOrg": //所属部门
|
|
sendMapCont.MultipleChoice = false
|
|
sendCont.MultipleChoice = false
|
|
isWrite = true
|
|
case "owner": //拥有者
|
|
sendMapCont.MultipleChoice = false
|
|
sendCont.MultipleChoice = false
|
|
isWrite = true
|
|
case "founder": //创建人
|
|
sendMapCont.MultipleChoice = false
|
|
sendCont.MultipleChoice = false
|
|
isWrite = true
|
|
case "orgCentent": //角色选择组织选择
|
|
sendMapCont.MultipleChoice = false
|
|
sendCont.MultipleChoice = false
|
|
isWrite = true
|
|
case "expand-user": //角色选择组织选择
|
|
sendMapCont.MultipleChoice = true
|
|
sendCont.MultipleChoice = true
|
|
isWrite = true
|
|
default:
|
|
isWrite = false
|
|
}
|
|
if isWrite {
|
|
sendList = append(sendList, sendCont)
|
|
sendMapList = append(sendMapList, sendMapCont)
|
|
}
|
|
|
|
}
|
|
}
|
|
// sendData["master"] = master
|
|
// sendData["sunTable"] = sunTable
|
|
sendData["sendList"] = sendList
|
|
sendData["unitList"] = unitList
|
|
sendData["sendMapList"] = sendMapList
|
|
publicmethod.Result(0, sendMapList, c)
|
|
}
|
|
// publicmethod.Result(0, sendList, c)
|
|
}
|
|
|