Browse Source
Merge branch 'gva_workflow' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow
main
Merge branch 'gva_workflow' of https://github.com/flipped-aurora/gin-vue-admin into gva_workflow
main
QM303176530
4 years ago
23 changed files with 138 additions and 217 deletions
-
32.docker-compose/shell/server-handle.sh
-
3README.md
-
18dockerfile_server
-
29server/Dockerfile
-
4server/Makefile
-
38server/api/v1/sys_work_flow.go
-
2server/cmd/datas/apis.go
-
6server/cmd/datas/casbins.go
-
4server/cmd/datas/init.go
-
2server/core/server.go
-
2server/go.mod
-
8server/initialize/gorm.go
-
1server/initialize/router.go
-
0server/middleware/casbin_rbac.go
-
25server/model/sys_workflow.go
-
14server/model/sys_workflow_process.go
-
57server/model/wf_process.go
-
14server/router/sys_workflow.go
-
17server/service/sys_workflow.go
-
2web/src/api/user.js
-
72web/src/components/gva-wfd/behavior/deleteItem.js
-
2web/src/main.js
-
3web/src/view/workflow/workflowCreate/workflowCreate.vue
@ -1,19 +1,20 @@ |
|||
FROM golang:alpine as builder |
|||
FROM golang:alpine |
|||
|
|||
# 设置go mod proxy 国内代理 |
|||
# 设置golang path |
|||
ENV GOPROXY=https://goproxy.cn,https://goproxy.io,direct \ |
|||
GO111MODULE=on \ |
|||
CGO_ENABLED=1 |
|||
WORKDIR /ginvue |
|||
RUN go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct |
|||
ENV GO111MODULE=on |
|||
ENV GOPROXY=https://goproxy.io,direct |
|||
|
|||
WORKDIR /go/src/gin-vue-admin |
|||
COPY . . |
|||
RUN go env && go list && go build -o app main.go |
|||
RUN go env && go build -o server . |
|||
|
|||
FROM alpine:latest |
|||
LABEL MAINTAINER="SliverHorn@sliver_horn@qq.com" |
|||
|
|||
WORKDIR /go/src/gin-vue-admin |
|||
COPY --from=0 /go/src/gin-vue-admin/server ./ |
|||
COPY --from=0 /go/src/gin-vue-admin/config.yaml ./ |
|||
COPY --from=0 /go/src/gin-vue-admin/resource ./resource |
|||
|
|||
EXPOSE 8888 |
|||
ENTRYPOINT /ginvue/app |
|||
|
|||
# 根据Dockerfile生成Docker镜像 |
|||
# docker build -t ginvue . |
|||
# 根据Docker镜像启动Docker容器 |
|||
# docker run -itd -p 8888:8888 --name ginvue ginvue |
|||
ENTRYPOINT ./server |
@ -1,38 +0,0 @@ |
|||
package v1 |
|||
|
|||
import ( |
|||
"fmt" |
|||
"gin-vue-admin/global/response" |
|||
"gin-vue-admin/model" |
|||
"gin-vue-admin/service" |
|||
"gin-vue-admin/utils" |
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
// @Tags workflow
|
|||
// @Summary 注册工作流
|
|||
// @Produce application/json
|
|||
// @Param data body model.SysWorkflow true "注册工作流接口"
|
|||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"注册成功"}"
|
|||
// @Router /workflow/createWorkFlow [post]
|
|||
func CreateWorkFlow(c *gin.Context) { |
|||
var wk model.SysWorkflow |
|||
_ = c.ShouldBindJSON(&wk) |
|||
WKVerify := utils.Rules{ |
|||
"WorkflowNickName": {utils.NotEmpty()}, |
|||
"WorkflowName": {utils.NotEmpty()}, |
|||
"WorkflowDescription": {utils.NotEmpty()}, |
|||
"WorkflowStepInfo": {utils.NotEmpty()}, |
|||
} |
|||
WKVerifyErr := utils.Verify(wk, WKVerify) |
|||
if WKVerifyErr != nil { |
|||
response.FailWithMessage(WKVerifyErr.Error(), c) |
|||
return |
|||
} |
|||
err := service.Create(wk) |
|||
if err != nil { |
|||
response.FailWithMessage(fmt.Sprintf("获取失败:%v", err), c) |
|||
} else { |
|||
response.OkWithMessage("获取成功", c) |
|||
} |
|||
} |
@ -1,25 +0,0 @@ |
|||
package model |
|||
|
|||
import ( |
|||
"gorm.io/gorm" |
|||
) |
|||
|
|||
// 工作流属性表
|
|||
type SysWorkflow struct { |
|||
gorm.Model |
|||
WorkflowNickName string `json:"workflowNickName" gorm:"comment:工作流中文名称"` // 工作流名称
|
|||
WorkflowName string `json:"workflowName" gorm:"comment:工作流英文名称"` // 工作流英文id
|
|||
WorkflowDescription string `json:"workflowDescription" gorm:"comment:工作流描述"` // 工作流描述
|
|||
WorkflowStepInfo []SysWorkflowStepInfo `json:"workflowStep" gorm:"comment:工作流步骤"` // 工作流步骤
|
|||
} |
|||
|
|||
// 工作流状态表
|
|||
type SysWorkflowStepInfo struct { |
|||
gorm.Model |
|||
SysWorkflowID uint `json:"workflowID" gorm:"comment:所属工作流ID"` // 所属工作流ID
|
|||
IsStart bool `json:"isStart" gorm:"comment:是否是开始流节点"` // 是否是开始流节点
|
|||
StepName string `json:"stepName" gorm:"comment:工作流节点名称"` // 工作流名称
|
|||
StepNo float64 `json:"stepNo" gorm:"comment:步骤id (第几步)"` // 步骤id (第几步)
|
|||
StepAuthorityID string `json:"stepAuthorityID" gorm:"comment:操作者级别id"` // 操作者级别id
|
|||
IsEnd bool `json:"isEnd" gorm:"comment:是否是完结流节点"` // 是否是完结流节点
|
|||
} |
@ -1,14 +0,0 @@ |
|||
package model |
|||
|
|||
import "gorm.io/gorm" |
|||
|
|||
// 工作流流转表
|
|||
type SysWorkFlowProcess struct { |
|||
gorm.Model |
|||
ApplicationID uint `json:"applicationID" gorm:"comment:当前工作流所属申请的ID"` // 当前工作流所属申请的ID
|
|||
CurrentNode string `json:"currentNode" gorm:"comment:当前进度节点"` // 当前进度节点
|
|||
HistoricalNode string `json:"historicalNode" gorm:"comment:上一个进度节点"` // 上一个进度节点
|
|||
CurrentUser string `json:"currentUser" gorm:"comment:当前进度操作人"` // 当前进度操作人
|
|||
HistoricalUser string `json:"historicalUser" gorm:"comment:上一个进度的操作人"` // 上一个进度的操作人
|
|||
State bool `json:"state" gorm:"comment:是否是正在进行的状态"` // 状态 是否是正在进行的状态
|
|||
} |
@ -0,0 +1,57 @@ |
|||
package model |
|||
|
|||
type WorkflowProcess struct { |
|||
ID string `json:"id" gorm:"comment:流程标识;primaryKey"` |
|||
Name string `json:"name" gorm:"comment:流程名称"` |
|||
Category string `json:"category" gorm:"comment:分类"` |
|||
Clazz string `json:"clazz" gorm:"comment:类型"` |
|||
Label string `json:"label" gorm:"comment:流程标题"` |
|||
HideIcon bool `json:"hideIcon" gorm:"comment:是否隐藏图标"` |
|||
Nodes []WorkflowNode `json:"nodes"` // 流程节点数据
|
|||
Edges []WorkflowEdge `json:"edges"` // 流程链接数据
|
|||
} |
|||
|
|||
type WorkflowNode struct { |
|||
ID string `json:"id" gorm:"comment:节点id;primaryKey"` |
|||
WorkflowProcessID string `json:"-" gorm:"comment:流程标识"` |
|||
Clazz string `json:"clazz" gorm:"comment:节点类型"` |
|||
Label string `json:"label" gorm:"comment:节点名称"` |
|||
Type string `json:"type" gorm:"comment:图标类型"` |
|||
Shape string `json:"shape" gorm:"comment:形状"` |
|||
X float64 `json:"y" gorm:"comment:x位置"` |
|||
Y float64 `json:"x" gorm:"comment:y位置"` |
|||
WaitState string `json:"waitState" gorm:"comment:等待属性"` |
|||
StateValue string `json:"stateValue" gorm:"comment:等待值"` |
|||
To string `json:"to" gorm:"comment:收件人"` |
|||
Subject string `json:"subject" gorm:"comment:标题"` |
|||
Content string `json:"content" gorm:"comment:内容"` |
|||
Cycle string `json:"cycle" gorm:"comment:循环时间"` |
|||
Duration string `json:"duration" gorm:"comment:持续时间"` |
|||
HideIcon bool `json:"hideIcon" gorm:"comment:是否隐藏图标"` |
|||
} |
|||
|
|||
type WorkflowEdge struct { |
|||
ID string `json:"id" gorm:"comment:唯一标识;primaryKey"` |
|||
WorkflowProcessID string `json:"-" gorm:"comment:流程标识"` |
|||
Clazz string `json:"clazz" gorm:"comment:类型(线)"` |
|||
Source string `json:"source" gorm:"comment:起点节点"` |
|||
Target string `json:"target" gorm:"comment:目标节点"` |
|||
SourceAnchor int `json:"sourceAnchor" gorm:"comment:起点"` |
|||
TargetAnchor int `json:"targetAnchor" gorm:"comment:目标点"` |
|||
Shape string `json:"shape" gorm:"comment:形状"` |
|||
StartPoint WorkflowPoint `json:"startPoint"` // 起点信息
|
|||
EndPoint WorkflowPoint `json:"endPoint"` // 终点信息
|
|||
Label string `json:"label" gorm:"comment:标题"` |
|||
HideIcon bool `json:"hideIcon" gorm:"comment:隐藏图标"` |
|||
ConditionExpression string `json:"conditionExpression" gorm:"comment:条件标识"` |
|||
Seq string `json:"seq" gorm:"comment:序号"` |
|||
Reverse bool `json:"reverse" gorm:"comment:是否反向"` |
|||
} |
|||
|
|||
type WorkflowPoint struct { |
|||
ID string `json:"-" gorm:"comment:唯一标识;primaryKey"` |
|||
WorkflowEdgeID string `json:"-"` |
|||
X float64 `json:"x"` |
|||
Y float64 `json:"y"` |
|||
Index int `json:"index"` |
|||
} |
@ -1,14 +0,0 @@ |
|||
package router |
|||
|
|||
import ( |
|||
"gin-vue-admin/api/v1" |
|||
"gin-vue-admin/middleware" |
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
func InitWorkflowRouter(Router *gin.RouterGroup) { |
|||
WorkflowRouter := Router.Group("workflow").Use(middleware.JWTAuth()).Use(middleware.CasbinHandler()) |
|||
{ |
|||
WorkflowRouter.POST("createWorkFlow", v1.CreateWorkFlow) // 创建工作流
|
|||
} |
|||
} |
@ -1,17 +0,0 @@ |
|||
package service |
|||
|
|||
import ( |
|||
"gin-vue-admin/global" |
|||
"gin-vue-admin/model" |
|||
) |
|||
|
|||
// @title Create
|
|||
// @description create a workflow, 创建工作流
|
|||
// @auth (2020/04/05 20:22)
|
|||
// @param wk model.SysWorkflow
|
|||
// @return error
|
|||
|
|||
func Create(wk model.SysWorkflow) error { |
|||
err := global.GVA_DB.Create(&wk).Error |
|||
return err |
|||
} |
@ -1,31 +1,45 @@ |
|||
/* eslint-disable */ |
|||
export default function(G6){ |
|||
G6.registerBehavior('deleteItem', { |
|||
getEvents() { |
|||
return { |
|||
'keydown': 'onKeydown', |
|||
'canvas:mouseleave': 'onCanvasLeave', |
|||
'canvas:mouseenter': 'onCanvasFocus', |
|||
} |
|||
}, |
|||
onKeydown(e){ |
|||
const items = this.graph.get('selectedItems'); |
|||
const focus = this.graph.get('focusGraphWrapper'); |
|||
if(e.keyCode === 8 && items && items.length > 0 && focus){ |
|||
if(this.graph.executeCommand) { |
|||
this.graph.executeCommand('delete', {}); |
|||
}else{ |
|||
this.graph.remove(items[0]); |
|||
export default function(G6) { |
|||
G6.registerBehavior('deleteItem', { |
|||
getEvents() { |
|||
return { |
|||
'keydown': 'onKeydown', |
|||
'canvas:mouseleave': 'onCanvasLeave', |
|||
'canvas:mouseenter': 'onCanvasFocus', |
|||
} |
|||
}, |
|||
onKeydown(e) { |
|||
const items = this.graph.get('selectedItems'); |
|||
const focus = this.graph.get('focusGraphWrapper'); |
|||
if (e.keyCode === 46 && items && items.length > 0 && focus) { |
|||
if (this.graph.executeCommand) { |
|||
this.graph.executeCommand('delete', {}); |
|||
} else { |
|||
this.graph.remove(items[0]); |
|||
} |
|||
this.graph.set('selectedItems', []); |
|||
this.graph.emit('afteritemselected', []); |
|||
} |
|||
if (e.ctrlKey == true && e.keyCode == 90) { //Ctrl+z
|
|||
e.returnvalue = false; |
|||
if (this.graph.executeCommand) { |
|||
this.graph.executeCommand('undo', {}); |
|||
} |
|||
} |
|||
if (e.ctrlKey == true && e.keyCode == 89) { //Ctrl+y
|
|||
e.returnvalue = false; |
|||
if (this.graph.executeCommand) { |
|||
this.graph.executeCommand('redo', {}); |
|||
} |
|||
|
|||
} |
|||
|
|||
}, |
|||
onCanvasLeave(e) { |
|||
this.graph.set('focusGraphWrapper', false); |
|||
}, |
|||
onCanvasFocus() { |
|||
this.graph.set('focusGraphWrapper', true); |
|||
} |
|||
this.graph.set('selectedItems',[]); |
|||
this.graph.emit('afteritemselected',[]); |
|||
} |
|||
}, |
|||
onCanvasLeave(e){ |
|||
this.graph.set('focusGraphWrapper',false); |
|||
}, |
|||
onCanvasFocus(){ |
|||
this.graph.set('focusGraphWrapper',true); |
|||
} |
|||
}); |
|||
} |
|||
}); |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue