Files
workflow/app/view/component/flow/editNode.html
T

488 lines
16 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template id="edit-node">
<v-form v-model="isFormValid" ref="dataForm" lazy-validation>
<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" 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" :disabled="node.type == 'start' || node.type == 'end'"></v-text-field>
</v-col>
<!-- 审批节点 -->
<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="constantObj.approverTypes"
dense filled single-line
item-text="text"
item-value="value"
class="jh-v-input"
label="审批人类型"
v-model="node.approverType"
@change="clearUser"
></v-select>
</v-col>
<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"
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="constantObj.approvalTypes"
dense filled single-line
item-text="text"
item-value="value"
class="jh-v-input"
label="多人审批方式"
v-model="node.approvalType"
></v-select>
</v-col>
</template>
<!-- 抄送节点 -->
<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>
<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"
persistent="true"
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"
@change="changeExpress($event, item)"></v-select>
</template>
<template v-slot:item.option-list="{ item }">
<div v-if="item.type == 'number'">
<div v-if="item.express == 'between'" 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-text-field v-else class="jh-v-input" dense filled v-model="item.option"></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>
</v-form>
</template>
<script>
Vue.component("edit-node", {
template: '#edit-node',
vuetify: new Vuetify(),
name: 'editNode',
props: {
lf: {
type: Object,
default: null
},
user: {
type: Array,
default: () => {
return []
}
},
group: {
type: Array,
default: () => {
return []
}
},
label: {
type: Array,
default: () => {
return []
}
},
workflowConfig: {
type: Object,
default: () => {
return {
nodeList: [],
lineList: []
}
}
},
workflowForm: {
type: Array,
default: () => {
return []
}
},
displayMode: {
type: String,
default: "complex"
},
},
data() {
return {
isFormValid: true,
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: 'approvalTask', Text: '审核节点' },
{ Value: 'conditionTask', Text: '条件节点' },
{ Value: 'noticeTask', 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: '<', value1: 'less' }, { text: '小于等于', value: '<=', value1: 'lessEqual'}, { text: '等于', value: '==', value1: 'equal'},
{ text: '大于等于', value: '>=', value1: 'moreEqual'}, { text: '大于', value: '>', value1: 'more'}, { text: '介于(a≤x≤b)', value: 'between'},]
}
},
isConditionGroupShown: false
}
},
watch: {
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
},
'node.conditionList': {
handler: async function (val) {
this.$forceUpdate()
this.$emit('reflesh-workflow')
},
deep: true
}
},
computed: {
isMobile() {
return window.innerWidth < 600;
},
prioritys(){
const { nodeList } = this.workflowConfig
var num = nodeList.filter(n=>n.properties.type == 'conditionTask').length
return [
{ text: '默认条件', priority: -1 },
..._.times(num - 1, i => {
return { text: `优先级${i + 1}`, priority: i + 1 }
})
]
},
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
item.option = null
},
changeExpress(express, item){
if(item.type == 'number' && express == 'between'){
this.$set(item, 'option', { begin: null, end: null})
}else{
this.$set(item, 'option', null)
}
this.$forceUpdate()
console.log('changeExpress', item, express);
},
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.userId
}
})
}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;
}
.add-btn {
width: 100%;
margin-top: 5px;
padding: 5px;
}
</style>