DishOrderApproval.vue 9.9 KB

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