index.vue 10 KB

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