From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/components/bpmnProcessDesigner/package/penal/flow-condition/FlowCondition.vue | 191 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 191 insertions(+), 0 deletions(-)
diff --git a/src/components/bpmnProcessDesigner/package/penal/flow-condition/FlowCondition.vue b/src/components/bpmnProcessDesigner/package/penal/flow-condition/FlowCondition.vue
new file mode 100644
index 0000000..304630d
--- /dev/null
+++ b/src/components/bpmnProcessDesigner/package/penal/flow-condition/FlowCondition.vue
@@ -0,0 +1,191 @@
+<template>
+ <div class="panel-tab__content">
+ <el-form :model="flowConditionForm" label-width="90px" size="small">
+ <el-form-item label="娴佽浆绫诲瀷">
+ <el-select v-model="flowConditionForm.type" @change="updateFlowType">
+ <el-option label="鏅�氭祦杞矾寰�" value="normal" />
+ <el-option label="榛樿娴佽浆璺緞" value="default" />
+ <el-option label="鏉′欢娴佽浆璺緞" value="condition" />
+ </el-select>
+ </el-form-item>
+ <el-form-item label="鏉′欢鏍煎紡" v-if="flowConditionForm.type === 'condition'" key="condition">
+ <el-select v-model="flowConditionForm.conditionType">
+ <el-option label="琛ㄨ揪寮�" value="expression" />
+ <el-option label="鑴氭湰" value="script" />
+ </el-select>
+ </el-form-item>
+ <el-form-item
+ label="琛ㄨ揪寮�"
+ v-if="flowConditionForm.conditionType && flowConditionForm.conditionType === 'expression'"
+ key="express"
+ >
+ <el-input
+ v-model="flowConditionForm.body"
+ style="width: 192px"
+ clearable
+ @change="updateFlowCondition"
+ />
+ </el-form-item>
+ <template
+ v-if="flowConditionForm.conditionType && flowConditionForm.conditionType === 'script'"
+ >
+ <el-form-item label="鑴氭湰璇█" key="language">
+ <el-input v-model="flowConditionForm.language" clearable @change="updateFlowCondition" />
+ </el-form-item>
+ <el-form-item label="鑴氭湰绫诲瀷" key="scriptType">
+ <el-select v-model="flowConditionForm.scriptType">
+ <el-option label="鍐呰仈鑴氭湰" value="inlineScript" />
+ <el-option label="澶栭儴鑴氭湰" value="externalScript" />
+ </el-select>
+ </el-form-item>
+ <el-form-item
+ label="鑴氭湰"
+ v-if="flowConditionForm.scriptType === 'inlineScript'"
+ key="body"
+ >
+ <el-input
+ v-model="flowConditionForm.body"
+ type="textarea"
+ clearable
+ @change="updateFlowCondition"
+ />
+ </el-form-item>
+ <el-form-item
+ label="璧勬簮鍦板潃"
+ v-if="flowConditionForm.scriptType === 'externalScript'"
+ key="resource"
+ >
+ <el-input v-model="flowConditionForm.resource" clearable @change="updateFlowCondition" />
+ </el-form-item>
+ </template>
+ </el-form>
+ </div>
+</template>
+
+<script lang="ts" setup>
+defineOptions({ name: 'FlowCondition' })
+
+const props = defineProps({
+ businessObject: Object,
+ type: String
+})
+const flowConditionForm = ref<any>({})
+const bpmnElement = ref()
+const bpmnElementSource = ref()
+const bpmnElementSourceRef = ref()
+const flowConditionRef = ref()
+const bpmnInstances = () => (window as any)?.bpmnInstances
+const resetFlowCondition = () => {
+ bpmnElement.value = bpmnInstances().bpmnElement
+ bpmnElementSource.value = bpmnElement.value.source
+ bpmnElementSourceRef.value = bpmnElement.value.businessObject.sourceRef
+ // 鍒濆鍖栭粯璁ype涓篸efault
+ flowConditionForm.value = { type: 'default' }
+ if (
+ bpmnElementSourceRef.value &&
+ bpmnElementSourceRef.value.default &&
+ bpmnElementSourceRef.value.default.id === bpmnElement.value.id
+ ) {
+ flowConditionForm.value = { type: 'default' }
+ } else if (!bpmnElement.value.businessObject.conditionExpression) {
+ // 鏅��
+ flowConditionForm.value = { type: 'normal' }
+ } else {
+ // 甯︽潯浠�
+ const conditionExpression = bpmnElement.value.businessObject.conditionExpression
+ flowConditionForm.value = { ...conditionExpression, type: 'condition' }
+ // resource 鍙洿鎺ユ爣璇� 鏄惁鏄閮ㄨ祫婧愯剼鏈�
+ if (flowConditionForm.value.resource) {
+ // this.$set(this.flowConditionForm, "conditionType", "script");
+ // this.$set(this.flowConditionForm, "scriptType", "externalScript");
+ flowConditionForm.value['conditionType'] = 'script'
+ flowConditionForm.value['scriptType'] = 'externalScript'
+ return
+ }
+ if (conditionExpression.language) {
+ // this.$set(this.flowConditionForm, "conditionType", "script");
+ // this.$set(this.flowConditionForm, "scriptType", "inlineScript");
+ flowConditionForm.value['conditionType'] = 'script'
+ flowConditionForm.value['scriptType'] = 'inlineScript'
+
+ return
+ }
+ // this.$set(this.flowConditionForm, "conditionType", "expression");
+ flowConditionForm.value['conditionType'] = 'expression'
+ }
+}
+const updateFlowType = (flowType) => {
+ // 姝e父鏉′欢绫�
+ if (flowType === 'condition') {
+ flowConditionRef.value = bpmnInstances().moddle.create('bpmn:FormalExpression')
+ bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), {
+ conditionExpression: flowConditionRef.value
+ })
+ return
+ }
+ // 榛樿璺緞
+ if (flowType === 'default') {
+ bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), {
+ conditionExpression: null
+ })
+ bpmnInstances().modeling.updateProperties(toRaw(bpmnElementSource.value), {
+ default: toRaw(bpmnElement.value)
+ })
+ return
+ }
+ // 姝e父璺緞锛屽鏋滄潵婧愯妭鐐圭殑榛樿璺緞鏄綋鍓嶈繛绾挎椂锛屾竻闄ょ埗鍏冪礌鐨勯粯璁よ矾寰勯厤缃�
+ if (
+ bpmnElementSourceRef.value.default &&
+ bpmnElementSourceRef.value.default.id === bpmnElement.value.id
+ ) {
+ bpmnInstances().modeling.updateProperties(toRaw(bpmnElementSource.value), {
+ default: null
+ })
+ }
+ bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), {
+ conditionExpression: null
+ })
+}
+const updateFlowCondition = () => {
+ let { conditionType, scriptType, body, resource, language } = flowConditionForm.value
+ let condition
+ if (conditionType === 'expression') {
+ condition = bpmnInstances().moddle.create('bpmn:FormalExpression', { body })
+ } else {
+ if (scriptType === 'inlineScript') {
+ condition = bpmnInstances().moddle.create('bpmn:FormalExpression', { body, language })
+ // this.$set(this.flowConditionForm, "resource", "");
+ flowConditionForm.value['resource'] = ''
+ } else {
+ // this.$set(this.flowConditionForm, "body", "");
+ flowConditionForm.value['body'] = ''
+ condition = bpmnInstances().moddle.create('bpmn:FormalExpression', {
+ resource,
+ language
+ })
+ }
+ }
+ bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), {
+ conditionExpression: condition
+ })
+}
+
+onBeforeUnmount(() => {
+ bpmnElement.value = null
+ bpmnElementSource.value = null
+ bpmnElementSourceRef.value = null
+})
+
+watch(
+ () => props.businessObject,
+ (val) => {
+ console.log(val, 'val')
+ nextTick(() => {
+ resetFlowCondition()
+ })
+ },
+ {
+ immediate: true
+ }
+)
+</script>
--
Gitblit v1.8.0