DishOrder.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <view class="dish-order-page">
  3. <view class="query-bar">
  4. <view class="status-chips">
  5. <view class="chip" :class="{ active: statusFilter === '' }" @click="changeStatusFilter('')">全部</view>
  6. <view class="chip" :class="{ active: statusFilter === '0' }" @click="changeStatusFilter('0')">空闲中</view>
  7. <view class="chip" :class="{ active: statusFilter === '1' }" @click="changeStatusFilter('1')">使用中</view>
  8. </view>
  9. <input class="query-input" v-model="searchForm.roomName" placeholder="包房名称" confirm-type="search"
  10. @confirm="refreshRoomList" />
  11. <input class="query-input" v-model="searchForm.roomNo" placeholder="包房编号" confirm-type="search"
  12. @confirm="refreshRoomList" />
  13. <button class="query-btn primary" @click="refreshRoomList">查询</button>
  14. <button class="query-btn" @click="resetSearch">重置</button>
  15. </view>
  16. <view v-if="roomLoading" class="state-box">
  17. <u-loading-icon text="加载中" textSize="14"></u-loading-icon>
  18. </view>
  19. <scroll-view v-else scroll-y class="room-scroll">
  20. <view class="room-grid">
  21. <view v-for="item in displayRoomList" :key="item.id" class="room-card"
  22. :class="[{ disabled: item.status === '1' }, item.useStatus === '0' ? 'free' : 'busy']"
  23. @click="enterOrder(item)">
  24. <view class="room-card-top">
  25. <view class="room-name">{{ item.roomName || '-' }}</view>
  26. <view class="room-status" :class="item.useStatus === '0' ? 'free' : 'busy'">
  27. {{ item.useStatus === '0' ? '空闲中' : '使用中' }}
  28. </view>
  29. </view>
  30. <view class="room-tags">
  31. <text class="room-tag">包房号 {{ item.roomNo || '-' }}</text>
  32. <text class="room-tag">容纳 {{ item.capacity || 0 }} 人</text>
  33. </view>
  34. <view v-if="item.remarks" class="room-remarks">{{ item.remarks }}</view>
  35. </view>
  36. <view v-if="displayRoomList.length === 0" class="empty-room">暂无包房</view>
  37. </view>
  38. </scroll-view>
  39. </view>
  40. </template>
  41. <script>
  42. import DishOrderService from '@/api/psi/DishOrderService'
  43. export default {
  44. data() {
  45. return {
  46. searchForm: {
  47. roomName: '',
  48. roomNo: '',
  49. status: '0'
  50. },
  51. statusFilter: '',
  52. roomList: [],
  53. roomLoading: false,
  54. dishOrderService: null
  55. }
  56. },
  57. computed: {
  58. displayRoomList() {
  59. if (!this.statusFilter) {
  60. return this.roomList
  61. }
  62. return this.roomList.filter(item => item.useStatus === this.statusFilter)
  63. }
  64. },
  65. onLoad() {
  66. uni.setNavigationBarTitle({ title: '点菜' })
  67. this.dishOrderService = new DishOrderService()
  68. this.refreshRoomList()
  69. },
  70. onShow() {
  71. if (!this.dishOrderService) {
  72. this.dishOrderService = new DishOrderService()
  73. }
  74. this.refreshRoomList()
  75. },
  76. methods: {
  77. refreshRoomList() {
  78. this.roomLoading = true
  79. this.dishOrderService.roomList({ ...this.searchForm }).then((data) => {
  80. this.roomList = Array.isArray(data) ? data : []
  81. }).finally(() => {
  82. this.roomLoading = false
  83. })
  84. },
  85. resetSearch() {
  86. this.searchForm.roomName = ''
  87. this.searchForm.roomNo = ''
  88. this.statusFilter = ''
  89. this.refreshRoomList()
  90. },
  91. changeStatusFilter(value) {
  92. this.statusFilter = value
  93. },
  94. enterOrder(room) {
  95. if (room.status === '1') {
  96. uni.showToast({ title: '该包房已停用', icon: 'none' })
  97. return
  98. }
  99. uni.navigateTo({
  100. url: `/pages/psiManagement/dishManage/DishOrderDetail?roomId=${room.id}`
  101. })
  102. }
  103. }
  104. }
  105. </script>
  106. <style scoped>
  107. .dish-order-page {
  108. height: calc(100vh - var(--window-top, 0px));
  109. box-sizing: border-box;
  110. display: flex;
  111. flex-direction: column;
  112. overflow: hidden;
  113. padding: 24rpx;
  114. background: #f5f6fa;
  115. }
  116. .query-bar {
  117. flex-shrink: 0;
  118. display: flex;
  119. flex-wrap: wrap;
  120. align-items: center;
  121. gap: 12rpx;
  122. margin-bottom: 22rpx;
  123. padding: 18rpx;
  124. border-radius: 12rpx;
  125. background: #fff;
  126. }
  127. .status-chips {
  128. display: flex;
  129. gap: 10rpx;
  130. margin-right: auto;
  131. }
  132. .chip {
  133. height: 56rpx;
  134. padding: 0 26rpx;
  135. border-radius: 999rpx;
  136. background: #f2f4f7;
  137. font-size: 26rpx;
  138. line-height: 56rpx;
  139. color: #606266;
  140. }
  141. .chip.active {
  142. color: #fff;
  143. background: #2979ff;
  144. font-weight: 700;
  145. }
  146. .query-input {
  147. flex: 1;
  148. min-width: 180rpx;
  149. height: 72rpx;
  150. box-sizing: border-box;
  151. padding: 0 22rpx;
  152. border: 1rpx solid #dcdfe6;
  153. border-radius: 8rpx;
  154. font-size: 28rpx;
  155. color: #303133;
  156. background: #fff;
  157. }
  158. .query-btn {
  159. height: 72rpx;
  160. margin: 0;
  161. padding: 0;
  162. border-radius: 8rpx;
  163. font-size: 28rpx;
  164. line-height: 72rpx;
  165. color: #606266;
  166. background: #f7f8fa;
  167. }
  168. .query-btn.primary {
  169. color: #fff;
  170. background: #2979ff;
  171. }
  172. .room-scroll {
  173. flex: 1;
  174. height: 0;
  175. min-height: 0;
  176. }
  177. .room-grid {
  178. display: grid;
  179. grid-template-columns: repeat(auto-fill, minmax(320rpx, 1fr));
  180. gap: 22rpx;
  181. padding-bottom: 4rpx;
  182. }
  183. .room-card {
  184. min-height: 260rpx;
  185. box-sizing: border-box;
  186. padding: 24rpx;
  187. border: 3rpx solid #e5e7eb;
  188. border-radius: 10rpx;
  189. background: #fff;
  190. }
  191. .room-card.disabled {
  192. background: #f7f8fa;
  193. }
  194. .room-card.free {
  195. border-color: #b3e19d;
  196. background: #f0f9eb;
  197. }
  198. .room-card.busy {
  199. border-color: #fbc4c4;
  200. background: #fef0f0;
  201. }
  202. .room-card-top {
  203. display: flex;
  204. justify-content: space-between;
  205. gap: 18rpx;
  206. }
  207. .room-name {
  208. font-size: 34rpx;
  209. font-weight: 700;
  210. color: #1f2937;
  211. line-height: 46rpx;
  212. overflow: hidden;
  213. white-space: nowrap;
  214. text-overflow: ellipsis;
  215. }
  216. .room-status {
  217. height: 44rpx;
  218. padding: 0 18rpx;
  219. border-radius: 999rpx;
  220. font-size: 24rpx;
  221. line-height: 44rpx;
  222. white-space: nowrap;
  223. }
  224. .room-status.free {
  225. color: #fff;
  226. background: #19be6b;
  227. }
  228. .room-status.busy {
  229. color: #fff;
  230. background: #fa3534;
  231. }
  232. .room-tags {
  233. display: flex;
  234. flex-wrap: wrap;
  235. gap: 10rpx;
  236. margin-top: 20rpx;
  237. }
  238. .room-tag {
  239. padding: 6rpx 16rpx;
  240. border-radius: 8rpx;
  241. background: rgba(255, 255, 255, 0.72);
  242. font-size: 24rpx;
  243. color: #606266;
  244. }
  245. .room-remarks {
  246. margin-top: 22rpx;
  247. font-size: 26rpx;
  248. color: #606266;
  249. line-height: 38rpx;
  250. overflow: hidden;
  251. display: -webkit-box;
  252. -webkit-line-clamp: 2;
  253. -webkit-box-orient: vertical;
  254. }
  255. .state-box,
  256. .empty-room {
  257. flex: 1;
  258. min-height: 360rpx;
  259. display: flex;
  260. align-items: center;
  261. justify-content: center;
  262. border-radius: 12rpx;
  263. background: #fff;
  264. color: #909399;
  265. }
  266. @media (min-width: 768px) {
  267. .query-input {
  268. height: 44px;
  269. font-size: 16px;
  270. }
  271. .query-btn {
  272. width: 88px;
  273. height: 44px;
  274. font-size: 16px;
  275. line-height: 44px;
  276. }
  277. .chip {
  278. height: 40px;
  279. padding: 0 22px;
  280. font-size: 16px;
  281. line-height: 40px;
  282. }
  283. .room-grid {
  284. grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  285. gap: 16px;
  286. }
  287. .room-card {
  288. min-height: 150px;
  289. padding: 18px;
  290. }
  291. .room-name {
  292. font-size: 24px;
  293. line-height: 32px;
  294. }
  295. .room-status {
  296. height: 32px;
  297. padding: 0 16px;
  298. font-size: 15px;
  299. line-height: 32px;
  300. }
  301. .room-tag {
  302. padding: 4px 12px;
  303. font-size: 14px;
  304. }
  305. .room-remarks {
  306. font-size: 15px;
  307. line-height: 22px;
  308. }
  309. }
  310. </style>