工作流录入 根据id查询方法增加

This commit is contained in:
pixel
2020-10-27 18:59:51 +08:00
parent 4e514dc83e
commit bf21fec50e
9 changed files with 172 additions and 298 deletions

View File

@@ -22,22 +22,26 @@
<gva-wfd
ref="wfd"
:data="demoData"
v-if="done"
:height="600"
:users="users"
:authorities="authorities"
:groups="groups"
:categorys="categorys"
:lang="lang"
:processModel="processModel"
/>
</div>
</template>
<script>
import {
findWorkflowProcess
findWorkflowProcess,
createWorkflowProcess
} from "@/api/workflowProcess"; // 此处请自行替换地址
import gvaWfd from "@/components/gva-wfd";
import { getUserList } from "@/api/user";
import { getAuthorityList } from "@/api/authority";
import edge from '../../../components/gva-wfd/shape/edge';
export default {
name: "Workflow",
components: {
@@ -47,178 +51,17 @@ export default {
return {
visible: false,
lang: "zh",
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: "任何一人拒绝"
}
],
combos: [],
groups: []
},
done:false,
demoData: {},
processModel:{
id: '',
name: '',
category: '',
clazz: 'process',
dataObjs: [],
signalDefs: [],
messageDefs: [],
},
users: [],
authorities: [],
groups: [
@@ -235,11 +78,37 @@ export default {
};
},
methods: {
save() {
async save() {
this.visible = false;
console.log(this.$refs["wfd"].graph.save());
console.log(this.$refs["wfd"].processModel);
console.log(JSON.stringify(this.$refs["wfd"].graph.save()));
const obj = this.$refs["wfd"].graph.save()
const processModel = this.processModel
const nodeMap={}
obj.edges.map(item=>{
if(nodeMap[item.source]){
nodeMap[item.source].push(item)
}else{
nodeMap[item.source] = [item]
}
})
obj.nodes.map(item=>{
item.edges = nodeMap[item.id]
})
processModel.nodes = obj.nodes
if(!processModel.id){
this.$message({
type:"error",
message:"流程ID为必填项(点击空白处录入流程基本信息)"
})
return
}
const res = await createWorkflowProcess(processModel)
if(res.code == 0){
this.$message({
type:"success",
message:"创建成功"
})
}
},
saveXML() {
console.log(this.$refs["wfd"].graph.saveXML());
@@ -264,9 +133,23 @@ export default {
});
});
}
if(this.$route.params.ID){
const res = await findWorkflowProcess({ ID: this.$route.params.ID });
console.log(res.data)
if(this.$route.query.id){
const res = await findWorkflowProcess({ id: this.$route.query.id });
this.disabled = this.$route.query.type == "view"
if(res.code == 0){
const nodes = []
const edges = []
res.data.reworkflowProcess.nodes.map(item=>{
edges.push(...item.edges)
delete item.edges
nodes.push(item)
})
delete res.data.reworkflowProcess.nodes
this.demoData = {edges,nodes}
this.processModel = res.data.reworkflowProcess
this.done = true
}
console.log(this.demoData)
}
}
};