mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-10-18 14:10:52 +08:00
审批流优化
This commit is contained in:
@@ -28,3 +28,8 @@ export function flow_history_edit(params: Record<string, any>) {
|
||||
export function flow_history_delete(params: Record<string, any>) {
|
||||
return request.post({ url: '/flow_history/del', params })
|
||||
}
|
||||
|
||||
// 获取下一个审批节点,中间可能有系统任务和结束节点被跳过
|
||||
export function flow_apply_next_node(params: Record<string, any>) {
|
||||
return request.post({ url: '/flow_apply/next_node', params })
|
||||
}
|
||||
|
@@ -172,7 +172,7 @@ export default {
|
||||
basicSetting: res[0].formData,
|
||||
flowFormData: res[1].formData,
|
||||
flowProcessData: res[2].formData,
|
||||
flowProcessTreeData: res[2].TreeNode
|
||||
flowProcessDataList: res[2].treeToList
|
||||
|
||||
// advancedSetting: getCmpData("advancedSetting"),
|
||||
}
|
||||
|
@@ -19,8 +19,8 @@
|
||||
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="dialogVisible = false">Cancel</el-button>
|
||||
<el-button type="primary" @click="getData"> Confirm </el-button>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="getData"> 确定 </el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
@@ -228,9 +228,23 @@ export default {
|
||||
return newArr
|
||||
}
|
||||
const TreeNode = handel(findStartNode, 0)
|
||||
|
||||
// tree转list
|
||||
function treeToList(tree) {
|
||||
const arr = []
|
||||
tree.forEach((item) => {
|
||||
arr.push(item)
|
||||
if (item.children) {
|
||||
arr.push(...treeToList(item.children))
|
||||
}
|
||||
})
|
||||
return arr
|
||||
}
|
||||
|
||||
console.log('TreeNode', TreeNode)
|
||||
console.log('treeToList', treeToList(TreeNode))
|
||||
// 检查连线方向是否正确;
|
||||
resolve({ formData: data, TreeNode })
|
||||
resolve({ formData: data, treeToList: treeToList(TreeNode) })
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -105,7 +105,6 @@ import {
|
||||
watch,
|
||||
nextTick,
|
||||
toRefs,
|
||||
watchEffect,
|
||||
getCurrentInstance
|
||||
} from 'vue'
|
||||
// "captchaType":"blockPuzzle",
|
||||
|
113
admin/src/views/flow_apply/components/apply_submit.vue
Normal file
113
admin/src/views/flow_apply/components/apply_submit.vue
Normal file
@@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:show-close="false"
|
||||
:fullscreen="false"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
:destroy-on-close="true"
|
||||
top="1px"
|
||||
>
|
||||
<el-form ref="formRef" :model="formData" label-width="84px" :rules="formRules">
|
||||
<el-form-item label="审批节点" prop="flowName">
|
||||
<el-input v-model="formData.flowName" placeholder="请输入流程名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="审批人" prop="applyUserId">
|
||||
<el-select
|
||||
class="flex-1"
|
||||
v-model="formData.applyUserId"
|
||||
placeholder="请选择审批人"
|
||||
@change="handleTemplateChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="(item, index) in flow_template"
|
||||
:key="index"
|
||||
:label="item.flowName"
|
||||
:value="item.id"
|
||||
clearable
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="getData"> 确定 </el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { flow_apply_next_node } from '@/api/flow_history'
|
||||
|
||||
const formRef = ref(null)
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
|
||||
const props = defineProps({
|
||||
save: {
|
||||
type: Function,
|
||||
default: () => {}
|
||||
}
|
||||
})
|
||||
const formData = reactive({
|
||||
id: '',
|
||||
templateId: '',
|
||||
// applyUserId: '',
|
||||
// applyUserNickname: '',
|
||||
flowName: '',
|
||||
flowGroup: '',
|
||||
flowRemark: '',
|
||||
flowFormData: '',
|
||||
flowProcessData: '',
|
||||
status: 0,
|
||||
formValue: ''
|
||||
})
|
||||
const formRules = {
|
||||
id: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入',
|
||||
trigger: ['blur']
|
||||
}
|
||||
]
|
||||
}
|
||||
function open(row) {
|
||||
console.log('open')
|
||||
formData.value = row
|
||||
dialogVisible.value = true
|
||||
flow_apply_next_node({
|
||||
id: row.id,
|
||||
historyId: ''
|
||||
}).then((res) => {
|
||||
console.log('res', res)
|
||||
})
|
||||
}
|
||||
function closeFn() {
|
||||
dialogVisible.value = false
|
||||
|
||||
formData.value = {}
|
||||
}
|
||||
function getData() {
|
||||
formRef.value.getFormData().then((formData) => {
|
||||
console.log('formData', formData)
|
||||
props
|
||||
.save(formData)
|
||||
.then(() => {
|
||||
closeFn()
|
||||
})
|
||||
.catch(() => {})
|
||||
})
|
||||
}
|
||||
defineExpose({
|
||||
getData,
|
||||
open
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
// body {
|
||||
// margin: 0; /* 如果页面出现垂直滚动条,则加入此行CSS以消除之 */
|
||||
// }
|
||||
</style>
|
@@ -184,7 +184,7 @@ const formRules = {
|
||||
status: [
|
||||
{
|
||||
required: true,
|
||||
message: '请选择状态:0待提交,1审批中,2审批完成,3审批失败',
|
||||
message: '请选择状态',
|
||||
trigger: ['blur']
|
||||
}
|
||||
]
|
||||
|
@@ -62,7 +62,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="更新时间" prop="updateTime" min-width="100" />
|
||||
<el-table-column label="创建时间" prop="createTime" min-width="100" />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<el-table-column label="操作" width="260" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-perms="['flow_apply:edit']"
|
||||
@@ -72,6 +72,15 @@
|
||||
>
|
||||
编辑表单
|
||||
</el-button>
|
||||
<el-button
|
||||
v-perms="['flow_apply:edit']"
|
||||
type="primary"
|
||||
link
|
||||
@click="OpenApplySubmit(row)"
|
||||
>
|
||||
提交申请
|
||||
</el-button>
|
||||
|
||||
<el-button
|
||||
v-perms="['flow_apply:edit']"
|
||||
type="primary"
|
||||
@@ -103,6 +112,7 @@
|
||||
@close="showEdit = false"
|
||||
/>
|
||||
<ViewForm ref="viewFormRef" :save="SaveViewForm"></ViewForm>
|
||||
<ApplySubmit ref="ApplySubmitRef"></ApplySubmit>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
@@ -112,12 +122,14 @@ import { usePaging } from '@/hooks/usePaging'
|
||||
import feedback from '@/utils/feedback'
|
||||
import EditPopup from './edit.vue'
|
||||
|
||||
import ApplySubmit from '@/views/flow_apply/components/apply_submit.vue'
|
||||
import ViewForm from '@/components/flow/XForm/view.vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'flow_apply'
|
||||
})
|
||||
const viewFormRef = shallowRef<InstanceType<typeof EditPopup>>()
|
||||
const viewFormRef = shallowRef<InstanceType<typeof ViewForm>>()
|
||||
const ApplySubmitRef = shallowRef<InstanceType<typeof ApplySubmit>>()
|
||||
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
||||
const showEdit = ref(false)
|
||||
const queryParams = reactive({
|
||||
@@ -164,15 +176,24 @@ const OpenViewForm = async (data: any) => {
|
||||
let form_data = {}
|
||||
try {
|
||||
form_data = JSON.parse(data.formValue)
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
// 解析失败
|
||||
}
|
||||
let form_json = {}
|
||||
try {
|
||||
form_json = JSON.parse(data.flowFormData)
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
// 解析失败
|
||||
}
|
||||
console.log(data, form_data, form_json)
|
||||
|
||||
viewFormRef.value?.open(data.id, form_json, form_data)
|
||||
}
|
||||
const OpenApplySubmit = async (data: any) => {
|
||||
console.log('OpenApplySubmit')
|
||||
|
||||
ApplySubmitRef.value?.open(data)
|
||||
}
|
||||
const SaveViewForm = (id, form_data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
flow_apply_edit({
|
||||
|
@@ -132,7 +132,8 @@ function save(info) {
|
||||
flowGroup: info.basicSetting.flowGroup,
|
||||
flowRemark: info.basicSetting.flowRemark,
|
||||
flowFormData: JSON.stringify(info.flowFormData),
|
||||
flowProcessData: JSON.stringify(info.flowProcessData)
|
||||
flowProcessData: JSON.stringify(info.flowProcessData),
|
||||
flowProcessDataList: JSON.stringify(info.flowProcessDataList)
|
||||
})
|
||||
.then(() => {
|
||||
feedback.msgSuccess('修改成功')
|
||||
|
@@ -9,27 +9,25 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type FlowApplyHandler struct {
|
||||
Service IFlowApplyService
|
||||
}
|
||||
type FlowApplyHandler struct{}
|
||||
|
||||
// @Summary 申请流程列表
|
||||
// @Tags flow_apply-申请流程
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param PageNo query int true "页码"
|
||||
// @Param PageSize query int true "每页数量"
|
||||
// @Param templateId query int false "模板"
|
||||
// @Param applyUserId query int false "申请人id"
|
||||
// @Param applyUserNickname query string false "申请人昵称"
|
||||
// @Param flowName query string false "流程名称"
|
||||
// @Param flowGroup query int false "流程分类"
|
||||
// @Param flowRemark query string false "流程描述"
|
||||
// @Param flowFormData query string false "表单配置"
|
||||
// @Param flowProcessData query string false "流程配置"
|
||||
// @Param status query int false "状态:0待提交,1审批中,2审批完成,3审批失败"
|
||||
// @Success 200 {object} []FlowApplyResp "成功"
|
||||
// @Failure 400 {object} string "请求错误"
|
||||
// @Param Token header string true "token"
|
||||
// @Param PageNo query int true "页码"
|
||||
// @Param PageSize query int true "每页数量"
|
||||
// @Param templateId query int false "模板"
|
||||
// @Param applyUserId query int false "申请人id"
|
||||
// @Param applyUserNickname query string false "申请人昵称"
|
||||
// @Param flowName query string false "流程名称"
|
||||
// @Param flowGroup query int false "流程分类"
|
||||
// @Param flowRemark query string false "流程描述"
|
||||
// @Param flowFormData query string false "表单配置"
|
||||
// @Param flowProcessData query string false "流程配置"
|
||||
// @Param status query int false "状态:0待提交,1审批中,2审批完成,3审批失败"
|
||||
// @Success 200 {object} []FlowApplyResp "成功"
|
||||
// @Failure 400 {object} string "请求错误"
|
||||
// @Router /api/flow_apply/list [get]
|
||||
func (hd FlowApplyHandler) List(c *gin.Context) {
|
||||
var page request.PageReq
|
||||
@@ -40,40 +38,40 @@ func (hd FlowApplyHandler) List(c *gin.Context) {
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
|
||||
return
|
||||
}
|
||||
res, err := hd.Service.List(page, listReq)
|
||||
res, err := Service.List(page, listReq)
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
// @Summary 申请流程详情
|
||||
// @Tags flow_apply-申请流程
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param Token header string true "token"
|
||||
// @Param id query int false ""
|
||||
// @Success 200 {object} FlowApplyResp "成功"
|
||||
// @Success 200 {object} FlowApplyResp "成功"
|
||||
// @Router /api/flow_apply/detail [get]
|
||||
func (hd FlowApplyHandler) Detail(c *gin.Context) {
|
||||
var detailReq FlowApplyDetailReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &detailReq)) {
|
||||
return
|
||||
}
|
||||
res, err := hd.Service.Detail(detailReq.Id)
|
||||
res, err := Service.Detail(detailReq.Id)
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
// @Summary 申请流程新增
|
||||
// @Tags flow_apply-申请流程
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param templateId body int false "模板"
|
||||
// @Param applyUserId body int false "申请人id"
|
||||
// @Param applyUserNickname body string false "申请人昵称"
|
||||
// @Param flowName body string false "流程名称"
|
||||
// @Param flowGroup body int false "流程分类"
|
||||
// @Param flowRemark body string false "流程描述"
|
||||
// @Param Token header string true "token"
|
||||
// @Param templateId body int false "模板"
|
||||
// @Param applyUserId body int false "申请人id"
|
||||
// @Param applyUserNickname body string false "申请人昵称"
|
||||
// @Param flowName body string false "流程名称"
|
||||
// @Param flowGroup body int false "流程分类"
|
||||
// @Param flowRemark body string false "流程描述"
|
||||
// @Param flowFormData body string false "表单配置"
|
||||
// @Param flowProcessData body string false "流程配置"
|
||||
// @Param status body int false "状态:0待提交,1审批中,2审批完成,3审批失败"
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Param status body int false "状态:0待提交,1审批中,2审批完成,3审批失败"
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Router /api/flow_apply/add [post]
|
||||
func (hd FlowApplyHandler) Add(c *gin.Context) {
|
||||
var addReq FlowApplyAddReq
|
||||
@@ -86,44 +84,44 @@ func (hd FlowApplyHandler) Add(c *gin.Context) {
|
||||
addReq.ApplyUserNickname = Nickname
|
||||
addReq.ApplyUserId = int(AdminId)
|
||||
|
||||
response.CheckAndResp(c, hd.Service.Add(addReq))
|
||||
response.CheckAndResp(c, Service.Add(addReq))
|
||||
}
|
||||
|
||||
// @Summary 申请流程编辑
|
||||
// @Tags flow_apply-申请流程
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param id body int false ""
|
||||
// @Param templateId body int false "模板"
|
||||
// @Param applyUserId body int false "申请人id"
|
||||
// @Param applyUserNickname body string false "申请人昵称"
|
||||
// @Param flowName body string false "流程名称"
|
||||
// @Param flowGroup body int false "流程分类"
|
||||
// @Param flowRemark body string false "流程描述"
|
||||
// @Param Token header string true "token"
|
||||
// @Param id body int false ""
|
||||
// @Param templateId body int false "模板"
|
||||
// @Param applyUserId body int false "申请人id"
|
||||
// @Param applyUserNickname body string false "申请人昵称"
|
||||
// @Param flowName body string false "流程名称"
|
||||
// @Param flowGroup body int false "流程分类"
|
||||
// @Param flowRemark body string false "流程描述"
|
||||
// @Param flowFormData body string false "表单配置"
|
||||
// @Param flowProcessData body string false "流程配置"
|
||||
// @Param status body int false "状态:0待提交,1审批中,2审批完成,3审批失败"
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Param status body int false "状态:0待提交,1审批中,2审批完成,3审批失败"
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Router /api/flow_apply/edit [post]
|
||||
func (hd FlowApplyHandler) Edit(c *gin.Context) {
|
||||
var editReq FlowApplyEditReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &editReq)) {
|
||||
return
|
||||
}
|
||||
response.CheckAndResp(c, hd.Service.Edit(editReq))
|
||||
response.CheckAndResp(c, Service.Edit(editReq))
|
||||
}
|
||||
|
||||
// @Summary 申请流程删除
|
||||
// @Tags flow_apply-申请流程
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param id body int false ""
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Param Token header string true "token"
|
||||
// @Param id body int false ""
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Router /api/flow_apply/del [post]
|
||||
func (hd FlowApplyHandler) Del(c *gin.Context) {
|
||||
var delReq FlowApplyDelReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &delReq)) {
|
||||
return
|
||||
}
|
||||
response.CheckAndResp(c, hd.Service.Del(delReq.Id))
|
||||
response.CheckAndResp(c, Service.Del(delReq.Id))
|
||||
}
|
||||
|
@@ -4,16 +4,17 @@ import "x_admin/core"
|
||||
|
||||
//FlowApplyListReq 申请流程列表参数
|
||||
type FlowApplyListReq struct {
|
||||
TemplateId int `form:"templateId"` // 模板
|
||||
ApplyUserId int `form:"applyUserId"` // 申请人id
|
||||
ApplyUserNickname string `form:"applyUserNickname"` // 申请人昵称
|
||||
FlowName string `form:"flowName"` // 流程名称
|
||||
FlowGroup int `form:"flowGroup"` // 流程分类
|
||||
FlowRemark string `form:"flowRemark"` // 流程描述
|
||||
FlowFormData string `form:"flowFormData"` // 表单配置
|
||||
FlowProcessData string `form:"flowProcessData"` // 流程配置
|
||||
FormValue string `form:"formValue"` // 表单值
|
||||
Status int `form:"status"` // 状态:0待提交,1审批中,2审批完成,3审批失败
|
||||
TemplateId int `form:"templateId"` // 模板
|
||||
ApplyUserId int `form:"applyUserId"` // 申请人id
|
||||
ApplyUserNickname string `form:"applyUserNickname"` // 申请人昵称
|
||||
FlowName string `form:"flowName"` // 流程名称
|
||||
FlowGroup int `form:"flowGroup"` // 流程分类
|
||||
FlowRemark string `form:"flowRemark"` // 流程描述
|
||||
FlowFormData string `form:"flowFormData"` // 表单配置
|
||||
FlowProcessData string `form:"flowProcessData"` // 流程配置
|
||||
FlowProcessDataList string `form:"flowProcessDataList"` // 流程配置list数据
|
||||
FormValue string `form:"formValue"` // 表单值
|
||||
Status int `form:"status"` // 状态:0待提交,1审批中,2审批完成,3审批失败
|
||||
}
|
||||
|
||||
//FlowApplyDetailReq 申请流程详情参数
|
||||
@@ -26,28 +27,30 @@ type FlowApplyAddReq struct {
|
||||
TemplateId int `form:"templateId"` // 模板
|
||||
ApplyUserId int `form:"applyUserId"` // 申请人id
|
||||
ApplyUserNickname string `form:"applyUserNickname"` // 申请人昵称
|
||||
FlowName string `form:"flowName"` // 流程名称
|
||||
FlowGroup int `form:"flowGroup"` // 流程分类
|
||||
FlowRemark string `form:"flowRemark"` // 流程描述
|
||||
FlowFormData string `form:"flowFormData"` // 表单配置
|
||||
FlowProcessData string `form:"flowProcessData"` // 流程配置
|
||||
FormValue string `form:"formValue"` // 表单值
|
||||
Status int `form:"status"` // 状态:0待提交,1审批中,2审批完成,3审批失败
|
||||
// FlowName string `form:"flowName"` // 流程名称
|
||||
// FlowGroup int `form:"flowGroup"` // 流程分类
|
||||
// FlowRemark string `form:"flowRemark"` // 流程描述
|
||||
// FlowFormData string `form:"flowFormData"` // 表单配置
|
||||
// FlowProcessData string `form:"flowProcessData"` // 流程配置
|
||||
// FlowProcessDataList string `form:"flowProcessDataList"` // 流程配置list数据
|
||||
FormValue string `form:"formValue"` // 表单值
|
||||
Status int `form:"status"` // 状态:0待提交,1审批中,2审批完成,3审批失败
|
||||
}
|
||||
|
||||
//FlowApplyEditReq 申请流程新增参数
|
||||
type FlowApplyEditReq struct {
|
||||
Id int `form:"id"` //
|
||||
TemplateId int `form:"templateId"` // 模板
|
||||
ApplyUserId int `form:"applyUserId"` // 申请人id
|
||||
ApplyUserNickname string `form:"applyUserNickname"` // 申请人昵称
|
||||
FlowName string `form:"flowName"` // 流程名称
|
||||
FlowGroup int `form:"flowGroup"` // 流程分类
|
||||
FlowRemark string `form:"flowRemark"` // 流程描述
|
||||
FlowFormData string `form:"flowFormData"` // 表单配置
|
||||
FlowProcessData string `form:"flowProcessData"` // 流程配置
|
||||
FormValue string `form:"formValue"` // 表单值
|
||||
Status int `form:"status"` // 状态:0待提交,1审批中,2审批完成,3审批失败
|
||||
Id int `form:"id"` //
|
||||
// TemplateId int `form:"templateId"` // 模板
|
||||
// ApplyUserId int `form:"applyUserId"` // 申请人id
|
||||
// ApplyUserNickname string `form:"applyUserNickname"` // 申请人昵称
|
||||
// FlowName string `form:"flowName"` // 流程名称
|
||||
// FlowGroup int `form:"flowGroup"` // 流程分类
|
||||
// FlowRemark string `form:"flowRemark"` // 流程描述
|
||||
// FlowFormData string `form:"flowFormData"` // 表单配置
|
||||
// FlowProcessData string `form:"flowProcessData"` // 流程配置
|
||||
// FlowProcessDataList string `form:"flowProcessDataList"` // 流程配置list数据
|
||||
FormValue string `form:"formValue"` // 表单值
|
||||
Status int `form:"status"` // 状态:0待提交,1审批中,2审批完成,3审批失败
|
||||
}
|
||||
|
||||
//FlowApplyDelReq 申请流程新增参数
|
||||
@@ -57,17 +60,18 @@ type FlowApplyDelReq struct {
|
||||
|
||||
//FlowApplyResp 申请流程返回信息
|
||||
type FlowApplyResp struct {
|
||||
Id int `json:"id" structs:"id"` //
|
||||
TemplateId int `json:"templateId" structs:"templateId"` // 模板
|
||||
ApplyUserId int `json:"applyUserId" structs:"applyUserId"` // 申请人id
|
||||
ApplyUserNickname string `json:"applyUserNickname" structs:"applyUserNickname"` // 申请人昵称
|
||||
FlowName string `json:"flowName" structs:"flowName"` // 流程名称
|
||||
FlowGroup int `json:"flowGroup" structs:"flowGroup"` // 流程分类
|
||||
FlowRemark string `json:"flowRemark" structs:"flowRemark"` // 流程描述
|
||||
FlowFormData string `json:"flowFormData" structs:"flowFormData"` // 表单配置
|
||||
FlowProcessData string `json:"flowProcessData" structs:"flowProcessData"` // 流程配置
|
||||
FormValue string `json:"formValue"` // 表单值
|
||||
Status int `json:"status" structs:"status"` // 状态:0待提交,1审批中,2审批完成,3审批失败
|
||||
UpdateTime core.TsTime `json:"updateTime" structs:"updateTime"` // 更新时间
|
||||
CreateTime core.TsTime `json:"createTime" structs:"createTime"` // 创建时间
|
||||
Id int `json:"id" structs:"id"` //
|
||||
TemplateId int `json:"templateId" structs:"templateId"` // 模板
|
||||
ApplyUserId int `json:"applyUserId" structs:"applyUserId"` // 申请人id
|
||||
ApplyUserNickname string `json:"applyUserNickname" structs:"applyUserNickname"` // 申请人昵称
|
||||
FlowName string `json:"flowName" structs:"flowName"` // 流程名称
|
||||
FlowGroup int `json:"flowGroup" structs:"flowGroup"` // 流程分类
|
||||
FlowRemark string `json:"flowRemark" structs:"flowRemark"` // 流程描述
|
||||
FlowFormData string `json:"flowFormData" structs:"flowFormData"` // 表单配置
|
||||
FlowProcessData string `json:"flowProcessData" structs:"flowProcessData"` // 流程配置
|
||||
FlowProcessDataList string `form:"flowProcessDataList"` // 流程配置list数据
|
||||
FormValue string `json:"formValue"` // 表单值
|
||||
Status int `json:"status" structs:"status"` // 状态:0待提交,1审批中,2审批完成,3审批失败
|
||||
UpdateTime core.TsTime `json:"updateTime" structs:"updateTime"` // 更新时间
|
||||
CreateTime core.TsTime `json:"createTime" structs:"createTime"` // 创建时间
|
||||
}
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package flow_apply
|
||||
|
||||
import (
|
||||
"x_admin/admin/flow_template"
|
||||
"x_admin/core"
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model"
|
||||
@@ -16,8 +18,11 @@ type IFlowApplyService interface {
|
||||
Del(id int) (e error)
|
||||
}
|
||||
|
||||
var Service = NewFlowApplyService()
|
||||
|
||||
// NewFlowApplyService 初始化
|
||||
func NewFlowApplyService(db *gorm.DB) IFlowApplyService {
|
||||
func NewFlowApplyService() *flowApplyService {
|
||||
db := core.GetDB()
|
||||
return &flowApplyService{db: db}
|
||||
}
|
||||
|
||||
@@ -99,10 +104,20 @@ func (Service flowApplyService) Detail(id int) (res FlowApplyResp, e error) {
|
||||
// Add 申请流程新增
|
||||
func (Service flowApplyService) Add(addReq FlowApplyAddReq) (e error) {
|
||||
var obj model.FlowApply
|
||||
|
||||
var flow_template_resp, err = flow_template.Service.Detail(addReq.TemplateId)
|
||||
if e = response.CheckErrDBNotRecord(err, "模板不存在!"); e != nil {
|
||||
return
|
||||
}
|
||||
response.Copy(&obj, addReq)
|
||||
err := Service.db.Create(&obj).Error
|
||||
e = response.CheckErr(err, "Add Create err")
|
||||
obj.FlowName = flow_template_resp.FlowName
|
||||
obj.FlowGroup = flow_template_resp.FlowGroup
|
||||
obj.FlowRemark = flow_template_resp.FlowRemark
|
||||
obj.FlowFormData = flow_template_resp.FlowFormData
|
||||
obj.FlowProcessData = flow_template_resp.FlowProcessData
|
||||
obj.FlowProcessDataList = flow_template_resp.FlowProcessDataList
|
||||
|
||||
err = Service.db.Create(&obj).Error
|
||||
e = response.CheckErr(err, "添加失败")
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"x_admin/core"
|
||||
"x_admin/middleware"
|
||||
"x_admin/admin/flow_apply"
|
||||
"x_admin/middleware"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -24,14 +24,10 @@ flow_apply:list
|
||||
flow_apply:detail
|
||||
*/
|
||||
|
||||
|
||||
// FlowApplyRoute(rg)
|
||||
func FlowApplyRoute(rg *gin.RouterGroup) {
|
||||
db := core.GetDB()
|
||||
|
||||
server := flow_apply.NewFlowApplyService(db)
|
||||
|
||||
handle := flow_apply.FlowApplyHandler{Service: server}
|
||||
handle := flow_apply.FlowApplyHandler{}
|
||||
|
||||
rg = rg.Group("/", middleware.TokenAuth())
|
||||
rg.GET("/flow_apply/list", handle.List)
|
||||
@@ -39,4 +35,5 @@ func FlowApplyRoute(rg *gin.RouterGroup) {
|
||||
rg.POST("/flow_apply/add", handle.Add)
|
||||
rg.POST("/flow_apply/edit", handle.Edit)
|
||||
rg.POST("/flow_apply/del", handle.Del)
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -15,21 +15,21 @@ type FlowHistoryHandler struct {
|
||||
// @Summary 流程历史列表
|
||||
// @Tags flow_history-流程历史
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param PageNo query int true "页码"
|
||||
// @Param PageSize query int true "每页数量"
|
||||
// @Param applyId query int false "申请id"
|
||||
// @Param templateId query int false "模板id"
|
||||
// @Param applyUserId query int false "申请人id"
|
||||
// @Param applyUserNickname query string false "申请人昵称"
|
||||
// @Param approverId query int false "审批人id"
|
||||
// @Param approverNickname query string false "审批用户昵称"
|
||||
// @Param nodeId query string false "节点"
|
||||
// @Param formValue query string false "表单值"
|
||||
// @Param passStatus query int false "通过状态:0待处理,1通过,2拒绝"
|
||||
// @Param passRemark query string false "通过备注"
|
||||
// @Success 200 {object} []FlowHistoryResp "成功"
|
||||
// @Failure 400 {object} string "请求错误"
|
||||
// @Param Token header string true "token"
|
||||
// @Param PageNo query int true "页码"
|
||||
// @Param PageSize query int true "每页数量"
|
||||
// @Param applyId query int false "申请id"
|
||||
// @Param templateId query int false "模板id"
|
||||
// @Param applyUserId query int false "申请人id"
|
||||
// @Param applyUserNickname query string false "申请人昵称"
|
||||
// @Param approverId query int false "审批人id"
|
||||
// @Param approverNickname query string false "审批用户昵称"
|
||||
// @Param nodeId query string false "节点"
|
||||
// @Param formValue query string false "表单值"
|
||||
// @Param passStatus query int false "通过状态:0待处理,1通过,2拒绝"
|
||||
// @Param passRemark query string false "通过备注"
|
||||
// @Success 200 {object} []FlowHistoryResp "成功"
|
||||
// @Failure 400 {object} string "请求错误"
|
||||
// @Router /api/flow_history/list [get]
|
||||
func (hd FlowHistoryHandler) List(c *gin.Context) {
|
||||
var page request.PageReq
|
||||
@@ -40,114 +40,132 @@ func (hd FlowHistoryHandler) List(c *gin.Context) {
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
|
||||
return
|
||||
}
|
||||
res, err := hd.Service.List(page, listReq)
|
||||
res, err := Service.List(page, listReq)
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
// @Summary 流程历史列表-所有
|
||||
// @Tags flow_history-流程历史
|
||||
// @Produce json
|
||||
// @Success 200 {object} []FlowHistoryResp "成功"
|
||||
// @Router /api/flow_history/list [get]
|
||||
// @Summary 流程历史列表-所有
|
||||
// @Tags flow_history-流程历史
|
||||
// @Produce json
|
||||
// @Success 200 {object} []FlowHistoryResp "成功"
|
||||
// @Router /api/flow_history/list [get]
|
||||
func (hd FlowHistoryHandler) ListAll(c *gin.Context) {
|
||||
res, err := hd.Service.ListAll()
|
||||
res, err := Service.ListAll()
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
// @Summary 流程历史详情
|
||||
// @Tags flow_history-流程历史
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param Token header string true "token"
|
||||
// @Param id query int false "历史id"
|
||||
// @Success 200 {object} FlowHistoryResp "成功"
|
||||
// @Success 200 {object} FlowHistoryResp "成功"
|
||||
// @Router /api/flow_history/detail [get]
|
||||
func (hd FlowHistoryHandler) Detail(c *gin.Context) {
|
||||
var detailReq FlowHistoryDetailReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &detailReq)) {
|
||||
return
|
||||
}
|
||||
res, err := hd.Service.Detail(detailReq.Id)
|
||||
res, err := Service.Detail(detailReq.Id)
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
// @Summary 流程历史新增
|
||||
// @Tags flow_history-流程历史
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param applyId body int false "申请id"
|
||||
// @Param templateId body int false "模板id"
|
||||
// @Param applyUserId body int false "申请人id"
|
||||
// @Param applyUserNickname body string false "申请人昵称"
|
||||
// @Param approverId body int false "审批人id"
|
||||
// @Param approverNickname body string false "审批用户昵称"
|
||||
// @Param nodeId body string false "节点"
|
||||
// @Param formValue body string false "表单值"
|
||||
// @Param passStatus body int false "通过状态:0待处理,1通过,2拒绝"
|
||||
// @Param passRemark body string false "通过备注"
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Param Token header string true "token"
|
||||
// @Param applyId body int false "申请id"
|
||||
// @Param templateId body int false "模板id"
|
||||
// @Param applyUserId body int false "申请人id"
|
||||
// @Param applyUserNickname body string false "申请人昵称"
|
||||
// @Param approverId body int false "审批人id"
|
||||
// @Param approverNickname body string false "审批用户昵称"
|
||||
// @Param nodeId body string false "节点"
|
||||
// @Param formValue body string false "表单值"
|
||||
// @Param passStatus body int false "通过状态:0待处理,1通过,2拒绝"
|
||||
// @Param passRemark body string false "通过备注"
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Router /api/flow_history/add [post]
|
||||
func (hd FlowHistoryHandler) Add(c *gin.Context) {
|
||||
var addReq FlowHistoryAddReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &addReq)) {
|
||||
return
|
||||
}
|
||||
response.CheckAndResp(c, hd.Service.Add(addReq))
|
||||
response.CheckAndResp(c, Service.Add(addReq))
|
||||
}
|
||||
|
||||
// @Summary 流程历史编辑
|
||||
// @Tags flow_history-流程历史
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param id body int false "历史id"
|
||||
// @Param applyId body int false "申请id"
|
||||
// @Param templateId body int false "模板id"
|
||||
// @Param applyUserId body int false "申请人id"
|
||||
// @Param applyUserNickname body string false "申请人昵称"
|
||||
// @Param approverId body int false "审批人id"
|
||||
// @Param approverNickname body string false "审批用户昵称"
|
||||
// @Param nodeId body string false "节点"
|
||||
// @Param formValue body string false "表单值"
|
||||
// @Param passStatus body int false "通过状态:0待处理,1通过,2拒绝"
|
||||
// @Param passRemark body string false "通过备注"
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Param Token header string true "token"
|
||||
// @Param id body int false "历史id"
|
||||
// @Param applyId body int false "申请id"
|
||||
// @Param templateId body int false "模板id"
|
||||
// @Param applyUserId body int false "申请人id"
|
||||
// @Param applyUserNickname body string false "申请人昵称"
|
||||
// @Param approverId body int false "审批人id"
|
||||
// @Param approverNickname body string false "审批用户昵称"
|
||||
// @Param nodeId body string false "节点"
|
||||
// @Param formValue body string false "表单值"
|
||||
// @Param passStatus body int false "通过状态:0待处理,1通过,2拒绝"
|
||||
// @Param passRemark body string false "通过备注"
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Router /api/flow_history/edit [post]
|
||||
func (hd FlowHistoryHandler) Edit(c *gin.Context) {
|
||||
var editReq FlowHistoryEditReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &editReq)) {
|
||||
return
|
||||
}
|
||||
response.CheckAndResp(c, hd.Service.Edit(editReq))
|
||||
response.CheckAndResp(c, Service.Edit(editReq))
|
||||
}
|
||||
|
||||
// @Summary 流程历史删除
|
||||
// @Tags flow_history-流程历史
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param id body int false "历史id"
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Param Token header string true "token"
|
||||
// @Param id body int false "历史id"
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Router /api/flow_history/del [post]
|
||||
func (hd FlowHistoryHandler) Del(c *gin.Context) {
|
||||
var delReq FlowHistoryDelReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &delReq)) {
|
||||
return
|
||||
}
|
||||
response.CheckAndResp(c, hd.Service.Del(delReq.Id))
|
||||
}
|
||||
|
||||
type FlowTree struct {
|
||||
Id string `json:"id"`
|
||||
Pid string `json:"pid"`
|
||||
Type string `json:"type"`
|
||||
|
||||
User string `json:"user"`
|
||||
// FieldAuth map[string]int `json:"fieldAuth"`
|
||||
|
||||
Children *FlowTree
|
||||
response.CheckAndResp(c, Service.Del(delReq.Id))
|
||||
}
|
||||
|
||||
// 提交申请
|
||||
//
|
||||
// @Router /api/flow_apply/SubmitApply [post]
|
||||
func (hd FlowHistoryHandler) SubmitApply(c *gin.Context) {
|
||||
// 申请流程id,
|
||||
// var addReq FlowApplyAddReq
|
||||
// if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &addReq)) {
|
||||
// return
|
||||
// }
|
||||
|
||||
// var Nickname = config.AdminConfig.GetNickname(c)
|
||||
// var AdminId = config.AdminConfig.GetAdminId(c)
|
||||
// addReq.ApplyUserNickname = Nickname
|
||||
// addReq.ApplyUserId = int(AdminId)
|
||||
// 解析json
|
||||
// 查找开始节点
|
||||
// 查找开始的下一级节点
|
||||
// 下一个可能是网关,系统任务,用户任务,结束
|
||||
// 网关,系统任务节点处理后继续向下查找节点,网关只能有一个满足条件
|
||||
|
||||
}
|
||||
|
||||
// 获取下一个审批节点,中间可能存在系统任务节点和网关
|
||||
func (hd FlowHistoryHandler) NextNode(c *gin.Context) {
|
||||
var nextNode NextNodeReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &nextNode)) {
|
||||
return
|
||||
}
|
||||
|
||||
response.CheckAndResp(c, Service.GetNextNode(nextNode))
|
||||
|
||||
}
|
||||
|
||||
// 同意审批(当前nodeId)
|
||||
|
||||
|
@@ -71,3 +71,18 @@ type FlowHistoryResp struct {
|
||||
UpdateTime core.TsTime `json:"updateTime" structs:"updateTime"` // 更新时间
|
||||
CreateTime core.TsTime `json:"createTime" structs:"createTime"` // 创建时间
|
||||
}
|
||||
|
||||
type NextNodeReq struct {
|
||||
ApplyId int `form:"applyId"` // 申请id
|
||||
NodeId string `form:"nodeId"` // 流程里的节点id
|
||||
}
|
||||
type FlowTree struct {
|
||||
Id string `json:"id"`
|
||||
Pid string `json:"pid"`
|
||||
Type string `json:"type"`
|
||||
|
||||
User string `json:"user"`
|
||||
// FieldAuth map[string]int `json:"fieldAuth"`
|
||||
|
||||
Children *FlowTree
|
||||
}
|
||||
|
@@ -1,9 +1,11 @@
|
||||
package flow_history
|
||||
|
||||
import (
|
||||
"x_admin/core"
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@@ -15,55 +17,60 @@ type IFlowHistoryService interface {
|
||||
Add(addReq FlowHistoryAddReq) (e error)
|
||||
Edit(editReq FlowHistoryEditReq) (e error)
|
||||
Del(id int) (e error)
|
||||
|
||||
GetNextNode(nextNode NextNodeReq) (e error)
|
||||
}
|
||||
|
||||
//NewFlowHistoryService 初始化
|
||||
func NewFlowHistoryService(db *gorm.DB) IFlowHistoryService {
|
||||
var Service = NewFlowHistoryService()
|
||||
|
||||
// NewFlowHistoryService 初始化
|
||||
func NewFlowHistoryService() IFlowHistoryService {
|
||||
db := core.GetDB()
|
||||
return &flowHistoryService{db: db}
|
||||
}
|
||||
|
||||
//flowHistoryService 流程历史服务实现类
|
||||
// flowHistoryService 流程历史服务实现类
|
||||
type flowHistoryService struct {
|
||||
db *gorm.DB
|
||||
}
|
||||
|
||||
//List 流程历史列表
|
||||
// List 流程历史列表
|
||||
func (Service flowHistoryService) List(page request.PageReq, listReq FlowHistoryListReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
// 查询
|
||||
dbModel := Service.db.Model(&model.FlowHistory{})
|
||||
if listReq.ApplyId > 0 {
|
||||
dbModel = dbModel.Where("apply_id = ?", listReq.ApplyId)
|
||||
}
|
||||
if listReq.TemplateId > 0 {
|
||||
dbModel = dbModel.Where("template_id = ?", listReq.TemplateId)
|
||||
}
|
||||
if listReq.ApplyUserId > 0 {
|
||||
dbModel = dbModel.Where("apply_user_id = ?", listReq.ApplyUserId)
|
||||
}
|
||||
if listReq.ApplyId > 0 {
|
||||
dbModel = dbModel.Where("apply_id = ?", listReq.ApplyId)
|
||||
}
|
||||
if listReq.TemplateId > 0 {
|
||||
dbModel = dbModel.Where("template_id = ?", listReq.TemplateId)
|
||||
}
|
||||
if listReq.ApplyUserId > 0 {
|
||||
dbModel = dbModel.Where("apply_user_id = ?", listReq.ApplyUserId)
|
||||
}
|
||||
if listReq.ApplyUserNickname != "" {
|
||||
dbModel = dbModel.Where("apply_user_nickname like ?", "%"+listReq.ApplyUserNickname+"%")
|
||||
}
|
||||
if listReq.ApproverId > 0 {
|
||||
dbModel = dbModel.Where("approver_id = ?", listReq.ApproverId)
|
||||
}
|
||||
dbModel = dbModel.Where("apply_user_nickname like ?", "%"+listReq.ApplyUserNickname+"%")
|
||||
}
|
||||
if listReq.ApproverId > 0 {
|
||||
dbModel = dbModel.Where("approver_id = ?", listReq.ApproverId)
|
||||
}
|
||||
if listReq.ApproverNickname != "" {
|
||||
dbModel = dbModel.Where("approver_nickname like ?", "%"+listReq.ApproverNickname+"%")
|
||||
}
|
||||
if listReq.NodeId != "" {
|
||||
dbModel = dbModel.Where("node_id = ?", listReq.NodeId)
|
||||
}
|
||||
if listReq.FormValue != "" {
|
||||
dbModel = dbModel.Where("form_value = ?", listReq.FormValue)
|
||||
}
|
||||
if listReq.PassStatus > 0 {
|
||||
dbModel = dbModel.Where("pass_status = ?", listReq.PassStatus)
|
||||
}
|
||||
if listReq.PassRemark != "" {
|
||||
dbModel = dbModel.Where("pass_remark = ?", listReq.PassRemark)
|
||||
}
|
||||
dbModel = dbModel.Where("approver_nickname like ?", "%"+listReq.ApproverNickname+"%")
|
||||
}
|
||||
if listReq.NodeId != "" {
|
||||
dbModel = dbModel.Where("node_id = ?", listReq.NodeId)
|
||||
}
|
||||
if listReq.FormValue != "" {
|
||||
dbModel = dbModel.Where("form_value = ?", listReq.FormValue)
|
||||
}
|
||||
if listReq.PassStatus > 0 {
|
||||
dbModel = dbModel.Where("pass_status = ?", listReq.PassStatus)
|
||||
}
|
||||
if listReq.PassRemark != "" {
|
||||
dbModel = dbModel.Where("pass_remark = ?", listReq.PassRemark)
|
||||
}
|
||||
// 总数
|
||||
var count int64
|
||||
err := dbModel.Count(&count).Error
|
||||
@@ -85,10 +92,11 @@ func (Service flowHistoryService) List(page request.PageReq, listReq FlowHistory
|
||||
Lists: resps,
|
||||
}, nil
|
||||
}
|
||||
//ListAll 流程历史列表
|
||||
|
||||
// ListAll 流程历史列表
|
||||
func (Service flowHistoryService) ListAll() (res []FlowHistoryResp, e error) {
|
||||
var objs model.FlowHistory
|
||||
|
||||
|
||||
err := Service.db.Find(&objs).Error
|
||||
if e = response.CheckErr(err, "ListAll Find err"); e != nil {
|
||||
return
|
||||
@@ -97,7 +105,7 @@ func (Service flowHistoryService) ListAll() (res []FlowHistoryResp, e error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
//Detail 流程历史详情
|
||||
// Detail 流程历史详情
|
||||
func (Service flowHistoryService) Detail(id int) (res FlowHistoryResp, e error) {
|
||||
var obj model.FlowHistory
|
||||
err := Service.db.Where("id = ?", id).Limit(1).First(&obj).Error
|
||||
@@ -111,7 +119,7 @@ func (Service flowHistoryService) Detail(id int) (res FlowHistoryResp, e error)
|
||||
return
|
||||
}
|
||||
|
||||
//Add 流程历史新增
|
||||
// Add 流程历史新增
|
||||
func (Service flowHistoryService) Add(addReq FlowHistoryAddReq) (e error) {
|
||||
var obj model.FlowHistory
|
||||
response.Copy(&obj, addReq)
|
||||
@@ -120,7 +128,7 @@ func (Service flowHistoryService) Add(addReq FlowHistoryAddReq) (e error) {
|
||||
return
|
||||
}
|
||||
|
||||
//Edit 流程历史编辑
|
||||
// Edit 流程历史编辑
|
||||
func (Service flowHistoryService) Edit(editReq FlowHistoryEditReq) (e error) {
|
||||
var obj model.FlowHistory
|
||||
err := Service.db.Where("id = ?", editReq.Id).Limit(1).First(&obj).Error
|
||||
@@ -138,7 +146,7 @@ func (Service flowHistoryService) Edit(editReq FlowHistoryEditReq) (e error) {
|
||||
return
|
||||
}
|
||||
|
||||
//Del 流程历史删除
|
||||
// Del 流程历史删除
|
||||
func (Service flowHistoryService) Del(id int) (e error) {
|
||||
var obj model.FlowHistory
|
||||
err := Service.db.Where("id = ?", id).Limit(1).First(&obj).Error
|
||||
@@ -149,8 +157,16 @@ func (Service flowHistoryService) Del(id int) (e error) {
|
||||
if e = response.CheckErr(err, "Del First err"); e != nil {
|
||||
return
|
||||
}
|
||||
// 删除
|
||||
err = Service.db.Delete(&obj).Error
|
||||
e = response.CheckErr(err, "Del Delete err")
|
||||
// 删除
|
||||
err = Service.db.Delete(&obj).Error
|
||||
e = response.CheckErr(err, "Del Delete err")
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一个流程
|
||||
*/
|
||||
func (Service flowHistoryService) GetNextNode(nextNode NextNodeReq) (e error) {
|
||||
//
|
||||
return e
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"x_admin/core"
|
||||
"x_admin/middleware"
|
||||
"x_admin/admin/flow_history"
|
||||
"x_admin/middleware"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -25,14 +25,10 @@ flow_history:listAll
|
||||
flow_history:detail
|
||||
*/
|
||||
|
||||
|
||||
// FlowHistoryRoute(rg)
|
||||
func FlowHistoryRoute(rg *gin.RouterGroup) {
|
||||
db := core.GetDB()
|
||||
|
||||
server := flow_history.NewFlowHistoryService(db)
|
||||
|
||||
handle := flow_history.FlowHistoryHandler{Service: server}
|
||||
handle := flow_history.FlowHistoryHandler{}
|
||||
|
||||
rg = rg.Group("/", middleware.TokenAuth())
|
||||
rg.GET("/flow_history/list", handle.List)
|
||||
@@ -41,4 +37,6 @@ func FlowHistoryRoute(rg *gin.RouterGroup) {
|
||||
rg.POST("/flow_history/add", handle.Add)
|
||||
rg.POST("/flow_history/edit", handle.Edit)
|
||||
rg.POST("/flow_history/del", handle.Del)
|
||||
}
|
||||
|
||||
rg.POST("/flow_history/next_node", handle.NextNode)
|
||||
}
|
||||
|
@@ -8,23 +8,21 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type FlowTemplateHandler struct {
|
||||
Service IFlowTemplateService
|
||||
}
|
||||
type FlowTemplateHandler struct{}
|
||||
|
||||
// @Summary 流程模板列表
|
||||
// @Tags flow_template-流程模板
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param PageNo query int true "页码"
|
||||
// @Param PageSize query int true "每页数量"
|
||||
// @Param Token header string true "token"
|
||||
// @Param PageNo query int true "页码"
|
||||
// @Param PageSize query int true "每页数量"
|
||||
// @Param flowName query string false "流程名称"
|
||||
// @Param flowGroup query int false "流程分类"
|
||||
// @Param flowGroup query int false "流程分类"
|
||||
// @Param flowRemark query string false "流程描述"
|
||||
// @Param flowFormData query string false "表单配置"
|
||||
// @Param flowProcessData query string false "流程配置"
|
||||
// @Success 200 {object} []FlowTemplateResp "成功"
|
||||
// @Failure 400 {object} string "请求错误"
|
||||
// @Param flowFormData query string false "表单配置"
|
||||
// @Param flowProcessData query string false "流程配置"
|
||||
// @Success 200 {object} []FlowTemplateResp "成功"
|
||||
// @Failure 400 {object} string "请求错误"
|
||||
// @Router /api/flow_template/list [get]
|
||||
func (hd FlowTemplateHandler) List(c *gin.Context) {
|
||||
var page request.PageReq
|
||||
@@ -35,7 +33,7 @@ func (hd FlowTemplateHandler) List(c *gin.Context) {
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &listReq)) {
|
||||
return
|
||||
}
|
||||
res, err := hd.Service.List(page, listReq)
|
||||
res, err := Service.List(page, listReq)
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
@@ -43,76 +41,76 @@ func (hd FlowTemplateHandler) List(c *gin.Context) {
|
||||
// @Tags flow_template-流程模板
|
||||
// @Router /api/flow_template/listAll [get]
|
||||
func (hd FlowTemplateHandler) ListAll(c *gin.Context) {
|
||||
res, err := hd.Service.ListAll()
|
||||
res, err := Service.ListAll()
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
// @Summary 流程模板详情
|
||||
// @Tags flow_template-流程模板
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param id query int false ""
|
||||
// @Success 200 {object} FlowTemplateResp "成功"
|
||||
// @Param Token header string true "token"
|
||||
// @Param id query int false ""
|
||||
// @Success 200 {object} FlowTemplateResp "成功"
|
||||
// @Router /api/flow_template/detail [get]
|
||||
func (hd FlowTemplateHandler) Detail(c *gin.Context) {
|
||||
var detailReq FlowTemplateDetailReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyQuery(c, &detailReq)) {
|
||||
return
|
||||
}
|
||||
res, err := hd.Service.Detail(detailReq.Id)
|
||||
res, err := Service.Detail(detailReq.Id)
|
||||
response.CheckAndRespWithData(c, res, err)
|
||||
}
|
||||
|
||||
// @Summary 流程模板新增
|
||||
// @Tags flow_template-流程模板
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param Token header string true "token"
|
||||
// @Param flowName body string false "流程名称"
|
||||
// @Param flowGroup body int false "流程分类"
|
||||
// @Param flowGroup body int false "流程分类"
|
||||
// @Param flowRemark body string false "流程描述"
|
||||
// @Param flowFormData body string false "表单配置"
|
||||
// @Param flowProcessData body string false "流程配置"
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Param flowFormData body string false "表单配置"
|
||||
// @Param flowProcessData body string false "流程配置"
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Router /api/flow_template/add [post]
|
||||
func (hd FlowTemplateHandler) Add(c *gin.Context) {
|
||||
var addReq FlowTemplateAddReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &addReq)) {
|
||||
return
|
||||
}
|
||||
response.CheckAndResp(c, hd.Service.Add(addReq))
|
||||
response.CheckAndResp(c, Service.Add(addReq))
|
||||
}
|
||||
|
||||
// @Summary 流程模板编辑
|
||||
// @Tags flow_template-流程模板
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param id body int false ""
|
||||
// @Param Token header string true "token"
|
||||
// @Param id body int false ""
|
||||
// @Param flowName body string false "流程名称"
|
||||
// @Param flowGroup body int false "流程分类"
|
||||
// @Param flowGroup body int false "流程分类"
|
||||
// @Param flowRemark body string false "流程描述"
|
||||
// @Param flowFormData body string false "表单配置"
|
||||
// @Param flowProcessData body string false "流程配置"
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Param flowFormData body string false "表单配置"
|
||||
// @Param flowProcessData body string false "流程配置"
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Router /api/flow_template/edit [post]
|
||||
func (hd FlowTemplateHandler) Edit(c *gin.Context) {
|
||||
var editReq FlowTemplateEditReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &editReq)) {
|
||||
return
|
||||
}
|
||||
response.CheckAndResp(c, hd.Service.Edit(editReq))
|
||||
response.CheckAndResp(c, Service.Edit(editReq))
|
||||
}
|
||||
|
||||
// @Summary 流程模板删除
|
||||
// @Tags flow_template-流程模板
|
||||
// @Produce json
|
||||
// @Param Token header string true "token"
|
||||
// @Param id body int false ""
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Param Token header string true "token"
|
||||
// @Param id body int false ""
|
||||
// @Success 200 {object} response.RespType "成功"
|
||||
// @Router /api/flow_template/del [post]
|
||||
func (hd FlowTemplateHandler) Del(c *gin.Context) {
|
||||
var delReq FlowTemplateDelReq
|
||||
if response.IsFailWithResp(c, util.VerifyUtil.VerifyBody(c, &delReq)) {
|
||||
return
|
||||
}
|
||||
response.CheckAndResp(c, hd.Service.Del(delReq.Id))
|
||||
response.CheckAndResp(c, Service.Del(delReq.Id))
|
||||
}
|
||||
|
@@ -2,11 +2,12 @@ package flow_template
|
||||
|
||||
//FlowTemplateListReq 流程模板列表参数
|
||||
type FlowTemplateListReq struct {
|
||||
FlowName string `form:"flowName"` // 流程名称
|
||||
FlowGroup int `form:"flowGroup"` // 流程分类
|
||||
FlowRemark string `form:"flowRemark"` // 流程描述
|
||||
FlowFormData string `form:"flowFormData"` // 表单配置
|
||||
FlowProcessData string `form:"flowProcessData"` // 流程配置
|
||||
FlowName string `form:"flowName"` // 流程名称
|
||||
FlowGroup int `form:"flowGroup"` // 流程分类
|
||||
FlowRemark string `form:"flowRemark"` // 流程描述
|
||||
FlowFormData string `form:"flowFormData"` // 表单配置
|
||||
FlowProcessData string `form:"flowProcessData"` // 流程配置
|
||||
FlowProcessDataList string `form:"flowProcessDataList"` // 流程配置list数据
|
||||
}
|
||||
|
||||
//FlowTemplateDetailReq 流程模板详情参数
|
||||
@@ -16,22 +17,24 @@ type FlowTemplateDetailReq struct {
|
||||
|
||||
//FlowTemplateAddReq 流程模板新增参数
|
||||
type FlowTemplateAddReq struct {
|
||||
FlowName string `form:"flowName"` // 流程名称
|
||||
FlowGroup int `form:"flowGroup"` // 流程分类
|
||||
FlowRemark string `form:"flowRemark"` // 流程描述
|
||||
FlowFormData string `form:"flowFormData"` // 表单配置
|
||||
FlowProcessData string `form:"flowProcessData"` // 流程配置
|
||||
FlowName string `form:"flowName"` // 流程名称
|
||||
FlowGroup int `form:"flowGroup"` // 流程分类
|
||||
FlowRemark string `form:"flowRemark"` // 流程描述
|
||||
FlowFormData string `form:"flowFormData"` // 表单配置
|
||||
FlowProcessData string `form:"flowProcessData"` // 流程配置
|
||||
FlowProcessDataList string `form:"flowProcessDataList"` // 流程配置list数据
|
||||
|
||||
}
|
||||
|
||||
//FlowTemplateEditReq 流程模板新增参数
|
||||
type FlowTemplateEditReq struct {
|
||||
Id int `form:"id"` //
|
||||
FlowName string `form:"flowName"` // 流程名称
|
||||
FlowGroup int `form:"flowGroup"` // 流程分类
|
||||
FlowRemark string `form:"flowRemark"` // 流程描述
|
||||
FlowFormData string `form:"flowFormData"` // 表单配置
|
||||
FlowProcessData string `form:"flowProcessData"` // 流程配置
|
||||
Id int `form:"id"` //
|
||||
FlowName string `form:"flowName"` // 流程名称
|
||||
FlowGroup int `form:"flowGroup"` // 流程分类
|
||||
FlowRemark string `form:"flowRemark"` // 流程描述
|
||||
FlowFormData string `form:"flowFormData"` // 表单配置
|
||||
FlowProcessData string `form:"flowProcessData"` // 流程配置
|
||||
FlowProcessDataList string `form:"flowProcessDataList"` // 流程配置list数据
|
||||
|
||||
}
|
||||
|
||||
@@ -42,11 +45,11 @@ type FlowTemplateDelReq struct {
|
||||
|
||||
//FlowTemplateResp 流程模板返回信息
|
||||
type FlowTemplateResp struct {
|
||||
Id int `json:"id" structs:"id"` //
|
||||
FlowName string `json:"flowName" structs:"flowName"` // 流程名称
|
||||
FlowGroup int `json:"flowGroup" structs:"flowGroup"` // 流程分类
|
||||
FlowRemark string `json:"flowRemark" structs:"flowRemark"` // 流程描述
|
||||
FlowFormData string `json:"flowFormData" structs:"flowFormData"` // 表单配置
|
||||
FlowProcessData string `json:"flowProcessData" structs:"flowProcessData"` // 流程配置
|
||||
|
||||
Id int `json:"id" structs:"id"` //
|
||||
FlowName string `json:"flowName" structs:"flowName"` // 流程名称
|
||||
FlowGroup int `json:"flowGroup" structs:"flowGroup"` // 流程分类
|
||||
FlowRemark string `json:"flowRemark" structs:"flowRemark"` // 流程描述
|
||||
FlowFormData string `json:"flowFormData" structs:"flowFormData"` // 表单配置
|
||||
FlowProcessData string `json:"flowProcessData" structs:"flowProcessData"` // 流程配置
|
||||
FlowProcessDataList string `form:"flowProcessDataList"` // 流程配置list数据
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package flow_template
|
||||
|
||||
import (
|
||||
"x_admin/core"
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model"
|
||||
@@ -17,8 +18,11 @@ type IFlowTemplateService interface {
|
||||
Del(id int) (e error)
|
||||
}
|
||||
|
||||
var Service = NewFlowTemplateService()
|
||||
|
||||
// NewFlowTemplateService 初始化
|
||||
func NewFlowTemplateService(db *gorm.DB) IFlowTemplateService {
|
||||
func NewFlowTemplateService() *flowTemplateService {
|
||||
db := core.GetDB()
|
||||
return &flowTemplateService{db: db}
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,6 @@ package admin
|
||||
|
||||
import (
|
||||
"x_admin/admin/flow_template"
|
||||
"x_admin/core"
|
||||
"x_admin/middleware"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -28,11 +27,8 @@ flow_template:detail
|
||||
|
||||
// FlowTemplateRoute(rg)
|
||||
func FlowTemplateRoute(rg *gin.RouterGroup) {
|
||||
db := core.GetDB()
|
||||
|
||||
server := flow_template.NewFlowTemplateService(db)
|
||||
|
||||
handle := flow_template.FlowTemplateHandler{Service: server}
|
||||
handle := flow_template.FlowTemplateHandler{}
|
||||
|
||||
rg = rg.Group("/", middleware.TokenAuth())
|
||||
rg.GET("/flow_template/list", handle.List)
|
||||
|
@@ -2,18 +2,19 @@ package model
|
||||
|
||||
//FlowApply 申请流程实体
|
||||
type FlowApply struct {
|
||||
Id int `gorm:"primarykey;comment:''"` //
|
||||
TemplateId int `gorm:"comment:'模板'"` // 模板
|
||||
ApplyUserId int `gorm:"comment:'申请人id'"` // 申请人id
|
||||
ApplyUserNickname string `gorm:"comment:'申请人昵称'"` // 申请人昵称
|
||||
FlowName string `gorm:"comment:'流程名称'"` // 流程名称
|
||||
FlowGroup int `gorm:"comment:'流程分类'"` // 流程分类
|
||||
FlowRemark string `gorm:"comment:'流程描述'"` // 流程描述
|
||||
FlowFormData string `gorm:"comment:'表单配置'"` // 表单配置
|
||||
FlowProcessData string `gorm:"comment:'流程配置'"` // 流程配置
|
||||
FormValue string `gorm:"comment:'表单值'"` // 表单值
|
||||
Status int `gorm:"comment:'状态:0待提交,1审批中,2审批完成,3审批失败'"` // 状态:0待提交,1审批中,2审批完成,3审批失败
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;comment:'更新时间'"` // 更新时间
|
||||
CreateTime int64 `gorm:"autoCreateTime;comment:'创建时间'"` // 创建时间
|
||||
DeleteTime int64 `gorm:"comment:'删除时间'"` // 删除时间
|
||||
Id int `gorm:"primarykey;comment:''"` //
|
||||
TemplateId int `gorm:"comment:'模板'"` // 模板
|
||||
ApplyUserId int `gorm:"comment:'申请人id'"` // 申请人id
|
||||
ApplyUserNickname string `gorm:"comment:'申请人昵称'"` // 申请人昵称
|
||||
FlowName string `gorm:"comment:'流程名称'"` // 流程名称
|
||||
FlowGroup int `gorm:"comment:'流程分类'"` // 流程分类
|
||||
FlowRemark string `gorm:"comment:'流程描述'"` // 流程描述
|
||||
FlowFormData string `gorm:"comment:'表单配置'"` // 表单配置
|
||||
FlowProcessData string `gorm:"comment:'流程配置'"` // 流程配置
|
||||
FlowProcessDataList string `gorm:"comment:'流程配置list数据'"` // 流程配置list数据
|
||||
FormValue string `gorm:"comment:'表单值'"` // 表单值
|
||||
Status int `gorm:"comment:'状态:0待提交,1审批中,2审批完成,3审批失败'"` // 状态:0待提交,1审批中,2审批完成,3审批失败
|
||||
UpdateTime int64 `gorm:"autoUpdateTime;comment:'更新时间'"` // 更新时间
|
||||
CreateTime int64 `gorm:"autoCreateTime;comment:'创建时间'"` // 创建时间
|
||||
DeleteTime int64 `gorm:"comment:'删除时间'"` // 删除时间
|
||||
}
|
||||
|
@@ -2,10 +2,11 @@ package model
|
||||
|
||||
//FlowTemplate 流程模板实体
|
||||
type FlowTemplate struct {
|
||||
Id int `gorm:"primarykey;comment:''"` //
|
||||
FlowName string `gorm:"comment:'流程名称'"` // 流程名称
|
||||
FlowGroup int `gorm:"comment:'流程分类'"` // 流程分类
|
||||
FlowRemark string `gorm:"comment:'流程描述'"` // 流程描述
|
||||
FlowFormData string `gorm:"comment:'表单配置'"` // 表单配置
|
||||
FlowProcessData string `gorm:"comment:'流程配置'"` // 流程配置
|
||||
Id int `gorm:"primarykey;comment:''"` //
|
||||
FlowName string `gorm:"comment:'流程名称'"` // 流程名称
|
||||
FlowGroup int `gorm:"comment:'流程分类'"` // 流程分类
|
||||
FlowRemark string `gorm:"comment:'流程描述'"` // 流程描述
|
||||
FlowFormData string `gorm:"comment:'表单配置'"` // 表单配置
|
||||
FlowProcessData string `gorm:"comment:'流程配置'"` // 流程配置
|
||||
FlowProcessDataList string `gorm:"comment:'流程配置list数据'"` // 流程配置list数据
|
||||
}
|
||||
|
Reference in New Issue
Block a user