index.vue 13 KB

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