Commit 8665d0a4 by YunaiV
parent 9ee8f8e1
...@@ -88,8 +88,8 @@ import ElementProperties from './properties/ElementProperties.vue' ...@@ -88,8 +88,8 @@ import ElementProperties from './properties/ElementProperties.vue'
// import ElementForm from './form/ElementForm.vue' // import ElementForm from './form/ElementForm.vue'
import UserTaskListeners from './listeners/UserTaskListeners.vue' import UserTaskListeners from './listeners/UserTaskListeners.vue'
import { getTaskCollapseItemName, isTaskCollapseItemShow } from './task/data' import { getTaskCollapseItemName, isTaskCollapseItemShow } from './task/data'
import TimeEventConfig from "./time-event-config/TimeEventConfig.vue" import TimeEventConfig from './time-event-config/TimeEventConfig.vue'
import { ref, computed, watch, onMounted } from 'vue' import { ref, watch, onMounted } from 'vue'
defineOptions({ name: 'MyPropertiesPanel' }) defineOptions({ name: 'MyPropertiesPanel' })
...@@ -150,7 +150,7 @@ const initBpmnInstances = () => { ...@@ -150,7 +150,7 @@ const initBpmnInstances = () => {
} }
// 检查所有实例是否都存在 // 检查所有实例是否都存在
const allInstancesExist = Object.values(instances).every(instance => instance) const allInstancesExist = Object.values(instances).every((instance) => instance)
if (allInstancesExist) { if (allInstancesExist) {
const w = window as any const w = window as any
w.bpmnInstances = instances w.bpmnInstances = instances
...@@ -283,15 +283,9 @@ function updateNode() { ...@@ -283,15 +283,9 @@ function updateNode() {
timerDef.timeCycle = moddle.create('bpmn:FormalExpression', { body: condition.value }) timerDef.timeCycle = moddle.create('bpmn:FormalExpression', { body: condition.value })
} }
modeling.updateModdleProperties( modeling.updateModdleProperties(element, element.businessObject, {
element, eventDefinitions: [timerDef]
element.businessObject, })
{
eventDefinitions: [timerDef]
}
)
console.log('当前eventDefinitions:', element.businessObject.eventDefinitions)
} }
// 初始化和监听 // 初始化和监听
......
<template> <template>
<div> <div>
<div style="margin-bottom: 10px;">当前选择:<el-input v-model="isoString" readonly style="width: 300px;" /></div> <div style="margin-bottom: 10px"
<div v-for="unit in units" :key="unit.key" style="margin-bottom: 8px;"> >当前选择:<el-input v-model="isoString" readonly style="width: 300px"
/></div>
<div v-for="unit in units" :key="unit.key" style="margin-bottom: 8px">
<span>{{ unit.label }}</span> <span>{{ unit.label }}</span>
<el-button-group> <el-button-group>
<el-button v-for="val in unit.presets" :key="val" size="mini" @click="setUnit(unit.key, val)">{{ val }}</el-button> <el-button
<el-input v-model.number="custom[unit.key]" size="mini" style="width: 60px; margin-left: 8px;" placeholder="自定义" @change="setUnit(unit.key, custom[unit.key])" /> v-for="val in unit.presets"
:key="val"
size="mini"
@click="setUnit(unit.key, val)"
>{{ val }}</el-button
>
<el-input
v-model.number="custom[unit.key]"
size="mini"
style="width: 60px; margin-left: 8px"
placeholder="自定义"
@change="setUnit(unit.key, custom[unit.key])"
/>
</el-button-group> </el-button-group>
</div> </div>
</div> </div>
...@@ -49,18 +63,24 @@ function updateIsoString() { ...@@ -49,18 +63,24 @@ function updateIsoString() {
emit('change', isoString.value) emit('change', isoString.value)
} }
watch(() => props.value, (val) => { watch(
if (!val) return () => props.value,
// 解析ISO 8601字符串到custom (val) => {
const match = val.match(/^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/) if (!val) return
if (match) { // 解析ISO 8601字符串到custom
custom.value.Y = match[1] || '' const match = val.match(
custom.value.M = match[2] || '' /^P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/
custom.value.D = match[3] || '' )
custom.value.H = match[4] || '' if (match) {
custom.value.m = match[5] || '' custom.value.Y = match[1] || ''
custom.value.S = match[6] || '' custom.value.M = match[2] || ''
updateIsoString() custom.value.D = match[3] || ''
} custom.value.H = match[4] || ''
}, { immediate: true }) custom.value.m = match[5] || ''
</script> custom.value.S = match[6] || ''
updateIsoString()
}
},
{ immediate: true }
)
</script>
<template> <template>
<div class="panel-tab__content"> <div class="panel-tab__content">
<div style="margin-top: 10px;"> <div style="margin-top: 10px">
<span>类型:</span> <span>类型:</span>
<el-button-group> <el-button-group>
<el-button size="mini" :type="type==='time'?'primary':''" @click="setType('time')">时间</el-button> <el-button size="mini" :type="type === 'time' ? 'primary' : ''" @click="setType('time')"
<el-button size="mini" :type="type==='duration'?'primary':''" @click="setType('duration')">持续</el-button> >时间</el-button
<el-button size="mini" :type="type==='cycle'?'primary':''" @click="setType('cycle')">循环</el-button> >
<el-button
size="mini"
:type="type === 'duration' ? 'primary' : ''"
@click="setType('duration')"
>持续</el-button
>
<el-button size="mini" :type="type === 'cycle' ? 'primary' : ''" @click="setType('cycle')"
>循环</el-button
>
</el-button-group> </el-button-group>
<el-icon v-if="valid" color="green" style="margin-left:8px"><CircleCheckFilled /></el-icon> <el-icon v-if="valid" color="green" style="margin-left: 8px"><CircleCheckFilled /></el-icon>
</div> </div>
<div style="margin-top: 10px; display: flex; align-items: center;"> <div style="margin-top: 10px; display: flex; align-items: center">
<span>条件:</span> <span>条件:</span>
<el-input <el-input
v-model="condition" v-model="condition"
:placeholder="placeholder" :placeholder="placeholder"
style="width: calc(100% - 100px);" style="width: calc(100% - 100px)"
:readonly="type !== 'duration' && type !== 'cycle'" :readonly="type !== 'duration' && type !== 'cycle'"
@focus="handleInputFocus" @focus="handleInputFocus"
@blur="updateNode" @blur="updateNode"
...@@ -24,7 +33,9 @@ ...@@ -24,7 +33,9 @@
<el-icon color="orange"><WarningFilled /></el-icon> <el-icon color="orange"><WarningFilled /></el-icon>
</el-tooltip> </el-tooltip>
<el-tooltip :content="helpText" placement="top"> <el-tooltip :content="helpText" placement="top">
<el-icon color="#409EFF" style="cursor: pointer" @click="showHelp = true"><QuestionFilled /></el-icon> <el-icon color="#409EFF" style="cursor: pointer" @click="showHelp = true"
><QuestionFilled
/></el-icon>
</el-tooltip> </el-tooltip>
<el-button <el-button
v-if="type === 'time'" v-if="type === 'time'"
...@@ -57,40 +68,55 @@ ...@@ -57,40 +68,55 @@
</el-input> </el-input>
</div> </div>
<!-- 时间选择器 --> <!-- 时间选择器 -->
<el-dialog v-model="showDatePicker" title="选择时间" width="400px" @close="showDatePicker=false"> <el-dialog
v-model="showDatePicker"
title="选择时间"
width="400px"
@close="showDatePicker = false"
>
<el-date-picker <el-date-picker
v-model="dateValue" v-model="dateValue"
type="datetime" type="datetime"
placeholder="选择日期时间" placeholder="选择日期时间"
style="width: 100%;" style="width: 100%"
@change="onDateChange" @change="onDateChange"
/> />
<template #footer> <template #footer>
<el-button @click="showDatePicker=false">取消</el-button> <el-button @click="showDatePicker = false">取消</el-button>
<el-button type="primary" @click="onDateConfirm">确定</el-button> <el-button type="primary" @click="onDateConfirm">确定</el-button>
</template> </template>
</el-dialog> </el-dialog>
<!-- 持续时长选择器 --> <!-- 持续时长选择器 -->
<el-dialog v-model="showDurationDialog" title="时间配置" width="600px" @close="showDurationDialog=false"> <el-dialog
v-model="showDurationDialog"
title="时间配置"
width="600px"
@close="showDurationDialog = false"
>
<DurationConfig :value="condition" @change="onDurationChange" /> <DurationConfig :value="condition" @change="onDurationChange" />
<template #footer> <template #footer>
<el-button @click="showDurationDialog=false">取消</el-button> <el-button @click="showDurationDialog = false">取消</el-button>
<el-button type="primary" @click="onDurationConfirm">确定</el-button> <el-button type="primary" @click="onDurationConfirm">确定</el-button>
</template> </template>
</el-dialog> </el-dialog>
<!-- 循环配置器 --> <!-- 循环配置器 -->
<el-dialog v-model="showCycleDialog" title="时间配置" width="800px" @close="showCycleDialog=false"> <el-dialog
v-model="showCycleDialog"
title="时间配置"
width="800px"
@close="showCycleDialog = false"
>
<CycleConfig :value="condition" @change="onCycleChange" /> <CycleConfig :value="condition" @change="onCycleChange" />
<template #footer> <template #footer>
<el-button @click="showCycleDialog=false">取消</el-button> <el-button @click="showCycleDialog = false">取消</el-button>
<el-button type="primary" @click="onCycleConfirm">确定</el-button> <el-button type="primary" @click="onCycleConfirm">确定</el-button>
</template> </template>
</el-dialog> </el-dialog>
<!-- 帮助说明 --> <!-- 帮助说明 -->
<el-dialog v-model="showHelp" title="格式说明" width="600px" @close="showHelp=false"> <el-dialog v-model="showHelp" title="格式说明" width="600px" @close="showHelp = false">
<div v-html="helpHtml"></div> <div v-html="helpHtml"></div>
<template #footer> <template #footer>
<el-button @click="showHelp=false">关闭</el-button> <el-button @click="showHelp = false">关闭</el-button>
</template> </template>
</el-dialog> </el-dialog>
</div> </div>
...@@ -158,7 +184,6 @@ function syncFromBusinessObject() { ...@@ -158,7 +184,6 @@ function syncFromBusinessObject() {
} }
onMounted(syncFromBusinessObject) onMounted(syncFromBusinessObject)
// 切换类型 // 切换类型
function setType(t) { function setType(t) {
type.value = t type.value = t
...@@ -235,9 +260,10 @@ function updateNode() { ...@@ -235,9 +260,10 @@ function updateNode() {
if (!element) return if (!element) return
// 1. 复用原有 timerDef,或新建 // 1. 复用原有 timerDef,或新建
let timerDef = (element.businessObject.eventDefinitions && element.businessObject.eventDefinitions[0]) let timerDef =
element.businessObject.eventDefinitions && element.businessObject.eventDefinitions[0]
if (!timerDef) { if (!timerDef) {
timerDef =bpmnInstances().bpmnFactory.create('bpmn:TimerEventDefinition', {}) timerDef = bpmnInstances().bpmnFactory.create('bpmn:TimerEventDefinition', {})
modeling.updateProperties(element, { modeling.updateProperties(element, {
eventDefinitions: [timerDef] eventDefinitions: [timerDef]
}) })
...@@ -250,11 +276,17 @@ function updateNode() { ...@@ -250,11 +276,17 @@ function updateNode() {
// 3. 设置新的 // 3. 设置新的
if (type.value === 'time' && condition.value) { if (type.value === 'time' && condition.value) {
timerDef.timeDate =bpmnInstances().bpmnFactory.create('bpmn:FormalExpression', { body: condition.value }) timerDef.timeDate = bpmnInstances().bpmnFactory.create('bpmn:FormalExpression', {
body: condition.value
})
} else if (type.value === 'duration' && condition.value) { } else if (type.value === 'duration' && condition.value) {
timerDef.timeDuration =bpmnInstances().bpmnFactory.create('bpmn:FormalExpression', { body: condition.value }) timerDef.timeDuration = bpmnInstances().bpmnFactory.create('bpmn:FormalExpression', {
body: condition.value
})
} else if (type.value === 'cycle' && condition.value) { } else if (type.value === 'cycle' && condition.value) {
timerDef.timeCycle = bpmnInstances().bpmnFactory.create('bpmn:FormalExpression', { body: condition.value }) timerDef.timeCycle = bpmnInstances().bpmnFactory.create('bpmn:FormalExpression', {
body: condition.value
})
} }
bpmnInstances().modeling.updateProperties(toRaw(element), { bpmnInstances().modeling.updateProperties(toRaw(element), {
...@@ -262,13 +294,11 @@ function updateNode() { ...@@ -262,13 +294,11 @@ function updateNode() {
}) })
} }
watch( watch(
() => props.businessObject, () => props.businessObject,
(val) => { (val) => {
if (val) { if (val) {
nextTick(() => { nextTick(() => {
syncFromBusinessObject() syncFromBusinessObject()
}) })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment