| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <template>
- <div class="add-node-btn-box">
- <div class="add-node-btn">
- <a-popover v-model:visible="visible" placement="rightTop" trigger="click" :width="270">
- <template #content>
- <div class="add-node-popover-body">
- <ul style="height: 80px">
- <li>
- <a-button shape="circle" size="large" @click="addType('userTask')">
- <template #icon>
- <user-outlined style="color: #ff943e; font-size: 18px"/>
- </template>
- </a-button>
- <p>审批节点</p>
- </li>
- <li>
- <a-button shape="circle" size="large" @click="addType('serviceTask')">
- <template #icon>
- <send-outlined style="color: #3296fa; font-size: 18px"/>
- </template>
- </a-button>
- <p>抄送节点</p>
- </li>
- <li v-if="addExclusiveGateway">
- <a-button shape="circle" size="large" @click="addType('exclusiveGateway')">
- <template #icon>
- <share-alt-outlined style="color: #15bc83; font-size: 18px"/>
- </template>
- </a-button>
- <p>条件分支</p>
- </li>
- <li v-if="addParallelGateway">
- <a-button shape="circle" size="large" @click="addType('parallelGateway')">
- <template #icon>
- <partition-outlined :rotate="180" style="color: #ac28f5; font-size: 18px"/>
- </template>
- </a-button>
- <p>并行分支</p>
- </li>
- </ul>
- </div>
- </template>
- <a-button type="primary" shape="circle">
- <!-- @click="addNodeButton" -->
- <template #icon>
- <plus-outlined/>
- </template>
- </a-button>
- </a-popover>
- </div>
- </div>
- </template>
- <script>
- import {cloneDeep} from 'lodash-es'
- import config from '@/components/XnWorkflow/nodes/config/config'
- const NodeTitleMap = {
- userTask: '审核人',
- serviceTask: '抄送人',
- exclusiveGateway: '条件路由',
- parallelGateway: '并行路由'
- }
- export default {
- props: {
- modelValue: {
- type: Object, default: () => {
- }
- },
- parentData: {
- type: Object, default: () => {
- }
- },
- nodeItem: {
- type: Object, default: () => {
- }
- }
- },
- emits: ['update:modelValue'],
- data() {
- return {
- visible: false,
- addExclusiveGateway: true,
- addParallelGateway: true
- }
- },
- mounted() {
- },
- methods: {
- addNodeButton() {
- // 他的上级是条件分支或并行分支,将其不在添加 // 控制节点下面
- if (!this.parentData) {
- this.disabledChildren()
- } else {
- if (this.parentData.type === 'exclusiveGateway' || this.parentData.type === 'parallelGateway') {
- this.addExclusiveGateway = false
- this.addParallelGateway = false
- }
- }
- },
- disabledChildren() {
- // 如果下级是条件分支或并行分支,将其不在添加 // 控制节点上面
- if (this.modelValue && this.modelValue.type) {
- if (this.modelValue.type === 'exclusiveGateway' || this.modelValue.type === 'parallelGateway') {
- this.addExclusiveGateway = false
- this.addParallelGateway = false
- }
- }
- // 不管其他的,如果是条件分支的项,那么他的下面无法添加条件
- if (this.nodeItem) {
- this.addExclusiveGateway = false
- }
- },
- getBaseCondition(type, title) {
- const condition = cloneDeep(config.nodeModel.node)
- condition.id = this.$TOOL.snowyUuid()
- condition.type = type
- condition.title = title
- return condition
- },
- addType(type) {
- const nodeModel = this.getBaseCondition(type, NodeTitleMap[type]) || {}
- nodeModel.childNode = this.modelValue
- if (type === 'userTask') {
- // 创建 configInfo
- const configInfo = cloneDeep(config.nodeConfigInfo.userTaskConfigInfo)
- nodeModel.properties.configInfo = configInfo
- } else if (type === 'exclusiveGateway') {
- nodeModel.dataLegal = true
- // 创建分支节点1
- const condition1 = this.getBaseCondition('sequenceFlow', '条件1')
- // 创建分支节点1 configInfo
- const condition1ConfigInfo1 = cloneDeep(config.nodeConfigInfo.conditionConfigInfo)
- condition1ConfigInfo1.priorityLevel = 1
- condition1.properties.configInfo = condition1ConfigInfo1
- // 创建分支节点2
- const condition2 = this.getBaseCondition('sequenceFlow', '条件2')
- // 创建分支节点2 configInfo
- const condition1ConfigInfo2 = cloneDeep(config.nodeConfigInfo.conditionConfigInfo)
- condition1ConfigInfo2.priorityLevel = 2
- condition2.properties.configInfo = condition1ConfigInfo2
- // 装进去
- nodeModel.conditionNodeList.push(condition1)
- nodeModel.conditionNodeList.push(condition2)
- } else if (type === 'parallelGateway') {
- // 创建主节点
- nodeModel.dataLegal = true
- // 创建分支节点1
- const condition1 = this.getBaseCondition('userTask', '审批人1')
- condition1.properties.configInfo = cloneDeep(config.nodeConfigInfo.userTaskConfigInfo)
- condition1.dataLegal = true
- // 创建分支节点2
- const condition2 = this.getBaseCondition('userTask', '审批人2')
- condition2.properties.configInfo = cloneDeep(config.nodeConfigInfo.userTaskConfigInfo)
- condition2.dataLegal = true
- // 装进去
- nodeModel.conditionNodeList.push(condition1)
- nodeModel.conditionNodeList.push(condition2)
- }
- this.visible = false
- this.$emit('update:modelValue', nodeModel)
- }
- }
- }
- </script>
|