list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <view class="list-page-container">
  3. <!-- 1. 自定义顶部导航:彻底抹除红框1的原生蓝线 -->
  4. <view class="custom-nav-bar" :style="{ paddingTop: statusBarHeight + 'px' }">
  5. <view class="nav-content">
  6. <view class="back-icon" @click="goBack">
  7. <view class="arrow-left"></view>
  8. </view>
  9. <text class="nav-title">全部订单</text>
  10. <view class="placeholder-right"></view>
  11. </view>
  12. </view>
  13. <!-- 2. 分类切换:使用翻译位移,彻底消除红框2残影 -->
  14. <view class="tabs-fixed">
  15. <view class="tabs-box">
  16. <view v-for="(tab, index) in tabs" :key="index"
  17. class="tab-item"
  18. :class="{active: currentTab === index}"
  19. @click="switchTab(index)">
  20. <text class="tab-txt">{{tab}}</text>
  21. </view>
  22. <!-- 指示器:只负责位移,不负责显隐,彻底杜绝虚影 -->
  23. <view class="indicator-track">
  24. <view class="indicator-bar" :style="{transform: 'translateX(' + (currentTab * 100) + '%)'}">
  25. <view class="bar-inner"></view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 3. 固定高度的滚动区:强制启用滚动,解决不能滑动问题 -->
  31. <scroll-view
  32. scroll-y
  33. class="order-scroll-view"
  34. :style="{ height: scrollHeight }"
  35. @scrolltolower="onReachEnd"
  36. :refresher-enabled="false"
  37. :show-scrollbar="false">
  38. <view class="order-list-inner">
  39. <view class="order-card" v-for="(item, index) in displayList" :key="index" @click="goDetail(item)">
  40. <view class="card-head">
  41. <text class="order-id">单号:{{item.orderNo}}</text>
  42. <view class="status-badge" :class="item.statusType">{{item.statusName}}</view>
  43. </view>
  44. <view class="card-body">
  45. <view class="model-row" v-for="(model, mIdx) in item.models.slice(0, 2)" :key="mIdx">
  46. <text class="m-type">{{model.type}}</text>
  47. <text class="m-spec">{{model.surface}} | {{model.length}}mm</text>
  48. <text class="m-count">{{model.count}} 支</text>
  49. </view>
  50. <view class="more-hint" v-if="item.models.length > 2">
  51. <text>查看更多 {{item.models.length - 2}} 个型号...</text>
  52. </view>
  53. <view class="total-summary">
  54. <text class="summary-label">共计:</text>
  55. <text class="summary-val">{{item.models.length}}</text>
  56. <text class="summary-unit">个型号</text>
  57. <view class="summary-split"></view>
  58. <text class="summary-val highlight">{{item.totalCount}}</text>
  59. <text class="summary-unit">支</text>
  60. </view>
  61. </view>
  62. <view class="card-foot">
  63. <text class="time">{{item.time}}</text>
  64. <view class="btns">
  65. <view class="btn-cancel" v-if="item.status === 1" @click.stop="onCancel(item)">撤销</view>
  66. <view class="btn-view primary" @click.stop="goDetail(item)">订单详情</view>
  67. </view>
  68. </view>
  69. </view>
  70. <!-- 加载提示区 -->
  71. <view class="list-status-info" v-if="displayList.length > 0">
  72. <view class="loading-wrap" v-if="loading">
  73. <view class="load-dot"></view><text>排队加载中...</text>
  74. </view>
  75. <view class="nomore-wrap" v-if="noMore">
  76. <text class="nomore-line"></text>
  77. <text class="nomore-text">已加载全部数据</text>
  78. <text class="nomore-line"></text>
  79. </view>
  80. </view>
  81. <!-- 缺省态 -->
  82. <view class="empty-state" v-if="displayList.length === 0 && !loading">
  83. <image src="https://img.icons8.com/clouds/200/open-box.png" mode="aspectFit"></image>
  84. <text>暂无订单记录</text>
  85. </view>
  86. <view class="safe-bottom"></view>
  87. </view>
  88. </scroll-view>
  89. <!-- 底部菜单栏 -->
  90. <erp-tab-bar active="order"></erp-tab-bar>
  91. </view>
  92. </template>
  93. <script>
  94. import ErpTabBar from '@/components/erp-tab-bar/erp-tab-bar.vue';
  95. export default {
  96. components: {
  97. ErpTabBar
  98. },
  99. data() {
  100. return {
  101. statusBarHeight: 20,
  102. navBarHeight: 44,
  103. tabBarHeight: 50, // 对应 100rpx
  104. currentTab: 0,
  105. loading: false,
  106. noMore: false,
  107. tabs: ['全部', '待审核', '待签批', '生产中', '已完成'],
  108. allOrders: [
  109. {
  110. orderNo: 'ORD20240428001',
  111. models: [
  112. { type: 'TY0019', length: '6000', surface: '阳极氧化', count: '100' },
  113. { type: 'TY0018', length: '6000', surface: 'PL坯料', count: '50' }
  114. ],
  115. totalCount: 150,
  116. status: 1, statusName: '待审核', statusType: 'pending', time: '2024-04-28 10:20'
  117. },
  118. {
  119. orderNo: 'ORD20240428002',
  120. models: [
  121. { type: 'TY0020', length: '5800', surface: '粉末喷涂', count: '80' }
  122. ],
  123. totalCount: 80,
  124. status: 2, statusName: '待签批', statusType: 'process', time: '2024-04-28 09:15'
  125. },
  126. {
  127. orderNo: 'ORD20240427088',
  128. models: [
  129. { type: 'TY0018', length: '6000', surface: 'PL坯料', count: '300' }
  130. ],
  131. totalCount: 300,
  132. status: 4, statusName: '已完成', statusType: 'finish', time: '2024-04-27 15:40'
  133. },
  134. {
  135. orderNo: 'ORD20240427045',
  136. models: [
  137. { type: 'TY0021', length: '3000', surface: '电泳涂漆', count: '50' },
  138. { type: 'TY0022', length: '4000', surface: '木纹转印', count: '40' },
  139. { type: 'TY0023', length: '5000', surface: '氟碳喷涂', count: '30' }
  140. ],
  141. totalCount: 120,
  142. status: 3, statusName: '生产中', statusType: 'making', time: '2024-04-27 11:05'
  143. }
  144. ],
  145. displayList: []
  146. }
  147. },
  148. computed: {
  149. scrollHeight() {
  150. // 减去状态栏、导航栏、选项卡的高度
  151. return `calc(100vh - ${this.statusBarHeight + this.navBarHeight + this.tabBarHeight}px)`;
  152. }
  153. },
  154. onLoad(options) {
  155. const info = uni.getSystemInfoSync();
  156. this.statusBarHeight = info.statusBarHeight;
  157. // 修正选项卡高度(单位px)
  158. this.tabBarHeight = info.windowWidth / 750 * 110;
  159. if (options.tab) this.currentTab = parseInt(options.tab);
  160. this.refresh();
  161. },
  162. methods: {
  163. goBack() { uni.navigateBack(); },
  164. switchTab(i) { this.currentTab = i; this.refresh(); },
  165. refresh() { this.displayList = []; this.noMore = false; this.loadData(); },
  166. onReachEnd() { if (!this.loading && !this.noMore) this.loadData(); },
  167. loadData() {
  168. this.loading = true;
  169. setTimeout(() => {
  170. let raw = this.currentTab === 0 ? this.allOrders : this.allOrders.filter(o => o.status === this.currentTab);
  171. this.displayList = [...this.displayList, ...raw];
  172. this.noMore = true; // 模拟一次性加载完演示数据
  173. this.loading = false;
  174. }, 500);
  175. },
  176. onCancel(item) {
  177. uni.showModal({
  178. title: '确认撤销',
  179. content: `确认要撤销订单:${item.orderNo} 吗?`,
  180. confirmColor: '#ff4d4f',
  181. success: (res) => {
  182. if (res.confirm) {
  183. uni.showLoading({ title: '撤销中' });
  184. setTimeout(() => {
  185. uni.hideLoading();
  186. uni.showToast({ title: '已撤销' });
  187. // 逻辑修复:修改状态而非移除
  188. const target = this.allOrders.find(o => o.orderNo === item.orderNo);
  189. if (target) {
  190. target.status = 0;
  191. target.statusName = '已撤销';
  192. target.statusType = 'expired';
  193. }
  194. // 再次过滤刷新当前视图
  195. this.refresh();
  196. }, 800);
  197. }
  198. }
  199. });
  200. },
  201. goDetail(item) {
  202. const dataStr = encodeURIComponent(JSON.stringify(item));
  203. uni.navigateTo({
  204. url: `/pages/order/detail?data=${dataStr}`
  205. });
  206. }
  207. }
  208. }
  209. </script>
  210. <style scoped>
  211. /deep/ ::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; -webkit-appearance: none; background: transparent; }
  212. .list-page-container { width: 100vw; height: 100vh; background: #f8fafc; overflow: hidden; display: flex; flex-direction: column; }
  213. /* 1. 自定义导航栏:解决蓝线红框1 */
  214. .custom-nav-bar { background: #ffffff; width: 100%; flex-shrink: 0; }
  215. .nav-content { height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 30rpx; }
  216. .back-icon { width: 60rpx; height: 44px; display: flex; align-items: center; }
  217. .arrow-left { width: 20rpx; height: 20rpx; border-left: 4rpx solid #333; border-bottom: 4rpx solid #333; transform: rotate(45deg); margin-left: 10rpx; }
  218. .nav-title { font-size: 34rpx; font-weight: bold; color: #1a1a1a; }
  219. .placeholder-right { width: 60rpx; }
  220. /* 2. 选项卡:解决残影红框2 */
  221. .tabs-fixed { background: #fff; width: 100%; flex-shrink: 0; border-bottom: 1rpx solid #f0f0f0; }
  222. .tabs-box { height: 110rpx; position: relative; display: flex; width: 100%; }
  223. .tab-item { flex: 1; display: flex; align-items: center; justify-content: center; z-index: 5; }
  224. .tab-txt { font-size: 28rpx; color: #888; transition: all 0.2s; }
  225. .tab-item.active .tab-txt { color: #C1001C; font-weight: bold; font-size: 32rpx; }
  226. /* 指示器轨道:通过位移消除虚影 */
  227. .indicator-track { position: absolute; bottom: 10rpx; left: 0; width: 100%; height: 6rpx; display: flex; }
  228. .indicator-bar { width: 20%; height: 100%; display: flex; align-items: center; justify-content: center; transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28); }
  229. .bar-inner { width: 40rpx; height: 100%; background: #C1001C; border-radius: 6rpx; }
  230. /* 3. 滚动区:解决不可滑动问题 */
  231. .order-scroll-view { width: 100%; }
  232. .order-list-inner { padding: 30rpx; padding-bottom: 60rpx; }
  233. .order-card { background: #fff; border-radius: 24rpx; padding: 36rpx; margin-bottom: 30rpx; box-shadow: 0 4rpx 20rpx rgba(0,0,0,0.02); }
  234. .card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30rpx; }
  235. .order-id { font-size: 28rpx; color: #1a1a1a; font-weight: bold; }
  236. .status-badge { font-size: 20rpx; padding: 4rpx 16rpx; border-radius: 8rpx; }
  237. .status-badge.pending { background: #FFF1F2; color: #C1001C; }
  238. .status-badge.expired { background: #f5f5f5; color: #999; }
  239. .status-badge.process { background: #fff7e6; color: #ffa940; }
  240. .status-badge.making { background: #e6fffb; color: #36cfc9; }
  241. /* 已撤销样式 */
  242. .status-badge.expired { background: #f5f5f5; color: #999; }
  243. .status-badge.finish { background: #f6ffed; color: #52c41a; }
  244. .card-body { padding: 24rpx 0; border-top: 1rpx dashed #f0f0f0; margin-bottom: 24rpx; }
  245. .model-row { display: flex; align-items: center; margin-bottom: 12rpx; font-size: 24rpx; }
  246. .m-type { font-size: 28rpx; font-weight: bold; color: #333; width: 140rpx; }
  247. .m-spec { color: #888; flex: 1; padding: 0 20rpx; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  248. .m-count { color: #555; width: 100rpx; text-align: right; font-weight: 500; }
  249. .more-hint { padding: 10rpx 0; font-size: 24rpx; color: #999; text-align: center; background: #fafafa; border-radius: 8rpx; margin-bottom: 16rpx; }
  250. .total-summary {
  251. display: flex; align-items: center; justify-content: flex-end;
  252. padding-top: 20rpx; border-top: 1rpx solid #fafafa;
  253. }
  254. .summary-label { font-size: 24rpx; color: #999; }
  255. .summary-val { font-size: 32rpx; font-weight: bold; color: #333; margin: 0 4rpx; }
  256. .summary-val.highlight { color: #C1001C; }
  257. .summary-unit { font-size: 22rpx; color: #999; margin-right: 12rpx; }
  258. .summary-split { width: 1rpx; height: 20rpx; background: #eee; margin: 0 16rpx; }
  259. .card-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 10rpx; }
  260. .time { font-size: 24rpx; color: #bbb; }
  261. .btns { display: flex; gap: 16rpx; }
  262. .btn-cancel, .btn-view { padding: 12rpx 30rpx; border-radius: 30rpx; font-size: 24rpx; }
  263. .btn-cancel { border: 1rpx solid #ddd; color: #666; }
  264. .btn-view.primary { background: #C1001C; color: #fff; }
  265. .list-status-info { padding: 40rpx 0; display: flex; justify-content: center; }
  266. .nomore-wrap { display: flex; align-items: center; color: #ccc; font-size: 24rpx; }
  267. .nomore-line { width: 40rpx; height: 1rpx; background: #eee; margin: 0 20rpx; }
  268. .loading-wrap { color: #999; font-size: 24rpx; display: flex; align-items: center; }
  269. .load-dot { width: 10rpx; height: 10rpx; background: #C1001C; border-radius: 50%; margin-right: 10rpx; animation: flash 0.6s infinite alternate; }
  270. @keyframes flash { from { opacity: 0.3; } to { opacity: 1; } }
  271. .empty-state { display: flex; flex-direction: column; align-items: center; padding-top: 200rpx; color: #bbb; font-size: 28rpx; }
  272. .empty-state image { width: 220rpx; height: 220rpx; margin-bottom: 30rpx; opacity: 0.6; }
  273. .safe-bottom { height: 40rpx; }
  274. </style>