關于workflow 的審批流程的業務實作<一>
文章目錄
- 關于workflow 的審批流程的業務實作<一>
- 一、業務背景
- 二、業務分析
- 2.1用戶表單設計
- 2.2用戶流程定義
- 2.3用戶發起審批
- 2.4進行審批
| 版本 | 時間 | 變更內容 | 作者 | 備注 |
|---|---|---|---|---|
| v1.0 | 2021/11/13 | 創建 | henry_oulen@163.com | 微信號:henry_oulen |
一、業務背景
- 作業流在作業中非常常見,一般的業務系統中
例如下面的例子

因此開發出一個審批業務極為重要
那么下面我們針對這個業務具體來講解
二、業務分析
-
定義表單設計
-
定義流程設計
-
用戶發起審批
-
用戶進行表單審批
2.1用戶表單設計
如何能夠實作不同的表單能夠進行自定義 那么一個欄位的表結構尤其重要
"formData": [{
"type": "holidayTypes",
"field": "leaveType",
"title": "請假型別 :",
"info": "",
"hidden": false,
"display": true,
"validate": [{
"trigger": "change",
"message": "請選擇請假型別",
"required": true
}],
"conditions": true
}, {
"type": "datePicker",
"field": "leaveTime",
"title": "開始時間 :",
"info": "",
"props": {
"type": "datetime",
"prefixIcon": "el-icon-date",
"placeholder": "請選擇請假時間"
},
"_fc_drag_tag": "datePicker",
"hidden": false,
"display": true,
"value": null,
"validate": [{
"type": "string",
"trigger": "change",
"mode": "required",
"message": "請選擇請假時間",
"required": true
}],
"emit": ["change"]
}, {
"type": "datePicker",
"field": "leaveEndTime",
"title": "結束時間 :",
"info": "",
"props": {
"type": "datetime",
"prefixIcon": "el-icon-date",
"placeholder": "請選擇結束時間"
},
"_fc_drag_tag": "datePicker",
"hidden": false,
"display": true,
"value": null,
"validate": [{
"type": "string",
"trigger": "change",
"mode": "required",
"message": "請選擇請假結束時間",
"required": true
}],
"emit": ["change"]
}, {
"type": "input",
"field": "leaveDuration",
"title": "請假時長 :",
"info": "",
"value": "0",
"props": {
"disabled": true,
"type": "text",
"placeholder": ""
},
"_fc_drag_tag": "input",
"hidden": false,
"display": true,
"validate": [{
"trigger": "change",
"mode": "required",
"message": "",
"required": true,
"type": "string"
}],
"conditions": true
}, {
"type": "input",
"field": "leaveReason",
"title": "請假事由 :",
"info": "",
"props": {
"type": "textarea",
"readonly": false,
"placeholder": "請輸入內容"
},
"_fc_drag_tag": "input",
"hidden": false,
"display": true,
"value": "",
"validate": [{
"type": "string",
"trigger": "change",
"mode": "required",
"message": "請輸入請假事由",
"required": true
}]
}]

思路分析
每一個欄位其實就是一個字典
通過固定的鍵值對來取值,這樣做的目的就是動態獲取欄位的名稱 和對于的值
{
"type": "holidayTypes",
"field": "leaveType",
"title": "請假型別 :",
"info": "",
"hidden": false,
"display": true,
"validate": [{
"trigger": "change",
"message": "請選擇請假型別",
"required": true,
}]
}
2.2用戶流程定義
思路:條件分支和子節點分支
processData
里面主要的資料就是我們用來進行處理流程的資料

"processData": {
"type": "start",
"content": "所有人",
"nodeId": "3ych7azs3lsqb8bcbgg",
"properties": {
"title": "發起人",
"initiator": []
},
"childNode": {
"type": "condition",
"nodeId": "ZcKEzh",
"childNode": {
"type": "copy",
"nodeId": "uK3Fzh",
"childNode": {
"type": "approver",
"nodeId": "OKVXzh",
"childNode": {},
"prevId": "uK3Fzh",
"content": "test@8888",
"properties": {
"title": "審批人",
"assigneeType": "user",
"menbers": [{
"user_id": 3,
"user_name": "test@8888"
}],
"counterSign": true,
"residenceTime": 0
}
},
"prevId": "QkyEzh",
"content": "test@8888",
"properties": {
"title": "抄送人",
"menbers": [{
"user_id": 3,
"user_name": "test@8888"
}],
"userOptional": true
}
},
"prevId": "fwzG4i",
"conditions": [{
"content": "[請假時長 : 等于 5]",
"prevId": "ZcKEzh",
"nodeId": "WpKEzh",
"properties": {
"priority": 0,
"isDefault": false,
"initiator": null,
"conditions": [{
"conditionValue": {
"type": "equal",
"value": 5
},
"field": "leaveDuration"
}]
},
"childNode": {
"type": "approver",
"nodeId": "4BTXzh",
"childNode": {
"type": "condition",
"nodeId": "RtWXzh",
"childNode": {
"type": "approver",
"nodeId": "iGYXzh",
"childNode": {},
"prevId": "RtWXzh",
"content": "日程測驗",
"properties": {
"title": "審批人",
"assigneeType": "user",
"menbers": [{
"user_id": 22,
"user_name": "日程測驗"
}],
"counterSign": true,
"residenceTime": 0
}
},
"prevId": "4BTXzh",
"conditions": [{
"content": "[請假時長 : 等于 5]",
"prevId": "RtWXzh",
"nodeId": "BmWXzh",
"properties": {
"priority": 0,
"isDefault": false,
"initiator": null,
"conditions": [{
"conditionValue": {
"type": "equal",
"value": 5
},
"field": "leaveDuration"
}]
},
"childNode": {
"type": "copy",
"nodeId": "HXtXzh",
"childNode": {},
"prevId": "BmWXzh",
"content": "子賬號",
"properties": {
"title": "抄送人",
"menbers": [{
"user_id": 13,
"user_name": "子賬號"
}],
"userOptional": true
}
}
}, {
"content": "其他情況進入此流程",
"prevId": "RtWXzh",
"nodeId": "ZoWXzh",
"properties": {
"priority": 1,
"isDefault": true,
"initiator": null,
"conditions": []
}
}]
},
"prevId": "WpKEzh",
"content": "測驗登錄1",
"properties": {
"title": "審批人",
"assigneeType": "user",
"menbers": [{
"user_id": 20,
"user_name": "測驗登錄1"
}],
"counterSign": true,
"residenceTime": 0
}
}
}, {
"content": "[請假時長 : 大于 5]",
"prevId": "ZcKEzh",
"nodeId": "V4nOzh",
"properties": {
"priority": 1,
"isDefault": false,
"initiator": null,
"conditions": [{
"conditionValue": {
"type": "greaterThan",
"value": 5
},
"field": "leaveDuration"
}]
},
"childNode": {
"type": "approver",
"nodeId": "PEUXzh",
"childNode": {},
"prevId": "V4nOzh",
"content": "測驗密碼傳輸",
"properties": {
"title": "審批人",
"assigneeType": "user",
"menbers": [{
"user_id": 15,
"user_name": "測驗密碼傳輸"
}],
"counterSign": true,
"residenceTime": 0
}
}
}, {
"content": "[請假時長 : 小于 3]",
"prevId": "ZcKEzh",
"nodeId": "yAxZzh",
"properties": {
"priority": 2,
"isDefault": false,
"initiator": null,
"conditions": [{
"conditionValue": {
"type": "lesThan",
"value": 3
},
"field": "leaveDuration"
}]
},
"childNode": {
"type": "condition",
"nodeId": "nH4azh",
"childNode": {
"type": "approver",
"nodeId": "G57azh",
"childNode": {},
"prevId": "nH4azh",
"content": "測驗登錄1",
"properties": {
"title": "審批人",
"assigneeType": "user",
"menbers": [{
"user_id": 20,
"user_name": "測驗登錄1"
}],
"counterSign": true,
"residenceTime": 0
}
},
"prevId": "yAxZzh",
"conditions": [{
"content": "[請假時長 : 大于 0]",
"prevId": "nH4azh",
"nodeId": "sG4azh",
"properties": {
"priority": 0,
"isDefault": false,
"initiator": null,
"conditions": [{
"conditionValue": {
"type": "greaterThan",
"value": 0
},
"field": "leaveDuration"
}]
},
"childNode": {
"type": "approver",
"nodeId": "sG6azh",
"childNode": {},
"prevId": "sG4azh",
"content": "子賬號",
"properties": {
"title": "審批人",
"assigneeType": "user",
"menbers": [{
"user_id": 13,
"user_name": "子賬號"
}],
"counterSign": true,
"residenceTime": 0
}
}
}, {
"content": "其他情況進入此流程",
"prevId": "nH4azh",
"nodeId": "BC4azh",
"properties": {
"priority": 1,
"isDefault": true,
"initiator": null,
"conditions": []
}
}]
}
}, {
"content": "其他情況進入此流程",
"prevId": "ZcKEzh",
"nodeId": "miKEzh",
"properties": {
"priority": 3,
"isDefault": true,
"initiator": null,
"conditions": []
}
}]
}
}
2.3用戶發起審批
用戶發起審批
拆解
01
用戶填寫表單資料的時候
需要發起請求獲取流程分支的資料
也就是把表單的資料發給后端
02通過欄位的值 和流程分支里面的資料進行對比 選擇走哪個分支


2.4進行審批
當用戶發起來真正的審批流的時候,也就是用戶已經進行了一次 task任務的執行和沒有執行的任務的操作
01 發起審批的時候
需要處理兩個事件
1:根據前面的流程來處理掉 第一個審批人的任務
2:根據流程的總節點數量和處理是不是最后的一個用戶,來判斷整個審批是不是已經結束

審批流程的參考資料 有能力的也可以先參考以下檔案進行學習
南斗開源平臺:https://gitee.com/nandouinfo/fastdp
流程后端 https://github.com/go-workflow/go-workflow
流程前端 https://github.com/go-workflow/workflow-ui
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/357126.html
標籤:其他
下一篇:AJAX —— 原生 AJAX / jQuery 發送 AJAX / axios 發送 AJAX / fetch 發送 AJAX
