Browse Source

工作流增删改查功能完善

main
QM303176530 4 years ago
parent
commit
91fd065869
  1. 49
      server/cmd/datas/init.go
  2. 6
      server/model/wf_process.go
  3. 62
      server/service/wk_process.go
  4. 355
      web/src/view/workflow/workflowCreate/workflowCreate.vue
  5. 176
      web/src/view/workflow/workflowProcess/workflowProcess.vue

49
server/cmd/datas/init.go

@ -56,52 +56,3 @@ func InitMysqlTables(db *gorm.DB) {
}
color.Info.Println("[Mysql]-->初始化数据表成功")
}
func InitPostgresqlData(db *gorm.DB) {
var err error
err = InitSysApi(db)
err = InitSysUser(db)
err = InitExaCustomer(db)
err = InitCasbinModel(db)
err = InitSysAuthority(db)
err = InitSysBaseMenus(db)
err = InitAuthorityMenu(db)
err = InitSysAuthorityMenus(db)
err = InitSysDataAuthorityId(db)
err = InitSysDictionaryDetail(db)
err = InitExaFileUploadAndDownload(db)
err = InitSysDictionaryToPostgresql(db)
if err != nil {
color.Error.Printf("[Postgresql]-->初始化数据失败,err: %v\n", err)
os.Exit(0)
}
color.Info.Println("[Postgresql]-->初始化数据成功")
}
func InitPostgresqlTables(db *gorm.DB) {
var err error
if !db.Migrator().HasTable("casbin_rule") {
err = db.Migrator().CreateTable(&gormadapter.CasbinRule{})
}
err = db.AutoMigrate(
model.SysApi{},
model.SysUser{},
model.ExaFile{},
model.ExaCustomer{},
model.SysBaseMenu{},
model.SysAuthority{},
model.JwtBlacklist{},
model.ExaFileChunk{},
model.ExaSimpleUploader{},
model.SysOperationRecord{},
model.SysDictionaryDetail{},
model.SysBaseMenuParameter{},
model.ExaFileUploadAndDownload{},
SysDictionaryToPostgresql{},
)
if err != nil {
color.Error.Printf("[Postgresql]-->初始化数据表失败,err: %v\n", err)
os.Exit(0)
}
color.Info.Println("[Postgresql]-->初始化数据表成功")
}

6
server/model/wf_process.go

@ -10,7 +10,7 @@ type WorkflowProcess struct {
ID string `json:"id" form:"id" gorm:"comment:流程标识;primaryKey;unique;not null"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
Name string `json:"name" gorm:"comment:流程名称"`
Category string `json:"category" gorm:"comment:分类"`
Clazz string `json:"clazz" gorm:"comment:类型"`
@ -25,7 +25,7 @@ type WorkflowNode struct {
ID string `json:"id" form:"id" gorm:"comment:节点id;primaryKey;unique;not null"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
WorkflowProcessID string `json:"-" gorm:"comment:流程标识"`
Clazz string `json:"clazz" gorm:"comment:节点类型"`
Label string `json:"label" gorm:"comment:节点名称"`
@ -48,7 +48,7 @@ type WorkflowEdge struct {
ID string `json:"id" form:"id" gorm:"comment:唯一标识;primaryKey;unique;not null"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
WorkflowProcessID string `json:"-" gorm:"comment:流程标识"`
Clazz string `json:"clazz" gorm:"comment:类型(线)"`
Source string `json:"source" gorm:"comment:起点节点"`

62
server/service/wk_process.go

@ -4,6 +4,7 @@ import (
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
"gorm.io/gorm"
)
// @title CreateWorkflowProcess
@ -24,7 +25,27 @@ func CreateWorkflowProcess(workflowProcess model.WorkflowProcess) (err error) {
// @return error
func DeleteWorkflowProcess(workflowProcess model.WorkflowProcess) (err error) {
err = global.GVA_DB.Delete(workflowProcess).Error
err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
var txErr error
txErr = tx.Delete(workflowProcess).Error
if txErr != nil {
return txErr
}
var edges []model.WorkflowEdge
txErr = tx.Delete(model.WorkflowNode{}, "workflow_process_id = ?", workflowProcess.ID).Error
if txErr != nil {
return txErr
}
txErr = tx.Find(&edges, "workflow_process_id = ?", workflowProcess.ID).Error
if txErr != nil {
return txErr
}
txErr = tx.Select("StartPoint", "EndPoint").Delete(&edges).Error
if txErr != nil {
return txErr
}
return nil
})
return err
}
@ -46,8 +67,43 @@ func DeleteWorkflowProcessByIds(ids request.IdsReq) (err error) {
// @return error
func UpdateWorkflowProcess(workflowProcess *model.WorkflowProcess) (err error) {
err = global.GVA_DB.Save(workflowProcess).Error
return err
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
var txErr error
var edges []model.WorkflowEdge
var edgesIds []string
txErr = tx.Unscoped().Delete(workflowProcess).Error
if txErr != nil {
return txErr
}
txErr = tx.Unscoped().Delete(model.WorkflowNode{}, "workflow_process_id = ?", workflowProcess.ID).Error
if txErr != nil {
return txErr
}
txErr = tx.Unscoped().Find(&edges, "workflow_process_id = ?", workflowProcess.ID).Error
if txErr != nil {
return txErr
}
txErr = tx.Unscoped().Delete(&edges).Error
if txErr != nil {
return txErr
}
for _, v := range edges {
edgesIds = append(edgesIds, v.ID)
}
txErr = tx.Unscoped().Delete(model.WorkflowStartPoint{}, "workflow_edge_id in ?", edgesIds).Error
if txErr != nil {
return txErr
}
txErr = tx.Unscoped().Delete(model.WorkflowEndPoint{}, "workflow_edge_id in ?", edgesIds).Error
if txErr != nil {
return txErr
}
txErr = tx.Create(&workflowProcess).Error
if txErr != nil {
return txErr
}
return nil
})
}
// @title GetWorkflowProcess

355
web/src/view/workflow/workflowCreate/workflowCreate.vue

@ -51,7 +51,8 @@
<script>
import {
findWorkflowProcess,
createWorkflowProcess
createWorkflowProcess,
updateWorkflowProcess
} from "@/api/workflowProcess"; //
import gvaWfd from "@/components/gva-wfd";
import { getUserList } from "@/api/user";
@ -67,174 +68,174 @@ export default {
lang: "zh",
done:false,
demoData: {
// nodes: [
// {
// clazz: "start",
// label: "",
// type: "start-node",
// shape: "start-node",
// x: 110,
// y: 195,
// id: "start1603681292875",
// style: {}
// },
// {
// clazz: "parallelGateway",
// label: "",
// type: "parallel-gateway-node",
// shape: "parallel-gateway-node",
// x: 228,
// y: 195,
// id: "parallelGateway1603681296419",
// style: {}
// },
// {
// clazz: "userTask",
// label: "1",
// type: "user-task-node",
// shape: "user-task-node",
// x: 372,
// y: 84,
// id: "userTask1603681299962",
// style: {},
// assignValue: 1,
// assignType: "user"
// },
// {
// clazz: "userTask",
// label: "2",
// type: "user-task-node",
// shape: "user-task-node",
// x: 370,
// y: 321,
// id: "userTask1603681302372",
// style: {},
// assignValue: 2,
// assignType: "user"
// },
// {
// clazz: "parallelGateway",
// label: "",
// type: "parallel-gateway-node",
// shape: "parallel-gateway-node",
// x: 519,
// y: 195,
// id: "parallelGateway1603681338222",
// style: {}
// },
// {
// clazz: "end",
// label: "",
// type: "end-node",
// shape: "end-node",
// x: 704,
// y: 317,
// id: "end1603681358043",
// style: {}
// },
// {
// clazz: "end",
// label: "",
// type: "end-node",
// shape: "end-node",
// x: 706.5,
// y: 55.5,
// id: "end1603681360882",
// style: {}
// }
// ],
// edges: [
// {
// id: "flow1603681320738",
// clazz: "flow",
// source: "parallelGateway1603681296419",
// target: "userTask1603681299962",
// sourceAnchor: 0,
// targetAnchor: 3,
// shape: "flow-polyline-round",
// style: {},
// startPoint: { x: 228, y: 169, index: 0 },
// endPoint: { x: 321.5, y: 84, index: 3 }
// },
// {
// id: "flow1603681321969",
// clazz: "flow",
// source: "parallelGateway1603681296419",
// target: "userTask1603681302372",
// sourceAnchor: 2,
// targetAnchor: 3,
// shape: "flow-polyline-round",
// style: {},
// startPoint: { x: 228, y: 221, index: 2 },
// endPoint: { x: 319.5, y: 321, index: 3 }
// },
// {
// id: "flow1603681323274",
// clazz: "flow",
// source: "start1603681292875",
// target: "parallelGateway1603681296419",
// sourceAnchor: 1,
// targetAnchor: 3,
// shape: "flow-polyline-round",
// style: {},
// startPoint: { x: 138, y: 195, index: 1 },
// endPoint: { x: 202, y: 195, index: 3 },
// label: "",
// conditionExpression: "complete"
// },
// {
// id: "flow1603681341777",
// clazz: "flow",
// source: "userTask1603681299962",
// target: "parallelGateway1603681338222",
// sourceAnchor: 1,
// targetAnchor: 3,
// shape: "flow-polyline-round",
// style: {},
// startPoint: { x: 422.5, y: 84, index: 1 },
// endPoint: { x: 493, y: 195, index: 3 }
// },
// {
// id: "flow1603681343425",
// clazz: "flow",
// source: "userTask1603681302372",
// target: "parallelGateway1603681338222",
// sourceAnchor: 1,
// targetAnchor: 3,
// shape: "flow-polyline-round",
// style: {},
// startPoint: { x: 420.5, y: 321, index: 1 },
// endPoint: { x: 493, y: 195, index: 3 }
// },
// {
// id: "flow1603681362913",
// clazz: "flow",
// source: "parallelGateway1603681338222",
// target: "end1603681360882",
// sourceAnchor: 0,
// targetAnchor: 2,
// shape: "flow-polyline-round",
// style: {},
// startPoint: { x: 519, y: 169, index: 0 },
// endPoint: { x: 678.5, y: 55.5, index: 2 },
// conditionExpression: "complete",
// label: ""
// },
// {
// id: "flow1603681392729",
// clazz: "flow",
// source: "parallelGateway1603681338222",
// target: "end1603681358043",
// sourceAnchor: 2,
// targetAnchor: 2,
// shape: "flow-polyline-round",
// style: {},
// startPoint: { x: 519, y: 221, index: 2 },
// endPoint: { x: 676, y: 317, index: 2 },
// conditionExpression: "reject",
// label: ""
// }
// ],
nodes: [
{
clazz: "start",
label: "发起请假",
type: "start-node",
shape: "start-node",
x: 110,
y: 195,
id: "start1603681292875",
style: {}
},
{
clazz: "parallelGateway",
label: "会签",
type: "parallel-gateway-node",
shape: "parallel-gateway-node",
x: 228,
y: 195,
id: "parallelGateway1603681296419",
style: {}
},
{
clazz: "userTask",
label: "审批人1",
type: "user-task-node",
shape: "user-task-node",
x: 372,
y: 84,
id: "userTask1603681299962",
style: {},
assignValue: 1,
assignType: "user"
},
{
clazz: "userTask",
label: "审批人2",
type: "user-task-node",
shape: "user-task-node",
x: 370,
y: 321,
id: "userTask1603681302372",
style: {},
assignValue: 2,
assignType: "user"
},
{
clazz: "parallelGateway",
label: "会签结果检测",
type: "parallel-gateway-node",
shape: "parallel-gateway-node",
x: 519,
y: 195,
id: "parallelGateway1603681338222",
style: {}
},
{
clazz: "end",
label: "请假失败",
type: "end-node",
shape: "end-node",
x: 704,
y: 317,
id: "end1603681358043",
style: {}
},
{
clazz: "end",
label: "请假成功",
type: "end-node",
shape: "end-node",
x: 706.5,
y: 55.5,
id: "end1603681360882",
style: {}
}
],
edges: [
{
id: "flow1603681320738",
clazz: "flow",
source: "parallelGateway1603681296419",
target: "userTask1603681299962",
sourceAnchor: 0,
targetAnchor: 3,
shape: "flow-polyline-round",
style: {},
startPoint: { x: 228, y: 169, index: 0 },
endPoint: { x: 321.5, y: 84, index: 3 }
},
{
id: "flow1603681321969",
clazz: "flow",
source: "parallelGateway1603681296419",
target: "userTask1603681302372",
sourceAnchor: 2,
targetAnchor: 3,
shape: "flow-polyline-round",
style: {},
startPoint: { x: 228, y: 221, index: 2 },
endPoint: { x: 319.5, y: 321, index: 3 }
},
{
id: "flow1603681323274",
clazz: "flow",
source: "start1603681292875",
target: "parallelGateway1603681296419",
sourceAnchor: 1,
targetAnchor: 3,
shape: "flow-polyline-round",
style: {},
startPoint: { x: 138, y: 195, index: 1 },
endPoint: { x: 202, y: 195, index: 3 },
label: "发起",
conditionExpression: "complete"
},
{
id: "flow1603681341777",
clazz: "flow",
source: "userTask1603681299962",
target: "parallelGateway1603681338222",
sourceAnchor: 1,
targetAnchor: 3,
shape: "flow-polyline-round",
style: {},
startPoint: { x: 422.5, y: 84, index: 1 },
endPoint: { x: 493, y: 195, index: 3 }
},
{
id: "flow1603681343425",
clazz: "flow",
source: "userTask1603681302372",
target: "parallelGateway1603681338222",
sourceAnchor: 1,
targetAnchor: 3,
shape: "flow-polyline-round",
style: {},
startPoint: { x: 420.5, y: 321, index: 1 },
endPoint: { x: 493, y: 195, index: 3 }
},
{
id: "flow1603681362913",
clazz: "flow",
source: "parallelGateway1603681338222",
target: "end1603681360882",
sourceAnchor: 0,
targetAnchor: 2,
shape: "flow-polyline-round",
style: {},
startPoint: { x: 519, y: 169, index: 0 },
endPoint: { x: 678.5, y: 55.5, index: 2 },
conditionExpression: "complete",
label: "所有人同意"
},
{
id: "flow1603681392729",
clazz: "flow",
source: "parallelGateway1603681338222",
target: "end1603681358043",
sourceAnchor: 2,
targetAnchor: 2,
shape: "flow-polyline-round",
style: {},
startPoint: { x: 519, y: 221, index: 2 },
endPoint: { x: 676, y: 317, index: 2 },
conditionExpression: "reject",
label: "任何一人拒绝"
}
],
},
wkType:"create",
users: [],
@ -275,17 +276,23 @@ export default {
})
return
}
// if(this.$route.query.type == 'edit'){
// //
// }else{
if(this.$route.query.type == 'edit'){
const res = await updateWorkflowProcess(processModel)
if(res.code == 0){
this.$message({
type:"success",
message:"编辑成功"
})
}
}else{
const res = await createWorkflowProcess(processModel)
if(res.success){
if(res.code == 0){
this.$message({
type:"success",
message:"创建成功"
})
}
// }
}
},
saveXML() {
console.log(this.$refs["wfd"].graph.saveXML());

176
web/src/view/workflow/workflowProcess/workflowProcess.vue

@ -6,10 +6,7 @@
<el-input placeholder="搜索条件" v-model="searchInfo.name"></el-input>
</el-form-item>
<el-form-item label="流程标题">
<el-input
placeholder="搜索条件"
v-model="searchInfo.label"
></el-input>
<el-input placeholder="搜索条件" v-model="searchInfo.label"></el-input>
</el-form-item>
<el-form-item>
<el-button @click="onSubmit" type="primary">查询</el-button>
@ -18,20 +15,10 @@
<el-popover placement="top" v-model="deleteVisible" width="160">
<p>确定要删除吗</p>
<div style="text-align: right; margin: 0">
<el-button @click="deleteVisible = false" size="mini" type="text"
>取消</el-button
>
<el-button @click="onDelete" size="mini" type="primary"
>确定</el-button
>
<el-button @click="deleteVisible = false" size="mini" type="text">取消</el-button>
<el-button @click="onDelete" size="mini" type="primary">确定</el-button>
</div>
<el-button
icon="el-icon-delete"
size="mini"
slot="reference"
type="danger"
>批量删除</el-button
>
<el-button icon="el-icon-delete" size="mini" slot="reference" type="danger">批量删除</el-button>
</el-popover>
</el-form-item>
</el-form>
@ -46,72 +33,38 @@
tooltip-effect="dark"
>
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column label="日期" width="180">
<el-table-column label="日期" width="180">
<template slot-scope="scope">{{scope.row.CreatedAt|formatDate}}</template>
</el-table-column>
<el-table-column
label="流程名称"
prop="name"
width="120"
></el-table-column>
<el-table-column label="流程名称" prop="name" width="120"></el-table-column>
<el-table-column
label="分类"
prop="category"
width="120"
></el-table-column>
<el-table-column label="分类" prop="category" width="120"></el-table-column>
<el-table-column label="类型" prop="clazz" width="120"></el-table-column>
<el-table-column
label="流程标题"
prop="label"
width="120"
></el-table-column>
<el-table-column label="流程标题" prop="label" width="120"></el-table-column>
<el-table-column label="是否隐藏图标" prop="hideIcon" width="120">
<template slot-scope="scope">{{
<template slot-scope="scope">
{{
scope.row.hideIcon | formatBoolean
}}</template>
}}
</template>
</el-table-column>
<el-table-column
label="详细介绍"
prop="description"
width="120"
></el-table-column>
<el-table-column label="详细介绍" prop="description" width="120"></el-table-column>
<el-table-column label="按钮组">
<template slot-scope="scope">
<el-button
@click="updateWorkflowProcess(scope.row)"
size="small"
type="primary"
>变更</el-button
>
<el-button class="table-button" @click="updateWorkflowProcess(scope.row)" size="small" type="primary">变更</el-button>
<el-button class="table-button" @click="viewWorkflowProcess(scope.row)" size="small" type="warning">查看</el-button>
<el-popover placement="top" width="160" v-model="scope.row.visible">
<p>确定要删除吗</p>
<div style="text-align: right; margin: 0">
<el-button
size="mini"
type="text"
@click="scope.row.visible = false"
>取消</el-button
>
<el-button
type="primary"
size="mini"
@click="deleteWorkflowProcess(scope.row)"
>确定</el-button
>
<el-button size="mini" type="text" @click="scope.row.visible = false">取消</el-button>
<el-button type="primary" size="mini" @click="deleteWorkflowProcess(scope.row)">确定</el-button>
</div>
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
slot="reference"
>删除</el-button
>
<el-button type="danger" icon="el-icon-delete" size="mini" slot="reference">删除</el-button>
</el-popover>
</template>
</el-table-column>
@ -132,12 +85,12 @@
<script>
import {
deleteWorkflowProcess,
deleteWorkflowProcessByIds,
getWorkflowProcessList
} from "@/api/workflowProcess"; //
deleteWorkflowProcess,
deleteWorkflowProcessByIds,
getWorkflowProcessList
} from "@/api/workflowProcess"; //
import { formatTimeToStr } from "@/utils/date";
import infoList from "@/components/mixins/infoList";
import infoList from "@/mixins/infoList";
export default {
name: "WorkflowProcess",
@ -148,7 +101,7 @@ export default {
dialogFormVisible: false,
visible: false,
deleteVisible: false,
multipleSelection: [],
multipleSelection: []
};
},
filters: {
@ -162,46 +115,58 @@ export default {
},
formatBoolean: function(bool) {
if (bool != null) {
return bool ? "是" :"否";
return bool ? "是" : "否";
} else {
return "";
}
}
},
methods: {
//
onSubmit() {
this.page = 1
this.pageSize = 10
if (this.searchInfo.hideIcon==""){
this.searchInfo.hideIcon=null
}
this.getTableData()
},
handleSelectionChange(val) {
this.multipleSelection = val
},
async onDelete() {
const ids = []
this.multipleSelection &&
this.multipleSelection.map(item => {
ids.push(item.id)
})
const res = await deleteWorkflowProcessByIds({ ids })
if (res.code == 0) {
this.$message({
type: 'success',
message: '删除成功'
})
this.deleteVisible = false
this.getTableData()
}
},
//
onSubmit() {
this.page = 1;
this.pageSize = 10;
if (this.searchInfo.hideIcon == "") {
this.searchInfo.hideIcon = null;
}
this.getTableData();
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
async onDelete() {
const ids = [];
this.multipleSelection &&
this.multipleSelection.map(item => {
ids.push(item.id);
});
const res = await deleteWorkflowProcessByIds({ ids });
if (res.code == 0) {
this.$message({
type: "success",
message: "删除成功"
});
this.deleteVisible = false;
this.getTableData();
}
},
async updateWorkflowProcess(row) {
this.$router.push({name:"workflowCreate",query:{
id:row.id,
type:'edit'
}})
this.$router.push({
name: "workflowCreate",
query: {
id: row.id,
type: "edit"
}
});
},
async viewWorkflowProcess(row) {
this.$router.push({
name: "workflowCreate",
query: {
id: row.id,
type: "view"
}
});
},
async deleteWorkflowProcess(row) {
this.visible = false;
@ -219,7 +184,8 @@ export default {
}
},
async created() {
await this.getTableData();}
await this.getTableData();
}
};
</script>

Loading…
Cancel
Save