farmDetails.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <template>
  2. <div class="farm-details-page">
  3. <custom-header name="农场详情"></custom-header>
  4. <div class="farm-details-content">
  5. <farm-info-card
  6. :data="{
  7. farmName: farmDetail.name,
  8. area: farmDetail.mianji + '亩',
  9. variety: farmDetail.typeName,
  10. address: farmDetail.address,
  11. mapImage: '/map.png',
  12. maxWidth:'58px',
  13. }"
  14. >
  15. <template #right>
  16. <div @click="handleFarmInfo">基本信息</div>
  17. </template>
  18. </farm-info-card>
  19. <tabs v-model:active="activeTab" class="custom-tabs" scrollspy sticky offset-top="40" background="#f5f7fb">
  20. <tab title="农情互动" class="tab-item">
  21. <common-box title="农情互动">
  22. <template #right>
  23. <span @click="handleDetail('farm_list')">查看详情</span>
  24. </template>
  25. <template v-if="farmWorkData.quest">
  26. <div class="question-header">
  27. <img class="question-icon" src="@/assets/img/home/ask-icon.png" alt="" />
  28. <div class="question-title">{{ farmWorkData.quest }}</div>
  29. </div>
  30. <template v-if="farmWorkData.images.length">
  31. <div class="answer-content">
  32. 答:{{ farmWorkData.agriDate }} {{ farmWorkData.answerLabel }}出现{{
  33. farmWorkData.indicatorName
  34. }}
  35. </div>
  36. <div class="answer-img">
  37. <img v-for="image in farmWorkData.images" :key="image" :src="config.base_img_url2 + image.cloudFilename" alt="" />
  38. </div>
  39. </template>
  40. <div v-else class="answer-btn">
  41. <div class="answer-btn-item">转发给客户</div>
  42. <div class="answer-btn-item-group">
  43. <div class="answer-btn-item">否</div>
  44. <div class="answer-btn-item primary">是</div>
  45. </div>
  46. </div>
  47. </template>
  48. <empty
  49. v-else
  50. image="https://birdseye-img.sysuimars.com/birdseye-look-mini/custom-empty-image.png"
  51. image-size="80"
  52. description="暂无数据"
  53. class="empty-state"
  54. />
  55. </common-box>
  56. </tab>
  57. <tab title="农事服务" class="tab-item">
  58. <common-box title="农事服务">
  59. <template #right>
  60. <span @click="handleDetail('service_list')">查看详情</span>
  61. </template>
  62. <tab-list
  63. type="light"
  64. v-model="farmServiceActiveTab"
  65. :tabs="farmServiceTabs"
  66. @change="handleFarmServiceTabChange"
  67. />
  68. <stats-box :stats-data="serviceStatsData" />
  69. <div v-for="(section, index) in detailList" :key="index" class="content-section">
  70. <record-item
  71. :record-item-data="section"
  72. onlyRecipeName
  73. :content-mode="farmServiceActiveTab === 0 ? 'serviceDetail' : ''"
  74. title-mode="default"
  75. :title-right-text="farmServiceActiveTab === 0 ? '分享成果' : ''"
  76. :title-right-type="farmServiceActiveTab === 1 ? 'dot' : null"
  77. :title-right-dot-text="farmServiceActiveTab === 1 ? '2区' : ''"
  78. class="recipe-item"
  79. />
  80. </div>
  81. <empty
  82. v-if="detailList.length === 0"
  83. image="https://birdseye-img.sysuimars.com/birdseye-look-mini/custom-empty-image.png"
  84. image-size="80"
  85. description="暂无数据"
  86. class="empty-state"
  87. />
  88. </common-box>
  89. </tab>
  90. <tab title="农场报告" class="tab-item">
  91. <common-box title="农场报告">
  92. <template #right>
  93. <span @click="handleDetail('farm_report')">查看详情</span>
  94. </template>
  95. <span class="report-content"
  96. >果园面积共XX亩,共有XX棵生产树。果园面积共XX亩,共有XX棵生产树。果园面积共XX亩,共有XX棵生产树。果园面积共XX亩,共有XX棵生产树。果园面积共XX亩,共有XX棵生产树。果园面积共XX亩,共有XX棵生产树。</span
  97. >
  98. </common-box>
  99. </tab>
  100. <tab title="农事方案" class="tab-item plan-tab-item">
  101. <common-box title="农事方案">
  102. <template #right>
  103. <span @click="handleDetail('agricultural_plan')">查看更多</span>
  104. </template>
  105. <record-item v-if="detailList.length > 0" :record-item-data="detailList[0]" title-mode="default" class="recipe-item" />
  106. <empty
  107. v-else
  108. image="https://birdseye-img.sysuimars.com/birdseye-look-mini/custom-empty-image.png"
  109. image-size="80"
  110. description="暂无数据"
  111. class="empty-state"
  112. />
  113. </common-box>
  114. </tab>
  115. </tabs>
  116. </div>
  117. <div class="custom-bottom-fixed-btns">
  118. <div class="bottom-btn secondary-btn">转发给客户</div>
  119. <div class="bottom-btn primary-btn">在线沟通</div>
  120. </div>
  121. </div>
  122. <!-- 农场信息 -->
  123. <farm-info-popup ref="farmInfoRef" :farmId="farmIdVal" :showBtn="true"></farm-info-popup>
  124. </template>
  125. <script setup>
  126. import { ref, onMounted} from "vue";
  127. import { useRoute, useRouter } from "vue-router";
  128. import { Tab, Tabs, Empty } from "vant";
  129. import customHeader from "@/components/customHeader.vue";
  130. import FarmInfoCard from "@/components/pageComponents/FarmInfoCard.vue";
  131. import tabList from "@/components/pageComponents/TabList.vue";
  132. import commonBox from "@/components/pageComponents/CommonBox.vue";
  133. import StatsBox from "@/components/pageComponents/StatsBox.vue";
  134. import recordItem from "@/components/recordItem.vue";
  135. import farmInfoPopup from "../home/components/farmInfoPopup.vue";
  136. import config from "@/api/config";
  137. const router = useRouter();
  138. const route = useRoute();
  139. const activeTab = ref(0);
  140. const farmServiceTabs = ["过往服务", "未来服务"];
  141. const farmServiceActiveTab = ref(0);
  142. const farmInfoRef = ref(null);
  143. const handleFarmInfo = () => {
  144. farmInfoRef.value.handleShow();
  145. };
  146. const handleFarmServiceTabChange = (index) => {
  147. if (index === 0) {
  148. getFarmPastServiceCost();
  149. getDetailList();
  150. } else {
  151. getFutureFarmWorkList();
  152. serviceStatsData.value = [
  153. { value: "1258", unit: "元", desc: "预计收益" },
  154. { value: "1258", unit: "元", desc: "预计成本" },
  155. ];
  156. }
  157. };
  158. const serviceStatsData = ref([]);
  159. onMounted(() => {
  160. farmIdVal.value = route.query.farmId;
  161. paramsPage.value = {
  162. farmId: farmIdVal.value,
  163. limit: 1,
  164. page: 1,
  165. }
  166. getFarmDetail();
  167. getFarmWorkList();
  168. getDetailList();
  169. getFarmPastServiceCost();
  170. });
  171. const farmIdVal = ref(null);
  172. const farmDetail = ref({});
  173. const paramsPage = ref({});
  174. const getFarmDetail = () => {
  175. VE_API.user.getFarmDetail({ farmId: farmIdVal.value }).then(({ data }) => {
  176. farmDetail.value = data || {};
  177. });
  178. };
  179. const farmWorkData = ref({});
  180. const getFarmWorkList = () => {
  181. VE_API.user.getFarmWorkList(paramsPage.value).then(({ data }) => {
  182. if (data && data.length > 0) {
  183. farmWorkData.value = data[0] || {};
  184. }
  185. });
  186. };
  187. const detailList = ref([]);
  188. const getDetailList = () => {
  189. const params = {
  190. ...paramsPage.value,
  191. flowStatus: '4,5',
  192. };
  193. VE_API.user.getDetailList(params).then(({ data }) => {
  194. detailList.value = data || [];
  195. });
  196. };
  197. const getFutureFarmWorkList = () => {
  198. VE_API.user.getFutureFarmWorkList(paramsPage.value).then(({ data }) => {
  199. detailList.value = data || [];
  200. });
  201. };
  202. const getFarmPastServiceCost = () => {
  203. VE_API.user.getFarmPastServiceCost({ farmId: farmIdVal.value }).then(({ data }) => {
  204. serviceStatsData.value = [
  205. { value: data.totalCost, unit: "元", desc: "总收益" },
  206. { value: data.totalCost, unit: "元", desc: "投入成本" },
  207. { value: data.serviceCount, unit: "次", desc: "服务次数" },
  208. ];
  209. });
  210. };
  211. const handleDetail = (path) => {
  212. router.push(`/${path}?farmId=${farmIdVal.value}`);
  213. };
  214. </script>
  215. <style scoped lang="scss">
  216. .farm-details-page {
  217. width: 100%;
  218. height: 100vh;
  219. background: #f2f3f5;
  220. .farm-details-content {
  221. box-sizing: border-box;
  222. padding: 10px 12px 70px 12px;
  223. overflow: auto;
  224. height: calc(100% - 40px);
  225. box-sizing: border-box;
  226. .custom-tabs {
  227. ::v-deep {
  228. .van-tabs__wrap {
  229. height: auto;
  230. }
  231. .van-tabs__nav {
  232. .van-tab {
  233. color: #8b8b8b;
  234. background: #f7f8fa;
  235. height: 34px;
  236. font-weight: 400;
  237. border-radius: 25px;
  238. }
  239. .van-tab--active {
  240. color: #fff;
  241. background: #2199f8;
  242. font-weight: 400;
  243. }
  244. }
  245. .van-tabs__line {
  246. display: none;
  247. }
  248. .van-tabs__nav--line {
  249. padding: 12px 0;
  250. }
  251. }
  252. .tab-item + .tab-item {
  253. margin-top: 12px;
  254. }
  255. }
  256. .question-header {
  257. display: flex;
  258. align-items: center;
  259. margin-bottom: 6px;
  260. gap: 8px;
  261. font-weight: 500;
  262. .question-icon {
  263. width: 22px;
  264. height: 20px;
  265. }
  266. }
  267. .answer-content {
  268. color: #333333;
  269. margin: 6px 0 10px 0;
  270. }
  271. .answer-img {
  272. display: flex;
  273. gap: 5px;
  274. img {
  275. flex: 1;
  276. max-width: 105px;
  277. height: 105px;
  278. border-radius: 5px;
  279. object-fit: cover;
  280. }
  281. }
  282. .content-section {
  283. .recipe-item {
  284. border: 1px solid rgba(0, 0, 0, 0.1);
  285. margin: 12px 0 0 0;
  286. }
  287. }
  288. .plan-tab-item {
  289. .recipe-item {
  290. padding: 0;
  291. }
  292. }
  293. .plan-list-wrapper {
  294. height: 500px;
  295. margin-top: 12px;
  296. }
  297. .report-content {
  298. font-size: 13px;
  299. }
  300. .answer-btn {
  301. display: flex;
  302. align-items: center;
  303. justify-content: space-between;
  304. margin-top: 10px;
  305. > div {
  306. display: flex;
  307. gap: 10px;
  308. }
  309. }
  310. .answer-btn-item {
  311. padding: 7px 12px;
  312. border-radius: 25px;
  313. font-size: 12px;
  314. text-align: center;
  315. background: rgba(33, 153, 248, 0.1);
  316. color: #2199f8;
  317. min-width: 52px;
  318. box-sizing: border-box;
  319. &.primary {
  320. background: #2199f8;
  321. color: #ffffff;
  322. }
  323. }
  324. .empty-state {
  325. ::v-deep .van-empty {
  326. padding: 40px 0;
  327. }
  328. }
  329. }
  330. }
  331. </style>