index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template>
  2. <view class="detail-page-container">
  3. <erp-nav-bar title="订单详情" />
  4. <!-- 2. 状态横幅区域:不再包含状态栏边距 -->
  5. <view class="status-banner-container" :class="order.statusType" id="nav-header">
  6. <view class="status-banner-content">
  7. <view class="header-main">
  8. <text class="status-title">{{ order.statusName }}</text>
  9. <text class="status-sub">{{ statusSubText }}</text>
  10. </view>
  11. <view class="header-icon-wrap">
  12. <view class="status-visual-icon"></view>
  13. </view>
  14. </view>
  15. </view>
  16. <!-- 2. 主内容滚动区:计算锁定高度以支持 100% 滚动 -->
  17. <scroll-view scroll-y class="main-content-scroll" :style="{ height: scrollHeight }" :show-scrollbar="false">
  18. <view class="detail-inner-box">
  19. <!-- 卡片:规格清单 (支持多个型号展现) -->
  20. <view class="model-item-card-inner" v-for="(model, mIdx) in (order.models || [order])" :key="mIdx">
  21. <view class="data-group-card" :class="{ 'first-card': mIdx === 0 }">
  22. <view class="card-head">规格清单 #{{ mIdx + 1 }}</view>
  23. <view class="data-item"><text class="l">产品型号</text><text class="v bold">{{ model.type }}</text>
  24. </view>
  25. <view class="data-item"><text class="l">型号名称</text><text class="v">{{ model.typeName ||
  26. '铝型材主料' }}</text></view>
  27. <view class="data-item"><text class="l">型材材质</text><text class="v">{{ model.material ||
  28. '6063-T5' }}</text></view>
  29. <view class="line-split"></view>
  30. <view class="data-item"><text class="l">表面处理</text><text class="v">{{ model.surface }}</text>
  31. </view>
  32. <view class="data-item"><text class="l">包装方式</text><text class="v">{{ model.package ||
  33. '普通包装' }}</text></view>
  34. <view class="line-split"></view>
  35. <view class="data-item"><text class="l">订单长度</text><text class="v">{{ model.length }} mm</text>
  36. </view>
  37. <view class="data-item"><text class="l">型材壁厚</text><text class="v">{{ model.wallThickness ||
  38. '1.2' }} mm</text></view>
  39. <view class="data-item"><text class="l">需求支数</text><text class="v highlight">{{ model.count }}
  40. 支</text></view>
  41. </view>
  42. </view>
  43. <!-- 卡片:订单详情 -->
  44. <view class="data-group-card shadow-less">
  45. <view class="card-head">订单详情</view>
  46. <view class="data-item"><text class="l">订单单号</text><text class="v selectable">{{ order.orderNo
  47. }}</text></view>
  48. <!-- ERP单号 -->
  49. <view class="data-item" v-if="order.erpDocCode">
  50. <text class="l">ERP 单号</text>
  51. <text class="v selectable erp-no">{{ order.erpDocCode }}</text>
  52. </view>
  53. <view class="data-item"><text class="l">下单日期</text><text class="v">{{ order.time }}</text></view>
  54. <view class="data-item"><text class="l">支付方式</text><text class="v">月结扣款</text></view>
  55. </view>
  56. <!-- 底部占位 -->
  57. <view class="list-bottom-placeholder"></view>
  58. </view>
  59. </scroll-view>
  60. <!-- 3. 底部固定操作栏 -->
  61. <view class="detail-action-bar-fixed" id="footer-bar">
  62. <view class="action-btn-wrap" v-if="order.status === 0">
  63. <button class="action-btn cancel" @click="doCancel">撤销该订单</button>
  64. <button class="action-btn primary" @click="callSales">呼叫业务员</button>
  65. </view>
  66. <view class="action-btn-wrap single" v-else>
  67. <button class="action-btn primary" @click="goHome">再下一单</button>
  68. </view>
  69. <view class="safe-area-bottom-support"></view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import ErpNavBar from '@/components/erp-nav-bar.vue';
  75. import { getOrderDetail } from '@/api/erp/order.js';
  76. export default {
  77. components: { ErpNavBar },
  78. data() {
  79. return {
  80. footerHeight: 80, // px
  81. headerHeight: 120, // px
  82. rowId: '',
  83. loading: false,
  84. order: {
  85. orderNo: '-',
  86. status: 1,
  87. statusName: '加载中',
  88. statusType: 'pending',
  89. models: [],
  90. erpNo: '',
  91. time: '-'
  92. }
  93. }
  94. },
  95. computed: {
  96. statusSubText() {
  97. const map = {
  98. pending: '您的订单已提交,正在排队等待审核...',
  99. expired: '该订单已被驳回。',
  100. cancelled: '该订单已被撤销。',
  101. process: '审核已完成,正在由相关主管签批...',
  102. making: '订单已入库排产,工厂正在全力生产中...',
  103. finish: '该订单生产已完成并正式入库。'
  104. };
  105. return map[this.order.statusType] || '订单状态更新中';
  106. },
  107. scrollHeight() {
  108. const info = uni.getSystemInfoSync();
  109. const safeBottom = info.safeAreaInsets ? info.safeAreaInsets.bottom : 0;
  110. const statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 20;
  111. return `calc(100vh - ${statusBarHeight + 164}px - ${80 + safeBottom}px)`;
  112. }
  113. },
  114. onLoad(options) {
  115. if (options.rowId) {
  116. this.rowId = options.rowId;
  117. this.loadOrderDetail();
  118. }
  119. },
  120. methods: {
  121. async loadOrderDetail() {
  122. if (this.loading) return;
  123. this.loading = true;
  124. try {
  125. const res = await getOrderDetail(this.rowId);
  126. const data = res.data || res;
  127. if (!data) {
  128. uni.showToast({ title: '订单不存在', icon: 'none' });
  129. return;
  130. }
  131. // 状态展示映射(与 ErpOrderStatus 枚举对齐)
  132. const statusMap = {
  133. '-1': { name: '已撤销', type: 'cancelled' },
  134. 0: { name: '待审核', type: 'pending' },
  135. 1: { name: '已驳回', type: 'expired' },
  136. 2: { name: '待签批', type: 'process' },
  137. 3: { name: '生产中', type: 'making' },
  138. 4: { name: '已完成', type: 'finish' }
  139. };
  140. const s = statusMap[data.status] || { name: '未知', type: 'expired' };
  141. this.order = {
  142. orderNo: data.code || '-',
  143. rowId: data.rowId,
  144. status: data.status,
  145. statusName: s.name,
  146. statusType: s.type,
  147. time: data.createTime || '-',
  148. totalCount: data.totalCount || 0,
  149. erpDocCode: data.erpDocCode || '',
  150. models: (data.details || []).map(d => ({
  151. type: d.modelNum || '未知型号',
  152. typeName: d.modelName || '铝型材主料',
  153. material: d.material || '6063-T5',
  154. surface: d.surfaceName || '无',
  155. package: d.packName || '普通包装',
  156. length: d.length ? Number(d.length).toFixed(4) : '0',
  157. wallThickness: d.wallThickness ? Number(d.wallThickness).toFixed(4) : '1.2',
  158. count: d.count || 0
  159. }))
  160. };
  161. } catch (e) {
  162. console.error('加载订单详情失败', e);
  163. uni.showToast({ title: '加载失败', icon: 'none' });
  164. } finally {
  165. this.loading = false;
  166. }
  167. },
  168. goBack() { uni.navigateBack(); },
  169. doCancel() {
  170. uni.showModal({
  171. title: '确认撤销',
  172. content: '确定要撤销该订单吗?',
  173. confirmColor: '#ff3b30',
  174. success: (res) => {
  175. if (res.confirm) {
  176. this.order.status = -1;
  177. this.order.statusName = '已撤销';
  178. this.order.statusType = 'cancelled';
  179. uni.showToast({ title: '撤销成功' });
  180. }
  181. }
  182. });
  183. },
  184. callSales() { uni.makePhoneCall({ phoneNumber: '13888888888' }); },
  185. goHome() { uni.reLaunch({ url: '/pages/order/index' }); }
  186. }
  187. }
  188. </script>
  189. <style scoped>
  190. /deep/ ::-webkit-scrollbar {
  191. display: none !important;
  192. width: 0 !important;
  193. height: 0 !important;
  194. -webkit-appearance: none;
  195. background: transparent;
  196. }
  197. .detail-page-container {
  198. width: 100vw;
  199. height: 100vh;
  200. background: #f8fbfd;
  201. display: flex;
  202. flex-direction: column;
  203. overflow: hidden;
  204. position: relative;
  205. }
  206. .status-banner-container {
  207. color: #fff;
  208. flex-shrink: 0;
  209. }
  210. .status-banner-container.pending {
  211. background: linear-gradient(135deg, #C1001C 0%, #FF4D4F 100%);
  212. }
  213. .status-banner-container.process {
  214. background: linear-gradient(135deg, #FF6A00 0%, #EE0979 100%);
  215. }
  216. .status-banner-container.making {
  217. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  218. }
  219. .status-banner-container.finish {
  220. background: linear-gradient(135deg, #2af598 0%, #009efd 100%);
  221. }
  222. .status-banner-container.expired {
  223. background: linear-gradient(135deg, #868f96 0%, #596164 100%);
  224. }
  225. .status-banner-container.cancelled {
  226. background: linear-gradient(135deg, #a0a0a0 0%, #666666 100%);
  227. }
  228. /* 状态横幅内容 */
  229. .status-banner-content {
  230. padding: 40rpx;
  231. padding-bottom: 60rpx;
  232. display: flex;
  233. justify-content: space-between;
  234. align-items: center;
  235. }
  236. .header-main {
  237. flex: 1;
  238. }
  239. .status-title {
  240. font-size: 48rpx;
  241. font-weight: bold;
  242. display: block;
  243. margin-bottom: 12rpx;
  244. }
  245. .status-sub {
  246. font-size: 26rpx;
  247. opacity: 0.9;
  248. }
  249. .status-visual-icon {
  250. width: 60rpx;
  251. height: 60rpx;
  252. border: 4rpx solid rgba(255, 255, 255, 0.3);
  253. border-radius: 50%;
  254. opacity: 0.6;
  255. }
  256. /* 修正:移除负边距,并明确滚动方向 */
  257. .main-content-scroll {
  258. width: 100%;
  259. flex: 1;
  260. }
  261. .detail-inner-box {
  262. padding: 30rpx;
  263. padding-top: 10rpx;
  264. }
  265. .data-group-card {
  266. background: #fff;
  267. border-radius: 30rpx;
  268. padding: 40rpx;
  269. margin-bottom: 30rpx;
  270. box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.02);
  271. }
  272. /* 第一张卡片增加顶部间隔(红框1优化点) */
  273. .first-card {
  274. margin-top: 20rpx;
  275. }
  276. .card-head {
  277. font-size: 30rpx;
  278. font-weight: bold;
  279. color: #333;
  280. margin-bottom: 30rpx;
  281. border-left: 8rpx solid #C1001C;
  282. padding-left: 20rpx;
  283. }
  284. .line-split {
  285. height: 1rpx;
  286. background: #f5f5f5;
  287. margin: 24rpx 0;
  288. }
  289. .data-item {
  290. display: flex;
  291. justify-content: space-between;
  292. margin-bottom: 24rpx;
  293. font-size: 28rpx;
  294. align-items: center;
  295. }
  296. .l {
  297. color: #999;
  298. }
  299. .v {
  300. color: #333;
  301. font-weight: 500;
  302. }
  303. .v.bold {
  304. font-weight: bold;
  305. font-size: 30rpx;
  306. }
  307. .v.erp-no {
  308. color: #C1001C;
  309. font-weight: bold;
  310. }
  311. .v.highlight {
  312. color: #ff3b30;
  313. font-weight: bold;
  314. font-size: 34rpx;
  315. }
  316. .list-bottom-placeholder {
  317. height: 260rpx;
  318. }
  319. .detail-action-bar-fixed {
  320. position: fixed;
  321. bottom: 0;
  322. left: 0;
  323. right: 0;
  324. background: #fff;
  325. padding: 30rpx 40rpx;
  326. box-shadow: 0 -10rpx 40rpx rgba(0, 0, 0, 0.04);
  327. z-index: 999;
  328. flex-shrink: 0;
  329. }
  330. .action-btn-wrap {
  331. display: flex;
  332. gap: 24rpx;
  333. }
  334. .action-btn {
  335. flex: 1;
  336. height: 96rpx;
  337. border-radius: 48rpx;
  338. display: flex;
  339. align-items: center;
  340. justify-content: center;
  341. font-size: 32rpx;
  342. font-weight: bold;
  343. }
  344. .action-btn.primary {
  345. background: #C1001C;
  346. color: #fff;
  347. border: none;
  348. }
  349. .action-btn.cancel {
  350. background: #fff1f0;
  351. color: #ff3b30;
  352. border: 1rpx solid #ffccc7;
  353. font-weight: normal;
  354. }
  355. .safe-area-bottom-support {
  356. height: constant(safe-area-inset-bottom);
  357. height: env(safe-area-inset-bottom);
  358. }
  359. </style>