513 lines
17 KiB
HTML
513 lines
17 KiB
HTML
<template id="edit-node">
|
||
<v-form 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-card elevation="0" outlined>
|
||
<v-form ref="conditionForm" lazy-validation>
|
||
<v-data-table
|
||
:headers="headers"
|
||
:items="node.conditionList || []"
|
||
v-model="node.conditionList"
|
||
:items-per-page="15"
|
||
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)" :rules="validationRules.requireRules"></v-select>
|
||
</template>
|
||
<template v-slot:item.express="{ item, index }">
|
||
<v-select :items="constantObj.operators[item.type]" dense filled single-line class="jh-v-input" v-model="item.express"
|
||
@change="changeExpress($event, item, index)" :rules="validationRules.requireRules"></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" type="number" dense filled v-model="item.option.begin" :rules="validationRules.requireRules"></v-text-field>
|
||
<span> 至 </span>
|
||
<v-text-field class="jh-v-input" type="number" dense filled v-model="item.option.end" :rules="validationRules.requireRules"></v-text-field>
|
||
</div>
|
||
<v-text-field v-else class="jh-v-input" type="number" dense filled v-model="item.option" :rules="validationRules.requireRules"></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 :rules="validationRules.arrayRequireRules"></v-select>
|
||
</template>
|
||
</v-data-table>
|
||
</v-form>
|
||
</v-card>
|
||
<v-btn class="add-btn" @click="doUiAction('addCondition')" v-show="(node.conditionList?.length || 0) < this.conditions.length">添加条件</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 {
|
||
validationRules: {
|
||
requireRules: [
|
||
v => !!v || '必填',
|
||
],
|
||
arrayRequireRules: [
|
||
v => (v && !!v.length) || '必填',
|
||
],
|
||
},
|
||
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.$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 }
|
||
})
|
||
]
|
||
},
|
||
selectedCondition(){
|
||
return this.node.conditionList?.map(item => item.id).filter(item => item) || []
|
||
},
|
||
conditions(){
|
||
var conditions = [
|
||
{
|
||
id: 'single-applyPerson',
|
||
name: '申请人',
|
||
type: 'single',
|
||
operator: [
|
||
{
|
||
text: '包含'
|
||
}
|
||
],
|
||
optionList: this.user,
|
||
disabled: this.selectedCondition.includes('single-applyPerson')
|
||
},
|
||
...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,
|
||
disabled: this.selectedCondition.includes(i.id)
|
||
}
|
||
})
|
||
]
|
||
|
||
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.conditionValidate();
|
||
await this.closeConditionGroupDialog();
|
||
break;
|
||
default:
|
||
console.error("[doUiAction] uiActionId not find", {uiActionId});
|
||
break;
|
||
}
|
||
},
|
||
init(node) {
|
||
this.node = node.properties;
|
||
},
|
||
async clearUser(){
|
||
this.$set(this.node, 'user', null)
|
||
await this.$emit('reflesh-workflow')
|
||
},
|
||
addCondition(){
|
||
if(this.node?.conditionList && this.node.conditionList.length > 0){
|
||
this.$set(this.node, 'conditionList', [...this.node.conditionList, {
|
||
id: null,
|
||
express: null,
|
||
option: null
|
||
}])
|
||
}else{
|
||
this.$set(this.node, 'conditionList', [{
|
||
id: null,
|
||
express: null,
|
||
option: null
|
||
}])
|
||
}
|
||
},
|
||
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 = null
|
||
},
|
||
changeExpress(express, item, index){
|
||
if (item.type === 'number' && express === 'between') {
|
||
this.node.conditionList[index].option = { begin: null, end: null };
|
||
} else {
|
||
this.node.conditionList[index].option = null;
|
||
}
|
||
},
|
||
async conditionValidate(){
|
||
if (await this.$refs.conditionForm.validate()) {
|
||
return true;
|
||
}
|
||
await window.vtoast.fail("请完善信息!");
|
||
throw new Error("请完善信息!")
|
||
},
|
||
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>
|