123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- <template>
- <div>
- <a-dialog :title="title" v-model="drawer" @close="handleClose" :footer="false">
- <component
- :is="componentType"
- v-model="form"
- :disabled="disabled"
- :skipConditionShow="skipConditionShow"
- >
- <template v-slot:[key]="data" v-for="(item, key) in $slots">
- <slot :name="key" v-bind="data || {}"></slot>
- </template>
- </component>
- </a-dialog>
- </div>
- </template>
- <script setup lang="ts">
- import start from './start.vue'
- import between from './between.vue'
- import serial from './serial.vue'
- import parallel from './parallel.vue'
- import end from './end.vue'
- import skip from './skip.vue'
- const COMPONENT_LIST = {
- start,
- between,
- serial,
- parallel,
- end,
- skip
- }
- const props = defineProps({
- value: {
- type: Object,
- default() {
- return {}
- }
- },
- node: {
- type: Object,
- default() {
- return {}
- }
- },
- lf: {
- type: Object,
- default() {
- return null
- }
- },
- disabled: {
- // 是否禁止
- type: Boolean,
- default: false
- },
- skipConditionShow: {
- // 是否显示跳转条件
- type: Boolean,
- default: true
- }
- })
- const drawer = ref(false)
- const form = ref({})
- const objId = ref(undefined)
- const nodeCode = ref(null)
- const title = computed(() => {
- if (props.node && props.node.type === 'skip') {
- return '设置边属性'
- } else if (props.node && props.node.type === 'serial') {
- return '设置串行网关属性'
- } else if (props.node && props.node.type === 'parallel') {
- return '设置并行网关属性'
- } else if (props.node && props.node.type === 'start') {
- return '设置开始属性'
- } else if (props.node && props.node.type === 'end') {
- return '设置结束属性'
- }
- return '设置中间属性'
- })
- // 组件类型
- const componentType = computed(() => {
- if (!props.node || !props.node.type) return
- return COMPONENT_LIST[props.node.type]
- })
- watch(
- () => props.node,
- (n) => {
- if (n) {
- objId.value = n.id
- if (n.type === 'skip') {
- let skipCondition = n.properties.skipCondition
- let conditionSpl = skipCondition ? skipCondition.split('@@|') : []
- let conditionSplTwo = conditionSpl && conditionSpl.length > 0 ? conditionSpl[1] : []
- let condition,
- conditionType,
- conditionValue = ''
- if (conditionSpl && conditionSpl.length > 0 && conditionSpl[0] === '@@spel') {
- conditionType = 'spel'
- conditionValue = conditionSplTwo
- } else if (conditionSpl && conditionSpl.length > 0 && conditionSpl[0] !== '@@spel') {
- condition =
- conditionSplTwo && conditionSplTwo.length > 0 ? conditionSplTwo.split('@@')[0] : ''
- conditionType =
- conditionSplTwo && conditionSplTwo.length > 0 ? conditionSplTwo.split('@@')[1] : ''
- conditionValue =
- conditionSplTwo && conditionSplTwo.length > 0 ? conditionSplTwo.split('@@')[2] : ''
- }
- form.value = {
- nodeType: n.type,
- skipType: n.properties.skipType,
- skipName: n.text instanceof Object ? n.text.value : n.text,
- skipCondition: skipCondition,
- condition: condition,
- conditionType: conditionType,
- conditionValue: conditionValue
- }
- } else {
- const propertiesStr = JSON.stringify(n.properties)
- const permissionFlag = n.properties?.permissionFlag
- const listenerType = n.properties?.listenerType
- const nodeRatioNumber = Number(n.properties.nodeRatio)
- n.properties.formCustom = propertiesStr === '{}' ? '1' : n.properties.formCustom || ''
- form.value = {
- nodeType: n.type,
- nodeCode: n.id,
- ...n.properties,
- nodeName: n.text instanceof Object ? n.text.value : n.text,
- collaborativeWay: nodeRatioNumber == 0 ? '1' : nodeRatioNumber == 100 ? '3' : '2',
- permissionFlagArr: permissionFlag === '' ? [] : (permissionFlag?.split('@@') ?? []),
- listenerTypeArr: listenerType === '' ? [] : (listenerType?.split(',') ?? []),
- nodeRatioNumber
- }
- }
- }
- }
- )
- watch(
- () => form.value.nodeCode,
- (n) => {
- nodeCode.value = n
- }
- )
- watch(
- () => form.value.skipType,
- (n) => {
- // 监听跳转属性变化并更新
- props.lf.setProperties(objId.value, {
- skipType: n
- })
- }
- )
- watch(
- () => form.value.nodeName,
- (n) => {
- // 监听节点名称变化并更新
- props.lf.updateText(objId.value, n)
- // 监听节点名称变化并更新
- props.lf.setProperties(objId.value, {
- nodeName: n
- })
- }
- )
- watch(
- () => form.value.nodeRatioNumber,
- (n) => {
- // 监听节点属性变化并更新
- props.lf.setProperties(objId.value, {
- nodeRatio: n ? n.toString() : undefined
- })
- }
- )
- watch(
- () => form.value.permissionFlagArr,
- (n) => {
- if (n === undefined) {
- n = []
- }
- // 监听节点属性变化并更新
- props.lf.setProperties(objId.value, {
- permissionFlagArr: n,
- permissionFlag: n.join('@@')
- })
- }
- )
- watch(
- () => form.value.skipAnyNode,
- (n) => {
- // 监听跳转属性变化并更新
- props.lf.setProperties(objId.value, {
- skipAnyNode: n
- })
- }
- )
- watch(
- () => form.value.listenerTypeArr,
- (n) => {
- if (n === undefined) {
- n = []
- }
- // 监听监听器类型变化并更新
- props.lf.setProperties(objId.value, {
- listenerTypeArr: n,
- listenerType: n.join(',')
- })
- }
- )
- watch(
- () => form.value.listenerPath,
- (n) => {
- // 监听监听器路径变化并更新
- props.lf.setProperties(objId.value, {
- listenerPath: n
- })
- }
- )
- watch(
- () => form.value.formCustom,
- (n) => {
- props.lf.setProperties(objId.value, {
- formCustom: n || ''
- })
- }
- )
- watch(
- () => form.value.formPath,
- (n) => {
- props.lf.setProperties(objId.value, {
- formPath: n
- })
- }
- )
- watch(
- () => form.value.skipName,
- (n) => {
- if (['skip'].includes(props.node.type)) {
- // 监听跳转名称变化并更新
- props.lf.updateText(objId.value, n)
- // 监听跳转属性变化并更新
- props.lf.setProperties(objId.value, {
- skipName: n
- })
- }
- }
- )
- watch(
- () => form.value.skipCondition,
- (n) => {
- // 监听跳转属性变化并更新
- props.lf.setProperties(objId.value, {
- skipCondition: n
- })
- }
- )
- function show() {
- drawer.value = true
- }
- function handleClose() {
- // 监听节点编码变量并更新
- if (nodeCode.value && objId.value) {
- if (['skip'].includes(props.node?.type)) {
- if (!props.lf.getEdgeModelById(nodeCode.value)) {
- props.lf.changeEdgeId(objId.value, nodeCode.value)
- }
- } else {
- if (!props.lf.getNodeModelById(nodeCode.value)) {
- props.lf.changeNodeId(objId.value, nodeCode.value)
- }
- }
- }
- drawer.value = false
- }
- defineExpose({
- show,
- handleClose
- })
- </script>
- <style scoped>
- .el-drawer__container ::-webkit-scrollbar {
- display: none;
- }
- </style>
|