mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-07 00:52:57 +08:00
审批
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request/index'
|
||||||
|
|
||||||
// 流程历史列表
|
// 流程历史列表
|
||||||
export function flow_history_list(params?: Record<string, any>) {
|
export function flow_history_list(params?: Record<string, any>) {
|
||||||
@@ -30,6 +30,11 @@ export function flow_history_delete(params: Record<string, any>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取下一个审批节点,中间可能有系统任务和结束节点被跳过
|
// 获取下一个审批节点,中间可能有系统任务和结束节点被跳过
|
||||||
export function flow_apply_next_node(params: Record<string, any>) {
|
export function flow_history_next_node(params: Record<string, any>) {
|
||||||
return request.post({ url: '/flow_apply/next_node', params })
|
return request.post({ url: '/flow_history/next_node', params })
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取下一个审批节点,中间可能有系统任务和结束节点被跳过
|
||||||
|
export function flow_history_get_approver(params: Record<string, any>) {
|
||||||
|
return request.post({ url: '/flow_history/get_approver', params })
|
||||||
}
|
}
|
||||||
|
@@ -216,9 +216,12 @@ export default {
|
|||||||
const newNode = {
|
const newNode = {
|
||||||
id: node.id,
|
id: node.id,
|
||||||
pid: pid,
|
pid: pid,
|
||||||
|
label: node?.text?.value,
|
||||||
type: node.type,
|
type: node.type,
|
||||||
fieldAuth: node?.properties?.fieldAuth,
|
fieldAuth: node?.properties?.fieldAuth,
|
||||||
user: node?.properties?.user || 0
|
userId: node?.properties?.userId || 0,
|
||||||
|
deptId: node?.properties?.deptId || 0,
|
||||||
|
postId: node?.properties?.postId || 0
|
||||||
}
|
}
|
||||||
if (sourceNodeIdSum[node.id]) {
|
if (sourceNodeIdSum[node.id]) {
|
||||||
newNode.children = handel(sourceNodeIdSum[node.id], node.id)
|
newNode.children = handel(sourceNodeIdSum[node.id], node.id)
|
||||||
|
@@ -9,9 +9,9 @@
|
|||||||
审批节点
|
审批节点
|
||||||
<div>设置审批人(具体人员,部门(负责人),岗位?)</div>
|
<div>设置审批人(具体人员,部门(负责人),岗位?)</div>
|
||||||
<!-- {{ adminUserList }} -->
|
<!-- {{ adminUserList }} -->
|
||||||
<el-form>
|
<el-form label-width="80px">
|
||||||
<el-form-item label="审批人">
|
<el-form-item label="审批人">
|
||||||
<el-select v-model="properties.user" placeholder="请选择审批人">
|
<el-select v-model="properties.userId" placeholder="请选择审批人">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in adminUserList"
|
v-for="item in adminUserList"
|
||||||
:key="item.value"
|
:key="item.value"
|
||||||
@@ -20,6 +20,27 @@
|
|||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="审批部门">
|
||||||
|
<el-select v-model="properties.deptId" placeholder="请选择审批部门">
|
||||||
|
<el-option
|
||||||
|
v-for="item in deptList"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="岗位">
|
||||||
|
<el-select v-model="properties.postId" placeholder="请选择岗位">
|
||||||
|
<el-option
|
||||||
|
v-for="item in postList"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -33,13 +54,33 @@
|
|||||||
<div v-if="node.type == 'bpmn:exclusiveGateway'">
|
<div v-if="node.type == 'bpmn:exclusiveGateway'">
|
||||||
<div>网关,只能有一个网关通过</div>
|
<div>网关,只能有一个网关通过</div>
|
||||||
<div>从form取值判断</div>
|
<div>从form取值判断</div>
|
||||||
|
<el-table fit size="small" :data="fieldList" style="width: 100%">
|
||||||
|
<el-table-column prop="label" label="表单"></el-table-column>
|
||||||
|
<el-table-column label="权限">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-select v-model="row.condition" placeholder="请选择审批人">
|
||||||
|
<el-option
|
||||||
|
v-for="item in conditionList"
|
||||||
|
:key="item.value"
|
||||||
|
:label="item.label"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="值">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-input v-model="row.conditionValue" placeholder="请输入"></el-input>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="node.type == 'bpmn:endEvent'">结束</div>
|
<div v-if="node.type == 'bpmn:endEvent'">结束</div>
|
||||||
|
|
||||||
<!-- 网关和结束节点不需要表单权限设置 -->
|
<!-- 网关和结束节点不需要表单权限设置 -->
|
||||||
<el-table
|
<el-table
|
||||||
v-if="['bpmn:startEvent', 'bpmn:userTask', 'bpmn:serviceTask'].includes(node.type)"
|
v-if="['bpmn:startEvent', 'bpmn:userTask'].includes(node.type)"
|
||||||
fit
|
fit
|
||||||
size="small"
|
size="small"
|
||||||
:data="fieldList"
|
:data="fieldList"
|
||||||
@@ -66,6 +107,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { adminLists } from '@/api/perms/admin'
|
import { adminLists } from '@/api/perms/admin'
|
||||||
|
import { deptLists } from '@/api/org/department'
|
||||||
|
import { postAll } from '@/api/org/post'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'PropertyPanel',
|
name: 'PropertyPanel',
|
||||||
@@ -74,10 +117,15 @@ export default {
|
|||||||
return {
|
return {
|
||||||
drawerVisible: false,
|
drawerVisible: false,
|
||||||
adminUserList: [],
|
adminUserList: [],
|
||||||
|
deptList: [],
|
||||||
|
postList: [],
|
||||||
|
|
||||||
node: {},
|
node: {},
|
||||||
properties: {
|
properties: {
|
||||||
user: '', //审批人id
|
userId: '', //审批人id
|
||||||
|
deptId: '', //审批部门id
|
||||||
|
postId: '', //岗位id
|
||||||
|
|
||||||
fieldAuth: {} // 字段权限
|
fieldAuth: {} // 字段权限
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -88,7 +136,21 @@ export default {
|
|||||||
* auth: 1,
|
* auth: 1,
|
||||||
* }]
|
* }]
|
||||||
*/
|
*/
|
||||||
fieldList: []
|
fieldList: [],
|
||||||
|
conditionList: [
|
||||||
|
{
|
||||||
|
value: 1,
|
||||||
|
label: '等于'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 2,
|
||||||
|
label: '大于等于'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 3,
|
||||||
|
label: '小于等于'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -96,8 +158,11 @@ export default {
|
|||||||
open(node, fieldList) {
|
open(node, fieldList) {
|
||||||
this.node = node
|
this.node = node
|
||||||
|
|
||||||
this.properties.user = node?.properties?.user || ''
|
this.properties.userId = node?.properties?.userId || ''
|
||||||
|
this.properties.deptId = node?.properties?.deptId || ''
|
||||||
|
this.properties.postId = node?.properties?.postId || ''
|
||||||
this.properties.fieldAuth = node?.properties?.fieldAuth || {}
|
this.properties.fieldAuth = node?.properties?.fieldAuth || {}
|
||||||
|
|
||||||
this.fieldList = fieldList.map((item) => {
|
this.fieldList = fieldList.map((item) => {
|
||||||
let auth = 1
|
let auth = 1
|
||||||
const formId = item?.field?.id
|
const formId = item?.field?.id
|
||||||
@@ -111,6 +176,8 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.getAdminList()
|
this.getAdminList()
|
||||||
|
this.getDeptList()
|
||||||
|
this.getPostList()
|
||||||
this.drawerVisible = true
|
this.drawerVisible = true
|
||||||
},
|
},
|
||||||
close() {
|
close() {
|
||||||
@@ -122,7 +189,9 @@ export default {
|
|||||||
this.setProperties('fieldAuth', {
|
this.setProperties('fieldAuth', {
|
||||||
...fieldAuth
|
...fieldAuth
|
||||||
})
|
})
|
||||||
this.setProperties('user', this.properties.user)
|
this.setProperties('userId', this.properties.userId)
|
||||||
|
this.setProperties('deptId', this.properties.deptId)
|
||||||
|
this.setProperties('postId', this.properties.postId)
|
||||||
},
|
},
|
||||||
getAdminList() {
|
getAdminList() {
|
||||||
adminLists().then((res) => {
|
adminLists().then((res) => {
|
||||||
@@ -135,6 +204,28 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
getDeptList() {
|
||||||
|
deptLists().then((res) => {
|
||||||
|
console.log('res', res)
|
||||||
|
this.deptList = res.map((item) => {
|
||||||
|
return {
|
||||||
|
value: item.id,
|
||||||
|
label: item.name
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getPostList() {
|
||||||
|
postAll().then((res) => {
|
||||||
|
console.log('res', res)
|
||||||
|
this.postList = res.map((item) => {
|
||||||
|
return {
|
||||||
|
value: item.id,
|
||||||
|
label: item.name
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
setProperties(key, val) {
|
setProperties(key, val) {
|
||||||
this.$emit('setProperties', this.node, {
|
this.$emit('setProperties', this.node, {
|
||||||
[key]: val
|
[key]: val
|
||||||
|
@@ -8,12 +8,29 @@
|
|||||||
:destroy-on-close="true"
|
:destroy-on-close="true"
|
||||||
top="1px"
|
top="1px"
|
||||||
>
|
>
|
||||||
|
<div v-for="node of next_nodes" :key="node.id">
|
||||||
|
{{ node.label }}
|
||||||
|
<el-select
|
||||||
|
class="flex-1"
|
||||||
|
v-if="node.type == 'bpmn:userTask'"
|
||||||
|
v-model="node.applyUserId"
|
||||||
|
placeholder="请选择审批人"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="(item, index) in node.approver"
|
||||||
|
:key="index"
|
||||||
|
:label="item.nickname"
|
||||||
|
:value="item.id"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</div>
|
||||||
<el-form ref="formRef" :model="formData" label-width="84px" :rules="formRules">
|
<el-form ref="formRef" :model="formData" label-width="84px" :rules="formRules">
|
||||||
<el-form-item label="审批节点" prop="flowName">
|
<el-form-item label="审批节点" prop="flowName">
|
||||||
<el-input v-model="formData.flowName" placeholder="请输入流程名称" />
|
<el-input v-model="formData.flowName" placeholder="请输入流程名称" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="审批人" prop="applyUserId">
|
<el-form-item label="审批人" prop="applyUserId">
|
||||||
<el-select
|
<!-- <el-select
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
v-model="formData.applyUserId"
|
v-model="formData.applyUserId"
|
||||||
placeholder="请选择审批人"
|
placeholder="请选择审批人"
|
||||||
@@ -26,7 +43,7 @@
|
|||||||
:value="item.id"
|
:value="item.id"
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select> -->
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
@@ -39,7 +56,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { flow_apply_next_node } from '@/api/flow_history'
|
import { flow_history_next_node, flow_history_get_approver } from '@/api/flow_history'
|
||||||
|
|
||||||
const formRef = ref(null)
|
const formRef = ref(null)
|
||||||
|
|
||||||
@@ -64,6 +81,7 @@ const formData = reactive({
|
|||||||
status: 0,
|
status: 0,
|
||||||
formValue: ''
|
formValue: ''
|
||||||
})
|
})
|
||||||
|
const next_nodes = ref([])
|
||||||
const formRules = {
|
const formRules = {
|
||||||
id: [
|
id: [
|
||||||
{
|
{
|
||||||
@@ -77,11 +95,21 @@ function open(row) {
|
|||||||
console.log('open')
|
console.log('open')
|
||||||
formData.value = row
|
formData.value = row
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
flow_apply_next_node({
|
flow_history_next_node({
|
||||||
id: row.id,
|
applyId: row.id,
|
||||||
historyId: ''
|
nodeId: ''
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
console.log('res', res)
|
console.log('res', res)
|
||||||
|
next_nodes.value = res
|
||||||
|
|
||||||
|
res.map((item) => {
|
||||||
|
if (item.type == 'bpmn:userTask') {
|
||||||
|
flow_history_get_approver(item).then((approver) => {
|
||||||
|
console.log('approver', approver)
|
||||||
|
item.approver = approver
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
function closeFn() {
|
function closeFn() {
|
||||||
|
@@ -69,7 +69,7 @@ type FlowApplyResp struct {
|
|||||||
FlowRemark string `json:"flowRemark" structs:"flowRemark"` // 流程描述
|
FlowRemark string `json:"flowRemark" structs:"flowRemark"` // 流程描述
|
||||||
FlowFormData string `json:"flowFormData" structs:"flowFormData"` // 表单配置
|
FlowFormData string `json:"flowFormData" structs:"flowFormData"` // 表单配置
|
||||||
FlowProcessData string `json:"flowProcessData" structs:"flowProcessData"` // 流程配置
|
FlowProcessData string `json:"flowProcessData" structs:"flowProcessData"` // 流程配置
|
||||||
FlowProcessDataList string `form:"flowProcessDataList"` // 流程配置list数据
|
FlowProcessDataList string `json:"flowProcessDataList"` // 流程配置list数据
|
||||||
FormValue string `json:"formValue"` // 表单值
|
FormValue string `json:"formValue"` // 表单值
|
||||||
Status int `json:"status" structs:"status"` // 状态:0待提交,1审批中,2审批完成,3审批失败
|
Status int `json:"status" structs:"status"` // 状态:0待提交,1审批中,2审批完成,3审批失败
|
||||||
UpdateTime core.TsTime `json:"updateTime" structs:"updateTime"` // 更新时间
|
UpdateTime core.TsTime `json:"updateTime" structs:"updateTime"` // 更新时间
|
||||||
|
@@ -50,7 +50,8 @@ func (hd FlowHistoryHandler) List(c *gin.Context) {
|
|||||||
// @Success 200 {object} []FlowHistoryResp "成功"
|
// @Success 200 {object} []FlowHistoryResp "成功"
|
||||||
// @Router /api/flow_history/list [get]
|
// @Router /api/flow_history/list [get]
|
||||||
func (hd FlowHistoryHandler) ListAll(c *gin.Context) {
|
func (hd FlowHistoryHandler) ListAll(c *gin.Context) {
|
||||||
res, err := Service.ListAll()
|
var listReq FlowHistoryListReq
|
||||||
|
res, err := Service.ListAll(listReq)
|
||||||
response.CheckAndRespWithData(c, res, err)
|
response.CheckAndRespWithData(c, res, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,8 +164,21 @@ func (hd FlowHistoryHandler) NextNode(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
response.CheckAndResp(c, Service.GetNextNode(nextNode))
|
// response.CheckAndResp(c, Service.GetNextNode(nextNode))
|
||||||
|
res, err := Service.GetNextNode(nextNode)
|
||||||
|
response.CheckAndRespWithData(c, res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取节点的可审批用户
|
||||||
|
func (hd FlowHistoryHandler) GetApprover(c *gin.Context) {
|
||||||
|
var node FlowTree
|
||||||
|
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &node)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// response.CheckAndResp(c, Service.GetNextNode(node))
|
||||||
|
res, err := Service.GetApprover(node)
|
||||||
|
response.CheckAndRespWithData(c, res, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 同意审批(当前nodeId)
|
// 同意审批(当前nodeId)
|
||||||
|
@@ -73,16 +73,21 @@ type FlowHistoryResp struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type NextNodeReq struct {
|
type NextNodeReq struct {
|
||||||
ApplyId int `form:"applyId"` // 申请id
|
ApplyId int `form:"applyId"` // 申请id
|
||||||
NodeId string `form:"nodeId"` // 流程里的节点id
|
CurrentNodeId string `form:"nodeId"` // 流程里的节点id
|
||||||
|
FormValue string `form:"formValue"`
|
||||||
}
|
}
|
||||||
type FlowTree struct {
|
type FlowTree struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Pid string `json:"pid"`
|
Pid string `json:"pid"`
|
||||||
Type string `json:"type"`
|
Label string `json:"label"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
|
||||||
User string `json:"user"`
|
UserId int `json:"userId"`
|
||||||
// FieldAuth map[string]int `json:"fieldAuth"`
|
DeptId int `json:"deptId"`
|
||||||
|
PostId int `json:"postId"`
|
||||||
|
|
||||||
Children *FlowTree
|
FieldAuth map[string]int `json:"fieldAuth"`
|
||||||
|
|
||||||
|
Children *[]FlowTree `json:"children"`
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,15 @@
|
|||||||
package flow_history
|
package flow_history
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"x_admin/admin/flow_apply"
|
||||||
|
"x_admin/admin/system/admin"
|
||||||
"x_admin/core"
|
"x_admin/core"
|
||||||
"x_admin/core/request"
|
"x_admin/core/request"
|
||||||
"x_admin/core/response"
|
"x_admin/core/response"
|
||||||
"x_admin/model"
|
"x_admin/model"
|
||||||
|
"x_admin/model/system_model"
|
||||||
|
"x_admin/util"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
@@ -24,7 +29,7 @@ type IFlowHistoryService interface {
|
|||||||
var Service = NewFlowHistoryService()
|
var Service = NewFlowHistoryService()
|
||||||
|
|
||||||
// NewFlowHistoryService 初始化
|
// NewFlowHistoryService 初始化
|
||||||
func NewFlowHistoryService() IFlowHistoryService {
|
func NewFlowHistoryService() *flowHistoryService {
|
||||||
db := core.GetDB()
|
db := core.GetDB()
|
||||||
return &flowHistoryService{db: db}
|
return &flowHistoryService{db: db}
|
||||||
}
|
}
|
||||||
@@ -94,10 +99,16 @@ func (Service flowHistoryService) List(page request.PageReq, listReq FlowHistory
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ListAll 流程历史列表
|
// ListAll 流程历史列表
|
||||||
func (Service flowHistoryService) ListAll() (res []FlowHistoryResp, e error) {
|
func (Service flowHistoryService) ListAll(listReq FlowHistoryListReq) (res []FlowHistoryResp, e error) {
|
||||||
var objs model.FlowHistory
|
|
||||||
|
|
||||||
err := Service.db.Find(&objs).Error
|
// 查询
|
||||||
|
dbModel := Service.db.Model(&model.FlowHistory{})
|
||||||
|
if listReq.ApplyId > 0 {
|
||||||
|
dbModel = dbModel.Where("apply_id = ?", listReq.ApplyId)
|
||||||
|
}
|
||||||
|
// 数据
|
||||||
|
var objs []model.FlowHistory
|
||||||
|
err := dbModel.Find(&objs).Error
|
||||||
if e = response.CheckErr(err, "ListAll Find err"); e != nil {
|
if e = response.CheckErr(err, "ListAll Find err"); e != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -164,9 +175,105 @@ func (Service flowHistoryService) Del(id int) (e error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取下一个流程
|
* 获取节点的审批用户
|
||||||
*/
|
*/
|
||||||
func (Service flowHistoryService) GetNextNode(nextNode NextNodeReq) (e error) {
|
func (Service flowHistoryService) GetApprover(node FlowTree) (res []admin.SystemAuthAdminResp, e error) {
|
||||||
//
|
var userId = node.UserId
|
||||||
return e
|
var deptId = node.DeptId
|
||||||
|
var postId = node.PostId
|
||||||
|
adminTbName := core.DBTableName(&system_model.SystemAuthAdmin{})
|
||||||
|
|
||||||
|
adminModel := Service.db.Table(adminTbName+" AS admin").Where("admin.is_delete = ?", 0)
|
||||||
|
if userId > 0 {
|
||||||
|
adminModel.Or("admin.id =?", userId)
|
||||||
|
}
|
||||||
|
if deptId > 0 {
|
||||||
|
adminModel.Or("admin.dept_id =?", deptId)
|
||||||
|
}
|
||||||
|
if postId > 0 {
|
||||||
|
adminModel.Or("admin.post_id =?", postId)
|
||||||
|
}
|
||||||
|
// 数据
|
||||||
|
var adminResp []admin.SystemAuthAdminResp
|
||||||
|
err := adminModel.Find(&adminResp).Error
|
||||||
|
if e = response.CheckErr(err, "获取审批用户失败"); e != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for i := 0; i < len(adminResp); i++ {
|
||||||
|
adminResp[i].Avatar = util.UrlUtil.ToAbsoluteUrl(adminResp[i].Avatar)
|
||||||
|
if adminResp[i].ID == 1 {
|
||||||
|
adminResp[i].Role = "系统管理员"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return adminResp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取下一批流程,直到审批或结束节点
|
||||||
|
*/
|
||||||
|
func (Service flowHistoryService) GetNextNode(nextNode NextNodeReq) (res []FlowTree, e error) {
|
||||||
|
var applyDetail, err = flow_apply.Service.Detail(nextNode.ApplyId)
|
||||||
|
if e = response.CheckErr(err, "获取审批申请失败"); e != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// start
|
||||||
|
var flowTree []FlowTree
|
||||||
|
json.Unmarshal([]byte(applyDetail.FlowProcessDataList), &flowTree)
|
||||||
|
var formValue map[string]interface{}
|
||||||
|
json.Unmarshal([]byte(nextNode.FormValue), &formValue)
|
||||||
|
|
||||||
|
var next []FlowTree
|
||||||
|
|
||||||
|
if nextNode.CurrentNodeId == "" {
|
||||||
|
for _, v := range flowTree {
|
||||||
|
if v.Type == "bpmn:startEvent" {
|
||||||
|
next = *v.Children
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for _, v := range flowTree {
|
||||||
|
if v.Id == nextNode.CurrentNodeId {
|
||||||
|
next = *v.Children
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var nextNodes []FlowTree
|
||||||
|
res = DeepNextNode(nextNodes, &next, formValue)
|
||||||
|
return res, e
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回节点数组,最后一个节点为用户或结束节点
|
||||||
|
func DeepNextNode(nextNodes []FlowTree, flowTree *[]FlowTree, formValue map[string]interface{}) []FlowTree {
|
||||||
|
for _, v := range *flowTree {
|
||||||
|
if v.Type == "bpmn:startEvent" {
|
||||||
|
// 开始节点
|
||||||
|
child := DeepNextNode(nextNodes, v.Children, formValue)
|
||||||
|
nextNodes = append(nextNodes, child...)
|
||||||
|
break
|
||||||
|
} else if v.Type == "bpmn:exclusiveGateway" {
|
||||||
|
// 网关
|
||||||
|
|
||||||
|
// 判断formValue值,决定是不是递归这个网关
|
||||||
|
child := DeepNextNode(nextNodes, v.Children, formValue)
|
||||||
|
nextNodes = append(nextNodes, v)
|
||||||
|
nextNodes = append(nextNodes, child...)
|
||||||
|
break
|
||||||
|
} else if v.Type == "bpmn:serviceTask" {
|
||||||
|
// 系统服务
|
||||||
|
child := DeepNextNode(nextNodes, v.Children, formValue)
|
||||||
|
nextNodes = append(nextNodes, v)
|
||||||
|
nextNodes = append(nextNodes, child...)
|
||||||
|
} else if v.Type == "bpmn:userTask" {
|
||||||
|
//用户节点
|
||||||
|
nextNodes = append(nextNodes, v)
|
||||||
|
break
|
||||||
|
} else if v.Type == "bpmn:endEvent" {
|
||||||
|
// 结束节点
|
||||||
|
nextNodes = append(nextNodes, v)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nextNodes
|
||||||
}
|
}
|
||||||
|
@@ -39,4 +39,5 @@ func FlowHistoryRoute(rg *gin.RouterGroup) {
|
|||||||
rg.POST("/flow_history/del", handle.Del)
|
rg.POST("/flow_history/del", handle.Del)
|
||||||
|
|
||||||
rg.POST("/flow_history/next_node", handle.NextNode)
|
rg.POST("/flow_history/next_node", handle.NextNode)
|
||||||
|
rg.POST("/flow_history/get_approver", handle.GetApprover)
|
||||||
}
|
}
|
||||||
|
@@ -93,6 +93,35 @@ func (adminSrv systemAuthAdminService) Self(adminId uint) (res SystemAuthAdminSe
|
|||||||
return SystemAuthAdminSelfResp{User: admin, Permissions: auths}, nil
|
return SystemAuthAdminSelfResp{User: admin, Permissions: auths}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取管理员列表-用户id加部门岗位
|
||||||
|
func (adminSrv systemAuthAdminService) ListByUserIdOrDeptIdPostId(userId, deptId, postId int) (res []SystemAuthAdminResp, e error) {
|
||||||
|
adminTbName := core.DBTableName(&system_model.SystemAuthAdmin{})
|
||||||
|
|
||||||
|
adminModel := adminSrv.db.Table(adminTbName+" AS admin").Where("admin.is_delete = ?", 0)
|
||||||
|
if userId > 0 {
|
||||||
|
adminModel.Or("admin.id =?", userId)
|
||||||
|
}
|
||||||
|
if deptId > 0 {
|
||||||
|
adminModel.Or("admin.dept_id =?", deptId)
|
||||||
|
}
|
||||||
|
if postId > 0 {
|
||||||
|
adminModel.Or("admin.post_id =?", postId)
|
||||||
|
}
|
||||||
|
// 数据
|
||||||
|
var adminResp []SystemAuthAdminResp
|
||||||
|
err := adminModel.Find(&adminResp).Error
|
||||||
|
if e = response.CheckErr(err, "List Find err"); e != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for i := 0; i < len(adminResp); i++ {
|
||||||
|
adminResp[i].Avatar = util.UrlUtil.ToAbsoluteUrl(adminResp[i].Avatar)
|
||||||
|
if adminResp[i].ID == 1 {
|
||||||
|
adminResp[i].Role = "系统管理员"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return adminResp, nil
|
||||||
|
}
|
||||||
|
|
||||||
// List 管理员列表
|
// List 管理员列表
|
||||||
func (adminSrv systemAuthAdminService) List(page request.PageReq, listReq SystemAuthAdminListReq) (res response.PageResp, e error) {
|
func (adminSrv systemAuthAdminService) List(page request.PageReq, listReq SystemAuthAdminListReq) (res response.PageResp, e error) {
|
||||||
// 分页信息
|
// 分页信息
|
||||||
|
@@ -77,7 +77,7 @@ func (service {{{ toCamelCase .EntityName }}}Service) List(page request.PageReq,
|
|||||||
}
|
}
|
||||||
//ListAll {{{ .FunctionName }}}列表
|
//ListAll {{{ .FunctionName }}}列表
|
||||||
func (service {{{ toCamelCase .EntityName }}}Service) ListAll() (res []{{{ title (toCamelCase .EntityName) }}}Resp, e error) {
|
func (service {{{ toCamelCase .EntityName }}}Service) ListAll() (res []{{{ title (toCamelCase .EntityName) }}}Resp, e error) {
|
||||||
var objs model.{{{ title (toCamelCase .EntityName) }}}
|
var objs []model.{{{ title (toCamelCase .EntityName) }}}
|
||||||
|
|
||||||
err := service.db.Find(&objs).Error
|
err := service.db.Find(&objs).Error
|
||||||
if e = response.CheckErr(err, "ListAll Find err"); e != nil {
|
if e = response.CheckErr(err, "ListAll Find err"); e != nil {
|
||||||
|
Reference in New Issue
Block a user