index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. <template>
  2. <view class="list-page-container">
  3. <erp-nav-bar title="全部订单" />
  4. <!-- 2. 分类切换:使用翻译位移,彻底消除红框2残影 -->
  5. <view class="tabs-fixed">
  6. <view class="tabs-box">
  7. <view v-for="(tab, index) in tabs" :key="index" class="tab-item"
  8. :class="{ active: currentTab === index }" @click="switchTab(index)">
  9. <text class="tab-txt">{{ tab }}</text>
  10. </view>
  11. <!-- 指示器:只负责位移,不负责显隐,彻底杜绝虚影 -->
  12. <view class="indicator-track">
  13. <view class="indicator-bar" :style="{ transform: 'translateX(' + (currentTab * 100) + '%)' }">
  14. <view class="bar-inner"></view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 3. 固定高度的滚动区:强制启用滚动,解决不能滑动问题 -->
  20. <scroll-view scroll-y class="order-scroll-view" :style="{ height: scrollHeight }" @scrolltolower="onReachEnd"
  21. :refresher-enabled="false" :show-scrollbar="false">
  22. <view class="order-list-inner">
  23. <view class="order-card" v-for="(item, index) in displayList" :key="index" @click="goDetail(item)">
  24. <view class="card-head">
  25. <text class="order-id">单号:{{ item.orderNo }}</text>
  26. <view class="status-badge" :class="item.statusType">{{ item.statusName }}</view>
  27. </view>
  28. <view class="card-body">
  29. <view class="model-row" v-for="(model, mIdx) in item.models.slice(0, 2)" :key="mIdx">
  30. <text class="m-type">{{ model.type }}</text>
  31. <text class="m-spec">{{ model.surface }} | {{ model.length }}mm</text>
  32. <text class="m-count">{{ model.count }} 支</text>
  33. </view>
  34. <view class="more-hint" v-if="item.models.length > 2">
  35. <text>查看更多 {{ item.models.length - 2 }} 个型号...</text>
  36. </view>
  37. <view class="total-summary">
  38. <text class="summary-label">共计:</text>
  39. <text class="summary-val">{{ item.models.length }}</text>
  40. <text class="summary-unit">个型号</text>
  41. <view class="summary-split"></view>
  42. <text class="summary-val highlight">{{ item.totalCount }}</text>
  43. <text class="summary-unit">支</text>
  44. </view>
  45. </view>
  46. <view class="card-foot">
  47. <text class="time">{{ item.time }}</text>
  48. <view class="btns">
  49. <view class="btn-cancel" v-if="item.status === 1" @click.stop="onCancel(item)">撤销</view>
  50. <view class="btn-view primary" @click.stop="goDetail(item)">订单详情</view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 加载提示区 -->
  55. <view class="list-status-info" v-if="displayList.length > 0">
  56. <view class="loading-wrap" v-if="loading">
  57. <view class="load-dot"></view><text>排队加载中...</text>
  58. </view>
  59. <view class="nomore-wrap" v-if="noMore">
  60. <text class="nomore-line"></text>
  61. <text class="nomore-text">已加载全部数据</text>
  62. <text class="nomore-line"></text>
  63. </view>
  64. </view>
  65. <!-- 缺省态 -->
  66. <view class="empty-state" v-if="displayList.length === 0 && !loading">
  67. <image src="https://img.icons8.com/clouds/200/open-box.png" mode="aspectFit"></image>
  68. <text>暂无订单记录</text>
  69. </view>
  70. <view class="safe-bottom"></view>
  71. </view>
  72. </scroll-view>
  73. <!-- 底部菜单栏 -->
  74. <erp-tab-bar active="order"></erp-tab-bar>
  75. </view>
  76. </template>
  77. <script>
  78. import ErpTabBar from '@/components/erp-tab-bar.vue';
  79. import ErpNavBar from '@/components/erp-nav-bar.vue';
  80. export default {
  81. components: { ErpTabBar, ErpNavBar },
  82. data() {
  83. return {
  84. statusBarHeight: 20,
  85. navBarHeight: 44,
  86. tabBarHeight: 50, // 对应 100rpx
  87. currentTab: 0,
  88. loading: false,
  89. noMore: false,
  90. tabs: ['全部', '待审核', '待签批', '生产中', '已完成'],
  91. allOrders: [
  92. {
  93. orderNo: 'ORD20240428001',
  94. models: [
  95. { type: 'TY0019', length: '6000', surface: '阳极氧化', count: '100' },
  96. { type: 'TY0018', length: '6000', surface: 'PL坯料', count: '50' }
  97. ],
  98. totalCount: 150,
  99. status: 1, statusName: '待审核', statusType: 'pending', time: '2024-04-28 10:20'
  100. },
  101. {
  102. orderNo: 'ORD20240428002',
  103. models: [
  104. { type: 'TY0020', length: '5800', surface: '粉末喷涂', count: '80' }
  105. ],
  106. totalCount: 80,
  107. status: 2, statusName: '待签批', statusType: 'process', time: '2024-04-28 09:15'
  108. },
  109. {
  110. orderNo: 'ORD20240427088',
  111. models: [
  112. { type: 'TY0018', length: '6000', surface: 'PL坯料', count: '300' }
  113. ],
  114. totalCount: 300,
  115. status: 4, statusName: '已完成', statusType: 'finish', time: '2024-04-27 15:40'
  116. },
  117. {
  118. orderNo: 'ORD20240427045',
  119. models: [
  120. { type: 'TY0021', length: '3000', surface: '电泳涂漆', count: '50' },
  121. { type: 'TY0022', length: '4000', surface: '木纹转印', count: '40' },
  122. { type: 'TY0023', length: '5000', surface: '氟碳喷涂', count: '30' }
  123. ],
  124. totalCount: 120,
  125. status: 3, statusName: '生产中', statusType: 'making', time: '2024-04-27 11:05'
  126. }
  127. ],
  128. displayList: []
  129. }
  130. },
  131. computed: {
  132. scrollHeight() {
  133. // 减去状态栏、导航栏、选项卡的高度
  134. return `calc(100vh - ${this.statusBarHeight + this.navBarHeight + this.tabBarHeight}px)`;
  135. }
  136. },
  137. onLoad(options) {
  138. const info = uni.getSystemInfoSync();
  139. this.statusBarHeight = info.statusBarHeight;
  140. // 修正选项卡高度(单位px)
  141. this.tabBarHeight = info.windowWidth / 750 * 110;
  142. if (options.tab) this.currentTab = parseInt(options.tab);
  143. this.refresh();
  144. },
  145. methods: {
  146. goBack() { uni.navigateBack(); },
  147. switchTab(i) { this.currentTab = i; this.refresh(); },
  148. refresh() { this.displayList = []; this.noMore = false; this.loadData(); },
  149. onReachEnd() { if (!this.loading && !this.noMore) this.loadData(); },
  150. loadData() {
  151. this.loading = true;
  152. setTimeout(() => {
  153. let raw = this.currentTab === 0 ? this.allOrders : this.allOrders.filter(o => o.status === this.currentTab);
  154. this.displayList = [...this.displayList, ...raw];
  155. this.noMore = true; // 模拟一次性加载完演示数据
  156. this.loading = false;
  157. }, 500);
  158. },
  159. onCancel(item) {
  160. uni.showModal({
  161. title: '确认撤销',
  162. content: `确认要撤销订单:${item.orderNo} 吗?`,
  163. confirmColor: '#ff4d4f',
  164. success: (res) => {
  165. if (res.confirm) {
  166. uni.showLoading({ title: '撤销中' });
  167. setTimeout(() => {
  168. uni.hideLoading();
  169. uni.showToast({ title: '已撤销' });
  170. // 逻辑修复:修改状态而非移除
  171. const target = this.allOrders.find(o => o.orderNo === item.orderNo);
  172. if (target) {
  173. target.status = 0;
  174. target.statusName = '已撤销';
  175. target.statusType = 'expired';
  176. }
  177. // 再次过滤刷新当前视图
  178. this.refresh();
  179. }, 800);
  180. }
  181. }
  182. });
  183. },
  184. goDetail(item) {
  185. const dataStr = encodeURIComponent(JSON.stringify(item));
  186. uni.navigateTo({
  187. url: `/pages/order/detail/index?data=${dataStr}`
  188. });
  189. }
  190. }
  191. }
  192. </script>
  193. <style scoped>
  194. /deep/ ::-webkit-scrollbar {
  195. display: none !important;
  196. width: 0 !important;
  197. height: 0 !important;
  198. -webkit-appearance: none;
  199. background: transparent;
  200. }
  201. .list-page-container {
  202. width: 100vw;
  203. height: 100vh;
  204. background: #f8fafc;
  205. overflow: hidden;
  206. display: flex;
  207. flex-direction: column;
  208. }
  209. /* 2. 选项卡:解决残影红框2 */
  210. .tabs-fixed {
  211. background: #fff;
  212. width: 100%;
  213. flex-shrink: 0;
  214. border-bottom: 1rpx solid #f0f0f0;
  215. }
  216. .tabs-box {
  217. height: 110rpx;
  218. position: relative;
  219. display: flex;
  220. width: 100%;
  221. }
  222. .tab-item {
  223. flex: 1;
  224. display: flex;
  225. align-items: center;
  226. justify-content: center;
  227. z-index: 5;
  228. }
  229. .tab-txt {
  230. font-size: 28rpx;
  231. color: #888;
  232. transition: all 0.2s;
  233. }
  234. .tab-item.active .tab-txt {
  235. color: #C1001C;
  236. font-weight: bold;
  237. font-size: 32rpx;
  238. }
  239. /* 指示器轨道:通过位移消除虚影 */
  240. .indicator-track {
  241. position: absolute;
  242. bottom: 10rpx;
  243. left: 0;
  244. width: 100%;
  245. height: 6rpx;
  246. display: flex;
  247. }
  248. .indicator-bar {
  249. width: 20%;
  250. height: 100%;
  251. display: flex;
  252. align-items: center;
  253. justify-content: center;
  254. transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  255. }
  256. .bar-inner {
  257. width: 40rpx;
  258. height: 100%;
  259. background: #C1001C;
  260. border-radius: 6rpx;
  261. }
  262. /* 3. 滚动区:解决不可滑动问题 */
  263. .order-scroll-view {
  264. width: 100%;
  265. }
  266. .order-list-inner {
  267. padding: 30rpx;
  268. padding-bottom: 60rpx;
  269. }
  270. .order-card {
  271. background: #fff;
  272. border-radius: 24rpx;
  273. padding: 36rpx;
  274. margin-bottom: 30rpx;
  275. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.02);
  276. }
  277. .card-head {
  278. display: flex;
  279. justify-content: space-between;
  280. align-items: center;
  281. margin-bottom: 30rpx;
  282. }
  283. .order-id {
  284. font-size: 28rpx;
  285. color: #1a1a1a;
  286. font-weight: bold;
  287. }
  288. .status-badge {
  289. font-size: 20rpx;
  290. padding: 4rpx 16rpx;
  291. border-radius: 8rpx;
  292. }
  293. .status-badge.pending {
  294. background: #FFF1F2;
  295. color: #C1001C;
  296. }
  297. .status-badge.expired {
  298. background: #f5f5f5;
  299. color: #999;
  300. }
  301. .status-badge.process {
  302. background: #fff7e6;
  303. color: #ffa940;
  304. }
  305. .status-badge.making {
  306. background: #e6fffb;
  307. color: #36cfc9;
  308. }
  309. /* 已撤销样式 */
  310. .status-badge.expired {
  311. background: #f5f5f5;
  312. color: #999;
  313. }
  314. .status-badge.finish {
  315. background: #f6ffed;
  316. color: #52c41a;
  317. }
  318. .card-body {
  319. padding: 24rpx 0;
  320. border-top: 1rpx dashed #f0f0f0;
  321. margin-bottom: 24rpx;
  322. }
  323. .model-row {
  324. display: flex;
  325. align-items: center;
  326. margin-bottom: 12rpx;
  327. font-size: 24rpx;
  328. }
  329. .m-type {
  330. font-size: 28rpx;
  331. font-weight: bold;
  332. color: #333;
  333. width: 140rpx;
  334. }
  335. .m-spec {
  336. color: #888;
  337. flex: 1;
  338. padding: 0 20rpx;
  339. overflow: hidden;
  340. text-overflow: ellipsis;
  341. white-space: nowrap;
  342. }
  343. .m-count {
  344. color: #555;
  345. width: 100rpx;
  346. text-align: right;
  347. font-weight: 500;
  348. }
  349. .more-hint {
  350. padding: 10rpx 0;
  351. font-size: 24rpx;
  352. color: #999;
  353. text-align: center;
  354. background: #fafafa;
  355. border-radius: 8rpx;
  356. margin-bottom: 16rpx;
  357. }
  358. .total-summary {
  359. display: flex;
  360. align-items: center;
  361. justify-content: flex-end;
  362. padding-top: 20rpx;
  363. border-top: 1rpx solid #fafafa;
  364. }
  365. .summary-label {
  366. font-size: 24rpx;
  367. color: #999;
  368. }
  369. .summary-val {
  370. font-size: 32rpx;
  371. font-weight: bold;
  372. color: #333;
  373. margin: 0 4rpx;
  374. }
  375. .summary-val.highlight {
  376. color: #C1001C;
  377. }
  378. .summary-unit {
  379. font-size: 22rpx;
  380. color: #999;
  381. margin-right: 12rpx;
  382. }
  383. .summary-split {
  384. width: 1rpx;
  385. height: 20rpx;
  386. background: #eee;
  387. margin: 0 16rpx;
  388. }
  389. .card-foot {
  390. display: flex;
  391. justify-content: space-between;
  392. align-items: center;
  393. padding-top: 10rpx;
  394. }
  395. .time {
  396. font-size: 24rpx;
  397. color: #bbb;
  398. }
  399. .btns {
  400. display: flex;
  401. gap: 16rpx;
  402. }
  403. .btn-cancel,
  404. .btn-view {
  405. padding: 12rpx 30rpx;
  406. border-radius: 30rpx;
  407. font-size: 24rpx;
  408. }
  409. .btn-cancel {
  410. border: 1rpx solid #ddd;
  411. color: #666;
  412. }
  413. .btn-view.primary {
  414. background: #C1001C;
  415. color: #fff;
  416. }
  417. .list-status-info {
  418. padding: 40rpx 0;
  419. display: flex;
  420. justify-content: center;
  421. }
  422. .nomore-wrap {
  423. display: flex;
  424. align-items: center;
  425. color: #ccc;
  426. font-size: 24rpx;
  427. }
  428. .nomore-line {
  429. width: 40rpx;
  430. height: 1rpx;
  431. background: #eee;
  432. margin: 0 20rpx;
  433. }
  434. .loading-wrap {
  435. color: #999;
  436. font-size: 24rpx;
  437. display: flex;
  438. align-items: center;
  439. }
  440. .load-dot {
  441. width: 10rpx;
  442. height: 10rpx;
  443. background: #C1001C;
  444. border-radius: 50%;
  445. margin-right: 10rpx;
  446. animation: flash 0.6s infinite alternate;
  447. }
  448. @keyframes flash {
  449. from {
  450. opacity: 0.3;
  451. }
  452. to {
  453. opacity: 1;
  454. }
  455. }
  456. .empty-state {
  457. display: flex;
  458. flex-direction: column;
  459. align-items: center;
  460. padding-top: 200rpx;
  461. color: #bbb;
  462. font-size: 28rpx;
  463. }
  464. .empty-state image {
  465. width: 220rpx;
  466. height: 220rpx;
  467. margin-bottom: 30rpx;
  468. opacity: 0.6;
  469. }
  470. .safe-bottom {
  471. height: 40rpx;
  472. }
  473. </style>