priceSheetPopup.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. <template>
  2. <popup class="price-sheet-popup" v-model:show="showPopup" :close-on-click-overlay="false">
  3. <div class="price-sheet-content">
  4. <div class="price-sheet-content-inner">
  5. <!-- 顶部标题区域 -->
  6. <div class="header-section">
  7. <div class="header-left">
  8. <div class="main-title">服务报价单</div>
  9. </div>
  10. <div class="header-right">
  11. <div class="qr-icon">
  12. <img src="@/assets/img/home/qrcode.png" alt="" />
  13. </div>
  14. <div class="qr-text">扫码查看详情</div>
  15. </div>
  16. </div>
  17. <div class="sheet-content">
  18. <!-- 报价详情区域 -->
  19. <div class="quotation-info">
  20. <div class="info-item">
  21. <span class="info-label">报价组织</span>
  22. <span class="info-value">{{ quotationData.serviceMain || '--' }}</span>
  23. </div>
  24. <div class="info-item">
  25. <span class="info-label">报价农事</span>
  26. <span class="info-value">{{ quotationData?.farmWorkName || '--' }}</span>
  27. </div>
  28. <div class="info-item catalog-label">
  29. <span class="info-label">报价目录</span>
  30. </div>
  31. <div class="total-bar">
  32. <span class="total-label">报价合计:</span>
  33. <span class="total-value">{{ priceData?.totalCost || '--' }}</span>
  34. <span class="total-unit">元</span>
  35. </div>
  36. </div>
  37. <!-- 肥药费用区域 -->
  38. <div class="fertilizer-cost-section">
  39. <div class="section-header">
  40. <div class="section-title">肥药费用</div>
  41. <div class="section-total">{{ priceData?.pesticideFertilizerCost || '--' }}<span class="unit-text">元</span></div>
  42. </div>
  43. <div class="cost-table">
  44. <div class="table-header">
  45. <div class="col-1">功效</div>
  46. <div class="col-2">名称</div>
  47. <div class="col-3">品牌</div>
  48. <div class="col-4">单价</div>
  49. <div class="col-5">用量</div>
  50. <div class="col-6">总价</div>
  51. </div>
  52. <div
  53. class="table-row"
  54. v-for="(item, index) in processedPrescriptionList"
  55. :key="index"
  56. >
  57. <div class="col-1">{{ item.typeName || '--' }}</div>
  58. <div class="col-2">{{ item.defaultName || '--' }}</div>
  59. <div class="col-3">{{ item.brand || '--' }}</div>
  60. <div class="col-4">{{ item.priceDisplay || '--' }}</div>
  61. <div class="col-5">{{ item.usageDisplay || '--' }}</div>
  62. <div class="col-6">{{ item.totalDisplay === '--' ? '--' : (item.totalDisplay + '元') }}</div>
  63. </div>
  64. </div>
  65. </div>
  66. <!-- 服务费用区域 -->
  67. <div class="service-cost-section">
  68. <div class="section-header">
  69. <div class="section-title">服务费用</div>
  70. <div class="section-total">{{ priceData?.farmWorkServiceCost || '--' }}<span class="unit-text">元</span></div>
  71. </div>
  72. <div class="service-details">
  73. <div class="detail-item">
  74. <div class="detail-value">{{ priceData?.executionMethodName || '--' }}</div>
  75. <div class="detail-label">执行方式</div>
  76. </div>
  77. <div class="detail-item">
  78. <div class="detail-value">{{ (priceData?.farmWorkServiceCost + '元/亩') || '--元/亩' }}</div>
  79. <div class="detail-label">亩单价</div>
  80. </div>
  81. <div class="detail-item">
  82. <div class="detail-value">{{ quotationData?.area ? (quotationData?.area + '亩') : '--' }}</div>
  83. <div class="detail-label">亩数</div>
  84. </div>
  85. </div>
  86. <div class="edit-btn-box">
  87. <div class="edit-btn" @click="handleEdit">编辑报价</div>
  88. </div>
  89. </div>
  90. </div>
  91. </div>
  92. <!-- 底部操作按钮 -->
  93. <div class="bottom-actions">
  94. <div class="action-buttons">
  95. <div class="action-btn blue-btn">
  96. <div class="icon-circle">
  97. <img src="@/assets/img/home/bird.png" alt="" />
  98. </div>
  99. <span class="btn-label">飞鸟用户</span>
  100. </div>
  101. <div class="action-btn green-btn">
  102. <div class="icon-circle">
  103. <img src="@/assets/img/home/wechat.png" alt="" />
  104. </div>
  105. <span class="btn-label">微信</span>
  106. </div>
  107. <div class="action-btn orange-btn">
  108. <div class="icon-circle">
  109. <el-icon :size="24"><Download /></el-icon>
  110. </div>
  111. <span class="btn-label">保存图片</span>
  112. </div>
  113. </div>
  114. <div class="cancel-btn" @click="handleCancel">取消</div>
  115. </div>
  116. </div>
  117. </popup>
  118. </template>
  119. <script setup>
  120. import { Popup } from "vant";
  121. import { ref, computed } from "vue";
  122. import { useRouter } from "vue-router";
  123. const router = useRouter();
  124. const showPopup = ref(false);
  125. // 报价数据
  126. const quotationData = ref({});
  127. const priceData = ref({});
  128. // 处理后的处方列表(展平并匹配价格)
  129. const processedPrescriptionList = computed(() => {
  130. if (!quotationData.value?.prescriptionList || !Array.isArray(quotationData.value.prescriptionList)) {
  131. return [];
  132. }
  133. // 创建价格映射表,方便快速查找
  134. const priceMap = new Map();
  135. if (priceData.value?.itemsList && Array.isArray(priceData.value.itemsList)) {
  136. priceData.value.itemsList.forEach(item => {
  137. priceMap.set(String(item.pesticideFertilizerId), { price: item.price, brand: item.brand });
  138. });
  139. }
  140. // 展平 prescriptionList 中的所有 pesticideFertilizerList
  141. const result = [];
  142. quotationData.value.prescriptionList.forEach(prescription => {
  143. if (prescription.pesticideFertilizerList && Array.isArray(prescription.pesticideFertilizerList)) {
  144. prescription.pesticideFertilizerList.forEach(item => {
  145. const pesticideFertilizerId = String(item.pesticideFertilizerId || '');
  146. const mapped = priceMap.get(pesticideFertilizerId) || {};
  147. const price = mapped.price || 0;
  148. const brand = mapped.brand || item.brand || '';
  149. const muUsage = item.muUsage || 0;
  150. const unit = item.unit || '';
  151. // 计算总价
  152. const total = price * muUsage;
  153. result.push({
  154. typeName: item.typeName || '--',
  155. defaultName: item.defaultName || item.pesticideFertilizerName || '--',
  156. brand: brand,
  157. price: price,
  158. unit: unit,
  159. muUsage: muUsage,
  160. total: total,
  161. // 显示的格式化字符串
  162. priceDisplay: price > 0 ? `${price}元/${unit}` : '--',
  163. usageDisplay: muUsage > 0 ? `${muUsage}${unit}` : '--',
  164. totalDisplay: total > 0 ? `${total.toFixed(2)}` : '--'
  165. });
  166. });
  167. }
  168. });
  169. return result;
  170. });
  171. const handleShowPopup = (data) => {
  172. if (data) {
  173. quotationData.value = data;
  174. fetchPriceData();
  175. }
  176. showPopup.value = true;
  177. };
  178. function fetchPriceData() {
  179. if (!quotationData.value?.orderId) {
  180. return;
  181. }
  182. VE_API.z_farm_work_record_cost.listByOrderId({ farmWorkOrderId: quotationData.value.orderId }).then(({ data }) => {
  183. if (data && data.length > 0) {
  184. priceData.value = data[0];
  185. }
  186. }).catch(() => {
  187. // 获取价格数据失败
  188. });
  189. }
  190. const handleEdit = () => {
  191. // 编辑报价逻辑
  192. // 可以触发编辑事件或打开编辑页面
  193. router.push({
  194. path: "/price_detail",
  195. query: { data: JSON.stringify(quotationData.value), priceData: JSON.stringify(priceData.value) },
  196. });
  197. };
  198. const handleCancel = () => {
  199. showPopup.value = false;
  200. };
  201. defineExpose({
  202. handleShowPopup,
  203. });
  204. </script>
  205. <style lang="scss" scoped>
  206. .price-sheet-popup {
  207. width: 90%;
  208. max-height: 95vh;
  209. background: none;
  210. border-radius: 12px;
  211. overflow: hidden;
  212. display: flex;
  213. flex-direction: column;
  214. backdrop-filter: 4px;
  215. ::v-deep {
  216. .van-popup__close-icon {
  217. color: #000;
  218. font-size: 18px;
  219. top: 12px;
  220. right: 12px;
  221. }
  222. }
  223. }
  224. .price-sheet-content {
  225. display: flex;
  226. flex-direction: column;
  227. max-height: 94vh;
  228. // height: 95vh;
  229. .price-sheet-content-inner {
  230. background: #fff;
  231. border-radius: 12px;
  232. display: flex;
  233. flex-direction: column;
  234. height: 100%;
  235. overflow: hidden;
  236. }
  237. }
  238. // 顶部标题区域
  239. .header-section {
  240. display: flex;
  241. justify-content: space-between;
  242. align-items: center;
  243. padding: 16px 10px 12px 16px;
  244. // background: linear-gradient(180deg, rgba(33, 153, 248, 0) 8%, rgba(139, 199, 252, 0.519) 94%, rgba(237, 241, 255, 1) 100%);
  245. background: linear-gradient(180deg, rgba(33, 153, 248, 0) 2%, rgba(139, 199, 252, 0.519) 50%, #c4e3fd);
  246. flex-shrink: 0;
  247. .header-left {
  248. flex: 1;
  249. .main-title {
  250. font-family: "PangMenZhengDao";
  251. font-size: 28px;
  252. color: #0387EF;
  253. }
  254. }
  255. .header-right {
  256. display: flex;
  257. flex-direction: column;
  258. align-items: center;
  259. margin-left: 16px;
  260. .qr-icon {
  261. color: #2199F8;
  262. margin-bottom: 4px;
  263. img {
  264. width: 40px;
  265. height: 40px;
  266. }
  267. }
  268. .qr-text {
  269. font-size: 12px;
  270. color: #171717;
  271. }
  272. }
  273. }
  274. .sheet-content {
  275. padding: 24px 16px 12px 16px;
  276. flex: 1;
  277. overflow-y: auto;
  278. overflow-x: hidden;
  279. }
  280. // 报价详情区域
  281. .quotation-info {
  282. margin-bottom: 12px;
  283. .info-item {
  284. font-size: 16px;
  285. color: #000;
  286. margin-bottom: 8px;
  287. .info-label {
  288. padding-right: 8px;
  289. color: rgba(0, 0, 0, 0.5);
  290. }
  291. .info-value {
  292. color: #000;
  293. }
  294. &.catalog-label {
  295. font-weight: bold;
  296. margin-top: 10px;
  297. margin-bottom: 10px;
  298. .info-label {
  299. color: #000;
  300. }
  301. }
  302. }
  303. .total-bar {
  304. display: flex;
  305. align-items: center;
  306. justify-content: center;
  307. background: rgba(33, 153, 248, 0.1);
  308. border: 1px solid rgba(33, 153, 248, 0.5);
  309. height: 38px;
  310. border-radius: 4px;
  311. .total-label {
  312. font-size: 14px;
  313. color: #000000;
  314. }
  315. .total-value {
  316. font-size: 22px;
  317. font-weight: bold;
  318. color: #2199F8;
  319. }
  320. .total-unit {
  321. font-size: 14px;
  322. color: #000;
  323. margin-left: 4px;
  324. }
  325. }
  326. }
  327. // 肥药费用区域
  328. .fertilizer-cost-section {
  329. margin-bottom: 10px;
  330. .section-header {
  331. display: flex;
  332. justify-content: space-between;
  333. align-items: center;
  334. margin-bottom: 8px;
  335. .section-title {
  336. font-size: 14px;
  337. color: #000;
  338. }
  339. .section-total {
  340. font-size: 16px;
  341. font-weight: bold;
  342. color: #000;
  343. .unit-text {
  344. padding-left: 2px;
  345. font-size: 12px;
  346. font-weight: normal;
  347. }
  348. }
  349. }
  350. .cost-table {
  351. border: 1px solid rgba(225, 225, 225, 0.5);
  352. border-radius: 5px;
  353. overflow: hidden;
  354. .table-header {
  355. display: flex;
  356. background: rgba(241, 241, 241, 0.4);
  357. padding: 8px 6px;
  358. font-size: 12px;
  359. color: #767676;
  360. border-bottom: 1px solid rgba(225, 225, 225, 0.5);
  361. .col-1 {
  362. width: 40px;
  363. text-align: center;
  364. }
  365. .col-2 {
  366. flex: 1;
  367. text-align: center;
  368. }
  369. .col-3 {
  370. width: 52px;
  371. text-align: center;
  372. }
  373. .col-4 {
  374. width: 56px;
  375. text-align: center;
  376. }
  377. .col-5 {
  378. width: 52px;
  379. text-align: center;
  380. }
  381. .col-6 {
  382. width: 52px;
  383. text-align: center;
  384. }
  385. }
  386. .table-row {
  387. display: flex;
  388. padding: 8px 6px;
  389. font-size: 11px;
  390. color: rgba(0, 0, 0, 0.6);
  391. background: #fff;
  392. border-bottom: 1px solid rgba(225, 225, 225, 0.3);
  393. &:last-child {
  394. border-bottom: none;
  395. }
  396. .col-1,
  397. .col-2,
  398. .col-3,
  399. .col-4,
  400. .col-5,
  401. .col-6 {
  402. display: flex;
  403. align-items: center;
  404. justify-content: center;
  405. }
  406. .col-1 {
  407. width: 40px;
  408. }
  409. .col-2 {
  410. flex: 1;
  411. }
  412. .col-3 {
  413. width: 52px;
  414. }
  415. .col-4 {
  416. width: 56px;
  417. }
  418. .col-5 {
  419. width: 52px;
  420. }
  421. .col-6 {
  422. width: 52px;
  423. }
  424. }
  425. }
  426. }
  427. // 服务费用区域
  428. .service-cost-section {
  429. position: relative;
  430. .section-header {
  431. display: flex;
  432. justify-content: space-between;
  433. align-items: center;
  434. margin-bottom: 12px;
  435. .section-title {
  436. font-size: 14px;
  437. color: #000;
  438. }
  439. .section-total {
  440. font-size: 16px;
  441. font-weight: bold;
  442. color: #000;
  443. .unit-text {
  444. padding-left: 2px;
  445. font-size: 12px;
  446. font-weight: normal;
  447. }
  448. }
  449. }
  450. .service-details {
  451. display: flex;
  452. align-items: center;
  453. border: 1px solid rgba(206, 206, 206, 0.5);
  454. padding: 8px 0;
  455. border-radius: 4px;
  456. margin-bottom: 10px;
  457. .detail-item {
  458. font-size: 14px;
  459. flex: 1;
  460. text-align: center;
  461. .detail-label {
  462. color: rgba(0, 0, 0, 0.2);
  463. margin-top: 6px;
  464. }
  465. .detail-value {
  466. color: rgba(0, 0, 0, 0.8);
  467. }
  468. }
  469. .detail-item + .detail-item {
  470. position: relative;
  471. &::before {
  472. content: '';
  473. position: absolute;
  474. left: 0;
  475. top: 50%;
  476. transform: translateY(-50%);
  477. width: 1px;
  478. height: 20px;
  479. background: rgba(0, 0, 0, 0.1);
  480. }
  481. }
  482. }
  483. .edit-btn-box {
  484. display: flex;
  485. justify-content: end;
  486. }
  487. .edit-btn {
  488. background: rgba(33, 153, 248, 0.1);
  489. color: #2199F8;
  490. padding: 6px 16px;
  491. border-radius: 20px;
  492. font-size: 14px;
  493. width: fit-content;
  494. cursor: pointer;
  495. }
  496. }
  497. // 底部操作按钮
  498. .bottom-actions {
  499. flex-shrink: 0;
  500. .action-buttons {
  501. padding: 16px;
  502. display: flex;
  503. justify-content: space-around;
  504. .action-btn {
  505. display: flex;
  506. flex-direction: column;
  507. align-items: center;
  508. cursor: pointer;
  509. .icon-circle {
  510. width: 48px;
  511. height: 48px;
  512. border-radius: 50%;
  513. display: flex;
  514. align-items: center;
  515. justify-content: center;
  516. color: #fff;
  517. margin-bottom: 4px;
  518. .el-icon {
  519. color: #fff;
  520. }
  521. img {
  522. width: 50px;
  523. }
  524. }
  525. &.blue-btn .icon-circle {
  526. background: #2199F8;
  527. }
  528. &.green-btn .icon-circle {
  529. background: #07C160;
  530. }
  531. &.orange-btn .icon-circle {
  532. background: #FF790B;
  533. }
  534. .btn-label {
  535. font-size: 12px;
  536. color: #fff;
  537. }
  538. }
  539. }
  540. .cancel-btn {
  541. text-align: center;
  542. font-size: 18px;
  543. color: #fff;
  544. cursor: pointer;
  545. }
  546. }
  547. </style>