serviceDetail.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. </div>
  47. </template>
  48. <script setup>
  49. import customHeader from "@/components/customHeader.vue";
  50. import FarmInfoCard from "@/components/pageComponents/FarmInfoCard.vue";
  51. import StatsBox from "@/components/pageComponents/StatsBox.vue";
  52. import { ref, onMounted, computed } from "vue";
  53. import { useRoute, useRouter } from "vue-router";
  54. import recordItem from "@/components/recordItem.vue";
  55. import { Empty } from "vant";
  56. const route = useRoute();
  57. const router = useRouter();
  58. const farmIdVal = ref(null);
  59. onMounted(() => {
  60. farmIdVal.value = route.query.farmId;
  61. getFarmDetail();
  62. getFarmPastServiceCost();
  63. getDetailList();
  64. });
  65. const farmDetail = ref({});
  66. const getFarmDetail = () => {
  67. VE_API.user.getFarmDetail({ farmId: farmIdVal.value }).then(({ data }) => {
  68. farmDetail.value = data || {};
  69. });
  70. };
  71. // 计算属性,确保数据符合 FarmInfoCard 的验证要求
  72. const farmInfoData = computed(() => {
  73. return {
  74. farmName: farmDetail.value.name || "",
  75. area: farmDetail.value.mianji ? farmDetail.value.mianji + "亩" : "",
  76. variety: farmDetail.value.typeName || "",
  77. address: farmDetail.value.address || "",
  78. maxWidth: "100%",
  79. };
  80. });
  81. const serviceStatsData = ref([]);
  82. const getFarmPastServiceCost = () => {
  83. VE_API.user.getFarmPastServiceCost({ farmId: farmIdVal.value }).then(({ data }) => {
  84. serviceStatsData.value = [
  85. { value: data?.totalCost, unit: "元", desc: "成交额" },
  86. { value: data?.serviceCount, unit: "次", desc: "服务次数" },
  87. ];
  88. });
  89. };
  90. const detailList = ref([]);
  91. const getDetailList = () => {
  92. const params = {
  93. farmId: farmIdVal.value,
  94. limit: 99,
  95. page: 1,
  96. flowStatus: "5",
  97. };
  98. VE_API.user.getDetailList(params).then(({ data }) => {
  99. detailList.value = data || [];
  100. });
  101. };
  102. const handleTitleRightClick = ({ id }) => {
  103. router.push({
  104. path: "/achievement_report",
  105. query: { miniJson: JSON.stringify({ id }) },
  106. });
  107. };
  108. </script>
  109. <style lang="scss" scoped>
  110. .service-detail-page {
  111. width: 100%;
  112. height: 100vh;
  113. background: #f7f7f7;
  114. display: flex;
  115. flex-direction: column;
  116. overflow: hidden;
  117. .service-detail-content {
  118. flex: 1;
  119. overflow-y: auto;
  120. padding: 10px 12px;
  121. .record-box {
  122. margin-bottom: 0;
  123. }
  124. .farm-service-box {
  125. padding: 16px 12px;
  126. background: #fff;
  127. border-radius: 8px;
  128. margin-top: 12px;
  129. .service-title {
  130. display: flex;
  131. align-items: center;
  132. gap: 6px;
  133. font-size: 16px;
  134. color: #000;
  135. font-weight: 500;
  136. padding-bottom: 12px;
  137. border-bottom: 1px solid #f5f5f5;
  138. img {
  139. width: 14px;
  140. height: 8px;
  141. }
  142. }
  143. .content-section {
  144. .recipe-item {
  145. border: 1px solid rgba(0, 0, 0, 0.1);
  146. margin: 12px 0 0 0;
  147. }
  148. }
  149. }
  150. }
  151. }
  152. </style>