purchase.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <div class="purchase-traceability-page">
  3. <!-- 顶部导航栏 -->
  4. <div class="nav-bar">
  5. <div class="nav-left" @click="handleBack">
  6. <i class="el-icon-arrow-left back-icon"></i>
  7. </div>
  8. <div class="nav-title">采购溯源</div>
  9. <div class="nav-right"></div>
  10. </div>
  11. <!-- 主内容区 -->
  12. <div class="content-wrapper">
  13. <!-- 产品图片区域 -->
  14. <div class="product-image-section">
  15. <div class="product-title">
  16. 采购溯源
  17. </div>
  18. <div style="height: 200px;">
  19. <img v-if="purchaseInfo && purchaseInfo.purchaseImgUrl" class="product-image" :src="purchaseInfo.purchaseImgUrl" alt="产品图片">
  20. </div>
  21. </div>
  22. <!-- 采购信息列表 -->
  23. <div class="info-list">
  24. <!-- 采购详情标题 -->
  25. <div class="info-title">
  26. 采购详情
  27. </div>
  28. <div class="info-item">
  29. <span class="info-label">批次号:</span>
  30. <span class="info-value">{{ purchaseInfo.sourceBatchNo }}</span>
  31. </div>
  32. <div class="info-item">
  33. <span class="info-label">产地:</span>
  34. <span class="info-value">{{ purchaseInfo.purchaseOrigins }}</span>
  35. </div>
  36. <div class="info-item">
  37. <span class="info-label">供应商名称:</span>
  38. <span class="info-value">{{ purchaseInfo.supplierName }}</span>
  39. </div>
  40. <div class="info-item">
  41. <span class="info-label">采收时间:</span>
  42. <span class="info-value">{{ purchaseInfo.purchaseCollectDate }}</span>
  43. </div>
  44. <div class="info-item">
  45. <span class="info-label">采购人员:</span>
  46. <span class="info-value">{{ purchaseInfo.purchaseUserName }}</span>
  47. </div>
  48. <div class="info-item">
  49. <span class="info-label">采购数量:</span>
  50. <span class="info-value">{{ purchaseInfo.purchaseQuantity }}{{ purchaseInfo.measuringUnit }}</span>
  51. </div>
  52. <div class="info-item">
  53. <span class="info-label">采购重量:</span>
  54. <span class="info-value">{{ purchaseInfo.purchaseWeight }}{{ purchaseInfo.weightUnit }}</span>
  55. </div>
  56. <div class="info-item">
  57. <span class="info-label">采购日期:</span>
  58. <span class="info-value">{{ purchaseInfo.purchaseDate }}</span>
  59. </div>
  60. <div class="images-section">
  61. <span class="section-subtitle">图片:</span>
  62. <div class="images-grid">
  63. <img v-if="purchaseInfo && purchaseInfo.purchaseImgUrl" class="detail-image" :src="purchaseInfo.purchaseImgUrl" alt="详情图片">
  64. </div>
  65. </div>
  66. </div>
  67. <!-- 返回首页按钮 -->
  68. <!-- <div class="home-button" @click="goToHome">
  69. <svg class="home-icon" viewBox="0 0 16 16" width="32" height="32">
  70. <path d="M8.354 1.146a.5.5 0 0 0-.708 0l-6 6a.5.5 0 1 0 .708.708L8 2.207l5.646 5.647a.5.5 0 0 0 .708-.708l-6-6zM8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0zm-.5 7a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2a.5.5 0 0 1 .5-.5zm0 3a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-1 0v-1a.5.5 0 0 1 .5-.5z"/>
  71. </svg>
  72. </div> -->
  73. </div>
  74. </div>
  75. </template>
  76. <script>
  77. export default {
  78. name: 'PurchaseTraceabilityPage',
  79. data() {
  80. return {
  81. // 使用项目中已有的图标路径
  82. productImageSrc: require('@/assets/traceability/1.svg'),
  83. detailImageSrc: require('@/assets/traceability/1.svg'),
  84. // 定义detail对象来存储从路由获取的参数
  85. detail: {},
  86. purchaseInfo: {}
  87. };
  88. },
  89. mounted() {
  90. console.log('路由参数:');
  91. console.log('路由参数:', this.$route.query);
  92. // 从路由参数中获取detail对象
  93. if (this.$route.query && this.$route.query.detail) {
  94. try {
  95. // 解析JSON字符串为对象
  96. this.detail = JSON.parse(this.$route.query.detail);
  97. console.log('获取到的detail参数:', this.detail);
  98. this.purchaseInfo = this.detail.purchaseInfo || {};
  99. } catch (error) {
  100. console.error('解析detail参数失败:', error);
  101. this.detail = {};
  102. this.purchaseInfo = {};
  103. }
  104. }
  105. },
  106. methods: {
  107. handleBack() {
  108. // 返回上一页
  109. this.$router.back();
  110. },
  111. goToHome() {
  112. // 返回首页
  113. this.$router.push('/pages/home/home');
  114. }
  115. }
  116. };
  117. </script>
  118. <style lang="scss" scoped>
  119. .purchase-traceability-page {
  120. background-color: #f5f5f5;
  121. min-height: 100vh;
  122. background-image: url('~@/assets/traceability/bg.jpg');
  123. background-size: cover;
  124. background-position: center;
  125. }
  126. .nav-bar {
  127. height: 56px;
  128. display: flex;
  129. align-items: center;
  130. justify-content: space-between;
  131. background-color: #fff;
  132. color: #000;
  133. box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  134. padding: 0 16px;
  135. position: fixed;
  136. top: 0;
  137. left: 0;
  138. right: 0;
  139. z-index: 100;
  140. }
  141. .nav-left {
  142. width: 40px;
  143. height: 40px;
  144. display: flex;
  145. align-items: center;
  146. justify-content: center;
  147. cursor: pointer;
  148. }
  149. .back-icon {
  150. fill: #333;
  151. font-size: 24px;
  152. }
  153. .nav-title {
  154. font-size: 18px;
  155. font-weight: 500;
  156. }
  157. .nav-right {
  158. width: 40px;
  159. }
  160. .content-wrapper {
  161. padding: 76px 20px 60px;
  162. }
  163. .product-image-section {
  164. display: flex;
  165. justify-content: center;
  166. margin-bottom: 20px;
  167. background-color: #fff;
  168. padding: 20px;
  169. border-radius: 10px;
  170. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.05);
  171. border: 1px solid #ffe6e6;
  172. position: relative;
  173. }
  174. .product-title {
  175. position: absolute;
  176. font-size: 16px;
  177. font-weight: bold;
  178. color: #fff;
  179. text-align: center;
  180. margin-bottom: 10px;
  181. padding: 5px 20px;
  182. background: #bd0402;
  183. border-radius: 5px;
  184. box-shadow: 0 1px 4px rgba(255, 107, 107, 0.3);
  185. top: -10px;
  186. }
  187. .product-image {
  188. width: 100%;
  189. height: 200px;
  190. border-radius: 5px;
  191. margin-top: 20px;
  192. object-fit: contain;
  193. }
  194. .info-list {
  195. background-color: #fff;
  196. border-radius: 10px;
  197. padding: 30px;
  198. margin-bottom: 30px;
  199. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.05);
  200. position: relative;
  201. padding-top: 30px;
  202. border: 1px solid #ffe6e6;
  203. }
  204. .info-title {
  205. position: absolute;
  206. top: -10px;
  207. left: 35%;
  208. background-color: #bd0402;
  209. color: #fff;
  210. text-align: center;
  211. padding: 5px 20px;
  212. margin-bottom: 15px;
  213. border-radius: 5px;
  214. font-size: 16px;
  215. font-weight: bold;
  216. }
  217. .info-item {
  218. display: flex;
  219. justify-content: space-between;
  220. align-items: center;
  221. padding: 10px 0;
  222. border-bottom: 1px solid #f0f0f0;
  223. }
  224. .info-item:last-child {
  225. border-bottom: none;
  226. }
  227. .info-label {
  228. font-size: 14px;
  229. color: #bd0402;
  230. }
  231. .info-value {
  232. font-size: 14px;
  233. color: #333;
  234. text-align: right;
  235. }
  236. .images-section {
  237. padding: 10px 0;
  238. }
  239. .section-subtitle {
  240. font-size: 14px;
  241. color: #bd0402;
  242. margin-bottom: 10px;
  243. display: block;
  244. }
  245. .images-grid {
  246. display: flex;
  247. flex-direction: column;
  248. gap: 10px;
  249. }
  250. .detail-image {
  251. width: 100%;
  252. height: 200px;
  253. border-radius: 5px;
  254. object-fit: cover;
  255. }
  256. .home-button {
  257. position: fixed;
  258. bottom: 30px;
  259. right: 30px;
  260. width: 50px;
  261. height: 50px;
  262. background-color: #bd0402;
  263. border-radius: 50%;
  264. display: flex;
  265. justify-content: center;
  266. align-items: center;
  267. box-shadow: 0 2px 10px rgba(189, 4, 2, 0.4);
  268. cursor: pointer;
  269. z-index: 10;
  270. }
  271. .home-icon {
  272. fill: #fff;
  273. }
  274. </style>