index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <view class="page">
  3. <u-navbar title="团餐订单" :autoBack="true" :placeholder="true" :border-bottom="false">
  4. <view slot="right" class="navbar-right" @click="goToDetail">订单明细</view>
  5. </u-navbar>
  6. <view class="search-bar">
  7. <u-search
  8. v-model="keyword"
  9. placeholder="请输入商品名称"
  10. bg-color="#f7f8fc"
  11. search-icon-color="#9aa1ab"
  12. :show-action="true"
  13. action-text="搜索"
  14. :action-style="actionStyle"
  15. @search="onSearch"
  16. @custom="onSearch"
  17. ></u-search>
  18. </view>
  19. <view class="status-tabs">
  20. <view
  21. v-for="(tab, index) in orderTabs"
  22. :key="tab.name"
  23. :class="['status-tab', { active: currentTab === index }]"
  24. @click="onTabChange(index)"
  25. >
  26. <text>{{ tab.name }}</text>
  27. <image
  28. v-if="currentTab === index"
  29. class="arrow-down"
  30. src="/static/merchantDish/select-tab.png"
  31. mode="aspectFit"
  32. ></image>
  33. </view>
  34. </view>
  35. <view class="filter-row" v-if="currentTab !== 2">
  36. <view class="filter-item" v-if="currentTab === 0" @click="openDatePicker">
  37. <text>{{ dateLabel }}</text>
  38. <u-icon name="arrow-down" size="22" color="#8b929c"></u-icon>
  39. </view>
  40. <view class="filter-item meal-filter" @click="openMealPicker">
  41. <text>{{ mealTypeLabel }}</text>
  42. <u-icon name="arrow-down" size="22" color="#8b929c"></u-icon>
  43. </view>
  44. <view class="total">合计:<text>{{ total }}</text>份</view>
  45. </view>
  46. <view class="list-wrap">
  47. <ListScrollView
  48. ref="listScroll"
  49. :api="api"
  50. :init="initParams"
  51. :page-size="20"
  52. :down-enabled="false"
  53. :up-text-visible="false"
  54. empty-text="暂无订单"
  55. @afterFetch="afterFetch"
  56. >
  57. <template v-slot:list="{ data }">
  58. <view class="order-list">
  59. <view class="order-item" v-for="item in data" :key="item.hostOrderId || item.id" @click="openOrder(item)">
  60. <view class="order-summary">
  61. <view class="summary-row date-row">
  62. <view class="summary-label">
  63. <u-icon name="clock" color="#8b929c" size="27"></u-icon>
  64. <text>预约日期:{{ getReserveDate(item) }}</text>
  65. </view>
  66. <text :class="['meal-tag', `meal-tag-${getMealCategory(item)}`]">{{ getMealLabel(item) }}</text>
  67. </view>
  68. <view class="summary-row leader-row">
  69. <view class="summary-label">
  70. <u-icon name="account" color="#8b929c" size="27"></u-icon>
  71. <text>{{ item.headName || item.leaderName || '团长姓名' }}</text>
  72. </view>
  73. <view class="order-count">合计:<text>{{ item.buyNumber || 0 }}</text>份</view>
  74. </view>
  75. <view class="summary-label address-line">
  76. <u-icon name="map" color="#8b929c" size="27"></u-icon>
  77. <text>{{ item.address || '暂无地址' }}</text>
  78. </view>
  79. <view class="region">{{ item.region || '' }}</view>
  80. </view>
  81. <view class="product-list">
  82. <view
  83. class="product-item"
  84. v-for="(product, productIndex) in (item.merchantPackageOrderDTOS || [])"
  85. :key="product.merchantOrderIds || product.id || productIndex"
  86. >
  87. <u-image
  88. width="80rpx"
  89. height="80rpx"
  90. border-radius="8rpx"
  91. :src="getProductImage(product.productImage)"
  92. mode="aspectFill"
  93. ></u-image>
  94. <view class="product-info">
  95. <text class="product-name">{{ product.packageName || '' }}</text>
  96. <text class="product-desc">{{ product.boxName || '默认餐盒'}}</text>
  97. </view>
  98. <text class="product-quantity">{{ product.numberUserCount || product.packageNumber || 0 }}份</text>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. </template>
  104. </ListScrollView>
  105. </view>
  106. <u-action-sheet
  107. :list="mealTypeOptions"
  108. v-model="mealPickerVisible"
  109. @click="onMealPick"
  110. ></u-action-sheet>
  111. <rangTime
  112. ref="rangeTime"
  113. :mode="1"
  114. title="选择日期"
  115. :default-start-date="startDate"
  116. :default-end-date="endDate"
  117. @onSubmit="onDateRangeConfirm"
  118. />
  119. </view>
  120. </template>
  121. <script>
  122. import ListScrollView from '@/components/list-scroll-view/index.vue'
  123. import rangTime from '@/components/dengrq-datetime-picker/dateSelector/index.vue'
  124. const MEAL_TYPE_OPTIONS = [
  125. { text: '全部', value: '' },
  126. { text: '早餐', value: 1 },
  127. { text: '午餐', value: 2 },
  128. { text: '晚餐', value: 3 }
  129. ]
  130. export default {
  131. components: {
  132. ListScrollView,
  133. rangTime
  134. },
  135. data() {
  136. return {
  137. api: {
  138. url: '/groupmeal/merchantPackageOrder/pageList',
  139. method: 'POST'
  140. },
  141. keyword: '',
  142. currentTab: 1,
  143. orderTabs: [
  144. { name: '预约单' },
  145. { name: '待出餐' },
  146. { name: '已出餐' }
  147. ],
  148. mealType: '',
  149. startDate: '',
  150. endDate: '',
  151. total: 0,
  152. mealPickerVisible: false,
  153. mealTypeOptions: MEAL_TYPE_OPTIONS,
  154. actionStyle: {
  155. width: 'auto',
  156. color: '#333',
  157. padding: '0 20rpx',
  158. borderLeft: '1rpx solid #e5e7eb'
  159. }
  160. }
  161. },
  162. computed: {
  163. initParams() {
  164. const params = {
  165. orderStatus: this.currentTab
  166. }
  167. if (this.currentTab === 0) params.isReservation = 1
  168. if (this.keyword) params.queryName = this.keyword
  169. if (this.mealType) params.category = this.mealType
  170. if (this.currentTab === 0 && this.startDate && this.endDate) {
  171. params.reservationDateStart = this.startDate
  172. params.reservationDateEnd = this.endDate
  173. }
  174. return params
  175. },
  176. mealTypeLabel() {
  177. return (MEAL_TYPE_OPTIONS.find((item) => item.value === this.mealType) || MEAL_TYPE_OPTIONS[0]).text
  178. },
  179. dateLabel() {
  180. if (!this.startDate || !this.endDate) return '选择日期'
  181. return `${this.formatDateLabel(this.startDate)}-${this.formatDateLabel(this.endDate)}`
  182. },
  183. },
  184. methods: {
  185. goToDetail() {
  186. uni.navigateTo({ url: '/pages/merchantDish/orders/order-blist' })
  187. },
  188. onSearch(value) {
  189. this.keyword = typeof value === 'string' ? value : this.keyword
  190. this.reloadList()
  191. },
  192. onTabChange(index) {
  193. this.currentTab = index
  194. this.reloadList()
  195. },
  196. openMealPicker() {
  197. this.mealPickerVisible = true
  198. },
  199. onMealPick(event) {
  200. const value = event && typeof event === 'object'
  201. ? event.value
  202. : (MEAL_TYPE_OPTIONS[event] || {}).value
  203. if (value === undefined) return
  204. this.mealType = value
  205. this.reloadList()
  206. },
  207. openDatePicker() {
  208. const picker = this.$refs.rangeTime
  209. if (!picker) return
  210. picker.startDate = this.startDate
  211. picker.endDate = this.endDate
  212. picker.open()
  213. },
  214. onDateRangeConfirm(value) {
  215. this.startDate = value.startDate
  216. this.endDate = value.endDate
  217. this.reloadList()
  218. },
  219. formatDateLabel(value) {
  220. const parts = String(value || '').slice(0, 10).split('-')
  221. if (parts.length !== 3) return value
  222. return `${Number(parts[1])}.${Number(parts[2])}`
  223. },
  224. getOrderId(item) {
  225. return item && (item.hostOrderId || item.id || item.orderId)
  226. },
  227. openOrder(item) {
  228. const orderId = this.getOrderId(item)
  229. if (!orderId) return
  230. uni.navigateTo({
  231. url: `/pages/merchantDish/orders/order-details?hostOrderId=${encodeURIComponent(orderId)}`
  232. })
  233. },
  234. getReserveDate(item) {
  235. const value = item.reserveDate || item.appointmentDate || item.mealDate || item.deliveryDate || item.createTime || ''
  236. return String(value).slice(0, 10).replace(/-/g, '.') || '--'
  237. },
  238. getMealLabel(item) {
  239. const products = item.merchantPackageOrderDTOS || []
  240. const firstProduct = products[0] || {}
  241. const text = item.mealTypeName || item.categoryName || item.mealName || firstProduct.mealTypeName || firstProduct.categoryName
  242. if (text) return text
  243. return ({ 1: '早餐', 2: '午餐', 3: '晚餐' })[this.getMealCategory(item)] || '团餐'
  244. },
  245. getMealCategory(item) {
  246. const products = item.merchantPackageOrderDTOS || []
  247. const firstProduct = products[0] || {}
  248. return Number(item.category || item.mealType || firstProduct.category || firstProduct.mealType) || 0
  249. },
  250. getProductImage(value) {
  251. return String(value || '').split(',').filter(Boolean)[0] || ''
  252. },
  253. reloadList() {
  254. this.$nextTick(() => {
  255. const list = this.$refs.listScroll
  256. if (list && list.mescroll) list.reloadList(this.initParams)
  257. })
  258. },
  259. afterFetch(result) {
  260. if (result && result.totalBuyNumber != null) {
  261. this.total = Number(result.totalBuyNumber) || 0
  262. return
  263. }
  264. const summary = (result && result.summary) || {}
  265. const summaryTotal = summary.buyNumber || summary.copies || summary.totalCopies
  266. if (summaryTotal != null) {
  267. this.total = Number(summaryTotal) || 0
  268. return
  269. }
  270. this.$nextTick(() => {
  271. const list = this.$refs.listScroll
  272. const records = (list && list.dataList) || []
  273. this.total = records.reduce((sum, item) => sum + (Number(item.buyNumber) || 0), 0)
  274. })
  275. }
  276. }
  277. }
  278. </script>
  279. <style lang="scss" scoped>
  280. .page {
  281. display: flex;
  282. flex-direction: column;
  283. height: 100vh;
  284. box-sizing: border-box;
  285. background: #fff;
  286. padding: 0 32rpx;
  287. overflow: hidden;
  288. }
  289. .search-bar {
  290. width: 100%;
  291. height: 64rpx;
  292. box-sizing: border-box;
  293. padding: 12rpx 20rpx;
  294. background: #F7F8FC;
  295. margin-bottom: 12rpx;
  296. }
  297. .navbar-right {
  298. padding: 0 24rpx;
  299. color: #333;
  300. font-size: 28rpx;
  301. }
  302. .filter-row {
  303. display: flex;
  304. align-items: center;
  305. justify-content: space-between;
  306. height: 76rpx;
  307. background: #f7f8fc;
  308. color: #7d858f;
  309. font-size: 26rpx;
  310. }
  311. .filter-item {
  312. display: flex;
  313. align-items: center;
  314. gap: 6rpx;
  315. }
  316. .meal-filter {
  317. justify-content: center;
  318. }
  319. .total {
  320. white-space: nowrap;
  321. }
  322. .total text {
  323. color: #1677ff;
  324. }
  325. .list-wrap {
  326. flex: 1;
  327. height: 0;
  328. margin: 0 -32rpx;
  329. // padding: 20rpx 24rpx 0;
  330. background: #f7f8fc;
  331. overflow: hidden;
  332. }
  333. .order-list {
  334. padding-bottom: 24rpx;
  335. }
  336. .order-item {
  337. margin-bottom: 20rpx;
  338. background: #fff;
  339. border-radius: 8rpx;
  340. overflow: hidden;
  341. padding: 24rpx;
  342. padding-top: 0;
  343. }
  344. .order-summary {
  345. position: relative;
  346. padding: 20rpx 24rpx 16rpx;
  347. color: #7f8792;
  348. font-size: 26rpx;
  349. border-bottom: 1px solid #dddddd;
  350. }
  351. .summary-row {
  352. display: flex;
  353. align-items: center;
  354. }
  355. .date-row {
  356. padding-right: 92rpx;
  357. }
  358. .leader-row {
  359. gap: 50rpx;
  360. margin-top: 10rpx;
  361. }
  362. .summary-label {
  363. font-size: 28rpx;
  364. display: flex;
  365. align-items: center;
  366. gap: 8rpx;
  367. min-width: 0;
  368. }
  369. .summary-label text {
  370. overflow: hidden;
  371. text-overflow: ellipsis;
  372. white-space: nowrap;
  373. }
  374. .meal-tag {
  375. position: absolute;
  376. top: 0;
  377. right: 0;
  378. display: flex;
  379. align-items: center;
  380. justify-content: center;
  381. width: 88rpx;
  382. height: 36rpx;
  383. box-sizing: border-box;
  384. border-radius: 0 12rpx 0 12rpx;
  385. background: linear-gradient(89deg, #1aeeae 0%, #0bda84 100%);
  386. color: #fff;
  387. font-size: 22rpx;
  388. text-align: center;
  389. }
  390. .meal-tag-2 {
  391. background: linear-gradient(89deg, #ffbf1e 0%, #ff781f 100%);
  392. }
  393. .meal-tag-3 {
  394. background: linear-gradient(90deg, #10abfe 0%, #2260f6 100%);
  395. }
  396. .order-count {
  397. flex-shrink: 0;
  398. color: #7f8792;
  399. font-size: 24rpx;
  400. }
  401. .order-count text {
  402. color: #1677ff;
  403. }
  404. .address-line {
  405. margin-top: 10rpx;
  406. }
  407. .region {
  408. margin-top: 8rpx;
  409. color: #8a8f98;
  410. font-size: 24rpx;
  411. }
  412. .product-list {
  413. margin: 0 24rpx;
  414. border-top: 1rpx solid #e5e7eb;
  415. }
  416. .product-item {
  417. display: flex;
  418. align-items: end;
  419. gap: 18rpx;
  420. min-height: 80rpx;
  421. box-sizing: border-box;
  422. border-bottom: 1rpx solid #f0f1f3;
  423. margin-top: 20rpx;
  424. }
  425. .product-item:last-child {
  426. border-bottom: 0;
  427. }
  428. .product-info {
  429. min-height: 80rpx;
  430. height: 100%;
  431. display: flex;
  432. flex: 1;
  433. min-width: 0;
  434. flex-direction: column;
  435. justify-content: space-between;
  436. gap: 8rpx;
  437. }
  438. .product-name,
  439. .product-desc {
  440. overflow: hidden;
  441. text-overflow: ellipsis;
  442. white-space: nowrap;
  443. }
  444. .product-name {
  445. color: #303133;
  446. font-size: 26rpx;
  447. font-weight: 600;
  448. }
  449. .product-desc {
  450. color: #8a91a8;
  451. font-size: 22rpx;
  452. }
  453. .product-quantity {
  454. flex-shrink: 0;
  455. align-self: flex-end;
  456. margin-bottom: 4rpx;
  457. color: #333;
  458. font-size: 24rpx;
  459. }
  460. .status-tabs {
  461. display: flex;
  462. justify-content: space-between;
  463. height: 92rpx;
  464. border-bottom: 1rpx solid #f0f1f3;
  465. }
  466. .status-tab {
  467. position: relative;
  468. display: flex;
  469. align-items: center;
  470. justify-content: center;
  471. width: 140rpx;
  472. color: #8a8f98;
  473. font-size: 28rpx;
  474. }
  475. .status-tab.active {
  476. color: #1677ff;
  477. font-weight: 600;
  478. }
  479. .arrow-down {
  480. position: absolute;
  481. bottom: 8rpx;
  482. left: 50%;
  483. width: 48rpx;
  484. height: 8rpx;
  485. transform: translateX(-50%);
  486. }
  487. ::v-deep .u-search {
  488. border-radius: 4rpx;
  489. }
  490. </style>