| | |
| | | } |
| | | |
| | | const haveSeat = async (newRoomVO: RoomVO) => { |
| | | ElMessageBox.confirm( |
| | | '入座, 是否继续?', |
| | | '提示', |
| | | { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | } |
| | | ).then(async () => { |
| | | haveSeatConfirm(newRoomVO) |
| | | }).catch(() => { |
| | | }); |
| | | // 1. 提取不同的提示语 |
| | | const message = newRoomVO.docId != null |
| | | ? '已经有人了, 是否确定要继续入座?' |
| | | : '入座, 是否继续?'; |
| | | |
| | | try { |
| | | // 2. 等待用户点击确认 |
| | | await ElMessageBox.confirm(message, '提示', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning' |
| | | }); |
| | | |
| | | if (newRoomVO.docId != null) { |
| | | await leaveSeatConfirm(newRoomVO); |
| | | } |
| | | |
| | | // 4. 离座成功(或原本就没人),最后执行入座 |
| | | await haveSeatConfirm(newRoomVO); |
| | | |
| | | } catch (err) { |
| | | // 只有用户主动点击取消时才忽略,其他报错可以打印出来方便排查 |
| | | if (err !== 'cancel') { |
| | | console.error('入座流程异常:', err); |
| | | } |
| | | } |
| | | } |
| | | |
| | | const leaveSeat = (roomVO: RoomVO) => { |