serviceDetail.vue 5.5 KB

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