fix: 处理 window.bpmnInstances 有时候为 undefined 问题
This commit is contained in:
parent
9f0065f89f
commit
6b3de50c69
@ -110,18 +110,18 @@ const timer = ref()
|
|||||||
provide('prefix', props.prefix)
|
provide('prefix', props.prefix)
|
||||||
provide('width', props.width)
|
provide('width', props.width)
|
||||||
const bpmnInstances = () => (window as any)?.bpmnInstances
|
const bpmnInstances = () => (window as any)?.bpmnInstances
|
||||||
const initModels = () => {
|
|
||||||
// console.log(props, 'props')
|
// 监听 props.bpmnModeler 然后 initModels
|
||||||
// console.log(props.bpmnModeler, 'sakdjjaskdsajdkasdjkadsjk')
|
const unwatchBpmn = watch(
|
||||||
// 初始化 modeler 以及其他 moddle
|
() => props.bpmnModeler,
|
||||||
// nextTick(() => {
|
() => {
|
||||||
if (!props.bpmnModeler) {
|
|
||||||
// 避免加载时 流程图 并未加载完成
|
// 避免加载时 流程图 并未加载完成
|
||||||
timer.value = setTimeout(() => initModels(), 10)
|
if (!props.bpmnModeler) {
|
||||||
|
console.log('缺少props.bpmnModeler')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (timer.value) {
|
|
||||||
clearTimeout(timer.value)
|
console.log('props.bpmnModeler 有值了!!!')
|
||||||
const w = window as any
|
const w = window as any
|
||||||
w.bpmnInstances = {
|
w.bpmnInstances = {
|
||||||
modeler: props.bpmnModeler,
|
modeler: props.bpmnModeler,
|
||||||
@ -134,12 +134,16 @@ const initModels = () => {
|
|||||||
replace: props.bpmnModeler.get('replace'),
|
replace: props.bpmnModeler.get('replace'),
|
||||||
selection: props.bpmnModeler.get('selection')
|
selection: props.bpmnModeler.get('selection')
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
console.log(bpmnInstances(), 'window.bpmnInstances')
|
console.log(bpmnInstances(), 'window.bpmnInstances')
|
||||||
getActiveElement()
|
getActiveElement()
|
||||||
// })
|
unwatchBpmn()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
immediate: true
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|
||||||
const getActiveElement = () => {
|
const getActiveElement = () => {
|
||||||
// 初始第一个选中元素 bpmn:Process
|
// 初始第一个选中元素 bpmn:Process
|
||||||
initFormOnChanged(null)
|
initFormOnChanged(null)
|
||||||
@ -187,11 +191,7 @@ const initFormOnChanged = (element) => {
|
|||||||
)
|
)
|
||||||
formVisible.value = elementType.value === 'UserTask' || elementType.value === 'StartEvent'
|
formVisible.value = elementType.value === 'UserTask' || elementType.value === 'StartEvent'
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
|
||||||
setTimeout(() => {
|
|
||||||
initModels()
|
|
||||||
}, 100)
|
|
||||||
})
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
const w = window as any
|
const w = window as any
|
||||||
w.bpmnInstances = null
|
w.bpmnInstances = null
|
||||||
|
Loading…
Reference in New Issue
Block a user