order-alist.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <view class="page-container">
  3. <!-- 导航栏 -->
  4. <u-navbar :autoBack="true" :placeholder="true" :border-bottom="false">
  5. <view class="navbar-title">团餐订单</view>
  6. <view slot="right" class="navbar-right">
  7. <text class="nav-btn" @click="goToDetail">订单明细</text>
  8. <text class="nav-btn manage-btn" v-if="currentStatusTab == 0" @click="toggleManageMode">{{ isManaging ? '退出管理' : '批量管理' }}</text>
  9. </view>
  10. </u-navbar>
  11. <!-- 搜索框 -->
  12. <view class="search-bar">
  13. <u-search bg-color="#F7F8FC" placeholder="请输入套餐名称或团长名" search-icon-color="#999"
  14. :showAction="true" actionText="搜索"
  15. :actionStyle="{
  16. width: 'auto',
  17. color: '#333',
  18. padding: '0 20rpx',
  19. borderLeft: '1rpx solid #DDDDDD'
  20. }"
  21. @search="onSearch" @custom="onSearch"
  22. ></u-search>
  23. </view>
  24. <!-- 状态Tabs -->
  25. <u-tabs :list="statusTabs"
  26. :current="currentStatusTab"
  27. inactive-color="#666666"
  28. :bar-style="{
  29. bottom: '20rpx',
  30. background: 'linear-gradient(90deg, #82BCFF 0%, rgba(130,188,255,0) 100%)'
  31. }"
  32. :active-item-style="{
  33. fontWeight: '500',
  34. fontSize: '32rpx',
  35. color: '#000000',
  36. }"
  37. @change="onTabChange"
  38. ></u-tabs>
  39. <!-- 订单列表 -->
  40. <view class="order-scroll-view" :style="{ paddingBottom: isManaging ? '120rpx' : '0' }">
  41. <ListScrollView ref="listScroll"
  42. :api="api"
  43. :init="{
  44. ...initParams,
  45. }">
  46. <template v-slot:list="{ data }">
  47. <u-checkbox-group width="40rpx" inactiveColor="#fff" placement="column"
  48. v-model="selectedOrders"
  49. @change="onSelect"
  50. >
  51. <view class="order-item" v-for="item in data" :key="item.orderId">
  52. <view class="order-header">
  53. <view class="location-box">
  54. <view class="location-info">
  55. <view class="name">
  56. <!-- <u-image width="40rpx" height="40rpx" src="/static/groupMeal/icon_user.png"></u-image> -->
  57. <u-icon name="account" color="#000000" size="30"></u-icon>
  58. <text>{{ item.headName }}</text>
  59. </view>
  60. <view class="desc">
  61. <text>合计份数:</text>
  62. <text class="val">{{ item.buyNumber }}份</text>
  63. </view>
  64. </view>
  65. <view class="location-address">
  66. <view class="atext">{{ item.address }}</view>
  67. <view class="btext">{{ item.region }}</view>
  68. </view>
  69. </view>
  70. <view class="order-actions" v-if="isManaging">
  71. <u-checkbox :name="item.orderId" shape="circle" v-model="item.checked"></u-checkbox>
  72. </view>
  73. </view>
  74. <ListExpand :items="item.merchantPackageOrderDTOS">
  75. <template v-slot:="{ items }">
  76. <view class="order-card" v-for="(eItem, ei) in items" :key="ei">
  77. <!-- <u-image width="84rpx" height="84rpx" border-radius="12rpx" :src="eItem.productImage && `${$config.apiUrl}/${eItem.productImage.split(',')[0]}`" mode="aspectFill"></u-image> -->
  78. <u-image width="84rpx" height="84rpx" border-radius="12rpx" :src="eItem.productImage" mode="aspectFill"></u-image>
  79. <view class="order-info">
  80. <view class="order-title">{{ eItem.packageName }}</view>
  81. <view class="order-line">
  82. <view class="leader-name">{{ eItem.dishName }}</view>
  83. <view class="quantity-tag">{{ eItem.numberUserCount }}份</view>
  84. </view>
  85. </view>
  86. </view>
  87. </template>
  88. </ListExpand>
  89. </view>
  90. </u-checkbox-group>
  91. </template>
  92. </ListScrollView>
  93. </view>
  94. <!-- 批量操作底部栏 -->
  95. <view class="footer-bar" v-if="isManaging">
  96. <u-checkbox-group v-model="isAllSelected" placement="row">
  97. <u-checkbox name="all" shape="circle" v-model="isAllSelected" @change="onSelectAll">全选</u-checkbox>
  98. </u-checkbox-group>
  99. <view class="action-buttons">
  100. <u-button type="primary" @click="handleBatchAction">出餐</u-button>
  101. </view>
  102. </view>
  103. <Tabbar />
  104. <!-- 弹窗 -->
  105. <Modal ref="myModal"
  106. :title="modalText.title"
  107. :content="modalText.content"
  108. />
  109. </view>
  110. </template>
  111. <script>
  112. import Modal from '@/components/modal/index.vue';
  113. import Tabbar from '@/pages/groupMeal/tabbar/index.vue';
  114. import ListExpand from '@/components/list-scroll-view/list-expand.vue';
  115. import ListScrollView from '@/components/list-scroll-view/index.vue';
  116. export default {
  117. components: {
  118. Modal,
  119. Tabbar,
  120. ListExpand,
  121. ListScrollView
  122. },
  123. data() {
  124. return {
  125. api: {
  126. url: '/groupmeal/merchantPackageOrder/pageList',
  127. method: 'POST',
  128. },
  129. isManaging: false,
  130. statusTabs: [{ name: '待出餐' }, { name: '已出餐' }],
  131. currentStatusTab: 0,
  132. selectedOrders: [],
  133. isAllSelected: false,
  134. // 弹窗
  135. modalText: {
  136. title: '提示',
  137. btntext: '好的',
  138. content: ''
  139. },
  140. };
  141. },
  142. computed: {
  143. // 数据参数
  144. initParams() {
  145. let params = {
  146. // 订单状态 0 未成团 1 已成团 2 已出餐 3 已送达
  147. orderStatus: 0,
  148. }
  149. // 待出餐
  150. if (this.currentStatusTab == 0) {
  151. params = {
  152. ...params,
  153. orderStatus: 1,
  154. }
  155. }
  156. // 已出餐
  157. else if (this.currentStatusTab == 1) {
  158. params = {
  159. ...params,
  160. orderStatus: 2,
  161. }
  162. }
  163. return params;
  164. }
  165. },
  166. onLoad() {
  167. },
  168. methods: {
  169. goToDetail() {
  170. uni.navigateTo({
  171. url: '/pages/groupMeal/orders/order-blist'
  172. });
  173. },
  174. toggleManageMode() {
  175. this.isManaging = !this.isManaging;
  176. this.onClearSel();
  177. },
  178. onTabChange(e) {
  179. this.currentStatusTab = e;
  180. // 清除已选数据
  181. this.onClearSel();
  182. // 关闭批量
  183. this.isManaging = false;
  184. // 触发更新
  185. this.$nextTick(() => {
  186. this.$refs.listScroll.downCallback();
  187. });
  188. },
  189. onSearch(value) {
  190. this.$refs[`listScroll`].reloadList({
  191. queryName: value,
  192. });
  193. },
  194. onSelect(e) {
  195. this.selectedOrders = e;
  196. // 控制全选
  197. this.isAllSelected = e.length === this.$refs.listScroll.dataList.length;
  198. },
  199. onSelectAll(e) {
  200. let allOrders = this.$refs.listScroll.dataList;
  201. if (e.value) {
  202. this.selectedOrders = allOrders.map(order => order.orderId);
  203. } else {
  204. this.selectedOrders = [];
  205. }
  206. allOrders.forEach(item => {
  207. item.checked = e.value;
  208. });
  209. },
  210. // 完成某种操作后,清空数据
  211. onClearSel() {
  212. this.selectedOrders = [];
  213. this.isAllSelected = false;
  214. },
  215. handleBatchAction() {
  216. if (this.selectedOrders.length === 0) {
  217. this.$tip.toast("请先选择订单")
  218. return;
  219. }
  220. this.modalText.content = '是否确认已经出餐?';
  221. this.$refs.myModal.onOpen(false, () => {
  222. let params = {
  223. orderId: this.selectedOrders.join()
  224. };
  225. this.$http.get('/groupmeal/merchantPackageOrder/orderReady', {params}).then(res => {
  226. if (res.data.code === 200) {
  227. // this.$tip.success(res.data.message);
  228. uni.showToast({
  229. icon:'success',
  230. title:res.data.message
  231. })
  232. // 触发更新
  233. this.isManaging = false;
  234. this.currentStatusTab = 1;
  235. this.onClearSel();
  236. this.$nextTick(() => {
  237. this.$refs.listScroll.downCallback();
  238. });
  239. } else {
  240. // this.$tip.error(res.data.message);
  241. uni.showToast({
  242. icon:'none',
  243. title:res.data.message
  244. })
  245. }
  246. });
  247. });
  248. }
  249. }
  250. };
  251. </script>
  252. <style lang="scss" scoped>
  253. .page-container {
  254. height: 100vh;
  255. display: flex;
  256. flex-direction: column;
  257. .navbar-title {
  258. font-weight: 500;
  259. font-size: 36rpx;
  260. color: #333333;
  261. }
  262. .navbar-right {
  263. padding: 0 24rpx;
  264. display: flex;
  265. align-items: center;
  266. .nav-btn {
  267. font-weight: 500;
  268. font-size: 28rpx;
  269. color: #333333;
  270. }
  271. .manage-btn {
  272. margin-left: 24rpx;
  273. }
  274. }
  275. .search-bar {
  276. padding: 12rpx 32rpx;
  277. background-color: #fff;
  278. .u-search {
  279. border-radius: 8rpx;
  280. background-color: #F7F8FC;
  281. }
  282. }
  283. .order-scroll-view {
  284. flex: 1;
  285. height: 0;
  286. padding: 20rpx 24rpx;
  287. background-color: #F7F8FC;
  288. .u-checkbox-group {
  289. width: 100%;
  290. }
  291. .order-item {
  292. width: 100%;
  293. margin-bottom: 24rpx;
  294. background: #fff;
  295. .order-actions {
  296. }
  297. }
  298. .order-header {
  299. gap: 24rpx;
  300. padding: 24rpx;
  301. display: flex;
  302. align-items: center;
  303. background: linear-gradient(90deg, #FDFDFF 0%, #E3F0FF 100%);
  304. .location-box {
  305. flex: 1;
  306. }
  307. .location-info {
  308. display: flex;
  309. align-items: center;
  310. justify-content: space-between;
  311. .name {
  312. font-weight: 500;
  313. font-size: 28rpx;
  314. color: #333333;
  315. display: flex;
  316. align-items: center;
  317. text {
  318. padding-left: 10rpx;
  319. }
  320. }
  321. .desc {
  322. font-weight: 400;
  323. font-size: 24rpx;
  324. color: #666666;
  325. .val {
  326. color: #449AFF;
  327. }
  328. }
  329. }
  330. .location-address {
  331. margin-top: 10rpx;
  332. .atext {
  333. font-weight: 500;
  334. font-size: 26rpx;
  335. color: #333333;
  336. }
  337. .btext {
  338. font-weight: 400;
  339. font-size: 26rpx;
  340. color: #666666;
  341. }
  342. }
  343. }
  344. .order-card {
  345. width: 100%;
  346. padding: 24rpx;
  347. display: flex;
  348. align-items: center;
  349. border-bottom: 1rpx solid #f0f0f0;
  350. .order-info {
  351. flex: 1;
  352. margin-left: 20rpx;
  353. .order-title {
  354. font-size: 26rpx;
  355. font-weight: 500;
  356. color: #303133;
  357. font-weight: bold;
  358. display: -webkit-box;
  359. -webkit-line-clamp: 1;
  360. -webkit-box-orient: vertical;
  361. overflow: hidden;
  362. }
  363. .order-line {
  364. margin-top: 8rpx;
  365. display: flex;
  366. align-items: center;
  367. .leader-name {
  368. flex: 1;
  369. font-weight: 400;
  370. font-size: 22rpx;
  371. color: #8A91A8;
  372. }
  373. .quantity-tag {
  374. font-size: 24rpx;
  375. color: #333333;
  376. }
  377. }
  378. }
  379. }
  380. }
  381. }
  382. .footer-bar {
  383. bottom: 50px;
  384. padding-bottom: 20px;
  385. .action-buttons {
  386. display: flex;
  387. gap: 20rpx;
  388. ::v-deep .u-btn {
  389. height: 69rpx;
  390. border-radius: 49rpx;
  391. }
  392. }
  393. }
  394. </style>