order.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. <template>
  2. <div class="hotel-order-page">
  3. <AiCrudPage
  4. ref="crudRef"
  5. :api-config="{
  6. list: 'get@/hotel/order/page',
  7. }"
  8. :search-schema="searchSchema"
  9. :columns="tableColumns"
  10. row-key="id"
  11. :hide-add="true"
  12. :hide-batch-delete="true"
  13. :show-export="false"
  14. :show-import="false"
  15. :hide-selection="true"
  16. >
  17. <!-- 工具栏:看板统计 -->
  18. <template #toolbar-start>
  19. <div class="order-dashboard">
  20. <div class="dashboard-item">
  21. <span class="dashboard-value warning">{{ dashboard.pendingCount }}</span>
  22. <span class="dashboard-label">待接单</span>
  23. </div>
  24. <div v-if="connected" class="sse-indicator" title="实时通知已连接">
  25. <span class="sse-dot" />
  26. </div>
  27. <div class="dashboard-item">
  28. <span class="dashboard-value primary">{{ dashboard.preparingCount }}</span>
  29. <span class="dashboard-label">备餐中</span>
  30. </div>
  31. <div class="dashboard-item">
  32. <span class="dashboard-value primary">{{ dashboard.deliveringCount }}</span>
  33. <span class="dashboard-label">配送中</span>
  34. </div>
  35. <div class="dashboard-divider" />
  36. <div class="dashboard-item">
  37. <span class="dashboard-value">{{ dashboard.todayTotal }}</span>
  38. <span class="dashboard-label">今日订单</span>
  39. </div>
  40. <div class="dashboard-item">
  41. <span class="dashboard-value success">¥{{ dashboard.todayRevenue }}</span>
  42. <span class="dashboard-label">今日营收</span>
  43. </div>
  44. </div>
  45. </template>
  46. </AiCrudPage>
  47. <!-- 订单详情弹窗 -->
  48. <NModal
  49. v-model:show="detailVisible"
  50. title="订单详情"
  51. preset="card"
  52. style="width: 680px;"
  53. :mask-closable="true"
  54. >
  55. <NSpin :show="detailLoading">
  56. <div v-if="detailData" class="order-detail">
  57. <!-- 基本信息 -->
  58. <div class="detail-section">
  59. <div class="detail-header">
  60. <span class="detail-order-no">{{ detailData.orderNo }}</span>
  61. <DictTag dict-type="hotel_order_status" :value="String(detailData.status)" size="small" />
  62. </div>
  63. <div class="detail-grid">
  64. <div class="detail-item">
  65. <span class="detail-label">房间号</span>
  66. <span class="detail-value">{{ detailData.roomNo }}</span>
  67. </div>
  68. <div class="detail-item">
  69. <span class="detail-label">联系人</span>
  70. <span class="detail-value">{{ detailData.contactName }}</span>
  71. </div>
  72. <div class="detail-item">
  73. <span class="detail-label">联系电话</span>
  74. <span class="detail-value">{{ detailData.contactPhone }}</span>
  75. </div>
  76. <div class="detail-item">
  77. <span class="detail-label">支付方式</span>
  78. <span class="detail-value">
  79. <DictTag v-if="detailData.payMethod" dict-type="hotel_pay_method" :value="detailData.payMethod" size="small" />
  80. </span>
  81. </div>
  82. <div class="detail-item">
  83. <span class="detail-label">配送时间</span>
  84. <span class="detail-value">
  85. <template v-if="detailData.deliveryTimeType === 'CUSTOM'">
  86. {{ detailData.customDeliveryTime }}
  87. </template>
  88. <template v-else>
  89. 立即送达
  90. </template>
  91. </span>
  92. </div>
  93. <div class="detail-item">
  94. <span class="detail-label">下单时间</span>
  95. <span class="detail-value">{{ detailData.createTime }}</span>
  96. </div>
  97. </div>
  98. <div v-if="detailData.note" class="detail-note">
  99. <span class="detail-label">备注:</span>{{ detailData.note }}
  100. </div>
  101. </div>
  102. <!-- 金额信息 -->
  103. <div class="detail-section">
  104. <div class="detail-amount-row">
  105. <span>菜品总额:<strong>¥{{ calcItemsTotal }}</strong></span>
  106. <span>配送费:<strong>¥{{ detailData.deliveryFee }}</strong></span>
  107. <span class="detail-total">合计:<strong>¥{{ detailData.totalAmount }}</strong></span>
  108. </div>
  109. </div>
  110. <!-- 时间线 -->
  111. <div v-if="hasTimeInfo" class="detail-section">
  112. <div class="detail-label" style="margin-bottom: 6px;">
  113. 时间记录
  114. </div>
  115. <div class="detail-grid">
  116. <div v-if="detailData.acceptTime" class="detail-item">
  117. <span class="detail-label">接单</span>
  118. <span class="detail-value">{{ detailData.acceptTime }}</span>
  119. </div>
  120. <div v-if="detailData.readyTime" class="detail-item">
  121. <span class="detail-label">出餐</span>
  122. <span class="detail-value">{{ detailData.readyTime }}</span>
  123. </div>
  124. <div v-if="detailData.deliverTime" class="detail-item">
  125. <span class="detail-label">配送</span>
  126. <span class="detail-value">{{ detailData.deliverTime }}</span>
  127. </div>
  128. <div v-if="detailData.completeTime" class="detail-item">
  129. <span class="detail-label">完成</span>
  130. <span class="detail-value">{{ detailData.completeTime }}</span>
  131. </div>
  132. <div v-if="detailData.refundTime" class="detail-item">
  133. <span class="detail-label">退单</span>
  134. <span class="detail-value">{{ detailData.refundTime }}</span>
  135. </div>
  136. </div>
  137. <div v-if="detailData.rejectReason" class="detail-note">
  138. <span class="detail-label">拒单原因:</span>{{ detailData.rejectReason }}
  139. </div>
  140. <div v-if="detailData.refundReason" class="detail-note">
  141. <span class="detail-label">退单原因:</span>{{ detailData.refundReason }}
  142. </div>
  143. </div>
  144. <!-- 菜品明细 -->
  145. <div class="detail-section">
  146. <div class="detail-label" style="margin-bottom: 6px;">
  147. 菜品明细
  148. </div>
  149. <NDataTable
  150. :columns="detailItemColumns"
  151. :data="detailData.items || []"
  152. :bordered="true"
  153. size="small"
  154. :pagination="false"
  155. />
  156. </div>
  157. </div>
  158. </NSpin>
  159. </NModal>
  160. <!-- 原因输入弹窗(拒单/退单审核) -->
  161. <NModal
  162. v-model:show="reasonVisible"
  163. :title="reasonTitle"
  164. preset="dialog"
  165. style="width: 420px;"
  166. :show-icon="false"
  167. :mask-closable="false"
  168. positive-text="确认"
  169. negative-text="取消"
  170. @positive-click="handleReasonConfirm"
  171. >
  172. <NInput
  173. v-model:value="reasonText"
  174. type="textarea"
  175. placeholder="请输入原因(选填)"
  176. :rows="3"
  177. />
  178. </NModal>
  179. </div>
  180. </template>
  181. <script setup>
  182. import { NDataTable, NInput, NModal, NSpin, useDialog, useMessage } from 'naive-ui'
  183. import { computed, h, onMounted, onUnmounted, ref, watch } from 'vue'
  184. import {
  185. acceptOrder,
  186. approveRefund,
  187. completeOrder,
  188. deliverOrder,
  189. getOrderDashboard,
  190. getOrderDetail,
  191. getOrderPage,
  192. hotelRefund,
  193. orderRefund,
  194. prepareOrder,
  195. readyOrder,
  196. rejectOrder,
  197. rejectRefund,
  198. } from '@/api/hotel'
  199. import { AiCrudPage } from '@/components/ai-form'
  200. import DictTag from '@/components/DictTag.vue'
  201. import { useDict } from '@/composables/useDict'
  202. import { useOrderNotification } from '@/composables/useOrderNotification'
  203. defineOptions({ name: 'HotelOrder' })
  204. const message = useMessage()
  205. const dialog = useDialog()
  206. const { dict } = useDict('hotel_order_status', 'hotel_pay_method', 'hotel_refund_status')
  207. const crudRef = ref(null)
  208. // ==================== SSE 实时通知 ====================
  209. const { connected, connect, disconnect, playSound } = useOrderNotification({
  210. onNewOrder: () => {
  211. crudRef.value?.refresh()
  212. loadDashboard()
  213. },
  214. onRefundRequest: () => {
  215. crudRef.value?.refresh()
  216. loadDashboard()
  217. },
  218. })
  219. /** 监听页面内通知事件(由 useOrderNotification 派发) */
  220. function handleHotelNotification(e) {
  221. const { type, message: msg, level } = e.detail
  222. const nType = level === 'warning' ? 'warning' : 'info'
  223. $notification[nType]({
  224. title: type === 'new-order' ? '新订单' : '退单申请',
  225. content: msg,
  226. duration: 5000,
  227. })
  228. }
  229. onMounted(() => {
  230. loadDashboard()
  231. connect()
  232. window.addEventListener('hotel-notification', handleHotelNotification)
  233. })
  234. onUnmounted(() => {
  235. disconnect()
  236. window.removeEventListener('hotel-notification', handleHotelNotification)
  237. })
  238. // 监听 SSE 连接状态,连接成功后检查待处理订单(浏览器刷新和页面标签刷新都会触发)
  239. watch(connected, (newVal) => {
  240. if (newVal) {
  241. console.log('[订单页面] SSE 连接已建立,检查待处理订单')
  242. checkPendingOrders()
  243. }
  244. })
  245. // ==================== 看板统计 ====================
  246. const dashboard = ref({
  247. pendingCount: 0,
  248. preparingCount: 0,
  249. deliveringCount: 0,
  250. todayTotal: 0,
  251. todayRevenue: '0.00',
  252. })
  253. async function loadDashboard() {
  254. try {
  255. const res = await getOrderDashboard()
  256. if (res.code === 200 && res.data) {
  257. dashboard.value = res.data
  258. }
  259. }
  260. catch (err) {
  261. // ignore
  262. void err
  263. }
  264. }
  265. /**
  266. * 页面加载时检查待接单订单,如果有则触发语音通知。
  267. * 这样刷新页面就能听到声音提醒了。
  268. */
  269. async function checkPendingOrders() {
  270. try {
  271. // 查询待接单订单(status=1)
  272. const res = await getOrderPage({
  273. pageNum: 1,
  274. pageSize: 1,
  275. status: 1, // 待接单
  276. })
  277. if (res.code === 200 && res.data?.total > 0) {
  278. console.warn('[SSE] 📢 检测到待接单订单,触发语音通知')
  279. // 播放声音
  280. playSound('new-order')
  281. // 触发一次新订单通知(显示桌面弹窗)
  282. window.dispatchEvent(new CustomEvent('hotel-notification', {
  283. detail: {
  284. type: 'new-order',
  285. message: `您有 ${res.data.total} 个待接单订单`,
  286. level: 'info',
  287. },
  288. }))
  289. }
  290. }
  291. catch (err) {
  292. console.error('[SSE] 检查待接单订单失败:', err)
  293. }
  294. }
  295. // ==================== 搜索配置 ====================
  296. const statusOptions = computed(() => {
  297. const list = dict.value.hotel_order_status || []
  298. return list.map(item => ({ label: item.label, value: Number(item.value) }))
  299. })
  300. const payMethodOptions = computed(() => dict.value.hotel_pay_method || [])
  301. const searchSchema = computed(() => [
  302. {
  303. field: 'roomNo',
  304. label: '房间号',
  305. type: 'input',
  306. props: { placeholder: '请输入房间号' },
  307. },
  308. {
  309. field: 'status',
  310. label: '订单状态',
  311. type: 'select',
  312. props: { placeholder: '请选择状态', options: statusOptions.value },
  313. },
  314. {
  315. field: 'contactName',
  316. label: '联系人',
  317. type: 'input',
  318. props: { placeholder: '请输入联系人姓名' },
  319. },
  320. {
  321. field: 'payMethod',
  322. label: '支付方式',
  323. type: 'select',
  324. props: { placeholder: '请选择支付方式', options: payMethodOptions.value },
  325. },
  326. ])
  327. // ==================== 状态标签渲染 ====================
  328. function renderStatus(status) {
  329. return h(DictTag, { dictType: 'hotel_order_status', value: String(status), size: 'small' })
  330. }
  331. // ==================== 表格列配置 ====================
  332. const tableColumns = computed(() => [
  333. { prop: 'orderNo', label: '订单号', width: 180 },
  334. { prop: 'roomNo', label: '房间号', width: 90 },
  335. { prop: 'contactName', label: '联系人', width: 90 },
  336. { prop: 'itemCount', label: '菜品数', width: 70 },
  337. {
  338. prop: 'totalAmount',
  339. label: '金额(元)',
  340. width: 100,
  341. render: row => `¥${row.totalAmount}`,
  342. },
  343. {
  344. prop: 'status',
  345. label: '状态',
  346. width: 110,
  347. render: row => renderStatus(row.status),
  348. },
  349. {
  350. prop: 'refundStatus',
  351. label: '退款',
  352. width: 90,
  353. render: (row) => {
  354. // refundStatus 为 null 表示未触发过退款,仅已支付订单才有退款语义
  355. if (row.refundStatus === null || row.refundStatus === undefined)
  356. return '-'
  357. return h(DictTag, { dictType: 'hotel_refund_status', value: String(row.refundStatus), size: 'small' })
  358. },
  359. },
  360. { prop: 'createTime', label: '下单时间', width: 172 },
  361. {
  362. label: '操作',
  363. width: 360,
  364. fixed: 'right',
  365. render: (row) => {
  366. const actions = []
  367. const s = row.status
  368. // 查看详情(所有状态)
  369. actions.push(h('a', {
  370. class: 'text-info cursor-pointer hover:opacity-80',
  371. onClick: () => openDetail(row),
  372. }, '详情'))
  373. // 接单(仅待接单)
  374. if (s === 1) {
  375. actions.push(h('a', {
  376. class: 'text-success cursor-pointer hover:opacity-80',
  377. onClick: () => handleAction('accept', row),
  378. }, '接单'))
  379. actions.push(h('a', {
  380. class: 'text-error cursor-pointer hover:opacity-80',
  381. onClick: () => handleAction('reject', row),
  382. }, '拒单'))
  383. }
  384. // 备餐(仅已接单)
  385. if (s === 2) {
  386. actions.push(h('a', {
  387. class: 'text-primary cursor-pointer hover:opacity-80',
  388. onClick: () => handleAction('prepare', row),
  389. }, '备餐'))
  390. }
  391. // 出餐(仅备餐中)
  392. if (s === 3) {
  393. actions.push(h('a', {
  394. class: 'text-success cursor-pointer hover:opacity-80',
  395. onClick: () => handleAction('ready', row),
  396. }, '出餐'))
  397. }
  398. // 配送(仅已出餐)
  399. if (s === 4) {
  400. actions.push(h('a', {
  401. class: 'text-primary cursor-pointer hover:opacity-80',
  402. onClick: () => handleAction('deliver', row),
  403. }, '配送'))
  404. }
  405. // 完成(仅配送中)
  406. if (s === 5) {
  407. actions.push(h('a', {
  408. class: 'text-success cursor-pointer hover:opacity-80',
  409. onClick: () => handleAction('complete', row),
  410. }, '完成'))
  411. }
  412. // 退单审核(仅退单待审核)
  413. if (s === 8) {
  414. actions.push(h('a', {
  415. class: 'text-success cursor-pointer hover:opacity-80',
  416. onClick: () => handleAction('approveRefund', row),
  417. }, '同意退单'))
  418. actions.push(h('a', {
  419. class: 'text-error cursor-pointer hover:opacity-80',
  420. onClick: () => handleAction('rejectRefund', row),
  421. }, '驳回'))
  422. }
  423. // 前台退单(除已完成、已退单、已拒单外)
  424. if (s !== 6 && s !== 7 && s !== 9) {
  425. actions.push(h('a', {
  426. class: 'text-warning cursor-pointer hover:opacity-80',
  427. onClick: () => handleAction('hotelRefund', row),
  428. }, '退单'))
  429. }
  430. // 手动退款:已支付未退款的异常场景(退房竞态取消/退款失败重试)
  431. // 7=已拒单 9=已退单 10=超时取消 11=退房联动取消;退款失败(2)也可重试
  432. const refundable = row.payStatus === 1
  433. && row.refundStatus !== 1
  434. && (row.refundStatus === 2 || s === 7 || s === 9 || s === 10 || s === 11)
  435. if (refundable) {
  436. actions.push(h('a', {
  437. class: 'text-error cursor-pointer hover:opacity-80',
  438. onClick: () => handleAction('refund', row),
  439. }, '退款'))
  440. }
  441. return h('div', { class: 'flex gap-2' }, actions)
  442. },
  443. },
  444. ])
  445. // ==================== 订单操作 ====================
  446. const reasonVisible = ref(false)
  447. const reasonTitle = ref('')
  448. const reasonText = ref('')
  449. const reasonCallback = ref(null)
  450. function handleAction(action, row) {
  451. switch (action) {
  452. case 'accept':
  453. dialog.warning({
  454. title: '确认接单',
  455. content: `确认接受订单 ${row.orderNo} 吗?`,
  456. positiveText: '确认接单',
  457. negativeText: '取消',
  458. onPositiveClick: async () => {
  459. await acceptOrder(row.id)
  460. message.success('接单成功')
  461. crudRef.value?.refresh()
  462. loadDashboard()
  463. },
  464. })
  465. break
  466. case 'reject':
  467. openReasonModal('拒单', async (reason) => {
  468. await rejectOrder(row.id, reason)
  469. message.success('已拒单')
  470. crudRef.value?.refresh()
  471. loadDashboard()
  472. })
  473. break
  474. case 'prepare':
  475. dialog.warning({
  476. title: '开始备餐',
  477. content: `确认开始备餐 ${row.orderNo}?`,
  478. positiveText: '确认',
  479. negativeText: '取消',
  480. onPositiveClick: async () => {
  481. await prepareOrder(row.id)
  482. message.success('已开始备餐')
  483. crudRef.value?.refresh()
  484. loadDashboard()
  485. },
  486. })
  487. break
  488. case 'ready':
  489. dialog.warning({
  490. title: '出餐完成',
  491. content: `确认订单 ${row.orderNo} 出餐完成?`,
  492. positiveText: '确认出餐',
  493. negativeText: '取消',
  494. onPositiveClick: async () => {
  495. await readyOrder(row.id)
  496. message.success('已出餐')
  497. crudRef.value?.refresh()
  498. loadDashboard()
  499. },
  500. })
  501. break
  502. case 'deliver':
  503. dialog.warning({
  504. title: '开始配送',
  505. content: `确认开始配送订单 ${row.orderNo}?`,
  506. positiveText: '确认配送',
  507. negativeText: '取消',
  508. onPositiveClick: async () => {
  509. await deliverOrder(row.id)
  510. message.success('已开始配送')
  511. crudRef.value?.refresh()
  512. loadDashboard()
  513. },
  514. })
  515. break
  516. case 'complete':
  517. dialog.warning({
  518. title: '完成配送',
  519. content: `确认订单 ${row.orderNo} 配送完成?`,
  520. positiveText: '确认完成',
  521. negativeText: '取消',
  522. onPositiveClick: async () => {
  523. await completeOrder(row.id)
  524. message.success('订单已完成')
  525. crudRef.value?.refresh()
  526. loadDashboard()
  527. },
  528. })
  529. break
  530. case 'hotelRefund':
  531. openReasonModal('前台退单', async (reason) => {
  532. await hotelRefund(row.id, reason)
  533. message.success('退单成功')
  534. crudRef.value?.refresh()
  535. loadDashboard()
  536. })
  537. break
  538. case 'approveRefund':
  539. dialog.warning({
  540. title: '同意退单',
  541. content: `确认同意订单 ${row.orderNo} 的退单申请?`,
  542. positiveText: '同意退单',
  543. negativeText: '取消',
  544. onPositiveClick: async () => {
  545. await approveRefund(row.id)
  546. message.success('已同意退单')
  547. crudRef.value?.refresh()
  548. loadDashboard()
  549. },
  550. })
  551. break
  552. case 'rejectRefund':
  553. openReasonModal('驳回退单', async (reason) => {
  554. await rejectRefund(row.id, reason)
  555. message.success('已驳回退单申请')
  556. crudRef.value?.refresh()
  557. loadDashboard()
  558. })
  559. break
  560. case 'refund':
  561. dialog.warning({
  562. title: '手动退款',
  563. content: `确认对订单 ${row.orderNo} 发起全额退款(¥${row.totalAmount})?`,
  564. positiveText: '确认退款',
  565. negativeText: '取消',
  566. onPositiveClick: async () => {
  567. try {
  568. const res = await orderRefund(row.id)
  569. if (res.code === 200) {
  570. message.success('退款成功')
  571. }
  572. else {
  573. message.error(res.msg || '退款失败,可稍后重试')
  574. }
  575. }
  576. catch {
  577. message.error('退款失败,订单已标记为退款失败状态,可稍后重试')
  578. }
  579. crudRef.value?.refresh()
  580. loadDashboard()
  581. },
  582. })
  583. break
  584. }
  585. }
  586. function openReasonModal(title, callback) {
  587. reasonTitle.value = title
  588. reasonText.value = ''
  589. reasonCallback.value = callback
  590. reasonVisible.value = true
  591. }
  592. async function handleReasonConfirm() {
  593. if (reasonCallback.value) {
  594. await reasonCallback.value(reasonText.value || undefined)
  595. }
  596. }
  597. // ==================== 订单详情 ====================
  598. const detailVisible = ref(false)
  599. const detailLoading = ref(false)
  600. const detailData = ref(null)
  601. const detailItemColumns = [
  602. { title: '菜品名称', key: 'dishName', minWidth: 120 },
  603. { title: '规格', key: 'specDesc', width: 120, render: row => row.specDesc || '' },
  604. { title: '加料', key: 'additionsDesc', width: 120, render: row => row.additionsDesc || '' },
  605. { title: '数量', key: 'quantity', width: 60 },
  606. { title: '单价', key: 'unitPrice', width: 80, render: row => `¥${row.unitPrice}` },
  607. { title: '小计', key: 'subtotal', width: 80, render: row => `¥${row.subtotal}` },
  608. { title: '备注', key: 'note', width: 100, render: row => row.note || '' },
  609. ]
  610. const calcItemsTotal = computed(() => {
  611. if (!detailData.value?.items)
  612. return '0.00'
  613. const sum = detailData.value.items.reduce((acc, item) => acc + Number(item.subtotal || 0), 0)
  614. return sum.toFixed(2)
  615. })
  616. const hasTimeInfo = computed(() => {
  617. if (!detailData.value)
  618. return false
  619. const d = detailData.value
  620. return d.acceptTime || d.readyTime || d.deliverTime || d.completeTime || d.refundTime || d.rejectReason || d.refundReason
  621. })
  622. async function openDetail(row) {
  623. detailVisible.value = true
  624. detailLoading.value = true
  625. detailData.value = null
  626. try {
  627. const res = await getOrderDetail(row.id)
  628. if (res.code === 200) {
  629. detailData.value = res.data
  630. }
  631. }
  632. catch {
  633. message.error('加载订单详情失败')
  634. }
  635. finally {
  636. detailLoading.value = false
  637. }
  638. }
  639. </script>
  640. <style scoped>
  641. .hotel-order-page {
  642. height: 100%;
  643. }
  644. /* ==================== 看板统计 ==================== */
  645. .order-dashboard {
  646. display: flex;
  647. align-items: center;
  648. gap: 16px;
  649. padding: 0 4px;
  650. }
  651. .dashboard-item {
  652. display: flex;
  653. flex-direction: column;
  654. align-items: center;
  655. min-width: 56px;
  656. }
  657. .dashboard-value {
  658. font-size: 18px;
  659. font-weight: 700;
  660. line-height: 1.2;
  661. color: #333;
  662. }
  663. .dashboard-value.warning {
  664. color: #f0a020;
  665. }
  666. .dashboard-value.primary {
  667. color: #2080f0;
  668. }
  669. .dashboard-value.success {
  670. color: #18a058;
  671. }
  672. .dashboard-label {
  673. font-size: 12px;
  674. color: #999;
  675. margin-top: 2px;
  676. }
  677. .dashboard-divider {
  678. width: 1px;
  679. height: 28px;
  680. background: #e8e8e8;
  681. margin: 0 4px;
  682. }
  683. /* ==================== SSE连接指示器 ==================== */
  684. .sse-indicator {
  685. display: flex;
  686. align-items: center;
  687. margin-left: 4px;
  688. }
  689. .sse-dot {
  690. display: inline-block;
  691. width: 8px;
  692. height: 8px;
  693. border-radius: 50%;
  694. background: #18a058;
  695. animation: sse-pulse 2s ease-in-out infinite;
  696. }
  697. @keyframes sse-pulse {
  698. 0%,
  699. 100% {
  700. opacity: 1;
  701. }
  702. 50% {
  703. opacity: 0.4;
  704. }
  705. }
  706. /* ==================== 订单详情 ==================== */
  707. .order-detail {
  708. display: flex;
  709. flex-direction: column;
  710. gap: 16px;
  711. }
  712. .detail-section {
  713. padding-bottom: 12px;
  714. border-bottom: 1px solid #f0f0f0;
  715. }
  716. .detail-section:last-child {
  717. border-bottom: none;
  718. padding-bottom: 0;
  719. }
  720. .detail-header {
  721. display: flex;
  722. align-items: center;
  723. justify-content: space-between;
  724. margin-bottom: 12px;
  725. }
  726. .detail-order-no {
  727. font-size: 16px;
  728. font-weight: 700;
  729. color: #333;
  730. }
  731. .detail-grid {
  732. display: grid;
  733. grid-template-columns: repeat(3, 1fr);
  734. gap: 8px 16px;
  735. }
  736. .detail-item {
  737. display: flex;
  738. flex-direction: column;
  739. gap: 2px;
  740. }
  741. .detail-label {
  742. font-size: 12px;
  743. color: #999;
  744. }
  745. .detail-value {
  746. font-size: 14px;
  747. color: #333;
  748. }
  749. .detail-note {
  750. margin-top: 8px;
  751. font-size: 13px;
  752. color: #666;
  753. padding: 6px 10px;
  754. background: #fafafa;
  755. border-radius: 4px;
  756. }
  757. .detail-amount-row {
  758. display: flex;
  759. gap: 24px;
  760. font-size: 14px;
  761. color: #333;
  762. }
  763. .detail-total {
  764. margin-left: auto;
  765. font-size: 16px;
  766. color: #f0a020;
  767. }
  768. </style>