detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <div class="order-detail-container">
  3. <div class="page-header">
  4. <el-button link @click="handleBack"
  5. ><el-icon><ArrowLeft /></el-icon><span>返回</span></el-button
  6. >
  7. <span class="page-title">订单详情</span>
  8. </div>
  9. <div class="page-content">
  10. <!-- 订单进度 -->
  11. <div class="progress-section">
  12. <div class="progress-steps">
  13. <div
  14. v-for="(step, index) in progressSteps"
  15. :key="index"
  16. :class="['step-item', { active: index <= currentStep, current: index === currentStep }]"
  17. >
  18. <div class="step-icon">
  19. <el-icon :size="24"><component :is="step.icon" /></el-icon>
  20. </div>
  21. <div class="step-info">
  22. <div class="step-title">{{ step.title }}</div>
  23. <div class="step-desc">{{ step.desc }}</div>
  24. <div class="step-time">{{ step.time }}</div>
  25. </div>
  26. <div v-if="index < progressSteps.length - 1" class="step-line" :class="{ active: index < currentStep }"></div>
  27. </div>
  28. </div>
  29. </div>
  30. <!-- 商品信息 -->
  31. <div class="section">
  32. <div class="section-title"><i class="title-bar"></i>商品信息</div>
  33. <el-table :data="productList" border style="width: 100%">
  34. <el-table-column label="商品信息" min-width="300">
  35. <template #default="{ row }">
  36. <div class="product-cell">
  37. <div class="product-image">
  38. <el-image :src="row.image" fit="contain"
  39. ><template #error
  40. ><div class="image-placeholder">
  41. <el-icon :size="30" color="#ccc"><Picture /></el-icon></div></template
  42. ></el-image>
  43. </div>
  44. <div class="product-info">
  45. <div class="product-name">{{ row.name }}</div>
  46. <div class="product-spec">{{ row.spec1 }} {{ row.spec2 }}</div>
  47. </div>
  48. </div>
  49. </template>
  50. </el-table-column>
  51. <el-table-column prop="price" label="单价" width="100" align="center"
  52. ><template #default="{ row }">¥{{ row.price }}</template></el-table-column
  53. >
  54. <el-table-column label="数量" width="150" align="center"
  55. ><template #default="{ row }"><el-input-number v-model="row.quantity" :min="1" size="small" disabled /></template
  56. ></el-table-column>
  57. <el-table-column prop="subtotal" label="小计" width="100" align="center"
  58. ><template #default="{ row }">¥{{ row.subtotal }}</template></el-table-column
  59. >
  60. <el-table-column label="操作" width="80" align="center"
  61. ><template #default><el-button type="danger" link size="small">清除</el-button></template></el-table-column
  62. >
  63. </el-table>
  64. <div class="product-summary">
  65. 共{{ productList.length }}件商品 运费:¥{{ orderInfo.freight }} 共计<span class="total-price">¥{{ orderInfo.totalAmount }}</span>
  66. </div>
  67. </div>
  68. <!-- 收货地址 -->
  69. <div class="section">
  70. <div class="section-title"><i class="title-bar"></i>收货地址</div>
  71. <div class="address-card">
  72. <div class="address-detail">{{ orderInfo.address }}</div>
  73. <div class="address-name">{{ orderInfo.receiverName }}</div>
  74. <div class="address-phone">{{ orderInfo.receiverPhone }}</div>
  75. </div>
  76. </div>
  77. <!-- 其他信息 -->
  78. <div class="section">
  79. <div class="section-title"><i class="title-bar"></i>其他信息</div>
  80. <div class="info-table">
  81. <div class="info-row">
  82. <span class="info-label">配送时间</span><span class="info-value">{{ orderInfo.deliveryTime }}</span>
  83. </div>
  84. <div class="info-row">
  85. <span class="info-label">采购事由</span><span class="info-value">{{ orderInfo.purchaseReason || '-' }}</span>
  86. </div>
  87. <div class="info-row">
  88. <span class="info-label">费用类型</span><span class="info-value">{{ orderInfo.costType || '-' }}</span>
  89. </div>
  90. <div class="info-row">
  91. <span class="info-label">订单备注</span><span class="info-value">{{ orderInfo.remark || '-' }}</span>
  92. </div>
  93. </div>
  94. </div>
  95. <!-- 发票信息 -->
  96. <div class="section">
  97. <div class="section-title"><i class="title-bar"></i>发票信息</div>
  98. <div class="info-table">
  99. <div class="info-row">
  100. <span class="info-label">发票类型</span><span class="info-value">{{ invoiceInfo.type || '-' }}</span>
  101. </div>
  102. <div class="info-row">
  103. <span class="info-label">发票抬头</span><span class="info-value">{{ invoiceInfo.title || '-' }}</span>
  104. </div>
  105. <div class="info-row">
  106. <span class="info-label">纳税人识别号</span><span class="info-value">{{ invoiceInfo.taxNo || '-' }}</span>
  107. </div>
  108. <div class="info-row">
  109. <span class="info-label">注册地址</span><span class="info-value">{{ invoiceInfo.registerAddress || '-' }}</span>
  110. </div>
  111. <div class="info-row">
  112. <span class="info-label">注册电话</span><span class="info-value">{{ invoiceInfo.registerPhone || '-' }}</span>
  113. </div>
  114. <div class="info-row">
  115. <span class="info-label">开户银行</span><span class="info-value">{{ invoiceInfo.bankName || '-' }}</span>
  116. </div>
  117. <div class="info-row">
  118. <span class="info-label">银行账号</span><span class="info-value">{{ invoiceInfo.bankAccount || '-' }}</span>
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. </div>
  124. </template>
  125. <script setup lang="ts">
  126. import { ref, reactive, onMounted } from 'vue';
  127. import { useRouter, useRoute } from 'vue-router';
  128. import { ArrowLeft, Document, Search, CircleCheck, Picture } from '@element-plus/icons-vue';
  129. import { getOrderInfo, getOrderProducts } from '@/api/pc/enterprise/order';
  130. import { getAddressInfo } from '@/api/pc/enterprise/address';
  131. import { getInvoiceList } from '@/api/pc/enterprise/invoice';
  132. import { ElMessage } from 'element-plus';
  133. const router = useRouter();
  134. const route = useRoute();
  135. const orderId = ref<any>(0);
  136. const currentStep = ref(1);
  137. const loading = ref(false);
  138. const progressSteps = ref([
  139. { title: '提交审核', icon: Document, desc: '采购一部提交订单审核', time: '2025/02/10 15:51:21' },
  140. { title: '审核中', icon: Search, desc: '采购一部提交订单审批', time: '2025/02/10 15:51:21' },
  141. { title: '审核完成', icon: CircleCheck, desc: '交易完成', time: '2025/02/10 15:51:21' }
  142. ]);
  143. const productList = ref<any[]>([]);
  144. const orderInfo = reactive({
  145. freight: '0.00',
  146. totalAmount: '0.00',
  147. address: '',
  148. receiverName: '',
  149. receiverPhone: '',
  150. deliveryTime: '',
  151. purchaseReason: '',
  152. costType: '',
  153. remark: ''
  154. });
  155. const invoiceInfo = reactive({
  156. type: '',
  157. title: '',
  158. taxNo: '',
  159. registerAddress: '',
  160. registerPhone: '',
  161. bankName: '',
  162. bankAccount: ''
  163. });
  164. // 加载订单详情
  165. const loadOrderDetail = async () => {
  166. try {
  167. loading.value = true;
  168. const res = await getOrderInfo(orderId.value);
  169. if (res.code === 200 && res.data) {
  170. const order = res.data;
  171. // 映射订单信息
  172. orderInfo.freight = order.shippingFee || '0.00';
  173. orderInfo.totalAmount = order.payableAmount || '0.00';
  174. orderInfo.deliveryTime = order.expectedDeliveryTime || '';
  175. orderInfo.purchaseReason = order.purchaseReason || '';
  176. orderInfo.remark = order.remark || '';
  177. // 获取商品信息
  178. const productsRes = await getOrderProducts([orderId.value]);
  179. if (productsRes.code === 200 && productsRes.rows) {
  180. productList.value = productsRes.rows.map((p: any) => ({
  181. id: p.id,
  182. name: p.productName || '',
  183. spec1: p.productUnit || '',
  184. spec2: p.productNo || '',
  185. price: p.orderPrice || '0.00',
  186. quantity: p.orderQuantity || 1,
  187. subtotal: (parseFloat(p.orderPrice || '0') * (p.orderQuantity || 1)).toFixed(2),
  188. image: p.productImage || ''
  189. }));
  190. }
  191. // 获取收货地址信息
  192. if (order.shippingAddressId) {
  193. const addressRes = await getAddressInfo(order.shippingAddressId);
  194. if (addressRes.code === 200 && addressRes.data) {
  195. orderInfo.address = addressRes.data.address || '';
  196. orderInfo.receiverName = addressRes.data.consignee || '';
  197. orderInfo.receiverPhone = addressRes.data.phone || '';
  198. }
  199. }
  200. // 获取发票信息
  201. const invoiceRes = await getInvoiceList({ pageNum: 1, pageSize: 1 });
  202. if (invoiceRes.code === 200 && invoiceRes.rows && invoiceRes.rows.length > 0) {
  203. const invoice = invoiceRes.rows[0];
  204. invoiceInfo.type = order.invoiceType || '';
  205. invoiceInfo.title = order.customerName || '';
  206. invoiceInfo.taxNo = invoice.taxId || '';
  207. invoiceInfo.registerAddress = invoice.address || '';
  208. invoiceInfo.registerPhone = invoice.phone || '';
  209. invoiceInfo.bankName = invoice.bankName || '';
  210. invoiceInfo.bankAccount = invoice.bankAccount || '';
  211. }
  212. }
  213. } catch (error) {
  214. console.error('加载订单详情失败:', error);
  215. ElMessage.error('加载订单详情失败');
  216. } finally {
  217. loading.value = false;
  218. }
  219. };
  220. onMounted(() => {
  221. const paramId = route.params.orderNo || route.params.id;
  222. console.log('路由参数:', route.params);
  223. console.log('获取到的参数:', paramId);
  224. // 直接使用字符串,不转换为数字,避免精度丢失
  225. orderId.value = paramId as string;
  226. console.log('订单ID:', orderId.value);
  227. if (orderId.value) {
  228. loadOrderDetail();
  229. } else {
  230. console.error('订单ID无效,无法加载订单详情');
  231. }
  232. });
  233. const handleBack = () => {
  234. router.push('/order/orderManage');
  235. };
  236. </script>
  237. <style scoped lang="scss">
  238. .order-detail-container {
  239. background: #f5f5f5;
  240. min-height: 100%;
  241. }
  242. .page-header {
  243. background: #fff;
  244. padding: 15px 20px;
  245. display: flex;
  246. align-items: center;
  247. gap: 10px;
  248. border-bottom: 1px solid #eee;
  249. .page-title {
  250. font-size: 16px;
  251. font-weight: bold;
  252. color: #333;
  253. }
  254. }
  255. .page-content {
  256. padding: 20px;
  257. }
  258. .progress-section {
  259. background: #fff;
  260. border-radius: 8px;
  261. padding: 30px 50px;
  262. margin-bottom: 15px;
  263. .progress-steps {
  264. display: flex;
  265. justify-content: space-between;
  266. position: relative;
  267. .step-item {
  268. display: flex;
  269. flex-direction: column;
  270. align-items: center;
  271. position: relative;
  272. flex: 1;
  273. .step-icon {
  274. width: 50px;
  275. height: 50px;
  276. border-radius: 8px;
  277. background: #f5f5f5;
  278. display: flex;
  279. align-items: center;
  280. justify-content: center;
  281. color: #999;
  282. margin-bottom: 10px;
  283. position: relative;
  284. z-index: 1;
  285. }
  286. &.active .step-icon {
  287. background: #e60012;
  288. color: #fff;
  289. }
  290. &.current .step-icon::after {
  291. content: '';
  292. position: absolute;
  293. bottom: -5px;
  294. left: 50%;
  295. transform: translateX(-50%);
  296. width: 8px;
  297. height: 8px;
  298. border-radius: 50%;
  299. background: #e60012;
  300. }
  301. .step-info {
  302. text-align: center;
  303. .step-title {
  304. font-size: 14px;
  305. color: #999;
  306. margin-bottom: 5px;
  307. }
  308. .step-desc {
  309. font-size: 12px;
  310. color: #666;
  311. margin-bottom: 3px;
  312. }
  313. .step-time {
  314. font-size: 12px;
  315. color: #999;
  316. }
  317. }
  318. &.active .step-info .step-title {
  319. color: #333;
  320. }
  321. .step-line {
  322. position: absolute;
  323. top: 25px;
  324. left: calc(50% + 30px);
  325. width: calc(100% - 60px);
  326. height: 2px;
  327. background: #eee;
  328. &.active {
  329. background: #e60012;
  330. }
  331. }
  332. &:last-child .step-line {
  333. display: none;
  334. }
  335. }
  336. }
  337. }
  338. .section {
  339. background: #fff;
  340. border-radius: 8px;
  341. padding: 20px;
  342. margin-bottom: 15px;
  343. .section-title {
  344. font-size: 16px;
  345. font-weight: bold;
  346. display: flex;
  347. align-items: center;
  348. gap: 8px;
  349. margin-bottom: 15px;
  350. }
  351. }
  352. .title-bar {
  353. display: inline-block;
  354. width: 3px;
  355. height: 16px;
  356. background: #e60012;
  357. border-radius: 2px;
  358. }
  359. .product-cell {
  360. display: flex;
  361. align-items: center;
  362. gap: 15px;
  363. .product-image {
  364. width: 80px;
  365. height: 80px;
  366. background: #f5f5f5;
  367. border-radius: 4px;
  368. overflow: hidden;
  369. flex-shrink: 0;
  370. .el-image {
  371. width: 100%;
  372. height: 100%;
  373. }
  374. .image-placeholder {
  375. width: 100%;
  376. height: 100%;
  377. display: flex;
  378. align-items: center;
  379. justify-content: center;
  380. }
  381. }
  382. .product-info {
  383. .product-name {
  384. font-size: 14px;
  385. color: #333;
  386. margin-bottom: 5px;
  387. line-height: 1.4;
  388. }
  389. .product-spec {
  390. font-size: 12px;
  391. color: #999;
  392. }
  393. }
  394. }
  395. .product-summary {
  396. text-align: right;
  397. padding: 15px 0;
  398. font-size: 14px;
  399. color: #666;
  400. .total-price {
  401. font-size: 18px;
  402. font-weight: bold;
  403. color: #e60012;
  404. margin-left: 5px;
  405. }
  406. }
  407. .address-card {
  408. padding: 15px;
  409. border: 1px solid #eee;
  410. border-radius: 4px;
  411. .address-detail {
  412. font-size: 14px;
  413. color: #333;
  414. margin-bottom: 8px;
  415. }
  416. .address-name {
  417. font-size: 14px;
  418. color: #666;
  419. margin-bottom: 5px;
  420. }
  421. .address-phone {
  422. font-size: 14px;
  423. color: #666;
  424. }
  425. }
  426. .info-table {
  427. .info-row {
  428. display: flex;
  429. padding: 10px 0;
  430. border-bottom: 1px solid #f5f5f5;
  431. &:last-child {
  432. border-bottom: none;
  433. }
  434. .info-label {
  435. width: 100px;
  436. font-size: 14px;
  437. color: #999;
  438. flex-shrink: 0;
  439. }
  440. .info-value {
  441. flex: 1;
  442. font-size: 14px;
  443. color: #333;
  444. }
  445. }
  446. }
  447. </style>