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/task/task-components/CallActivity.vue | 280 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 280 insertions(+), 0 deletions(-)
diff --git a/src/components/bpmnProcessDesigner/package/penal/task/task-components/CallActivity.vue b/src/components/bpmnProcessDesigner/package/penal/task/task-components/CallActivity.vue
new file mode 100644
index 0000000..6d8268b
--- /dev/null
+++ b/src/components/bpmnProcessDesigner/package/penal/task/task-components/CallActivity.vue
@@ -0,0 +1,280 @@
+<template>
+ <div>
+ <el-form label-width="100px">
+ <el-form-item label="瀹炰緥鍚嶇О" prop="processInstanceName">
+ <el-input
+ v-model="formData.processInstanceName"
+ clearable
+ placeholder="璇疯緭鍏ュ疄渚嬪悕绉�"
+ @change="updateCallActivityAttr('processInstanceName')"
+ />
+ </el-form-item>
+
+ <!-- TODO 闇�瑕佸彲閫夋嫨宸插瓨鍦ㄧ殑娴佺▼ -->
+ <el-form-item label="琚皟鐢ㄦ祦绋�" prop="calledElement">
+ <el-input
+ v-model="formData.calledElement"
+ clearable
+ placeholder="璇疯緭鍏ヨ璋冪敤娴佺▼"
+ @change="updateCallActivityAttr('calledElement')"
+ />
+ </el-form-item>
+
+ <el-form-item label="缁ф壙鍙橀噺" prop="inheritVariables">
+ <el-switch
+ v-model="formData.inheritVariables"
+ @change="updateCallActivityAttr('inheritVariables')"
+ />
+ </el-form-item>
+
+ <el-form-item label="缁ф壙涓氬姟閿�" prop="inheritBusinessKey">
+ <el-switch
+ v-model="formData.inheritBusinessKey"
+ @change="updateCallActivityAttr('inheritBusinessKey')"
+ />
+ </el-form-item>
+
+ <el-form-item v-if="!formData.inheritBusinessKey" label="涓氬姟閿〃杈惧紡" prop="businessKey">
+ <el-input
+ v-model="formData.businessKey"
+ clearable
+ placeholder="璇疯緭鍏ヤ笟鍔¢敭琛ㄨ揪寮�"
+ @change="updateCallActivityAttr('businessKey')"
+ />
+ </el-form-item>
+
+ <el-divider />
+ <div>
+ <div class="flex mb-10px">
+ <el-text>杈撳叆鍙傛暟</el-text>
+ <XButton
+ class="ml-auto"
+ type="primary"
+ preIcon="ep:plus"
+ title="娣诲姞鍙傛暟"
+ size="small"
+ @click="openVariableForm('in', null, -1)"
+ />
+ </div>
+ <el-table :data="inVariableList" max-height="240" fit border>
+ <el-table-column label="婧�" prop="source" min-width="100px" show-overflow-tooltip />
+ <el-table-column label="鐩爣" prop="target" min-width="100px" show-overflow-tooltip />
+ <el-table-column label="鎿嶄綔" width="110px">
+ <template #default="scope">
+ <el-button link @click="openVariableForm('in', scope.row, scope.$index)" size="small">
+ 缂栬緫
+ </el-button>
+ <el-divider direction="vertical" />
+ <el-button
+ link
+ size="small"
+ style="color: #ff4d4f"
+ @click="removeVariable('in', scope.$index)"
+ >
+ 绉婚櫎
+ </el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ </div>
+
+ <el-divider />
+ <div>
+ <div class="flex mb-10px">
+ <el-text>杈撳嚭鍙傛暟</el-text>
+ <XButton
+ class="ml-auto"
+ type="primary"
+ preIcon="ep:plus"
+ title="娣诲姞鍙傛暟"
+ size="small"
+ @click="openVariableForm('out', null, -1)"
+ />
+ </div>
+ <el-table :data="outVariableList" max-height="240" fit border>
+ <el-table-column label="婧�" prop="source" min-width="100px" show-overflow-tooltip />
+ <el-table-column label="鐩爣" prop="target" min-width="100px" show-overflow-tooltip />
+ <el-table-column label="鎿嶄綔" width="110px">
+ <template #default="scope">
+ <el-button
+ link
+ @click="openVariableForm('out', scope.row, scope.$index)"
+ size="small"
+ >
+ 缂栬緫
+ </el-button>
+ <el-divider direction="vertical" />
+ <el-button
+ link
+ size="small"
+ style="color: #ff4d4f"
+ @click="removeVariable('out', scope.$index)"
+ >
+ 绉婚櫎
+ </el-button>
+ </template>
+ </el-table-column>
+ </el-table>
+ </div>
+ </el-form>
+
+ <!-- 娣诲姞鎴栦慨鏀瑰弬鏁� -->
+ <el-dialog
+ v-model="variableDialogVisible"
+ title="鍙傛暟閰嶇疆"
+ width="600px"
+ append-to-body
+ destroy-on-close
+ >
+ <el-form :model="varialbeFormData" label-width="80px" ref="varialbeFormRef">
+ <el-form-item label="婧愶細" prop="source">
+ <el-input v-model="varialbeFormData.source" clearable />
+ </el-form-item>
+ <el-form-item label="鐩爣锛�" prop="target">
+ <el-input v-model="varialbeFormData.target" clearable />
+ </el-form-item>
+ </el-form>
+ <template #footer>
+ <el-button @click="variableDialogVisible = false">鍙� 娑�</el-button>
+ <el-button type="primary" @click="saveVariable">纭� 瀹�</el-button>
+ </template>
+ </el-dialog>
+ </div>
+</template>
+
+<script lang="ts" setup>
+defineOptions({ name: 'CallActivity' })
+const props = defineProps({
+ id: String,
+ type: String
+})
+const prefix = inject('prefix')
+const message = useMessage()
+
+const formData = ref({
+ processInstanceName: '',
+ calledElement: '',
+ inheritVariables: false,
+ businessKey: '',
+ inheritBusinessKey: false,
+ calledElementType: 'key'
+})
+const inVariableList = ref()
+const outVariableList = ref()
+const variableType = ref() // 鍙傛暟绫诲瀷
+const editingVariableIndex = ref(-1) // 缂栬緫鍙傛暟涓嬫爣
+const variableDialogVisible = ref(false)
+const varialbeFormRef = ref()
+const varialbeFormData = ref({
+ source: '',
+ target: ''
+})
+
+const bpmnInstances = () => (window as any)?.bpmnInstances
+const bpmnElement = ref()
+const otherExtensionList = ref()
+
+const initCallActivity = () => {
+ bpmnElement.value = bpmnInstances().bpmnElement
+ console.log(bpmnElement.value.businessObject, 'callActivity')
+
+ // 鍒濆鍖栨墍鏈夐厤缃」
+ Object.keys(formData.value).forEach((key) => {
+ formData.value[key] = bpmnElement.value.businessObject[key] ?? formData.value[key]
+ })
+
+ otherExtensionList.value = [] // 鍏朵粬鎵╁睍閰嶇疆
+ inVariableList.value = []
+ outVariableList.value = []
+ // 鍒濆鍖栬緭鍏ュ弬鏁�
+ bpmnElement.value.businessObject?.extensionElements?.values?.forEach((ex) => {
+ if (ex.$type === `${prefix}:In`) {
+ inVariableList.value.push(ex)
+ } else if (ex.$type === `${prefix}:Out`) {
+ outVariableList.value.push(ex)
+ } else {
+ otherExtensionList.value.push(ex)
+ }
+ })
+
+ // 榛樿娣诲姞
+ // bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), {
+ // calledElementType: 'key'
+ // })
+}
+
+const updateCallActivityAttr = (attr) => {
+ bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), {
+ [attr]: formData.value[attr]
+ })
+}
+
+const openVariableForm = (type, data, index) => {
+ editingVariableIndex.value = index
+ variableType.value = type
+ varialbeFormData.value = index === -1 ? {} : { ...data }
+ variableDialogVisible.value = true
+}
+
+const removeVariable = async (type, index) => {
+ try {
+ await message.delConfirm()
+ if (type === 'in') {
+ inVariableList.value.splice(index, 1)
+ }
+ if (type === 'out') {
+ outVariableList.value.splice(index, 1)
+ }
+ updateElementExtensions()
+ } catch {}
+}
+
+const saveVariable = () => {
+ if (editingVariableIndex.value === -1) {
+ if (variableType.value === 'in') {
+ inVariableList.value.push(
+ bpmnInstances().moddle.create(`${prefix}:In`, { ...varialbeFormData.value })
+ )
+ }
+ if (variableType.value === 'out') {
+ outVariableList.value.push(
+ bpmnInstances().moddle.create(`${prefix}:Out`, { ...varialbeFormData.value })
+ )
+ }
+ updateElementExtensions()
+ } else {
+ if (variableType.value === 'in') {
+ inVariableList.value[editingVariableIndex.value].source = varialbeFormData.value.source
+ inVariableList.value[editingVariableIndex.value].target = varialbeFormData.value.target
+ }
+ if (variableType.value === 'out') {
+ outVariableList.value[editingVariableIndex.value].source = varialbeFormData.value.source
+ outVariableList.value[editingVariableIndex.value].target = varialbeFormData.value.target
+ }
+ }
+ variableDialogVisible.value = false
+}
+
+const updateElementExtensions = () => {
+ const extensions = bpmnInstances().moddle.create('bpmn:ExtensionElements', {
+ values: [...inVariableList.value, ...outVariableList.value, ...otherExtensionList.value]
+ })
+ bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), {
+ extensionElements: extensions
+ })
+}
+
+watch(
+ () => props.id,
+ (val) => {
+ val &&
+ val.length &&
+ nextTick(() => {
+ initCallActivity()
+ })
+ },
+ { immediate: true }
+)
+</script>
+
+<style lang="scss" scoped></style>
--
Gitblit v1.8.0