流程编辑

This commit is contained in:
ChenXinXin committed 2024-04-22 11:10:18 +08:00
1 parent 7751704fe7
commit 696457321b
6 files changed
+915 -313

No files matched your search

+12 -27
View File
@@ -1,39 +1,27 @@
<template id="edit-line">
<v-form v-model="isFormValid" ref="dataForm" lazy-validation>
<v-row>
<v-col cols="12" class=" pb-3">
<v-row class="ma-0 pa-0">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">GUID</span>
<v-text-field class="jh-v-input" dense filled single-line disabled label="GUID" v-model="line.id"></v-text-field>
</v-col>
<v-col cols="12" class=" pb-3">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">源活动</span>
<v-text-field class="jh-v-input" dense filled single-line disabled label="源活动" v-model="line.from"></v-text-field>
</v-col>
<v-col cols="12" class=" pb-3">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">目标活动</span>
<v-text-field class="jh-v-input" dense filled single-line disabled label="目标活动" v-model="line.to"></v-text-field>
</v-col>
<v-col cols="12" class=" pb-3">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">名称</span>
<v-text-field class="jh-v-input" dense filled single-line label="名称" v-model="line.label"></v-text-field>
</v-col>
<v-col cols="12" class=" pb-3" v-if="mode == 'serial'">
<span class="jh-input-label">操作类型</span>
<v-select
:items="lineTypeList"
dense filled single-line
class="jh-v-input"
label="操作类型"
color="success"
item-color="success"
v-model="line.type"
></v-select>
</v-col>
<v-col cols="12" class=" pb-3">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">执行Hook</span>
<v-text-field class="jh-v-input" dense filled single-line label="执行Hook" v-model="line.hook"></v-text-field>
</v-col>
<v-col cols="12" class=" pb-3">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">备注说明</span>
<v-text-field class="jh-v-input" dense filled single-line label="备注说明" v-model="line.Remark"></v-text-field>
</v-col>
@@ -50,10 +38,6 @@
lf: {
type: Object,
default: null
},
mode: {
type: String,
default: 'serial'
}
},
data() {
@@ -61,14 +45,16 @@
line: { label: '' },
isUpdate: false,
isFormValid: true,
lineTypeList: []
}
},
watch: {
line: {
handler: function (line) {
handler: async function (line) {
// 更新节点或者连线的文案
this.lf.updateText(line.id, `${line.type}-${line.label}`);
this.lf.setProperties(line.id, line);
// 更新数据
await this.$emit('reflesh-workflow')
},
deep: true
}
@@ -79,10 +65,9 @@
},
},
methods: {
init(line, lineTypeList) {
init(line) {
this.isUpdate = false;
this.line = line.properties;
this.lineTypeList = lineTypeList;
this.$nextTick(() => {
this.isUpdate = true;
});
+374 -91
View File
@@ -1,92 +1,208 @@
<template id="edit-node">
<v-form v-model="isFormValid" ref="dataForm" lazy-validation>
<v-row>
<v-col cols="12">
<v-row class="ma-0 pa-0">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">GUID</span>
<v-text-field class="jh-v-input" dense filled single-line disabled label="GUID" v-model="node.id"></v-text-field>
</v-col>
<v-col cols="12">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">名称</span>
<v-text-field class="jh-v-input" dense filled single-line label="名称" v-model="node.label"></v-text-field>
<v-text-field class="jh-v-input" dense filled single-line label="名称" v-model="node.label" :disabled="node.type == 'start' || node.type == 'end'"></v-text-field>
</v-col>
<v-col cols="12">
<span class="jh-input-label">备注说明</span>
<v-text-field class="jh-v-input" dense filled single-line label="备注说明" v-model="node.Remark"></v-text-field>
</v-col>
<template v-if="!node.id.includes('start-') && !node.id.includes('end-')">
<v-col cols="12">
<span class="jh-input-label">指派类型</span>
<!-- 审批节点 -->
<template v-if="node.type == 'approvalTask'">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">审批人类型</span>
<v-select
:items="assignTypeList"
:items="constantObj.approverTypes"
dense filled single-line
item-text="text"
color="success"
item-color="success"
item-value="value"
class="jh-v-input"
label="指派类型"
v-model="node.assignType"
label="审批人类型"
v-model="node.approverType"
@change="clearUser"
></v-select>
</v-col>
<v-col cols="12">
<span class="jh-input-label">指派</span>
<v-autocomplete
class="jh-v-input"
dense filled single-line clearable
:items="optionList"
<template v-if="node.approverType == '指定上级'">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">指定上级</span>
<v-select
:items="constantObj.superiors"
dense filled single-line
item-text="text"
item-value="value"
:label="assignType"
:multiple="node.assignType === 'person'"
v-model="node.assignValue"
:disabled="!node.assignType">
</v-autocomplete>
</v-col>
<v-col cols="12" v-if="mode == 'serial'">
<span class="jh-input-label">允许的操作(英文逗号分隔)</span>
<v-text-field class="jh-v-input" dense filled single-line label="允许的操作(英文逗号分隔)" v-model="node.lineTypeList"></v-text-field>
</v-col>
<v-col cols="12" >
<span class="jh-input-label">可写模板</span>
class="jh-v-input"
v-model="node.user"
multiple
></v-select>
</v-col>
</template>
<template v-if="node.approverType == '指定部门负责人'">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">指定部门负责人</span>
<v-select
:items="constantObj.deptHeaders"
dense filled single-line
item-text="text"
item-value="value"
class="jh-v-input"
v-model="node.user"
multiple
></v-select>
</v-col>
</template>
<template v-if="node.approverType == '指定标签'">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">指定标签</span>
<v-select
:items="label"
dense filled single-line
item-text="labelName"
item-value="labelId"
class="jh-v-input"
v-model="node.user"
multiple
></v-select>
</v-col>
</template>
<template v-if="node.approverType == '指定人员'">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">指定人员</span>
<v-select
:items="user"
dense filled single-line
item-text="username"
item-value="userId"
class="jh-v-input"
v-model="node.user"
multiple
></v-select>
</v-col>
</template>
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">多人审批方式</span>
<v-select
:items="tpl"
dense filled single-line
item-text="text"
color="success"
item-color="success"
item-value="value"
class="jh-v-input"
label="可写模板"
multiple
v-model="node.formIdEdit"
></v-select>
</v-col>
<v-col cols="12" >
<span class="jh-input-label">隐藏模板</span>
<v-select
:items="tpl"
:items="constantObj.approvalTypes"
dense filled single-line
item-text="text"
item-value="value"
color="success"
item-color="success"
class="jh-v-input"
label="隐藏模板"
multiple
v-model="node.formIdHidden"
label="多人审批方式"
v-model="node.approvalType"
></v-select>
</v-col>
</template>
<template v-if="node.id.includes('end-')">
<v-col cols="12">
<span class="jh-input-label">流程完成Hook</span>
<v-text-field class="jh-v-input" dense filled single-line label="流程完成Hook" v-model="node.finishHook"></v-text-field>
<!-- 抄送节点 -->
<template v-if="node.type == 'noticeTask'">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">抄送人类型</span>
<v-select
:items="constantObj.noticerTypes"
dense filled single-line
item-text="text"
item-value="value"
class="jh-v-input"
label="抄送人类型"
v-model="node.noticerType"
@change="doUiAction('clearUser')"
></v-select>
</v-col>
<v-col cols="12">
<span class="jh-input-label">流程中断Hook</span>
<v-text-field class="jh-v-input" dense filled single-line label="流程中断Hook" v-model="node.interruptHook"></v-text-field>
<template v-if="node.noticerType == '指定人员'">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">指定人员</span>
<v-select
:items="user"
dense filled single-line
item-text="username"
item-value="userId"
class="jh-v-input"
v-model="node.user"
multiple
></v-select>
</v-col>
</template>
</template>
<!-- 条件节点 -->
<template v-if="node.type == 'conditionTask'">
<v-col cols="12" class="ma-0 pa-0 mb-1">
<span class="jh-input-label">优先级</span>
<v-select
:items="prioritys"
dense filled single-line
item-text="text"
item-value="priority"
class="jh-v-input"
label="审批人类型"
v-model="node.priority"
></v-select>
</v-col>
<v-col cols="12" class="ma-0 pa-0 mb-1" v-if="node.priority && node.priority != -1">
<span class="jh-input-label">条件组</span>
<v-dialog
v-model="isConditionGroupShown"
width="900"
>
<template v-slot:activator="{ on, attrs }">
<span role="button" class="success--text font-weight-medium font-size-2 ml-2" v-bind="attrs" v-on="on">
设置条件
</span>
</template>
<v-card>
<v-card-title>
同时满足以下条件
</v-card-title>
<v-card-text>
<!-- <v-row v-for="(index, item) in node.conditionList"> -->
<v-card elevation="0" outlined>
<v-data-table
:headers="headers"
:items="node.conditionList"
v-model="node.conditionList"
:items-per-page="10"
class="elevation-1"
>
<template v-slot:item.action="{ item, index }">
<span role="button" class="success--text font-weight-medium font-size-2 mr-2 ml-2" @click="doUiAction('deleteCondition', index)">
<v-icon size="16" class="success--text">mdi-delete-outline</v-icon>删除
</span>
</template>
<template v-slot:item.id="{ item }">
<v-select :items="conditions" dense filled single-line item-text="name" item-value="id" class="jh-v-input" v-model="item.id"
@change="changeConditionId($event, item)"></v-select>
</template>
<template v-slot:item.express="{ item }">
<v-select :items="constantObj.operators[item.type]" dense filled single-line class="jh-v-input" v-model="item.express"></v-select>
</template>
<template v-slot:item.option-list="{ item }">
<div v-if="item.type == 'number'" class="d-flex align-center">
<v-text-field class="jh-v-input" dense filled v-model="item.option.begin"></v-text-field>
<span> 至 </span>
<v-text-field class="jh-v-input" dense filled v-model="item.option.end"></v-text-field>
</div>
<v-select v-else :items="getOptionList(item)" item-text="text" item-value="value" dense filled class="jh-v-input" v-model="item.option" multiple></v-select>
</template>
</v-data-table>
</v-card>
<v-btn class="add-btn" @click="doUiAction('addCondition')">添加条件</v-btn>
</v-card-text>
<v-divider></v-divider>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
color="primary"
text
@click="doUiAction('closeConditionGroupDialog')"
>
关闭
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-col>
</template>
</v-row>
@@ -115,16 +231,31 @@
return []
}
},
tpl: {
label: {
type: Array,
default: () => {
return []
}
},
mode: {
workflowConfig: {
type: Object,
default: () => {
return {
nodeList: [],
lineList: []
}
}
},
workflowForm: {
type: Array,
default: () => {
return []
}
},
displayMode: {
type: String,
default: 'serial'
}
default: "complex"
},
},
data() {
return {
@@ -132,26 +263,82 @@
node: {
id: ''
},
headers:[
{ text: '条件', value: 'id', width: 150 },
{ text: '运算', value: 'express', width: 100 },
{ text: '选项', value: 'option-list', width: 280},
{ text: '操作', value: 'action', align: 'left', sortable: false, width: 80, class: 'fixed', cellClass: 'fixed'},
],
typeList: [
{ Value: 'start', Text: '起点' },
{ Value: 'end', Text: '终点' },
{ Value: 'userTask', Text: '审核节点' },
{ Value: 'receiveTask', Text: '处理节点' }
{ Value: 'userTask', Text: '审核人' },
{ Value: 'receiveTask', Text: '处理节点' },
{ Value: 'approvalTask', Text: '审核节点' },
{ Value: 'conditionTask', Text: '条件节点' },
{ Value: 'noticeTask', Text: '抄送节点' }
],
assignTypeList: [{value: 'person', text: '用户'}, {value: 'group', text: '组'}]
constantObj: {
approverTypes: [
{ text:'指定上级', value:'指定上级' },
{ text:'指定部门负责人', value:'指定部门负责人' },
{ text:'指定标签', value:'指定标签' },
{ text:'指定人员', value:'指定人员' },
{ text:'申请人自选', value:'申请人自选' },
],
approvalTypes: [
{
value: '依次审批',
text:'依次审批'
},
{
value: '会签',
text:'会签审批(需所有人同意)'
},
{
value: '或签',
text:'或签审批(1人同意即可)'
},
],
superiors:[
'直属上级',
..._.times(9, i => `第${i + 2}级上级`)
],
deptHeaders:[
'直接部门负责人',
..._.times(9, i => `第${i + 2}级部门负责人`)
],
noticerTypes: [
{ text:'指定人员', value:'指定人员' },
{ text:'申请人自选', value:'申请人自选' },
],
operators: {
'single': [{ text: '包含', value: 'include' }],
'multiple': [{ text: '完全包含', value: 'fullInclude' }, { text: '其一包含', value: 'oneInclude'}],
'number': [{ text: '小于', value: 'less' }, { text: '小于等于', value: 'lessEqual'}, { text: '等于', value: 'equal'},
{ text: '大于等于', value: 'moreEqual'}, { text: '大于', value: 'more'}, { text: '介于(a≤x≤b)', value: 'between'},]
}
},
isConditionGroupShown: false
}
},
watch: {
node: {
handler: function (node) {
handler: async function (node) {
// 更新节点或者连线的文案
this.lf.updateText(node.id, node.label);
this.lf.setProperties(node.id, node);
// 更新数据
await this.$emit('reflesh-workflow')
this.$forceUpdate()
},
deep: true
},
tpl: {
handler: function (tpl) {
console.log('tpl change', tpl)
'node.conditionList': {
handler: async function (val) {
this.$forceUpdate()
this.$emit('reflesh-workflow')
},
deep: true
}
@@ -160,31 +347,127 @@
isMobile() {
return window.innerWidth < 600;
},
assignType() {
if (!this.node.assignType) return '请选择指派类型';
return this.assignTypeList.find(e => e.value === this.node.assignType).text;
prioritys(){
var num = this.workflowConfig.nodeList.filter(n=>n.properties.type == 'conditionTask').length
return [
{ text: '默认条件', priority: -1 },
..._.times(num - 1, i => {
return { text: `优先级${i + 1}`, priority: i + 1 }
})
]
},
optionList() {
if (!this.node.assignType) {
return []
}
if (this.node.assignType === 'person') {
return this.user
}
if (this.node.assignType === 'group') {
return this.group
}
conditions(){
var conditions = [
{
id: 'single-applyPerson',
name: '申请人',
type: 'single',
operator: [
{
text: '包含'
}
],
optionList: this.user
},
...this.workflowForm
.filter(i => ['single', 'multiple', 'number'].includes(i.type))
.map(i => {
return {
id: i.id,
name: i.statement,
type: i.type,
operator: this.constantObj.operators[i.type],
optionList: i.optionList
}
})
]
return conditions || []
}
},
methods: {
async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) {
case 'init':
await this.init(uiActionData);
break;
case 'clearUser':
await this.clearUser();
break;
case 'addCondition':
await this.addCondition();
break;
case 'deleteCondition':
await this.deleteCondition(uiActionData);
break;
case 'closeConditionGroupDialog':
await this.closeConditionGroupDialog();
break;
default:
console.error("[doUiAction] uiActionId not find", {uiActionId});
break;
}
},
init(node) {
this.node = node.properties;
},
async clearUser(){
this.node.user = []
await this.$emit('reflesh-workflow')
},
addCondition(){
if(this.node?.conditionList && this.node.conditionList.length > 0){
this.$set(this.node, 'conditionList', [...this.node.conditionList, {}])
}else{
this.$set(this.node, 'conditionList', [{}])
}
this.$forceUpdate()
},
deleteCondition(index){
this.node.conditionList.splice(index, 1)
},
changeConditionId(id, item){
var conditionItem = this.conditions.find(c => c.id == id)
item.type = conditionItem.type || null
item.express = null
item.option = item.type == 'number'? { begin: null, end: null} : null
},
closeConditionGroupDialog(){
this.$forceUpdate()
this.$emit('reflesh-workflow')
this.isConditionGroupShown = false
},
getOptionList(item){
if(!item.id) return []
if(item.id == 'single-applyPerson'){
return this.user.map(u => {
return {
text: u.username,
value: u.id
}
})
}else{
let optionList = this.workflowForm.find(f => f.id == item.id)?.optionList
return optionList.map(o => {
return {
text: o,
value: o
}
})
}
}
}
})
</script>
<style>
.v-textarea textarea {
line-height: 1.2rem;
}
.v-textarea textarea {
line-height: 1.2rem;
}
.add-btn {
width: 100%;
margin-top: 5px;
padding: 5px;
}
</style>
+407 -86
View File
@@ -1,36 +1,105 @@
<template id="process-flow">
<v-card class="process-flow-container">
<!-- 左侧 节点选择列表 >>>>>>>>>>>>> -->
<v-card v-if="!readonly" :style="{'width': isMobile ? '100%' : '150px'}" outlined
:class="{'pa-4': !isMobile, 'pa-2': isMobile, 'mr-2': !isMobile}" outlined>
<div class="menu-item mb-2" v-for="item in menuList" @mousedown.stop.prevent="startDrag(item)">
<v-icon small class="mr-1">{{ item.icon }}</v-icon>
{{item.name}}
<template v-if="displayMode == 'simple'">
<!-- 简单左侧 >>>>>>>>>>>>> -->
<div style="width: 100%;">
<v-card class="d-flex mb-1 overflow-y-auto" height="700" outlined>
<div class="d-flex flex-column flex-fill align-center">
<template v-for="(nodeItem, nodeIndex) in workflowConfig.nodeList" :key="index">
<v-card elevation="2" width="240" @click="editNode(nodeItem)">
<v-card-text class="pa-4">
<span>{{nodeItem.properties.label}}</span>
</v-card-text>
</v-card>
<template v-if="!nodeItem.id.startsWith('end-')">
<div class="d-flex justify-center" style="position: relative;width: 240px;">
<div class="mr-2">
<div class="divider-vertical"></div>
<div class="arrow"></div>
</div>
<v-menu
:value="menuShown(event, nodeIndex)"
:data-menu-Index="nodeIndex"
:close-on-content-click="false"
offset-x
>
<template v-slot:activator="{ on, attrs }">
<div class="add-btn-box" v-bind="attrs" v-on="on" :data-menu-Index="nodeIndex" @click="showMenuShown"></div>
</template>
<v-list class="d-flex">
<v-list-item :data-from="nodeItem.id" :data-to="workflowConfig.nodeList[nodeIndex + 1].id" @click="addNodeBySimple({type: 'approvalTask', prevIndex: nodeIndex})">
<div class="d-flex flex-column align-center add-node-box">
<v-icon class="mb-1" color="#FCAD22">mdi-stamper</v-icon>
<span>审批节点</span>
</div>
</v-list-item>
<v-list-item :data-from="nodeItem.id" :data-to="workflowConfig.nodeList[nodeIndex + 1].id" @click="addNodeBySimple({type: 'noticeTask', prevIndex: nodeIndex})">
<div class="d-flex flex-column align-center add-node-box">
<v-icon class="mb-1" color="#3CB4B2">mdi-send</v-icon>
<span>抄送节点</span>
</div>
</v-list-item>
</v-list>
</v-menu>
</div>
</template>
</template>
</div>
</v-card>
</div>
</v-card>
<!-- <<<<<<<<<<<<< 左侧 节点选择列表 -->
<!-- <<<<<<<<<<<<< 简单左侧 -->
</template>
<template v-if="displayMode == 'complex'">
<!-- 复杂左侧 >>>>>>>>>>>>> -->
<div style="width: 100%;">
<!-- <<<<<<<<<<<<< 左上 节点选择列表 -->
<v-card v-if="!readonly" class="d-flex mb-1" outlined>
<div class="menu-item ma-1" v-for="item in menuList" @mousedown.stop.prevent="startDrag(item)">
<v-icon small class="mr-1">{{ item.icon }}</v-icon>
<span>{{item.name}}</span>
</div>
</v-card>
<!-- <<<<<<<<<<<<< 左上 节点选择列表 -->
<!-- 左下 主内容编辑区 >>>>>>>>>>>>> -->
<v-card class="flow-detail pa-2" outlined>
<div id="flowContent" ref="flowContent"></div>
</v-card>
<!-- <<<<<<<<<<<<< 左下 主内容编辑区 -->
</div>
<!-- <<<<<<<<<<<<< 复杂左侧 -->
</template>
<template>
<!-- 复杂右侧 >>>>>>>>>>>>> -->
<div :style="{'width': isMobile ? 'auto' : '350px'}">
<!-- 右上 模式切换区 >>>>>>>>>>>>> -->
<v-card class="mb-1 d-flex align-center" :class="{'ml-2': !isMobile}" >
<!-- <div>{{constantObj.displayModes[displayModeIndex].text}}</div> -->
<v-btn v-for="(displayMode, index) in constantObj.displayModes" v-if="index != displayModeIndex" class="ml-1 my-2" style="flex: 1;" color="primary"
small outlined @click="doUiAction('changeDisplayMode', displayMode.value)">
<span>切换展示模式</span>
</v-btn>
</v-card>
<!-- <<<<<<<<<<<<< 右上 模式切换区 -->
<!-- 右下 属性编辑区 >>>>>>>>>>>>> -->
<v-card v-show="!readonly" class="pa-2" :class="{'ml-2': !isMobile}" style="height: 100%;" outlined>
<div class="font-weight-medium text-subtitle-2 text-subtitle-2 mb-3">
<v-icon size="18" class="mr-1">mdi-application-cog-outline</v-icon>
<span style="transform: translateY(2px); display: inline-block;">{{editType == 'node' ? '节点属性' : editType == 'line' ? '连线属性' : '属性面板'}}</span>
</div>
<div v-if="editType == 'node' || editType == 'line'" class="flow-edit-content">
<edit-node ref="nodeForm" v-if="editType == 'node'" :lf="logicFlow" :user="user" :group="group" :label="label" :workflow-form="workflowForm" :workflow-config="workflowConfig"
:display-mode="displayMode" @reflesh-workflow="setBusinessData"></edit-node>
<edit-line ref="lineForm" v-if="editType == 'line'" :lf="logicFlow" @reflesh-workflow="setBusinessData"></edit-line>
</div>
<div v-else class="text-center mt-8">
请选择节点或连接线~
</div>
</v-card>
<!-- <<<<<<<<<<<<< 右下 属性编辑区 -->
</div>
<!-- <<<<<<<<<<<<< 复杂右侧 -->
</template>
<!-- 中间 主内容编辑区 >>>>>>>>>>>>> -->
<v-card class="flow-detail pa-4" outlined>
<div id="flowContent" ref="flowContent"></div>
</v-card>
<!-- <<<<<<<<<<<<< 中间 主内容编辑区 -->
<!-- 右侧 属性编辑区 >>>>>>>>>>>>> -->
<v-card v-show="!readonly" :style="{'width': isMobile ? 'auto' : '300px'}" class="pa-4" :class="{'ml-2': !isMobile}" outlined>
<div class="font-weight-medium text-subtitle-2 text-subtitle-2 mb-3">
<v-icon size="18" class="mr-1">mdi-application-cog-outline</v-icon>
<span style="transform: translateY(2px); display: inline-block;">{{editType == 'node' ? '节点属性' : editType == 'line' ? '连线属性' : '属性面板'}}</span>
</div>
<div v-if="editType == 'node' || editType == 'line'" class="flow-edit-content">
<edit-node ref="nodeForm" v-if="editType == 'node'" :lf="logicFlow" :user="user" :group="group" :mode="mode" :tpl="tpl"></edit-node>
<edit-line ref="lineForm" v-if="editType == 'line'" :lf="logicFlow" :mode="mode"></edit-line>
</div>
<div v-else class="text-center mt-8">
请选择节点或连接线~
</div>
</v-card>
<!-- <<<<<<<<<<<<< 右侧 属性编辑区 -->
</v-card>
</template>
@@ -51,7 +120,7 @@ Vue.component("process-flow", {
vuetify: new Vuetify(),
name: 'process-flow',
props: {
data: {
workflowConfig: {
type: Object,
default: () => {
return {
@@ -72,7 +141,13 @@ Vue.component("process-flow", {
return []
}
},
tpl: {
label: {
type: Array,
default: () => {
return []
}
},
workflowForm: {
type: Array,
default: () => {
return []
@@ -86,52 +161,242 @@ Vue.component("process-flow", {
type: Boolean,
default: false
},
mode: {
type: String,
default: 'serial'
}
},
data: () => {
return {
constantObj: {
displayModes: [
{
text: '简易模式',
value: 'simple'
},
{
text: '复杂模式',
value: 'complex'
},
],
nodeColor: {
'start':'#88939F',
'userTask':'#FCAD22',
'approvalTask':'#FCAD22',
'noticeTask':'#3CB4B2',
'conditionTask':'#88939F',
'approvalTask':'#88939F',
}
},
menuList: [
{name: '起点', type: 'start', icon: 'mdi-ray-start'},
{name: '终点', type: 'end', icon: 'mdi-ray-end'},
{name: '审批节点', type: 'userTask', icon: 'mdi-account-details-outline'},
{name: '处理节点', type: 'receiveTask', icon: 'mdi-account-check-outline'},
{name: '审批节点', type: 'approvalTask', icon: 'mdi-account-check-outline'},
{name: '抄送节点', type: 'noticeTask', icon: 'mdi-account-check-outline'},
{name: '条件节点', type: 'conditionTask', icon: 'mdi-account-check-outline'},
],
logicFlow: null, // logicflow实例
// 是否加载完毕
loadEasyFlowFinish: false,
// 数据
editType: 'flow', //编辑的类型
lineTypeList: [
{text: '同意', value: 'agree'},
{text: '拒绝', value: 'deny'},
]
displayModeIndex: 1, // 'complex'、'simple'
displayMode: 'complex', // 'complex'、'simple'
mode: "mode",
isAddNodeMenuShown: false,
activeMenuIndex: -1,
};
},
watch: {
mode() {
this.logicFlow.clearData();
}
},
workflowConfig: {
handler: async function (val) {
// 初始化起点和终点
if(!val.nodeList.length && !val.lineList.length){
let startId = this.getUUID('start')
let endId = this.getUUID('end')
let lineId = this.getUUID('line')
this.workflowConfig = {
"nodeList":[
{"id":startId,"type":"CustomNode","x":400,"y":160,"properties":{"id":startId,"label":"起点","type":"start"},"text":{"x":400,"y":160,"value":"起点"}},
{"id":endId,"type":"CustomNode","x":400,"y":320,"properties":{"id":endId,"label":"终点","type":"end"},"text":{"x":400,"y":320,"value":"终点"}}
],
"lineList":[
{"id":lineId,"type":"polyline","sourceNodeId":startId,"targetNodeId":endId,
"startPoint":{"x":400,"y":180},"endPoint":{"x":400,"y":300},
"properties":{"from":startId,"to":endId,"label":"连线文本","type":"同意","id":lineId,"Remark":"","endpoint":"Dot"},
"text":{"x":400,"y":225,"value":"同意-连线文本"},"pointsList":[{"x":400,"y":180},{"x":400,"y":300}]}
]
}
}
},
deep: true
},
},
computed: {
isMobile() {
return window.innerWidth < 600;
},
},
created(){
},
mounted() {
},
methods: {
init() {
this.initLogicFlowInstance();
this.initLogicFlowCustomType();
this.initLogicFlowControl();
this.initLogicFlowMenu();
this.initLogicFlowEvent();
this.initLogicFlowData();
async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) {
case 'complexModeInit':
await this.initLogicFlowInstance();
await this.initLogicFlowCustomType();
await this.initLogicFlowControl();
await this.initLogicFlowMenu();
await this.initLogicFlowEvent();
await this.initLogicFlowData();
break;
case 'changeDisplayMode':
await this.changeDisplayMode(uiActionData);
break;
default:
console.error("[doUiAction] uiActionId not find", {uiActionId});
break;
}
},
showMenuShown(event){
this.activeMenuIndex = event?.target.dataset.menuIndex
},
menuShown(index){
return event?.target.dataset.itemIndex == this.activeMenuIndex || false
},
async addNodeBySimple({type, prevIndex = -1}){
if(prevIndex == -1) throw new Error("[addNodeBySimple] 出错!");
// 加一个节点和两条线
var _this = this
var prevNode = _this.workflowConfig.nodeList[prevIndex]
var nextNode = _this.workflowConfig.nodeList[prevIndex + 1]
var node = await initNodebySimple(type, prevNode)
var prevLine = initLinebySimple(prevNode, node)
var nextLine = initLinebySimple(node, nextNode)
_this.workflowConfig.nodeList.splice(prevIndex + 1, 0 ,node)
_this.workflowConfig.lineList.push(prevLine, nextLine)
// 去掉原有的连线
_this.workflowConfig.lineList = _this.workflowConfig.lineList.filter(line => !(line.sourceNodeId == prevNode.id && line.targetNodeId == nextNode.id))
this.$emit('reflesh-workflow-config', this.workflowConfig)
// 两种模式统一数据,待优化
this.initLogicFlowData()
function initNodebySimple(type = 'approvalTask', prevNode){
if(!prevNode) throw new Error("[initNodebySimple] 无前置节点!");
var Id = _this.getUUID(type)
var node = {
"id": Id,
"type": "CustomNode",
"x": prevNode.x - 150,
"y": prevNode.y + 40,
"properties": {
"id": Id,
"label": type == 'approvalTask' ? '审批节点' : '抄送节点',
"type": type
},
"text": {
"x": prevNode.x - 130,
"y": prevNode.y + 40,
"value": type == 'approvalTask' ? '审批节点' : '抄送节点',
}
}
return node
}
function initLinebySimple(prevNode, nextNode){
if(!prevNode || !nextNode) throw new Error("[initNodebySimple] 无前置或后置节点!");
var Id = _this.getUUID(type)
var line = {
"id": Id,
"type": "polyline",
"sourceNodeId": prevNode.id,
"targetNodeId": nextNode.id,
"startPoint": {
"x": prevNode.x + 10,
"y": prevNode.y + 20,
},
"endPoint": {
"x": nextNode.x + 10,
"y": nextNode.y - 20,
},
"properties": {
"from": prevNode.id,
"to": nextNode.id,
"label": "连线文本",
"type": "同意",
"id": Id,
"endpoint": "Dot",
},
"text": {
"x": (prevNode.x + nextNode.x) / 2,
"y": (prevNode.y + nextNode.y) / 2,
"value": "同意-连线文本"
}
}
return line
}
},
// 切换展示模式
changeDisplayMode(displayMode){
var changeAble = true
var changeText = ""
var lineList = this.workflowConfig.lineList
var nodeList = this.workflowConfig.nodeList
if(displayMode == 'simple'){
// 检查是否有多个开始节点或结束节点
if(nodeList.filter(n=>n.properties.type == 'start').length != 1 || nodeList.filter(n=>n.properties.type == 'end').length != 1){
changeAble = false
changeText = "只允许存在1个开始节点或结束节点"
}
// 检查是否有条件节点
if(changeAble && nodeList.filter(n=>n.properties.type == 'conditionTask').length){
changeAble = false
changeText = "存在条件节点"
}
// 检查是否有多线程:有两条线的sourceNodeId/targetNodeId一样
var hasSerial = _.some(lineList, (item, index) => {
return _.some(lineList.slice(0, index), prevItem => {
return prevItem.sourceNodeId === item.sourceNodeId || prevItem.targetNodeId === item.targetNodeId
})
})
if(changeAble && hasSerial){
changeAble = false
changeText = "存在多线程"
}
// 检查是否存在节点未连接
if(changeAble && lineList.length != nodeList.length - 1){
changeAble = false
changeText = "存在节点未连接"
}
}
if(changeAble){
this.displayMode = displayMode
this.displayModeIndex = this.constantObj.displayModes.findIndex(m=>m.value == displayMode)
this.editType = null
if(this.displayMode == 'complex'){
this.$nextTick(()=>{
this.doUiAction('complexModeInit')
})
}
}else{
window.vtoast.fail("当前结构不能切换到简易模式:" + changeText + "!");
}
},
/**
* 初始化logicFlow实例
*/
@@ -161,7 +426,9 @@ Vue.component("process-flow", {
stopScrollGraph: true,
edgeType: 'polyline',
plugins: [MiniMap, Menu, SelectionSelect, Control, Popup],
isSilentMode: this.readonly
isSilentMode: this.readonly,
width: 1100,
height: 700
});
},
@@ -189,7 +456,7 @@ Vue.component("process-flow", {
if (_this.currentNodeId === this.id) {
style.fill = "#4caf50";
} else {
const rawNode = _this.data.nodeList.find(o => o.id === this.id)
const rawNode = _this.workflowConfig.nodeList.find(o => o.id === this.id)
if (rawNode && rawNode.inPath) {
style.fill = "#d4ffd6";
}
@@ -250,6 +517,7 @@ Vue.component("process-flow", {
text: '删除连线',
callback(edge) {
logicFlow.deleteEdge(edge.id);
this.getBusinessData()
}
}
]
@@ -267,14 +535,13 @@ Vue.component("process-flow", {
// 添加节点
logicFlow.on('node:add', (e) => {
const {data} = e;
this.data.nodeList.push(data);
this.workflowConfig.nodeList.push(data);
this.addNode(data);
this.editNode(data);
});
// 选中节点
logicFlow.on("node:click", (e) => {
const {data} = e;
data.properties.userList = [];
this.editNode(data);
});
// 添加边
@@ -305,7 +572,7 @@ Vue.component("process-flow", {
Remark: '',
endpoint: 'Dot' // 线的类型
}
this.data.lineList.push(line);
this.workflowConfig.lineList.push(line);
logicFlow.updateText(id, line.label);
logicFlow.setProperties(id, line);
this.editLine(logicFlow.getEdgeDataById(id));
@@ -320,13 +587,14 @@ Vue.component("process-flow", {
}
this.editLine(data);
});
// 双击节点
// 双击节点 TODO:删除后更新数据
logicFlow.on("node:dbclick", (e) => {
const {id} = e.data;
logicFlow.deleteNode(id);
});
// 双击边
// 双击边 TODO:删除后更新数据
logicFlow.on("edge:dbclick", (e) => {
const {id} = e.data;
logicFlow.deleteEdge(id);
@@ -354,7 +622,7 @@ Vue.component("process-flow", {
// this.logicFlow.render({ "nodes":[], "edges":[] })
// this.logicFlow.render({"nodes":[{"id":"3","type":"CustomNode","x":380,"y":140,"properties":{},"text":{"x":380,"y":140,"value":"开始"}},{"id":"1","type":"CustomNode","x":380,"y":280,"properties":{},"text":{"x":380,"y":280,"value":"经理"}},{"id":"2","type":"CustomNode","x":380,"y":420,"properties":{},"text":{"x":380,"y":420,"value":"结束"}}],"edges":[{"id":"a2ed12a0-7548-4725-a8e6-290d565d66da","type":"polyline","sourceNodeId":"3","targetNodeId":"1","startPoint":{"x":380,"y":160},"endPoint":{"x":380,"y":260},"properties":{},"text":{"x":380,"y":190,"value":"开始"},"pointsList":[{"x":380,"y":160},{"x":380,"y":260}]},{"id":"135f3e3a-d8c5-4329-83d6-833512175ea4","type":"polyline","sourceNodeId":"2","targetNodeId":"1","startPoint":{"x":330,"y":420},"endPoint":{"x":330,"y":280},"properties":{},"text":{"x":265,"y":350,"value":"经理审核拒绝"},"pointsList":[{"x":330,"y":420},{"x":265,"y":420},{"x":265,"y":280},{"x":330,"y":280}]},{"id":"c4dbefa6-1ce0-4cef-babe-444329affea7","type":"polyline","sourceNodeId":"1","targetNodeId":"2","startPoint":{"x":430,"y":280},"endPoint":{"x":430,"y":420},"properties":{},"text":{"x":495,"y":350,"value":"经理审核通过"},"pointsList":[{"x":430,"y":280},{"x":495,"y":280},{"x":495,"y":420},{"x":430,"y":420}]},{"id":"6fb6a3b1-a8fc-4d22-b9f0-5692208118d5","type":"polyline","sourceNodeId":"1","targetNodeId":"2","startPoint":{"x":348,"y":300},"endPoint":{"x":348,"y":400},"properties":{},"text":{"x":348,"y":350,"value":"同意-连线文本"},"pointsList":[{"x":348,"y":300},{"x":348,"y":400}]}]})
// this.logicFlow.render({"nodes":[{"id":"start-c31f75a55c48","type":"CustomNode","x":100,"y":80,"properties":{"id":"start-c31f75a55c48","label":"起点","type":"start","assignType":"person","assignValue":["admin"],"lineTypeList":"同意"},"text":{"x":100,"y":80,"value":"起点"}},{"id":"end-72e945407d48","type":"CustomNode","x":540,"y":80,"properties":{"id":"end-72e945407d48","label":"终点","type":"end","assignType":"person","assignValue":["admin"],"lineTypeList":""},"text":{"x":540,"y":80,"value":"终点"}},{"id":"userTask-fa96d9f1f548","type":"CustomNode","x":320,"y":80,"properties":{"id":"userTask-fa96d9f1f548","label":"审批节点","type":"userTask","assignType":"person","assignValue":["admin"],"lineTypeList":"同意,拒绝"},"text":{"x":320,"y":80,"value":"审批节点"}}],"edges":[{"id":"line-8c746156fb48","type":"polyline","sourceNodeId":"start-c31f75a55c48","targetNodeId":"userTask-fa96d9f1f548","startPoint":{"x":150,"y":80},"endPoint":{"x":270,"y":80},"properties":{"from":"start-c31f75a55c48","to":"userTask-fa96d9f1f548","label":"同意-连线文本3","type":"同意","id":"line-8c746156fb48","Remark":"","endpoint":"Dot"},"text":{"x":210,"y":80,"value":"同意-连线文本3"},"pointsList":[{"x":150,"y":80},{"x":270,"y":80}]},{"id":"line-088a246e9248","type":"polyline","sourceNodeId":"userTask-fa96d9f1f548","targetNodeId":"end-72e945407d48","startPoint":{"x":370,"y":80},"endPoint":{"x":490,"y":80},"properties":{"from":"userTask-fa96d9f1f548","to":"end-72e945407d48","label":"同意-连线文本","type":"同意","id":"line-088a246e9248","Remark":"","endpoint":"Dot"},"text":{"x":430,"y":80,"value":"同意-连线文本"},"pointsList":[{"x":370,"y":80},{"x":490,"y":80}]}]});
this.logicFlow.render(this.parseBusinessDataTologicFlowData(this.data));
this.logicFlow.render(this.parseBusinessDataTologicFlowData(this.workflowConfig));
},
/**
@@ -387,9 +655,6 @@ Vue.component("process-flow", {
id,
label: funObj.name,
type: funObj.type,
assignType: 'person',
assignValue: ['<$ ctx.userInfo.userId $>'],
lineTypeList: funObj.type === 'start' ? '同意' : funObj.type === 'end' ? '' : '同意,拒绝',
}
}
this.logicFlow.dnd.startDrag(node);
@@ -400,7 +665,7 @@ Vue.component("process-flow", {
* @param node
*/
addNode(node) {
this.data.nodeList.push(node);
this.workflowConfig.nodeList.push(node);
},
/**
@@ -414,7 +679,7 @@ Vue.component("process-flow", {
this.editType = 'node';
// this.currentNodeId = node.id;
this.$nextTick(function () {
this.$refs.nodeForm.init(node);
this.$refs.nodeForm.doUiAction('init', node);
})
},
@@ -427,11 +692,10 @@ Vue.component("process-flow", {
return
}
let fromNodeData = this.logicFlow.getNodeDataById(line.sourceNodeId).properties;
const lineTypeList = fromNodeData.lineTypeList ? fromNodeData.lineTypeList.split(',') : [];
this.editType = 'line';
// this.currentLineId = line.id;
this.$nextTick(function () {
this.$refs.lineForm.init(line, lineTypeList);
this.$refs.lineForm.init(line);
})
},
@@ -443,20 +707,29 @@ Vue.component("process-flow", {
return this.parseLogicFlowDataToBusinessData();
},
/**
* 设置流程图业务数据(组件外使用)
*/
setBusinessData(){
this.workflowConfig = this.parseLogicFlowDataToBusinessData();
},
/**
* 将流程设计器数据转换为业务数据
*/
parseLogicFlowDataToBusinessData() {
const logicFlowData = this.getOrderedGraphData();
return {
nodeList: logicFlowData.nodes.map(node => ({
...node.properties,
origin: node
})),
lineList: logicFlowData.edges.map(line => ({
...line.properties,
origin: line
}))
nodeList: logicFlowData.nodes.map(node => node),
lineList: logicFlowData.edges.map(line => line)
// nodeList: logicFlowData.nodes.map(node => ({
// ...node.properties,
// origin: node
// })),
// lineList: logicFlowData.edges.map(line => ({
// ...line.properties,
// origin: line
// }))
}
},
@@ -490,8 +763,8 @@ Vue.component("process-flow", {
*/
parseBusinessDataTologicFlowData() {
return {
nodes: this.data.nodeList.map(node => node.origin).filter(node => node != null),
edges: this.data.lineList.map(line => line.origin).filter(line => line != null)
nodes: this.workflowConfig.nodeList.map(node => node).filter(node => node != null),
edges: this.workflowConfig.lineList.map(line => line).filter(line => line != null)
}
}
}
@@ -503,9 +776,8 @@ Vue.component("process-flow", {
display: flex;
width: 100%;
/* height: calc(100vh - 260px); */
height: 500px;
color: #606266;
margin-bottom: 20px;
height: 700px;
margin-bottom: 10px;
}
.lf-element-text {
@@ -519,8 +791,8 @@ Vue.component("process-flow", {
}
#flowContent {
width: 100%;
height: 100%;
/* width: 100%; */
height: 650px;
position: relative;
background-image: url("/<$ ctx.app.config.appId $>/public/images/point.png");
background-repeat: repeat;
@@ -528,13 +800,6 @@ Vue.component("process-flow", {
cursor: grab;
}
.item {
position: absolute;
width: 60px;
height: 90px;
border: 1px solid #007AFF;
}
.menu-item {
padding: 8px 10px;
background: #f5f8fa;
@@ -542,6 +807,7 @@ Vue.component("process-flow", {
cursor: move;
border: 1px dashed #f5f8fa;
border-radius: 3px;
white-space: nowrap;
}
.menu-item:hover {
@@ -563,5 +829,60 @@ Vue.component("process-flow", {
width: 10px;
height: 10px;
}
.divider-vertical{
display: flex;
justify-content: center;
}
.divider-vertical::before{
content: '';
display: block;
width: 2px;
height: 60px;
background: #dbdbdb;
}
.arrow{
width: 0px;
height: 6px;
border: 6px solid;
border-color: #dbdbdb transparent transparent transparent;
justify-self: center;
}
.add-btn-box{
position: absolute;
width: 22px;
height: 22px;
background-color: #A0B5C8;
border-radius: 50%;
align-self: center;
margin-bottom: 10px;
margin-right: 7px;
}
.add-btn-box::before{
content: '';
position: absolute;
display: inline-block;
width: 2px;
height: 15px;
left: 10px;
top: 4px;
background-color: #fff;
}
.add-btn-box::after{
content: '';
position: absolute;
display: inline-block;
height: 2px;
width: 14px;
top: 10px;
left: 4px;
background-color: #fff;
}
.add-node-box{
width: 60px;
height: 40px;
}
/* .v-list-item:hover{
background-color: red;
} */
</style>
+2 -2
View File
@@ -76,8 +76,8 @@
<style scoped>
.tpl-form-design-container {
width: 100%;
height: 500px;
max-height: 500px;
height: 650px;
max-height: 700px;
overflow-y: auto;
}
@media (max-width: 500px) {
+69 -67
View File
@@ -1,79 +1,75 @@
<template id="workflow-basic-info">
<v-row>
<v-col cols="12" sm="12" md="12" xl="12">
<span class="jh-input-label">流程名<span class="red--text text--accent-2 ml-1">*必填</span></span>
<v-text-field
class="jh-v-input mr-2" dense filled single-line color="success"
v-model="basicInfo['workflowName']" :rules="validationRules.requireRules">
</v-text-field>
</v-col>
<v-col cols="12" sm="12" md="12" xl="12">
<span class="jh-input-label">模板图标</span>
<v-menu
:nudge-right="40"
transition="scale-transition"
offset-y
min-width="auto"
max-width="20%"
max-height="60%"
class="block"
>
<template v-slot:activator="{ on, attrs }">
<div class="workflow-basic-info-container">
<v-row>
<v-col cols="12" sm="12" md="12" xl="12">
<span class="jh-input-label">流程名<span class="red--text text--accent-2 ml-1">*必填</span></span>
<v-text-field
class="jh-v-input"
dense
single-line
filled
v-model="basicInfo['taskTemplateIcon']"
v-bind="attrs"
v-on="on"
>
<template #prepend-inner>
<v-icon size="18" class="mr-1" color="green">mdi-{{basicInfo['taskTemplateIcon']}}</v-icon>
</template>
class="jh-v-input mr-2" dense filled single-line color="success"
v-model="workflowInfo['workflowName']" :rules="validationRules.requireRules">
</v-text-field>
</template>
<v-card>
<div class="d-flex flex-wrap">
<div
v-for="icon in materialDesignIcons"
class="item-icon pa-1"
@click="setIcon(icon)"
>
<v-icon size="18" class="mr-1" :color="basicInfo['taskTemplateIcon'] == icon ? 'green' : ''">mdi-{{icon}}</v-icon>
</v-col>
<v-col cols="12" sm="12" md="12" xl="12">
<span class="jh-input-label">模板图标</span>
<v-menu
:nudge-right="40"
transition="scale-transition"
offset-y
min-width="auto"
max-width="20%"
max-height="60%"
class="block"
>
<template v-slot:activator="{ on, attrs }">
<v-text-field
class="jh-v-input"
dense
single-line
filled
v-model="workflowInfo['taskTemplateIcon']"
v-bind="attrs"
v-on="on"
>
<template #prepend-inner>
<v-icon size="18" class="mr-1" color="green">mdi-{{workflowInfo['taskTemplateIcon']}}</v-icon>
</template>
</v-text-field>
</template>
<v-card>
<div class="d-flex flex-wrap">
<div
v-for="icon in materialDesignIcons"
class="item-icon pa-1"
@click="setIcon(icon)"
>
<v-icon size="18" class="mr-1" :color="workflowInfo['taskTemplateIcon'] == icon ? 'green' : ''">mdi-{{icon}}</v-icon>
</div>
</div>
</div>
</v-card>
</v-menu>
</v-col>
</v-card>
</v-menu>
</v-col>
<v-col cols="12" sm="12" md="12" xl="12" class="pb-1">
<span class="jh-input-label">模板分组(支持输入自定义分组)</span>
<v-combobox v-model="basicInfo['taskTemplateGroup']" :items="constantObj.taskTemplateGroup" class="jh-v-input" dense
filled small hide-actions hide-controls hide-details>
</v-combobox>
</v-col>
<v-col cols="12" sm="12" md="12" xl="12">
<span class="jh-input-label">备注</span>
<v-text-field
class="jh-v-input mr-2" dense filled single-line color="success"
v-model="basicInfo['workflowRemark']">
</v-text-field>
</v-col>
<v-col cols="12" sm="12" md="12" xl="12">
<span class="jh-input-label">审批模式</span>
<v-select
class="jh-v-input mr-2" dense filled single-line color="success"
v-model="basicInfo['mode']" :items="constantObj.modeList" />
</v-col>
</v-row>
<v-col cols="12" sm="12" md="12" xl="12" class="pb-1">
<span class="jh-input-label">模板分组(支持输入自定义分组)</span>
<v-combobox v-model="workflowInfo['taskTemplateGroup']" :items="constantObj.taskTemplateGroup" class="jh-v-input" dense
filled small hide-actions hide-controls hide-details>
</v-combobox>
</v-col>
<v-col cols="12" sm="12" md="12" xl="12">
<span class="jh-input-label">备注</span>
<v-text-field
class="jh-v-input mr-2" dense filled single-line color="success"
v-model="workflowInfo['workflowRemark']">
</v-text-field>
</v-col>
</v-row>
</div>
</template>
<script type="module">
Vue.component("workflow-basic-info", {
template: '#workflow-basic-info',
// vuetify: new Vuetify(),
props: {
basicInfo: {
workflowInfo: {
type: Object,
default: () => {
return {
@@ -125,10 +121,16 @@ Vue.component("workflow-basic-info", {
}
},
setIcon(icon){
this.$set(this.basicInfo, 'taskTemplateIcon', icon)
this.$set(this.workflowInfo, 'taskTemplateIcon', icon)
}
}
})
</script>
<style scoped></style>
<style scoped>
.workflow-basic-info-container {
height: 650px;
max-height: 700px;
}
</style>
+51 -40
View File
@@ -42,20 +42,18 @@
<v-stepper-items flat outlined>
<v-stepper-content step="1">
<v-card flat>
<v-card-text>
<v-card-text class="pa-0">
<div class="mt-1">
{{formObj.basicInfo}}
<!-- <div class="text-subtitle-2 mb-2">基础信息</div> -->
<workflow-basic-info :basic-info="formObj.basicInfo"></workflow-basic-info>
<workflow-basic-info :workflow-info="formObj.workflowInfo"></workflow-basic-info>
</div>
</v-card-text>
</v-card>
</v-stepper-content>
<v-stepper-content step="2">
<v-card flat>
<v-card-text>
<v-card-text class="pa-0">
<div class="mt-1">
{{formObj.workflowForm}}
<!-- <div class="text-subtitle-2 mb-2">表单设置</div> -->
<tpl-form-design :form="formObj.workflowForm" v-if="!loading"></tpl-form-design>
</div>
@@ -64,16 +62,17 @@
</v-stepper-content>
<v-stepper-content step="3">
<v-card flat>
<v-card-text>
<v-card-text class="pa-0">
<div class="mt-1">
<!-- <div class="text-subtitle-2 mb-2">流程设置</div> -->
<process-flow
ref="processFlow"
:data="formObj.workflowConfig"
:workflow-config="formObj.workflowConfig"
:user="constantObj.userList"
:group="constantObj.groupList"
:tpl="constantObj.workflowFormList"
:mode="formObj.mode">
:label="constantObj.labelList"
:workflow-form="formObj.workflowForm"
@reflesh-workflow-config="refleshWorkflowConfig">
</process-flow>
</div>
</v-card-text>
@@ -83,21 +82,6 @@
</v-stepper>
</template>
<!-- <v-card flat>
<v-card-text>
<div class="mt-8">
<div class="text-subtitle-2 mb-2">流程设置</div>
<process-flow
ref="processFlow"
:data="formObj.workflowConfig"
:user="constantObj.userList"
:group="constantObj.groupList"
:tpl="constantObj.workflowFormList"
:mode="formObj.mode">
</process-flow>
</div>
</v-card-text>
</v-card> -->
</v-form>
</div>
@@ -135,6 +119,7 @@ Vue.component("workflow-editor-drawer", {
userList: [],
groupList: [],
workflowFormList: [],
labelList: []
},
formObj: {},
submitUiActionId: 'createItem',
@@ -154,23 +139,24 @@ Vue.component("workflow-editor-drawer", {
}
},
async created() {
this.doUiAction('getUserGroupData');
this.doUiAction('getConstantData');
},
methods: {
async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) {
case 'open':
await this.prepareFormObj(uiActionData);
await this.buildConstantWorkflowFormList();
// await this.buildConstantWorkflowFormList();
await this.buildConstantWorkflowConfig();
await this.openDrawer();
break;
case 'close':
await this.closeDrawer();
break;
case 'getUserGroupData':
case 'getConstantData':
await this.getUserList();
await this.getGroupList();
await this.getLabelList();
break;
case 'createItem':
await this.confirmCreateItemDialog();
@@ -197,18 +183,16 @@ Vue.component("workflow-editor-drawer", {
if(item) {
this.submitUiActionId = 'updateItem';
let formObj = _.clone(item);
formObj.basicInfo = {
formObj.workflowInfo = {
workflowName: item.workflowName,
workflowRemark: item.workflowRemark,
mode: item.mode,
...JSON.parse(item.workflowInfo),
}
formObj.workflowConfig = formObj.workflowConfig ? JSON.parse(formObj.workflowConfig) : null;
formObj.workflowForm = formObj.workflowForm ? (typeof formObj.workflowForm == 'string'? JSON.parse(formObj.workflowForm): formObj.workflowForm) : [];
formObj.mode = formObj.workflowConfig.mode || 'serial';
this.formObj = formObj;
} else {
this.submitUiActionId = 'createItem';
this.formObj = {basicInfo: {}, workflowForm: [], workflowConfig: {lineList: [], nodeList: []}, mode: 'serial'};
this.formObj = {workflowInfo: {}, workflowForm: [], workflowConfig: {lineList: [], nodeList: []}};
}
this.$refs.form.resetValidation();
this.loading = false;
@@ -238,7 +222,7 @@ Vue.component("workflow-editor-drawer", {
}
})).data.appData.resultData;
this.constantObj.userList = rows.map(e => {
return {text: e.username, value: e.userId, userId: e.userId}
return {username: e.username, userId: e.userId, userId: e.userId}
})
},
@@ -257,9 +241,25 @@ Vue.component("workflow-editor-drawer", {
}
})).data.appData.resultData;
this.constantObj.groupList = rows.map(e => {
return {text: e.groupName, value: e.groupId}
return {groupName: e.groupName, groupId: e.groupId}
});
},
/**
* 获取label数据
*/
async getLabelList() {
const {rows} = (await window.jianghuAxios({
data: {
appData: {
pageId: 'allPage',
actionId: 'selectLabelList',
actionData: {},
where: {},
}
}
})).data.appData.resultData;
this.constantObj.labelList = rows;
},
// -- <<<<<<<<<<<<< 获取数据 --------------------
// -- constantObj 数据构建 >>>>>>>>>>> ---------------
buildConstantWorkflowFormList() {
@@ -275,7 +275,7 @@ Vue.component("workflow-editor-drawer", {
buildConstantWorkflowConfig() {
if (!this.formObj.workflowConfig) return;
this.$refs.processFlow.init();
this.$refs.processFlow.doUiAction('complexModeInit');
},
// -- <<<<<<<<<<<<< constantObj 数据构建 ---------------
// ---- 数据准备 >>>>>>>>>>>>>> ---------
@@ -305,11 +305,20 @@ Vue.component("workflow-editor-drawer", {
this.loading = false;
}, 300)
},
// TODO: 检验数据
prepareValidate(){
var submitAble = false
// 判断info的数据
// 判断form的数据
// 判断流程图的数据
// 只允许在第一个节点设置条件节点
// 不允许节点孤立
},
prepareFormSubmitData() {
const {id, workflowId, workflowName, workflowRemark, workflowCategory, mode, workflowForm} = this.formObj;
const {id, workflowId, workflowInfo, workflowForm} = this.formObj;
const { workflowName, ...data } = workflowInfo
const workflowConfig = this.$refs.processFlow.getBusinessData();
workflowConfig.mode = mode
// TODO: 清除不存在的用户
workflowConfig.nodeList.forEach(node => {
if (node.type === 'userTask') {
node.assignValue = node.assignValue || [];
@@ -319,8 +328,7 @@ Vue.component("workflow-editor-drawer", {
});
this.formSubmitData = {
workflowName,
workflowRemark,
workflowCategory,
workflowInfo: data? JSON.stringify(data) : null,
workflowId: workflowId || null,
workflowConfig: workflowConfig ? JSON.stringify(workflowConfig) : null,
workflowForm: workflowForm ? JSON.stringify(workflowForm) : null,
@@ -375,6 +383,9 @@ Vue.component("workflow-editor-drawer", {
this.$emit('success');
},
// ---------- <<<<<<<<<< 修改流程 updateItem --------
refleshWorkflowConfig(data){
this.$set(this.formObj, 'workflowConfig', _.clone(data))
}
}
})
</script>