fix(wf): 工单审批按钮偶尔不渲染
ticketd_b 原先用 setTimeout 1s 后调 init(),挂载瞬间 props.ticket_ 还是 null,1 秒等待无法保证父表单 getTid 已完成且 props 已传到。 init 读到的 props.ticket_ 仍为 falsy 时会错误地走 workflow_key 分支调 init_key,把 transitions 初始化成新建工单的初始 transition, 导致审批人看不到"同意"等操作按钮。 改用 watch props.ticket_ / props.workflow_key 触发 init,并加 lastInitTicketId 去重避免重复调用。 复现:cuishuai 登录 → /ofm/publicity → 点详情 → 看不到"同意"按钮。 影响范围:所有使用 ticketd_b 的审批表单(请假/合同/宣传/维修等)。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a9c3903864
commit
119fa9cb94
|
|
@ -34,18 +34,27 @@ const props = defineProps({
|
||||||
|
|
||||||
const workflow = ref(null);
|
const workflow = ref(null);
|
||||||
const transitions = ref([]);
|
const transitions = ref([]);
|
||||||
onMounted(async () => {
|
let lastInitTicketId = null;
|
||||||
setTimeout(()=>{init()}, 1000)
|
const tryInit = () => {
|
||||||
// watch(
|
// 优先用 ticket_ 分支:等到 ticket_.id 出现再调
|
||||||
// () => props.ticket_,
|
if (props.ticket_ && props.ticket_.id) {
|
||||||
// async (newVal) => {
|
if (lastInitTicketId !== props.ticket_.id) {
|
||||||
// if (newVal && Object.keys(newVal).length > 0) {
|
lastInitTicketId = props.ticket_.id;
|
||||||
// init();
|
init();
|
||||||
// }
|
}
|
||||||
// },
|
return;
|
||||||
// { deep: true }
|
}
|
||||||
// )
|
// 没有 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 ticketId = ref(null);
|
||||||
const actionShow = ref(false);
|
const actionShow = ref(false);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue