index.vue 15 KB

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