|
@@ -1,35 +1,185 @@
|
|
-<script lang="jsx">
|
|
|
|
|
|
+<template>
|
|
|
|
+ <!-- `branch-wrap--${nodeConfig.local_status}`-->
|
|
|
|
+ <div class="branch-wrap" :class="[disabled ? 'branch-wrap--disabled' : '']">
|
|
|
|
+ <div class="branch-box-wrap">
|
|
|
|
+ <div class="branch-box">
|
|
|
|
+ <el-button class="add-branch" type="success" plain round @click="addTerm"> 添加条件 </el-button>
|
|
|
|
+ <div v-for="(item, index) in nodeConfig.conditionNodes" :key="index" class="col-box">
|
|
|
|
+ <div class="condition-node">
|
|
|
|
+ <div class="condition-node-box">
|
|
|
|
+ <div :class="['auto-judge', `auto-judge--${item.local_status}`]" @click="show(index)">
|
|
|
|
+ <!-- 不是第一个 也不是 最后一个-->
|
|
|
|
+ <div v-if="index != 0 && index != nodeConfig.conditionNodes.length - 1" class="sort-left" @click.stop="arrTransfer(index, -1)">
|
|
|
|
+ <el-icon><ArrowLeft /></el-icon>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="title">
|
|
|
|
+ <span class="node-title" :class="[index === nodeConfig.conditionNodes.length - 1 ? 'last-child-title' : '']">{{
|
|
|
|
+ index === nodeConfig.conditionNodes.length - 1 ? '默认条件' : item.nodeName
|
|
|
|
+ }}</span>
|
|
|
|
+ <span class="priority-title">优先级{{ item.priorityLevel }}</span>
|
|
|
|
+ <el-icon v-if="index != nodeConfig.conditionNodes.length - 1" class="close" @click.stop="delTerm(index)">
|
|
|
|
+ <Close />
|
|
|
|
+ </el-icon>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="content" :class="[index === nodeConfig.conditionNodes.length - 1 ? 'last-child-title' : '']" style="width: 200px">
|
|
|
|
+ <el-tooltip v-if="toText(nodeConfig, index)" effect="dark" placement="top">
|
|
|
|
+ <div class="text-overflow_ellipsis_line_2" v-html="toText(nodeConfig, index)" />
|
|
|
|
+ <template #content>
|
|
|
|
+ <div v-html="toText(nodeConfig, index)" />
|
|
|
|
+ </template>
|
|
|
|
+ </el-tooltip>
|
|
|
|
+ <span v-else class="placeholder"> 请设置条件 </span>
|
|
|
|
+ </div>
|
|
|
|
+ <!-- 最后一个没有,长度大于2倒数第二个没有 -->
|
|
|
|
+ <div
|
|
|
|
+ v-if="
|
|
|
|
+ !(nodeConfig.conditionNodes.length == 2 && (index === nodeConfig.conditionNodes.length - 1 || index === 0)) &&
|
|
|
|
+ !(
|
|
|
|
+ (nodeConfig.conditionNodes.length > 2 && index === nodeConfig.conditionNodes.length - 1) ||
|
|
|
|
+ index === nodeConfig.conditionNodes.length - 2
|
|
|
|
+ )
|
|
|
|
+ "
|
|
|
|
+ class="sort-right"
|
|
|
|
+ @click.stop="arrTransfer(index)"
|
|
|
|
+ >
|
|
|
|
+ <el-icon><ArrowRight /></el-icon>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <add-node v-model="item.childNode" :disabled="disabled"></add-node>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <slot v-if="item.childNode" :node="item"></slot>
|
|
|
|
+ <div v-if="index == 0" class="top-left-cover-line"></div>
|
|
|
|
+ <div v-if="index == 0" class="bottom-left-cover-line"></div>
|
|
|
|
+ <div v-if="index == nodeConfig.conditionNodes.length - 1" class="top-right-cover-line"></div>
|
|
|
|
+ <div v-if="index == nodeConfig.conditionNodes.length - 1" class="bottom-right-cover-line"></div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <add-node v-model="nodeConfig.childNode" :disabled="disabled"></add-node>
|
|
|
|
+ </div>
|
|
|
|
+ <el-drawer v-model="drawer" title="条件设置" destroy-on-close append-to-body :size="600">
|
|
|
|
+ <template #header>
|
|
|
|
+ <div class="node-wrap-drawer__title">
|
|
|
|
+ <label v-if="!isEditTitle" @click="editTitle">
|
|
|
|
+ {{ form.nodeName }}<el-icon class="node-wrap-drawer__title-edit"><Edit /></el-icon>
|
|
|
|
+ <!-- <div @click="rmConditionGroup(conditionGroup)">-->
|
|
|
|
+ <!-- -->
|
|
|
|
+ <!-- </div>-->
|
|
|
|
+ </label>
|
|
|
|
+ <el-input
|
|
|
|
+ v-if="isEditTitle"
|
|
|
|
+ ref="nodeTitle"
|
|
|
|
+ v-model="form.nodeName"
|
|
|
|
+ clearable
|
|
|
|
+ class="w-40"
|
|
|
|
+ @blur="saveTitle"
|
|
|
|
+ @keyup.enter="saveTitle"
|
|
|
|
+ ></el-input>
|
|
|
|
+ <el-input v-model="form.nodeKey" clearable class="w-40 pl-1.5" placeholder="请填写nodeKey"></el-input>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ <el-container>
|
|
|
|
+ <el-main style="padding: 0 0 20px 0">
|
|
|
|
+ <div class="top-tips">满足以下条件时进入当前分支</div>
|
|
|
|
+ <template v-for="(conditionGroup, conditionGroupIdx) in form.conditionList" :key="conditionGroupIdx">
|
|
|
|
+ <div v-if="conditionGroupIdx != 0" class="or-branch-link-tip">或满足</div>
|
|
|
|
+ <div class="condition-group-editor">
|
|
|
|
+ <div class="header">
|
|
|
|
+ <span>条件组 {{ conditionGroupIdx + 1 }}</span>
|
|
|
|
+ <div @click="deleteConditionGroup(conditionGroupIdx)">
|
|
|
|
+ <el-icon class="branch-delete-icon"><Delete /></el-icon>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+
|
|
|
|
+ <div class="main-content">
|
|
|
|
+ <!-- 单个条件 -->
|
|
|
|
+ <div class="condition-content-box cell-box">
|
|
|
|
+ <div v-if="false">描述</div>
|
|
|
|
+ <div>条件字段</div>
|
|
|
|
+ <div>运算符</div>
|
|
|
|
+ <div>值</div>
|
|
|
|
+ </div>
|
|
|
|
+ <div v-for="(condition, idx) in conditionGroup" :key="idx" class="condition-content">
|
|
|
|
+ <div class="condition-relation">
|
|
|
|
+ <span>{{ idx == 0 ? '当' : '且' }}</span>
|
|
|
|
+ <div v-if="conditionGroup.length > 1" @click="deleteConditionList(conditionGroup, idx)">
|
|
|
|
+ <el-icon class="branch-delete-icon"><Delete /></el-icon>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="condition-content">
|
|
|
|
+ <div class="condition-content-box">
|
|
|
|
+ <el-input
|
|
|
|
+ v-if="condition.type === 'custom'"
|
|
|
|
+ v-model="condition.label"
|
|
|
|
+ placeholder="自定义条件字段"
|
|
|
|
+ @input="getCurrentItemField(conditionGroupIdx, idx)"
|
|
|
|
+ />
|
|
|
|
+ <el-select
|
|
|
|
+ v-if="condition.type === 'form'"
|
|
|
|
+ v-model="condition.field"
|
|
|
|
+ filterable
|
|
|
|
+ placeholder="表单条件字段"
|
|
|
|
+ @change="getCurrentItemLabel(conditionGroupIdx, idx)"
|
|
|
|
+ >
|
|
|
|
+ <el-option v-for="{ id, label, key } in expressionFormList" :key="id" :label="label" :value="key" />
|
|
|
|
+ </el-select>
|
|
|
|
+ <el-select v-model="condition.operator" placeholder="请选择表达式">
|
|
|
|
+ <el-option v-for="{ value, label } in operatorType" :key="label" :label="label" :value="value"></el-option>
|
|
|
|
+ </el-select>
|
|
|
|
+ <el-input v-model="condition.value" placeholder="值" />
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ <div class="sub-content">
|
|
|
|
+ <el-button link type="primary" icon="Plus" @click="addConditionList(conditionGroup, 'custom')"> 添加自定义条件 </el-button>
|
|
|
|
+ <el-button
|
|
|
|
+ v-if="expressionFormList.length"
|
|
|
|
+ link
|
|
|
|
+ type="primary"
|
|
|
|
+ icon="Plus"
|
|
|
|
+ style="margin-left: 8px"
|
|
|
|
+ @click="addConditionList(conditionGroup, 'form')"
|
|
|
|
+ >
|
|
|
|
+ 添加表单条件
|
|
|
|
+ </el-button>
|
|
|
|
+ </div>
|
|
|
|
+ </div>
|
|
|
|
+ </template>
|
|
|
|
+ <el-button style="width: 100%" type="info" icon="Plus" text bg @click="addConditionGroup"> 添加条件组 </el-button>
|
|
|
|
+ </el-main>
|
|
|
|
+ <el-footer>
|
|
|
|
+ <el-button type="primary" @click="save"> 保存 </el-button>
|
|
|
|
+ <el-button @click="drawer = false">取消</el-button>
|
|
|
|
+ </el-footer>
|
|
|
|
+ </el-container>
|
|
|
|
+ </el-drawer>
|
|
|
|
+ </div>
|
|
|
|
+</template>
|
|
|
|
+
|
|
|
|
+<script>
|
|
import addNode from './addNode.vue'
|
|
import addNode from './addNode.vue'
|
|
import { operatorType } from './config'
|
|
import { operatorType } from './config'
|
|
import useFlowStore from '@/store/modules/flow'
|
|
import useFlowStore from '@/store/modules/flow'
|
|
import { Delete, Plus, ArrowLeft, Close, ArrowRight, Edit } from '@element-plus/icons-vue'
|
|
import { Delete, Plus, ArrowLeft, Close, ArrowRight, Edit } from '@element-plus/icons-vue'
|
|
-import {mapState, storeToRefs} from 'pinia'
|
|
|
|
|
|
+import { mapState } from 'pinia'
|
|
import { getNodeKey } from '@/utils/workflow'
|
|
import { getNodeKey } from '@/utils/workflow'
|
|
import { ElMessage } from 'element-plus'
|
|
import { ElMessage } from 'element-plus'
|
|
import { $log } from '@/utils'
|
|
import { $log } from '@/utils'
|
|
-import { defineComponent, reactive, ref, computed, /*getCurrentInstance,*/ unref, watch, nextTick, shallowRef, onMounted} from 'vue'
|
|
|
|
-// const emit = defineEmits(['update:modelValue', 'update'])
|
|
|
|
|
|
|
|
-export default defineComponent({
|
|
|
|
- name: 'Branch',
|
|
|
|
- emits: ['update:modelValue', 'update'],
|
|
|
|
|
|
+export default {
|
|
components: {
|
|
components: {
|
|
addNode
|
|
addNode
|
|
},
|
|
},
|
|
props: {
|
|
props: {
|
|
- modelValue: {
|
|
|
|
- type: Object,
|
|
|
|
- default: () => {}
|
|
|
|
- },
|
|
|
|
|
|
+ modelValue: { type: Object, default: () => {} },
|
|
disabled: {
|
|
disabled: {
|
|
type: Boolean,
|
|
type: Boolean,
|
|
default: false
|
|
default: false
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- setup(props, ctx) {
|
|
|
|
- const flowStore = useFlowStore()
|
|
|
|
- const { processForm } = storeToRefs(flowStore)
|
|
|
|
- const state = reactive({
|
|
|
|
|
|
+ data() {
|
|
|
|
+ return {
|
|
operatorType,
|
|
operatorType,
|
|
nodeConfig: {},
|
|
nodeConfig: {},
|
|
drawer: false,
|
|
drawer: false,
|
|
@@ -38,55 +188,67 @@ export default defineComponent({
|
|
form: {},
|
|
form: {},
|
|
expressionFormList: [],
|
|
expressionFormList: [],
|
|
local_formStructure: {}
|
|
local_formStructure: {}
|
|
- })
|
|
|
|
- watch(() => props.modelValue, () => {
|
|
|
|
- state.nodeConfig = props.modelValue
|
|
|
|
- }/*,
|
|
|
|
- {immediate: true}*/)
|
|
|
|
- watch(processForm, (val) => {
|
|
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ ...mapState(useFlowStore, ['processForm']) //映射函数,取出processForm
|
|
|
|
+ },
|
|
|
|
+ watch: {
|
|
|
|
+ modelValue() {
|
|
|
|
+ this.nodeConfig = this.modelValue
|
|
|
|
+ },
|
|
|
|
+ processForm: {
|
|
|
|
+ handler(processForm) {
|
|
// console.error(val, 'processForm change...', typeof val)
|
|
// console.error(val, 'processForm change...', typeof val)
|
|
- const { formStructure } = JSON.parse(val) // 表单设计字段
|
|
|
|
- state.local_formStructure = formStructure
|
|
|
|
|
|
+ const { formStructure } = JSON.parse(processForm) // 表单设计字段
|
|
|
|
+ this.local_formStructure = formStructure
|
|
// 使用 filter 方法找到 required 属性为 true 的对象
|
|
// 使用 filter 方法找到 required 属性为 true 的对象
|
|
- state.expressionFormList = (formStructure?.fields || []).filter(item => item.options && item.options.required === true)
|
|
|
|
- $log(state.expressionFormList, '这里打印出符合条件的表单对象')
|
|
|
|
|
|
+ this.expressionFormList = (formStructure?.fields || []).filter(item => item.options && item.options.required === true)
|
|
|
|
+ $log(this.expressionFormList, '这里打印出符合条件的表单对象')
|
|
},
|
|
},
|
|
- {immediate: true}
|
|
|
|
- )
|
|
|
|
-
|
|
|
|
- const show = (index) => {
|
|
|
|
- if (state.disabled) return
|
|
|
|
- if (index === state.nodeConfig.conditionNodes.length - 1) {
|
|
|
|
|
|
+ immediate: true
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ mounted() {
|
|
|
|
+ this.nodeConfig = this.modelValue
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ show(index) {
|
|
|
|
+ if (this.disabled) return
|
|
|
|
+ if (index === this.nodeConfig.conditionNodes.length - 1) {
|
|
// 最后一个节点不能编辑
|
|
// 最后一个节点不能编辑
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- state.index = index
|
|
|
|
- state.form = {}
|
|
|
|
- state.form = JSON.parse(JSON.stringify(state.nodeConfig.conditionNodes[index]))
|
|
|
|
- state.drawer = true
|
|
|
|
- }
|
|
|
|
- const editTitle = () => {
|
|
|
|
- state.isEditTitle = true
|
|
|
|
- nextTick(() => {
|
|
|
|
- // state.$refs.nodeTitle.focus()
|
|
|
|
|
|
+ this.index = index
|
|
|
|
+ this.form = {}
|
|
|
|
+ this.form = JSON.parse(JSON.stringify(this.nodeConfig.conditionNodes[index]))
|
|
|
|
+ // const { formStructure } = JSON.parse(this.processForm) // 表单设计字段
|
|
|
|
+ // // 使用 filter 方法找到 required 属性为 true 的对象
|
|
|
|
+ // const requiredList = (formStructure?.fields || []).filter(item => item.options && item.options.required === true)
|
|
|
|
+ // console.log(`%c 这里打印出符合条件的表单对象-=== ${JSON.stringify(requiredList)}`, 'background: orange; color: #fff')
|
|
|
|
+ // this.expressionFormList = requiredList || []
|
|
|
|
+ this.drawer = true
|
|
|
|
+ },
|
|
|
|
+ editTitle() {
|
|
|
|
+ this.isEditTitle = true
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.$refs.nodeTitle.focus()
|
|
})
|
|
})
|
|
- }
|
|
|
|
- const saveTitle = () => {
|
|
|
|
- state.isEditTitle = false
|
|
|
|
- }
|
|
|
|
- const save = () => {
|
|
|
|
- if (!state.form.nodeKey) {
|
|
|
|
|
|
+ },
|
|
|
|
+ saveTitle() {
|
|
|
|
+ this.isEditTitle = false
|
|
|
|
+ },
|
|
|
|
+ save() {
|
|
|
|
+ if (!this.form.nodeKey) {
|
|
return ElMessage.error('请填写nodeKey')
|
|
return ElMessage.error('请填写nodeKey')
|
|
}
|
|
}
|
|
- state.nodeConfig.conditionNodes[state.index] = state.form
|
|
|
|
-
|
|
|
|
- ctx.emit('update:modelValue', state.nodeConfig)
|
|
|
|
- // this.$emit('update:modelValue', this.nodeConfig)
|
|
|
|
- state.drawer = false
|
|
|
|
- }
|
|
|
|
- const addTerm = () => {
|
|
|
|
- let len = state.nodeConfig.conditionNodes.length + 1
|
|
|
|
- state.nodeConfig.conditionNodes.push({
|
|
|
|
|
|
+ this.nodeConfig.conditionNodes[this.index] = this.form
|
|
|
|
+ this.$emit('update:modelValue', this.nodeConfig)
|
|
|
|
+ this.drawer = false
|
|
|
|
+ },
|
|
|
|
+ addTerm() {
|
|
|
|
+ let len = this.nodeConfig.conditionNodes.length + 1
|
|
|
|
+ this.nodeConfig.conditionNodes.push({
|
|
nodeName: '条件' + len,
|
|
nodeName: '条件' + len,
|
|
nodeKey: getNodeKey(),
|
|
nodeKey: getNodeKey(),
|
|
type: 3,
|
|
type: 3,
|
|
@@ -94,39 +256,35 @@ export default defineComponent({
|
|
conditionMode: 1,
|
|
conditionMode: 1,
|
|
conditionList: []
|
|
conditionList: []
|
|
})
|
|
})
|
|
- }
|
|
|
|
- const delTerm = (index, event) => {
|
|
|
|
- event.stopPropagation()
|
|
|
|
- state.nodeConfig.conditionNodes.splice(index, 1)
|
|
|
|
- if (state.nodeConfig.conditionNodes.length == 1) {
|
|
|
|
- if (state.nodeConfig.childNode) {
|
|
|
|
- if (state.nodeConfig.conditionNodes[0].childNode) {
|
|
|
|
- reData(state.nodeConfig.conditionNodes[0].childNode, state.nodeConfig.childNode)
|
|
|
|
|
|
+ },
|
|
|
|
+ delTerm(index) {
|
|
|
|
+ this.nodeConfig.conditionNodes.splice(index, 1)
|
|
|
|
+ if (this.nodeConfig.conditionNodes.length == 1) {
|
|
|
|
+ if (this.nodeConfig.childNode) {
|
|
|
|
+ if (this.nodeConfig.conditionNodes[0].childNode) {
|
|
|
|
+ this.reData(this.nodeConfig.conditionNodes[0].childNode, this.nodeConfig.childNode)
|
|
} else {
|
|
} else {
|
|
- state.nodeConfig.conditionNodes[0].childNode = state.nodeConfig.childNode
|
|
|
|
|
|
+ this.nodeConfig.conditionNodes[0].childNode = this.nodeConfig.childNode
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- ctx.emit('update:modelValue', state.nodeConfig.conditionNodes[0].childNode)
|
|
|
|
- // this.$emit('update:modelValue', state.nodeConfig.conditionNodes[0].childNode)
|
|
|
|
|
|
+ this.$emit('update:modelValue', this.nodeConfig.conditionNodes[0].childNode)
|
|
}
|
|
}
|
|
- }
|
|
|
|
- const reData = (data, addData) => {
|
|
|
|
|
|
+ },
|
|
|
|
+ reData(data, addData) {
|
|
if (!data.childNode) {
|
|
if (!data.childNode) {
|
|
data.childNode = addData
|
|
data.childNode = addData
|
|
} else {
|
|
} else {
|
|
- reData(data.childNode, addData)
|
|
|
|
|
|
+ this.reData(data.childNode, addData)
|
|
}
|
|
}
|
|
- }
|
|
|
|
- const arrTransfer = (index, type = 1, event) => {
|
|
|
|
- event.stopPropagation();
|
|
|
|
- state.nodeConfig.conditionNodes[index] = state.nodeConfig.conditionNodes.splice(index + type, 1, state.nodeConfig.conditionNodes[index])[0]
|
|
|
|
- state.nodeConfig.conditionNodes.map((item, index) => {
|
|
|
|
|
|
+ },
|
|
|
|
+ arrTransfer(index, type = 1) {
|
|
|
|
+ this.nodeConfig.conditionNodes[index] = this.nodeConfig.conditionNodes.splice(index + type, 1, this.nodeConfig.conditionNodes[index])[0]
|
|
|
|
+ this.nodeConfig.conditionNodes.map((item, index) => {
|
|
item.priorityLevel = index + 1
|
|
item.priorityLevel = index + 1
|
|
})
|
|
})
|
|
- ctx.emit('update:modelValue', state.nodeConfig)
|
|
|
|
- // this.$emit('update:modelValue', this.nodeConfig)
|
|
|
|
- }
|
|
|
|
- const addConditionList = (conditionList, type) => {
|
|
|
|
|
|
+ this.$emit('update:modelValue', this.nodeConfig)
|
|
|
|
+ },
|
|
|
|
+ addConditionList(conditionList, type) {
|
|
conditionList.push({
|
|
conditionList.push({
|
|
label: '',
|
|
label: '',
|
|
field: '',
|
|
field: '',
|
|
@@ -134,27 +292,27 @@ export default defineComponent({
|
|
value: '',
|
|
value: '',
|
|
type
|
|
type
|
|
})
|
|
})
|
|
- }
|
|
|
|
- const deleteConditionList = (conditionList, index) => {
|
|
|
|
|
|
+ },
|
|
|
|
+ deleteConditionList(conditionList, index) {
|
|
conditionList.splice(index, 1)
|
|
conditionList.splice(index, 1)
|
|
- }
|
|
|
|
- const addConditionGroup = () => {
|
|
|
|
- state.addConditionList(state.form.conditionList[state.form.conditionList.push([]) - 1], 'custom')
|
|
|
|
- }
|
|
|
|
- const deleteConditionGroup = (index) => {
|
|
|
|
- state.form.conditionList.splice(index, 1)
|
|
|
|
- }
|
|
|
|
- const toText = (nodeConfig, index) => {
|
|
|
|
|
|
+ },
|
|
|
|
+ addConditionGroup() {
|
|
|
|
+ this.addConditionList(this.form.conditionList[this.form.conditionList.push([]) - 1], 'custom')
|
|
|
|
+ },
|
|
|
|
+ deleteConditionGroup(index) {
|
|
|
|
+ this.form.conditionList.splice(index, 1)
|
|
|
|
+ },
|
|
|
|
+ toText(nodeConfig, index) {
|
|
var { conditionList } = nodeConfig.conditionNodes[index]
|
|
var { conditionList } = nodeConfig.conditionNodes[index]
|
|
if (conditionList && conditionList.length) {
|
|
if (conditionList && conditionList.length) {
|
|
const text = conditionList
|
|
const text = conditionList
|
|
.map(conditionGroup =>
|
|
.map(conditionGroup =>
|
|
conditionGroup
|
|
conditionGroup
|
|
.map(item => {
|
|
.map(item => {
|
|
- const showOperator = state.operatorType.find(i => i.value === item.operator).label
|
|
|
|
|
|
+ const showOperator = this.operatorType.find(i => i.value === item.operator).label
|
|
if (item.type === 'form') {
|
|
if (item.type === 'form') {
|
|
let showLabel = item.showLabel
|
|
let showLabel = item.showLabel
|
|
- if (!showLabel) showLabel = state.expressionFormList.find(i => i.key === item.field)?.label
|
|
|
|
|
|
+ if (!showLabel) showLabel = this.expressionFormList.find(i => i.key === item.field)?.label
|
|
return `${showLabel}${showOperator}${item.value}`
|
|
return `${showLabel}${showOperator}${item.value}`
|
|
} else {
|
|
} else {
|
|
return `${item.label}${showOperator}${item.value}`
|
|
return `${item.label}${showOperator}${item.value}`
|
|
@@ -172,232 +330,20 @@ export default defineComponent({
|
|
return ''
|
|
return ''
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- const getCurrentItemLabel = (conditionIdx, idx) => {
|
|
|
|
- const currentCondition = state.form.conditionList[conditionIdx]
|
|
|
|
|
|
+ },
|
|
|
|
+ getCurrentItemLabel(conditionIdx, idx) {
|
|
|
|
+ const currentCondition = this.form.conditionList[conditionIdx]
|
|
const field = currentCondition[idx].field
|
|
const field = currentCondition[idx].field
|
|
- const labelObj = state.expressionFormList.find(i => i.key === field)
|
|
|
|
|
|
+ const labelObj = this.expressionFormList.find(i => i.key === field)
|
|
currentCondition[idx].showLabel = labelObj.label
|
|
currentCondition[idx].showLabel = labelObj.label
|
|
currentCondition[idx].label = field
|
|
currentCondition[idx].label = field
|
|
- }
|
|
|
|
- const getCurrentItemField = (conditionIdx, idx) => {
|
|
|
|
- const currentCondition = state.form.conditionList[conditionIdx]
|
|
|
|
|
|
+ },
|
|
|
|
+ getCurrentItemField(conditionIdx, idx) {
|
|
|
|
+ const currentCondition = this.form.conditionList[conditionIdx]
|
|
currentCondition[idx].field = currentCondition[idx].label
|
|
currentCondition[idx].field = currentCondition[idx].label
|
|
}
|
|
}
|
|
-
|
|
|
|
- onMounted(() => {
|
|
|
|
- // state.nodeConfig = props.modelValue
|
|
|
|
- })
|
|
|
|
- return () => {
|
|
|
|
- const disabled = props.disabled
|
|
|
|
- // `branch-wrap--${nodeConfig.local_status}`
|
|
|
|
- const drawerSlots = {
|
|
|
|
- header() {
|
|
|
|
- return <div class="node-wrap-drawer__title">
|
|
|
|
- {
|
|
|
|
- !state.isEditTitle ? <label onClick={editTitle}>
|
|
|
|
- {state.form.nodeName}
|
|
|
|
- <el-icon class="node-wrap-drawer__title-edit"><Edit/></el-icon>
|
|
|
|
- {/*<div @click="rmConditionGroup(conditionGroup)"> </div>*/}
|
|
|
|
- </label> : <el-input
|
|
|
|
- ref="nodeTitle"
|
|
|
|
- v-model={state.form.nodeName}
|
|
|
|
- clearable
|
|
|
|
- class="w-40"
|
|
|
|
- onBlur={saveTitle}
|
|
|
|
- onKeyup={(event) => {
|
|
|
|
- if (event.key === 'Enter') {
|
|
|
|
- saveTitle()
|
|
|
|
- }
|
|
|
|
- }}
|
|
|
|
- />
|
|
|
|
- }
|
|
|
|
- <el-input v-model={state.form.nodeKey} clearable class="w-40 pl-1.5" placeholder="请填写nodeKey"></el-input>
|
|
|
|
- </div>
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return <div class={['branch-wrap', disabled ? 'branch-wrap--disabled' : '']}>
|
|
|
|
- <div class="branch-box-wrap">
|
|
|
|
- <div class="branch-box">
|
|
|
|
- <el-button class="add-branch" type="success" plain round onClick={addTerm}> 添加条件</el-button>
|
|
|
|
- {
|
|
|
|
- (state.nodeConfig.conditionNodes || []).map((item, index) => {
|
|
|
|
- // const xx
|
|
|
|
- const contentTxt = toText(state.nodeConfig, index) // todo...
|
|
|
|
- const contentHtml = contentTxt ? <el-tooltip effect="dark" placement="top" v-slots={{content: () => <div v-html={contentTxt}/>}}>
|
|
|
|
- <div class="text-overflow_ellipsis_line_2" v-html={contentTxt}/>
|
|
|
|
- </el-tooltip> : <span v-else class="placeholder"> 请设置条件 </span>
|
|
|
|
- return <div key={index} class="col-box">
|
|
|
|
- <div class="condition-node">
|
|
|
|
- <div class="condition-node-box">
|
|
|
|
- <div class={['auto-judge', `auto-judge--${item.local_status}`]} onClick={show.bind(null, index)}>
|
|
|
|
- {/!*不是第一个 也不是 最后一个*!/}
|
|
|
|
- {
|
|
|
|
- index != 0 && index != state.nodeConfig.conditionNodes.length - 1 &&
|
|
|
|
- <div class="sort-left" onClick={arrTransfer.bind(null, index, -1)}>
|
|
|
|
- <el-icon><ArrowLeft/></el-icon>
|
|
|
|
- </div>
|
|
|
|
- }
|
|
|
|
- <div class="title">
|
|
|
|
- <span class={['node-title', index === state.nodeConfig.conditionNodes.length - 1 ? 'last-child-title' : '']}>{
|
|
|
|
- index === state.nodeConfig.conditionNodes.length - 1 ? '默认条件' : item.nodeName
|
|
|
|
- }</span>
|
|
|
|
- <span class="priority-title">优先级{item.priorityLevel}</span>
|
|
|
|
- {
|
|
|
|
- index != state.nodeConfig.conditionNodes.length - 1 && <el-icon class="close" onClick={delTerm.bind(null, index)}>
|
|
|
|
- <Close/>
|
|
|
|
- </el-icon>
|
|
|
|
- }
|
|
|
|
- </div>
|
|
|
|
-
|
|
|
|
- <div class={['content', index === state.nodeConfig.conditionNodes.length - 1 ? 'last-child-title' : '']} style="width: 200px">
|
|
|
|
- {contentHtml}
|
|
|
|
- </div>
|
|
|
|
- {/*最后一个没有,长度大于2倒数第二个没有*/}
|
|
|
|
- {
|
|
|
|
- !(state.nodeConfig.conditionNodes.length == 2 && (index === state.nodeConfig.conditionNodes.length - 1 || index === 0)) &&
|
|
|
|
- !(
|
|
|
|
- (state.nodeConfig.conditionNodes.length > 2 && index === state.nodeConfig.conditionNodes.length - 1) ||
|
|
|
|
- index === state.nodeConfig.conditionNodes.length - 2
|
|
|
|
- ) && <div
|
|
|
|
- class="sort-right"
|
|
|
|
- onClick={arrTransfer.bind(null, index)}>
|
|
|
|
- <el-icon><ArrowRight/></el-icon>
|
|
|
|
- </div>
|
|
|
|
- }
|
|
|
|
- </div>
|
|
|
|
- <add-node v-model={item.childNode} disabled={disabled}></add-node>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- {item.childNode && ctx.slots?.default({node: item})}
|
|
|
|
- {
|
|
|
|
- index === 0 && (<>
|
|
|
|
- <div class="top-left-cover-line"></div>
|
|
|
|
- <div class="bottom-left-cover-line"></div>
|
|
|
|
- </>)
|
|
|
|
- }
|
|
|
|
- {
|
|
|
|
- index == state.nodeConfig.conditionNodes.length - 1 && (<>
|
|
|
|
- <div class="top-right-cover-line"></div>
|
|
|
|
- <div class="bottom-right-cover-line"></div>
|
|
|
|
- </>)
|
|
|
|
- }
|
|
|
|
- </div>
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- </div>
|
|
|
|
- <add-node v-model={state.nodeConfig.childNode} disabled={disabled}></add-node>
|
|
|
|
- </div>
|
|
|
|
- <el-drawer v-model={state.drawer} title="条件设置" destroy-on-close append-to-body size={600} v-slots={drawerSlots}>
|
|
|
|
- <el-container>
|
|
|
|
- <el-main style="padding: 0 0 20px 0">
|
|
|
|
- <div class="top-tips">满足以下条件时进入当前分支</div>
|
|
|
|
- {
|
|
|
|
- state.form.conditionList.map((conditionGroup, conditionGroupIdx) => {
|
|
|
|
- return <>
|
|
|
|
- {
|
|
|
|
- conditionGroupIdx != 0 && <div class="or-branch-link-tip">或满足</div>
|
|
|
|
- }
|
|
|
|
- <div class="condition-group-editor">
|
|
|
|
- <div class="header">
|
|
|
|
- <span>条件组 {conditionGroupIdx + 1}</span>
|
|
|
|
- <div onClick={deleteConditionGroup.bind(null, conditionGroupIdx)}>
|
|
|
|
- <el-icon class="branch-delete-icon"><Delete/></el-icon>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- <div class="main-content">
|
|
|
|
- {/*单个条件*/}
|
|
|
|
- <div class="condition-content-box cell-box">
|
|
|
|
- {/*<div v-if="false">描述</div>*/}
|
|
|
|
- <div>条件字段</div>
|
|
|
|
- <div>运算符</div>
|
|
|
|
- <div>值</div>
|
|
|
|
- </div>
|
|
|
|
- {
|
|
|
|
- conditionGroup.map((condition, idx) => {
|
|
|
|
- return <div key={idx} class="condition-content">
|
|
|
|
- <div class="condition-relation">
|
|
|
|
- <span>{idx === 0 ? '当' : '且'}</span>
|
|
|
|
- {
|
|
|
|
- conditionGroup.length > 1 && <div onClick={deleteConditionList.bind(null, conditionGroup, idx)}>
|
|
|
|
- <el-icon className="branch-delete-icon"><Delete/></el-icon>
|
|
|
|
- </div>
|
|
|
|
- }
|
|
|
|
- </div>
|
|
|
|
- <div class="condition-content">
|
|
|
|
- <div class="condition-content-box">
|
|
|
|
- {
|
|
|
|
- condition.type === 'custom' && <el-input
|
|
|
|
- v-model={condition.label}
|
|
|
|
- placeholder="自定义条件字段"
|
|
|
|
- onInput={getCurrentItemField.bind(null, conditionGroupIdx, idx)}
|
|
|
|
- />
|
|
|
|
- }
|
|
|
|
- {
|
|
|
|
- condition.type === 'form' && <el-select
|
|
|
|
- v-model={condition.field}
|
|
|
|
- filterable
|
|
|
|
- placeholder="表单条件字段"
|
|
|
|
- onChange={getCurrentItemLabel.bind(null, conditionGroupIdx, idx)}
|
|
|
|
- >
|
|
|
|
- {
|
|
|
|
- state.expressionFormList.map(({id, label, key}) => {
|
|
|
|
- return <el-option key={id} label={label} value={key}/>
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- </el-select>
|
|
|
|
- }
|
|
|
|
- <el-select v-model={condition.operator} placeholder="请选择表达式">
|
|
|
|
- {
|
|
|
|
- operatorType.map(({label, value}) => {
|
|
|
|
- return <el-option key={value} label={label} value={value}/>
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- </el-select>
|
|
|
|
- <el-input v-model={condition.value} placeholder="值"/>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- </div>
|
|
|
|
- <div class="sub-content">
|
|
|
|
- <el-button link type="primary" icon="Plus" onClick={addConditionList.bind(null, conditionGroup, 'custom')}> 添加自定义条件
|
|
|
|
- </el-button>
|
|
|
|
- {
|
|
|
|
- !!state.expressionFormList.length && <el-button
|
|
|
|
- link
|
|
|
|
- type="primary"
|
|
|
|
- icon="Plus"
|
|
|
|
- style="margin-left: 8px"
|
|
|
|
- onClick={addConditionList.bind(null, conditionGroup, 'form')}
|
|
|
|
- >
|
|
|
|
- 添加表单条件
|
|
|
|
- </el-button>
|
|
|
|
- }
|
|
|
|
- </div>
|
|
|
|
- </div>
|
|
|
|
- </>
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- <el-button style="width: 100%" type="info" icon="Plus" text bg
|
|
|
|
- onClick={addConditionGroup}> 添加条件组
|
|
|
|
- </el-button>
|
|
|
|
- </el-main>
|
|
|
|
- <el-footer>
|
|
|
|
- <el-button type="primary"
|
|
|
|
- onClick={save}> 保存
|
|
|
|
- </el-button>
|
|
|
|
- <el-button
|
|
|
|
- onClick={() => state.drawer = false}>取消
|
|
|
|
- </el-button>
|
|
|
|
- </el-footer>
|
|
|
|
- </el-container>
|
|
|
|
- </el-drawer>
|
|
|
|
- </div>
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
-})
|
|
|
|
|
|
+}
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
<style scoped lang="scss">
|