serviceDetail.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div class="service-detail-page">
  3. <custom-header name="农场详情"></custom-header>
  4. <div class="service-detail-content">
  5. <farm-info-card
  6. v-if="
  7. farmInfoData.farmName !== '' ||
  8. farmInfoData.area !== '' ||
  9. farmInfoData.variety !== '' ||
  10. farmInfoData.address !== ''
  11. "
  12. class="record-box"
  13. :data="farmInfoData"
  14. >
  15. </farm-info-card>
  16. <div class="farm-service-box">
  17. <div class="service-title">
  18. <img src="@/assets/img/home/label-icon.png" alt="" />
  19. <span>农事服务</span>
  20. </div>
  21. <stats-box :stats-data="serviceStatsData" />
  22. <div
  23. v-for="(section, index) in detailList"
  24. :key="index"
  25. class="content-section"
  26. >
  27. <record-item
  28. :record-item-data="section"
  29. content-mode="serviceDetail"
  30. title-mode="default"
  31. title-right-text="生成成果报告"
  32. class="recipe-item"
  33. showFarmImage
  34. @titleRightClick="handleTitleRightClick"
  35. />
  36. </div>
  37. <empty
  38. v-if="detailList.length === 0"
  39. image="https://birdseye-img.sysuimars.com/birdseye-look-mini/custom-empty-image.png"
  40. image-size="80"
  41. description="暂无数据"
  42. class="empty-state"
  43. />
  44. </div>
  45. </div>
  46. <!-- 分享农事成效弹窗 -->
  47. <review-popup ref="reviewPopupRef" />
  48. </div>
  49. </template>
  50. <script setup>
  51. import customHeader from "@/components/customHeader.vue";
  52. import FarmInfoCard from "@/components/pageComponents/FarmInfoCard.vue";
  53. import StatsBox from "@/components/pageComponents/StatsBox.vue";
  54. import { ref, onMounted, computed } from "vue";
  55. import { useRoute } from "vue-router";
  56. import { base_img_url2 } from "@/api/config";
  57. import recordItem from "@/components/recordItem.vue";
  58. import reviewPopup from "@/views/old_mini/task_condition/components/reviewPopup.vue";
  59. import { Empty } from "vant";
  60. const route = useRoute();
  61. const farmIdVal = ref(null);
  62. onMounted(() => {
  63. farmIdVal.value = route.query.farmId;
  64. getFarmDetail();
  65. getFarmPastServiceCost();
  66. getDetailList();
  67. });
  68. const farmDetail = ref({});
  69. const getFarmDetail = () => {
  70. VE_API.user.getFarmDetail({ farmId: farmIdVal.value }).then(({ data }) => {
  71. farmDetail.value = data || {};
  72. });
  73. };
  74. // 计算属性,确保数据符合 FarmInfoCard 的验证要求
  75. const farmInfoData = computed(() => {
  76. return {
  77. farmName: farmDetail.value.name || "",
  78. area: farmDetail.value.mianji ? farmDetail.value.mianji + "亩" : "",
  79. variety: farmDetail.value.typeName || "",
  80. address: farmDetail.value.address || "",
  81. maxWidth: "58px",
  82. };
  83. });
  84. const serviceStatsData = ref([]);
  85. const getFarmPastServiceCost = () => {
  86. VE_API.user.getFarmPastServiceCost({ farmId: farmIdVal.value }).then(({ data }) => {
  87. serviceStatsData.value = [
  88. { value: data?.totalCost, unit: "元", desc: "总收益" },
  89. { value: data?.totalCost, unit: "元", desc: "投入成本" },
  90. { value: data?.serviceCount, unit: "次", desc: "服务次数" },
  91. ];
  92. });
  93. };
  94. const detailList = ref([]);
  95. const getDetailList = () => {
  96. const params = {
  97. farmId: farmIdVal.value,
  98. limit: 99,
  99. page: 1,
  100. flowStatus: "4,5",
  101. };
  102. VE_API.user.getDetailList(params).then(({ data }) => {
  103. detailList.value = data || [];
  104. });
  105. };
  106. const reviewPopupRef = ref(null);
  107. const handleTitleRightClick = ({ id, reviewImage }) => {
  108. VE_API.z_farm_work_record.getTriggerImg({ farmWorkRecordId: id }).then(({ data }) => {
  109. const preImg = data.length ? base_img_url2 + data[data.length - 1].cloudFilename : "";
  110. const resImg = reviewImage?.length ? base_img_url2 + reviewImage[reviewImage.length - 1] : "";
  111. reviewPopupRef.value.handleShowPopup(id, preImg, resImg);
  112. });
  113. };
  114. </script>
  115. <style lang="scss" scoped>
  116. .service-detail-page {
  117. width: 100%;
  118. height: 100vh;
  119. background: #f7f7f7;
  120. display: flex;
  121. flex-direction: column;
  122. overflow: hidden;
  123. .service-detail-content {
  124. flex: 1;
  125. overflow-y: auto;
  126. padding: 10px 12px;
  127. .record-box {
  128. margin-bottom: 0;
  129. }
  130. .farm-service-box {
  131. padding: 16px 12px;
  132. background: #fff;
  133. border-radius: 8px;
  134. margin-top: 12px;
  135. .service-title {
  136. display: flex;
  137. align-items: center;
  138. gap: 6px;
  139. font-size: 16px;
  140. color: #000;
  141. font-weight: 500;
  142. padding-bottom: 12px;
  143. border-bottom: 1px solid #f5f5f5;
  144. img {
  145. width: 14px;
  146. height: 8px;
  147. }
  148. }
  149. .content-section {
  150. .recipe-item {
  151. border: 1px solid rgba(0, 0, 0, 0.1);
  152. margin: 12px 0 0 0;
  153. }
  154. }
  155. }
  156. }
  157. }
  158. </style>