index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. <template>
  2. <view class="list-page-container">
  3. <erp-nav-bar title="全部订单" />
  4. <!-- 2. 分类切换:使用 scroll-view 滚动,彻底释放所有综合状态 -->
  5. <scroll-view scroll-x class="tabs-fixed" :show-scrollbar="false" :scroll-with-animation="true" :scroll-into-view="'tab-' + currentTab">
  6. <view class="tabs-box">
  7. <view v-for="(tab, index) in tabs" :key="index" :id="'tab-' + 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 * 140) + 'rpx)' }">
  14. <view class="bar-inner"></view>
  15. </view>
  16. </view>
  17. </view>
  18. </scroll-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-view primary" @click.stop="goDetail(item)">订单详情</view>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 加载提示区 -->
  54. <view class="list-status-info" v-if="displayList.length > 0">
  55. <view class="loading-wrap" v-if="loading">
  56. <view class="load-dot"></view><text>排队加载中...</text>
  57. </view>
  58. <view class="nomore-wrap" v-if="noMore">
  59. <text class="nomore-line"></text>
  60. <text class="nomore-text">已加载全部数据</text>
  61. <text class="nomore-line"></text>
  62. </view>
  63. </view>
  64. <!-- 缺省态 -->
  65. <view class="empty-state" v-if="displayList.length === 0 && !loading">
  66. <image src="https://img.icons8.com/clouds/200/open-box.png" mode="aspectFit"></image>
  67. <text>暂无订单记录</text>
  68. </view>
  69. <view class="safe-bottom"></view>
  70. </view>
  71. </scroll-view>
  72. <!-- 底部菜单栏 -->
  73. <!-- <erp-tab-bar active="order"></erp-tab-bar> -->
  74. </view>
  75. </template>
  76. <script>
  77. import ErpTabBar from '@/components/erp-tab-bar.vue';
  78. import ErpNavBar from '@/components/erp-nav-bar.vue';
  79. import { listMyOrder } from '@/api/erp/order.js';
  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. pageNum: 1,
  91. tabs: ['全部', '待确认', '已确认', '已审核', '已签批', '挤压完成', '生产完成', '已取消'],
  92. allOrders: [],
  93. displayList: []
  94. }
  95. },
  96. computed: {
  97. scrollHeight() {
  98. // 减去状态栏、导航栏、选项卡的高度
  99. return `calc(100vh - ${this.statusBarHeight + this.navBarHeight + this.tabBarHeight}px)`;
  100. }
  101. },
  102. onLoad(options) {
  103. const info = uni.getSystemInfoSync();
  104. this.statusBarHeight = info.statusBarHeight;
  105. // 修正选项卡高度(单位px)
  106. this.tabBarHeight = info.windowWidth / 750 * 110;
  107. if (options.tab) this.currentTab = parseInt(options.tab);
  108. this.refresh();
  109. },
  110. methods: {
  111. goBack() { uni.navigateBack(); },
  112. switchTab(i) { this.currentTab = i; this.refresh(); },
  113. refresh() { this.displayList = []; this.noMore = false; this.pageNum = 1; this.loadData(); },
  114. onReachEnd() { if (!this.loading && !this.noMore) this.loadData(); },
  115. async loadData() {
  116. if (this.loading || this.noMore) return;
  117. this.loading = true;
  118. try {
  119. const params = {
  120. pageNum: this.pageNum,
  121. pageSize: 5
  122. };
  123. if (this.currentTab > 0) {
  124. // 对应 status:0-待确认 1-已确认 2-已审核 3-已签批 4-挤压完成 5-生产完成 6-已取消
  125. const indexToStatus = [undefined, 0, 1, 2, 3, 4, 5, 6];
  126. params.status = indexToStatus[this.currentTab];
  127. }
  128. const res = await listMyOrder(params);
  129. const rows = res.rows || [];
  130. const formattedRows = rows.map(item => {
  131. const statusMap = {
  132. 0: { name: '待确认', type: 'pending' },
  133. 1: { name: '已确认', type: 'finish' },
  134. 2: { name: '已审核', type: 'approved' },
  135. 3: { name: '已签批', type: 'reviewed' },
  136. 4: { name: '挤压完成', type: 'exFinished' },
  137. 5: { name: '生产完成', type: 'productionFinish' },
  138. 6: { name: '已取消', type: 'cancelled' }
  139. };
  140. const s = statusMap[item.status] || { name: '待确认', type: 'pending' };
  141. return {
  142. orderNo: item.code,
  143. rowId: item.rowId,
  144. status: item.status,
  145. statusName: s.name,
  146. statusType: s.type,
  147. time: item.createTime,
  148. totalCount: item.totalCount || 0,
  149. models: (item.details || []).map(d => ({
  150. type: d.modelNum || '未知型号',
  151. length: Number(d.length || 0).toFixed(4),
  152. surface: d.surfaceName || '无',
  153. count: d.count || 0
  154. }))
  155. };
  156. });
  157. this.displayList = [...this.displayList, ...formattedRows];
  158. this.pageNum++;
  159. this.noMore = rows.length === 0 || this.displayList.length >= (res.total || 0);
  160. } catch (e) {
  161. console.error('加载订单列表失败', e);
  162. uni.showToast({ title: e || '加载订单列表失败', icon: 'none' });
  163. } finally {
  164. this.loading = false;
  165. }
  166. },
  167. goDetail(item) {
  168. uni.navigateTo({
  169. url: `/pages/order/detail/index?rowId=${item.rowId}`
  170. });
  171. }
  172. }
  173. }
  174. </script>
  175. <style scoped>
  176. /deep/ ::-webkit-scrollbar {
  177. display: none !important;
  178. width: 0 !important;
  179. height: 0 !important;
  180. -webkit-appearance: none;
  181. background: transparent;
  182. }
  183. .list-page-container {
  184. width: 100vw;
  185. height: 100vh;
  186. background: #f8fafc;
  187. overflow: hidden;
  188. display: flex;
  189. flex-direction: column;
  190. }
  191. /* 2. 选项卡:彻底解决残影红框2并支持 8 档横向滚动 */
  192. .tabs-fixed {
  193. background: #fff;
  194. width: 100%;
  195. flex-shrink: 0;
  196. border-bottom: 1rpx solid #f0f0f0;
  197. white-space: nowrap;
  198. }
  199. .tabs-box {
  200. height: 110rpx;
  201. position: relative;
  202. display: inline-flex;
  203. }
  204. .tab-item {
  205. width: 140rpx;
  206. height: 100%;
  207. display: flex;
  208. align-items: center;
  209. justify-content: center;
  210. flex-shrink: 0;
  211. z-index: 5;
  212. }
  213. .tab-txt {
  214. font-size: 28rpx;
  215. color: #888;
  216. transition: all 0.2s;
  217. }
  218. .tab-item.active .tab-txt {
  219. color: #C1001C;
  220. font-weight: bold;
  221. font-size: 32rpx;
  222. }
  223. /* 指示器轨道:等比平移消除虚影 */
  224. .indicator-track {
  225. position: absolute;
  226. bottom: 10rpx;
  227. left: 0;
  228. width: 100%;
  229. height: 6rpx;
  230. pointer-events: none;
  231. }
  232. .indicator-bar {
  233. width: 140rpx;
  234. height: 100%;
  235. display: flex;
  236. align-items: center;
  237. justify-content: center;
  238. transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  239. }
  240. .bar-inner {
  241. width: 40rpx;
  242. height: 100%;
  243. background: #C1001C;
  244. border-radius: 6rpx;
  245. }
  246. /* 3. 滚动区:解决不可滑动问题 */
  247. .order-scroll-view {
  248. width: 100%;
  249. }
  250. .order-list-inner {
  251. padding: 30rpx;
  252. padding-bottom: 60rpx;
  253. }
  254. .order-card {
  255. background: #fff;
  256. border-radius: 24rpx;
  257. padding: 36rpx;
  258. margin-bottom: 30rpx;
  259. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.02);
  260. }
  261. .card-head {
  262. display: flex;
  263. justify-content: space-between;
  264. align-items: center;
  265. margin-bottom: 30rpx;
  266. }
  267. .order-id {
  268. font-size: 28rpx;
  269. color: #1a1a1a;
  270. font-weight: bold;
  271. }
  272. .status-badge {
  273. font-size: 20rpx;
  274. padding: 4rpx 16rpx;
  275. border-radius: 8rpx;
  276. }
  277. .status-badge.pending {
  278. background: #FFF7E6;
  279. color: #FF9900;
  280. }
  281. .status-badge.finish {
  282. background: #E6F7FF;
  283. color: #1890FF;
  284. }
  285. .status-badge.approved {
  286. background: #F6FFED;
  287. color: #52C41A;
  288. }
  289. .status-badge.reviewed {
  290. background: #F9F0FF;
  291. color: #722ED1;
  292. }
  293. .status-badge.exFinished {
  294. background: #E6FFF9;
  295. color: #13C2C2;
  296. }
  297. .status-badge.productionFinish {
  298. background: #EEF2FE;
  299. color: #2F54EB;
  300. }
  301. .status-badge.cancelled {
  302. background: #FFF1F0;
  303. color: #F5222D;
  304. }
  305. .card-body {
  306. padding: 24rpx 0;
  307. border-top: 1rpx dashed #f0f0f0;
  308. margin-bottom: 24rpx;
  309. }
  310. .model-row {
  311. display: flex;
  312. align-items: center;
  313. margin-bottom: 12rpx;
  314. font-size: 24rpx;
  315. }
  316. .m-type {
  317. font-size: 28rpx;
  318. font-weight: bold;
  319. color: #333;
  320. width: 140rpx;
  321. }
  322. .m-spec {
  323. color: #888;
  324. flex: 1;
  325. padding: 0 20rpx;
  326. overflow: hidden;
  327. text-overflow: ellipsis;
  328. white-space: nowrap;
  329. }
  330. .m-count {
  331. color: #555;
  332. width: 100rpx;
  333. text-align: right;
  334. font-weight: 500;
  335. }
  336. .more-hint {
  337. padding: 10rpx 0;
  338. font-size: 24rpx;
  339. color: #999;
  340. text-align: center;
  341. background: #fafafa;
  342. border-radius: 8rpx;
  343. margin-bottom: 16rpx;
  344. }
  345. .total-summary {
  346. display: flex;
  347. align-items: center;
  348. justify-content: flex-end;
  349. padding-top: 20rpx;
  350. border-top: 1rpx solid #fafafa;
  351. }
  352. .summary-label {
  353. font-size: 24rpx;
  354. color: #999;
  355. }
  356. .summary-val {
  357. font-size: 32rpx;
  358. font-weight: bold;
  359. color: #333;
  360. margin: 0 4rpx;
  361. }
  362. .summary-val.highlight {
  363. color: #C1001C;
  364. }
  365. .summary-unit {
  366. font-size: 22rpx;
  367. color: #999;
  368. margin-right: 12rpx;
  369. }
  370. .summary-split {
  371. width: 1rpx;
  372. height: 20rpx;
  373. background: #eee;
  374. margin: 0 16rpx;
  375. }
  376. .card-foot {
  377. display: flex;
  378. justify-content: space-between;
  379. align-items: center;
  380. padding-top: 10rpx;
  381. }
  382. .time {
  383. font-size: 24rpx;
  384. color: #bbb;
  385. }
  386. .btns {
  387. display: flex;
  388. gap: 16rpx;
  389. }
  390. .btn-cancel,
  391. .btn-view {
  392. padding: 12rpx 30rpx;
  393. border-radius: 30rpx;
  394. font-size: 24rpx;
  395. }
  396. .btn-cancel {
  397. border: 1rpx solid #ddd;
  398. color: #666;
  399. }
  400. .btn-audit {
  401. border: 1rpx solid #ddd;
  402. color: #C1001C;
  403. padding: 12rpx 20rpx;
  404. border-radius: 30rpx;
  405. font-size: 24rpx;
  406. }
  407. .btn-view.primary {
  408. background: #C1001C;
  409. color: #fff;
  410. }
  411. .list-status-info {
  412. padding: 40rpx 0;
  413. display: flex;
  414. justify-content: center;
  415. }
  416. .nomore-wrap {
  417. display: flex;
  418. align-items: center;
  419. color: #ccc;
  420. font-size: 24rpx;
  421. }
  422. .nomore-line {
  423. width: 40rpx;
  424. height: 1rpx;
  425. background: #eee;
  426. margin: 0 20rpx;
  427. }
  428. .loading-wrap {
  429. color: #999;
  430. font-size: 24rpx;
  431. display: flex;
  432. align-items: center;
  433. }
  434. .load-dot {
  435. width: 10rpx;
  436. height: 10rpx;
  437. background: #C1001C;
  438. border-radius: 50%;
  439. margin-right: 10rpx;
  440. animation: flash 0.6s infinite alternate;
  441. }
  442. @keyframes flash {
  443. from {
  444. opacity: 0.3;
  445. }
  446. to {
  447. opacity: 1;
  448. }
  449. }
  450. .empty-state {
  451. display: flex;
  452. flex-direction: column;
  453. align-items: center;
  454. padding-top: 200rpx;
  455. color: #bbb;
  456. font-size: 28rpx;
  457. }
  458. .empty-state image {
  459. width: 220rpx;
  460. height: 220rpx;
  461. margin-bottom: 30rpx;
  462. opacity: 0.6;
  463. }
  464. .safe-bottom {
  465. height: 40rpx;
  466. }
  467. /* 审核记录弹窗 */
  468. .overlay {
  469. position: fixed;
  470. top: 0;
  471. left: 0;
  472. right: 0;
  473. bottom: 0;
  474. background: rgba(0, 0, 0, 0.45);
  475. z-index: 1000;
  476. display: flex;
  477. align-items: center;
  478. justify-content: center;
  479. }
  480. .audit-history-modal {
  481. width: 640rpx;
  482. max-height: 70vh;
  483. background: #fff;
  484. border-radius: 24rpx;
  485. overflow: hidden;
  486. display: flex;
  487. flex-direction: column;
  488. }
  489. .modal-head {
  490. display: flex;
  491. justify-content: space-between;
  492. align-items: center;
  493. padding: 30rpx 36rpx;
  494. border-bottom: 1rpx solid #f0f0f0;
  495. flex-shrink: 0;
  496. }
  497. .modal-title {
  498. font-size: 32rpx;
  499. font-weight: bold;
  500. color: #1a1a1a;
  501. }
  502. .modal-close {
  503. font-size: 26rpx;
  504. color: #999;
  505. padding: 8rpx;
  506. }
  507. .modal-body {
  508. flex: 1;
  509. padding: 20rpx 36rpx 36rpx;
  510. max-height: 60vh;
  511. }
  512. .audit-item {
  513. display: flex;
  514. padding: 24rpx 0;
  515. border-left: 2rpx solid #eee;
  516. margin-left: 12rpx;
  517. position: relative;
  518. }
  519. .audit-item:last-child {
  520. border-left-color: transparent;
  521. }
  522. .audit-dot {
  523. width: 16rpx;
  524. height: 16rpx;
  525. border-radius: 50%;
  526. position: absolute;
  527. left: -9rpx;
  528. top: 28rpx;
  529. }
  530. .audit-dot.pass {
  531. background: #52c41a;
  532. }
  533. .audit-dot.reject {
  534. background: #ff4d4f;
  535. }
  536. .audit-content {
  537. margin-left: 30rpx;
  538. flex: 1;
  539. }
  540. .audit-row {
  541. display: flex;
  542. align-items: center;
  543. gap: 16rpx;
  544. margin-bottom: 8rpx;
  545. }
  546. .audit-result {
  547. font-size: 26rpx;
  548. font-weight: bold;
  549. }
  550. .audit-result.pass {
  551. color: #52c41a;
  552. }
  553. .audit-result.reject {
  554. color: #ff4d4f;
  555. }
  556. .audit-auditor {
  557. font-size: 24rpx;
  558. color: #666;
  559. }
  560. .audit-reason {
  561. display: block;
  562. font-size: 24rpx;
  563. color: #ff4d4f;
  564. background: #fff1f0;
  565. padding: 12rpx 16rpx;
  566. border-radius: 8rpx;
  567. margin-bottom: 8rpx;
  568. line-height: 1.5;
  569. }
  570. .audit-time {
  571. display: block;
  572. font-size: 22rpx;
  573. color: #bbb;
  574. margin-top: 4rpx;
  575. }
  576. .audit-empty {
  577. text-align: center;
  578. padding: 60rpx 0;
  579. color: #bbb;
  580. font-size: 28rpx;
  581. }
  582. </style>