DishOrderApproval.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <view class="dish-order-approval">
  3. <view v-if="loading" class="loading-wrap">
  4. <u-loading-icon text="加载中" textSize="14"></u-loading-icon>
  5. </view>
  6. <view v-else-if="currentOrder" class="page-body">
  7. <view class="summary-card">
  8. <view class="summary-head">
  9. <view class="summary-title">订单信息</view>
  10. <view class="status-tag" :class="orderStatusClass(currentOrder.orderStatus)">{{ orderStatusName(currentOrder.orderStatus) }}</view>
  11. </view>
  12. <view class="summary-main">
  13. <view class="room-name">{{ currentOrder.roomName || '-' }}</view>
  14. <view class="order-no">{{ currentOrder.orderNo || '-' }}</view>
  15. </view>
  16. <view class="summary-grid">
  17. <view class="summary-item">
  18. <text>结账方式</text>
  19. <text>{{ settleTypeName(currentOrder.settleType) }}</text>
  20. </view>
  21. <view class="summary-item">
  22. <text>账单原金额</text>
  23. <text>¥{{ formatMoney(currentOrder.totalAmount) }}</text>
  24. </view>
  25. <view class="summary-item">
  26. <text>折扣比例</text>
  27. <text>{{ discountRateText(currentOrder) }}</text>
  28. </view>
  29. <view class="summary-item">
  30. <text>优惠金额</text>
  31. <text>¥{{ formatMoney(currentOrder.discountAmount) }}</text>
  32. </view>
  33. <view class="summary-item">
  34. <text>实收金额</text>
  35. <text>¥{{ formatMoney(currentOrder.payableAmount) }}</text>
  36. </view>
  37. <view class="summary-item summary-wide">
  38. <text>结账/取消时间</text>
  39. <text>{{ currentOrder.settleTime || '-' }}</text>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="tab-bar">
  44. <view
  45. v-for="tab in tabs"
  46. :key="tab.name"
  47. class="tab-item"
  48. :class="{ active: activeTab === tab.name }"
  49. @click="activeTab = tab.name"
  50. >
  51. <text>{{ tab.label }}</text>
  52. <text class="tab-count">{{ tab.count }}</text>
  53. </view>
  54. </view>
  55. <view class="dish-list">
  56. <view v-if="currentDetailList.length === 0" class="empty-wrap">
  57. <u-empty mode="data" text="暂无菜品"></u-empty>
  58. </view>
  59. <view v-for="(item, index) in currentDetailList" :key="item.id || index" class="dish-card">
  60. <view class="dish-row dish-title-row">
  61. <view class="dish-name">{{ item.dishName || '-' }}</view>
  62. <view class="dish-amount">¥{{ formatMoney(getDisplayAmount(item)) }}</view>
  63. </view>
  64. <view class="dish-meta">
  65. <text>{{ item.typeName || '未分类' }}</text>
  66. <text v-if="item.spec">规格:{{ item.spec }}</text>
  67. </view>
  68. <view class="dish-row">
  69. <view class="dish-price">单价 ¥{{ formatMoney(item.salePrice) }}</view>
  70. <view class="dish-qty">x {{ getDisplayQuantity(item) }}</view>
  71. </view>
  72. <view v-if="item.createTime && activeTab !== 'actual'" class="dish-time">
  73. {{ activeTab === 'add' ? '加菜时间' : '退菜时间' }}:{{ item.createTime }}
  74. </view>
  75. <view v-if="activeTab === 'reduce' && item.reason" class="dish-reason">
  76. 退菜原因:{{ item.reason }}
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <view v-else class="empty-page">
  82. <u-empty mode="data" text="暂无订单信息"></u-empty>
  83. </view>
  84. </view>
  85. </template>
  86. <script>
  87. import DishOrderService from '@/api/psi/DishOrderService'
  88. export default {
  89. name: 'DishOrderApproval',
  90. props: {
  91. businessId: {
  92. type: String,
  93. default: ''
  94. },
  95. formReadOnly: {
  96. type: Boolean,
  97. default: true
  98. },
  99. status: {
  100. type: String,
  101. default: ''
  102. }
  103. },
  104. data() {
  105. return {
  106. loading: false,
  107. activeTab: 'actual',
  108. currentOrder: null,
  109. routeBusinessId: '',
  110. dishOrderService: null
  111. }
  112. },
  113. computed: {
  114. tabs() {
  115. const order = this.currentOrder || {}
  116. return [
  117. { name: 'actual', label: '实际菜单', count: this.getList(order.detailList).length },
  118. { name: 'add', label: '加菜', count: this.getList(order.addDishList).length },
  119. { name: 'reduce', label: '退菜', count: this.getList(order.reduceDishList).length }
  120. ]
  121. },
  122. currentDetailList() {
  123. const order = this.currentOrder || {}
  124. if (this.activeTab === 'add') {
  125. return this.getList(order.addDishList)
  126. }
  127. if (this.activeTab === 'reduce') {
  128. return this.getList(order.reduceDishList)
  129. }
  130. return this.getList(order.detailList)
  131. }
  132. },
  133. watch: {
  134. businessId() {
  135. this.init()
  136. }
  137. },
  138. onLoad(option) {
  139. this.routeBusinessId = (option && (option.businessId || option.id)) || ''
  140. uni.setNavigationBarTitle({ title: '点菜订单审批' })
  141. this.init()
  142. },
  143. created() {
  144. this.dishOrderService = new DishOrderService()
  145. },
  146. mounted() {
  147. this.init()
  148. },
  149. methods: {
  150. init() {
  151. const id = this.getBusinessId()
  152. this.activeTab = 'actual'
  153. if (!id || id === 'false') {
  154. this.currentOrder = null
  155. return
  156. }
  157. if (!this.dishOrderService) {
  158. this.dishOrderService = new DishOrderService()
  159. }
  160. this.loading = true
  161. this.$emit('changeLoading', true)
  162. this.dishOrderService.findOrderById(id).then((data) => {
  163. this.currentOrder = data || {}
  164. }).catch(() => {
  165. this.currentOrder = null
  166. uni.showToast({ title: '订单信息加载失败', icon: 'none' })
  167. }).finally(() => {
  168. this.loading = false
  169. this.$emit('changeLoading', false)
  170. })
  171. },
  172. getBusinessId() {
  173. return this.businessId || this.routeBusinessId || ''
  174. },
  175. getKeyWatch() {
  176. this.init()
  177. },
  178. close() {
  179. this.currentOrder = null
  180. },
  181. saveForm(callback) {
  182. this.callFlowCallback(callback)
  183. },
  184. agreeForm(callback) {
  185. this.callFlowCallback(callback)
  186. },
  187. startForm(callback) {
  188. this.callFlowCallback(callback)
  189. },
  190. reapplyForm(callback) {
  191. this.callFlowCallback(callback)
  192. },
  193. updateStatusById(type, callback) {
  194. this.callFlowCallback(callback)
  195. },
  196. callFlowCallback(callback) {
  197. const order = this.currentOrder || {}
  198. if (callback) {
  199. callback('psi_dish_order', order.id || this.getBusinessId(), order)
  200. }
  201. },
  202. getList(list) {
  203. return Array.isArray(list) ? list : []
  204. },
  205. getDisplayQuantity(item) {
  206. return Math.abs(Number(item.quantity || 0))
  207. },
  208. getDisplayAmount(item) {
  209. return Math.abs(Number(item.amount || 0))
  210. },
  211. orderStatusName(value) {
  212. if (value === '0') {
  213. return '用餐中'
  214. }
  215. if (value === '1') {
  216. return '已结账'
  217. }
  218. if (value === '2') {
  219. return '已取消'
  220. }
  221. return '-'
  222. },
  223. orderStatusClass(value) {
  224. if (value === '1') {
  225. return 'success'
  226. }
  227. if (value === '2') {
  228. return 'danger'
  229. }
  230. return 'primary'
  231. },
  232. settleTypeName(value) {
  233. if (value === '0') {
  234. return '结账'
  235. }
  236. if (value === '1') {
  237. return '折扣结账'
  238. }
  239. if (value === '2') {
  240. return '优惠结账'
  241. }
  242. return '-'
  243. },
  244. discountRateText(order) {
  245. if (!order || order.settleType !== '1') {
  246. return '-'
  247. }
  248. return this.formatMoney(order.discountRate) + '%'
  249. },
  250. formatMoney(value) {
  251. return Number(value || 0).toFixed(2)
  252. }
  253. }
  254. }
  255. </script>
  256. <style scoped>
  257. .dish-order-approval {
  258. min-height: 100vh;
  259. background: #f5f6fa;
  260. padding: 20rpx 20rpx 40rpx;
  261. box-sizing: border-box;
  262. }
  263. .loading-wrap,
  264. .empty-page {
  265. min-height: 360rpx;
  266. display: flex;
  267. align-items: center;
  268. justify-content: center;
  269. background: #fff;
  270. border-radius: 16rpx;
  271. }
  272. .summary-card,
  273. .dish-card {
  274. background: #fff;
  275. border-radius: 16rpx;
  276. box-shadow: 0 8rpx 24rpx rgba(0, 0, 0, 0.04);
  277. }
  278. .summary-card {
  279. padding: 28rpx;
  280. }
  281. .summary-head,
  282. .summary-main,
  283. .dish-row,
  284. .tab-bar {
  285. display: flex;
  286. align-items: center;
  287. }
  288. .summary-head,
  289. .summary-main,
  290. .dish-row {
  291. justify-content: space-between;
  292. }
  293. .summary-title {
  294. font-size: 32rpx;
  295. font-weight: 600;
  296. color: #303133;
  297. }
  298. .status-tag {
  299. padding: 8rpx 18rpx;
  300. border-radius: 999rpx;
  301. font-size: 24rpx;
  302. line-height: 32rpx;
  303. color: #2979ff;
  304. background: #ecf5ff;
  305. }
  306. .status-tag.success {
  307. color: #19be6b;
  308. background: #e8f7ef;
  309. }
  310. .status-tag.danger {
  311. color: #fa3534;
  312. background: #fff1f0;
  313. }
  314. .summary-main {
  315. margin-top: 24rpx;
  316. gap: 24rpx;
  317. }
  318. .room-name {
  319. font-size: 40rpx;
  320. font-weight: 700;
  321. color: #1f2d3d;
  322. min-width: 0;
  323. flex: 1;
  324. overflow: hidden;
  325. text-overflow: ellipsis;
  326. white-space: nowrap;
  327. }
  328. .order-no {
  329. font-size: 24rpx;
  330. color: #909399;
  331. max-width: 320rpx;
  332. overflow: hidden;
  333. text-overflow: ellipsis;
  334. white-space: nowrap;
  335. }
  336. .summary-grid {
  337. display: grid;
  338. grid-template-columns: repeat(2, minmax(0, 1fr));
  339. gap: 22rpx;
  340. margin-top: 28rpx;
  341. }
  342. .summary-item {
  343. min-width: 0;
  344. padding: 18rpx;
  345. border-radius: 12rpx;
  346. background: #f7f8fa;
  347. }
  348. .summary-wide {
  349. grid-column: span 2;
  350. }
  351. .summary-item text:first-child {
  352. display: block;
  353. font-size: 24rpx;
  354. color: #909399;
  355. line-height: 34rpx;
  356. }
  357. .summary-item text:last-child {
  358. display: block;
  359. margin-top: 8rpx;
  360. font-size: 28rpx;
  361. font-weight: 600;
  362. color: #303133;
  363. line-height: 38rpx;
  364. word-break: break-all;
  365. }
  366. .tab-bar {
  367. margin: 24rpx 0;
  368. padding: 8rpx;
  369. background: #fff;
  370. border-radius: 14rpx;
  371. gap: 8rpx;
  372. }
  373. .tab-item {
  374. flex: 1;
  375. display: flex;
  376. align-items: center;
  377. justify-content: center;
  378. gap: 8rpx;
  379. height: 72rpx;
  380. border-radius: 10rpx;
  381. font-size: 28rpx;
  382. color: #606266;
  383. }
  384. .tab-item.active {
  385. background: #2979ff;
  386. color: #fff;
  387. font-weight: 600;
  388. }
  389. .tab-count {
  390. font-size: 22rpx;
  391. min-width: 32rpx;
  392. height: 32rpx;
  393. line-height: 32rpx;
  394. text-align: center;
  395. border-radius: 999rpx;
  396. background: rgba(144, 147, 153, 0.15);
  397. }
  398. .tab-item.active .tab-count {
  399. background: rgba(255, 255, 255, 0.24);
  400. }
  401. .dish-list {
  402. display: flex;
  403. flex-direction: column;
  404. gap: 18rpx;
  405. }
  406. .empty-wrap {
  407. padding: 60rpx 0;
  408. background: #fff;
  409. border-radius: 16rpx;
  410. }
  411. .dish-card {
  412. padding: 24rpx;
  413. }
  414. .dish-title-row {
  415. gap: 16rpx;
  416. }
  417. .dish-name {
  418. min-width: 0;
  419. flex: 1;
  420. font-size: 32rpx;
  421. font-weight: 600;
  422. color: #303133;
  423. overflow: hidden;
  424. text-overflow: ellipsis;
  425. white-space: nowrap;
  426. }
  427. .dish-amount {
  428. font-size: 30rpx;
  429. font-weight: 700;
  430. color: #fa3534;
  431. }
  432. .dish-meta {
  433. display: flex;
  434. flex-wrap: wrap;
  435. gap: 12rpx;
  436. margin-top: 14rpx;
  437. }
  438. .dish-meta text {
  439. padding: 6rpx 12rpx;
  440. border-radius: 8rpx;
  441. font-size: 24rpx;
  442. line-height: 32rpx;
  443. color: #606266;
  444. background: #f4f4f5;
  445. }
  446. .dish-price,
  447. .dish-qty,
  448. .dish-time,
  449. .dish-reason {
  450. font-size: 26rpx;
  451. color: #606266;
  452. }
  453. .dish-row:not(.dish-title-row) {
  454. margin-top: 18rpx;
  455. }
  456. .dish-qty {
  457. font-weight: 600;
  458. color: #303133;
  459. }
  460. .dish-time {
  461. margin-top: 14rpx;
  462. line-height: 36rpx;
  463. color: #909399;
  464. }
  465. .dish-reason {
  466. margin-top: 10rpx;
  467. line-height: 38rpx;
  468. word-break: break-all;
  469. }
  470. </style>