index.vue 15 KB

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