index.vue 14 KB

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