diff --git a/src/views/wf/ticketd_b.vue b/src/views/wf/ticketd_b.vue index 0078a9de..54f3eaed 100644 --- a/src/views/wf/ticketd_b.vue +++ b/src/views/wf/ticketd_b.vue @@ -34,18 +34,27 @@ const props = defineProps({ const workflow = ref(null); const transitions = ref([]); -onMounted(async () => { - setTimeout(()=>{init()}, 1000) - // watch( - // () => props.ticket_, - // async (newVal) => { - // if (newVal && Object.keys(newVal).length > 0) { - // init(); - // } - // }, - // { deep: true } - // ) -}) +let lastInitTicketId = null; +const tryInit = () => { + // 优先用 ticket_ 分支:等到 ticket_.id 出现再调 + if (props.ticket_ && props.ticket_.id) { + if (lastInitTicketId !== props.ticket_.id) { + lastInitTicketId = props.ticket_.id; + init(); + } + return; + } + // 没有 ticket_,退化到 workflow_key 分支(创建工单场景) + if (props.workflow_key) { + if (lastInitTicketId !== '__wf_key__:' + props.workflow_key) { + lastInitTicketId = '__wf_key__:' + props.workflow_key; + init(); + } + } +}; +onMounted(() => { tryInit(); }); +watch(() => props.ticket_, () => { tryInit(); }, { deep: true }); +watch(() => props.workflow_key, () => { tryInit(); }); const ticketId = ref(null); const actionShow = ref(false);