homeFile.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <template>
  2. <div class="file-wrap">
  3. <div class="file-title">
  4. <img src="@/assets/images/common/chart-yellow.png" alt="" />
  5. 果园档案
  6. </div>
  7. <div class="box-wrap">
  8. <div class="overview-file">
  9. <div class="box-title">总体档案</div>
  10. <div class="base-data">
  11. <div
  12. class="base-item"
  13. v-for="(item, index) in photoBaseData"
  14. :key="item.label"
  15. @click.stop="toggleFileItem(item.label, index)"
  16. >
  17. <span class="label">{{ item.label }}</span>
  18. <div v-if="index === 0" class="value">
  19. <el-select
  20. v-model="item.speciesItemId"
  21. size="small"
  22. @change="changeSelect"
  23. class="type-select"
  24. >
  25. <el-option
  26. v-for="item in selectOptions"
  27. :key="item.speciesItemId"
  28. :label="item.speciesItemName"
  29. :value="item.speciesItemId"
  30. />
  31. </el-select>
  32. </div>
  33. <div v-else class="value">{{ item.value }}</div>
  34. </div>
  35. </div>
  36. <div class="list">
  37. <div class="list-item" v-for="item in photoList" :key="item.key">
  38. <div class="list-name">
  39. <img src="@/assets/images/common/title-icon.png" alt="" />
  40. {{ item.key }}
  41. </div>
  42. {{ item.statement }}
  43. </div>
  44. </div>
  45. </div>
  46. <div class="box-r">
  47. <div class="overview-file">
  48. <div class="box-title">产量信息</div>
  49. <div class="box-wrap">
  50. <div
  51. class="box-item"
  52. v-for="(item, index) in outputBox"
  53. :key="index"
  54. @click="toggleAcitve(item.name, item.field)"
  55. :class="{ active: activeOuput === item.name }"
  56. >
  57. <div class="item-name">{{ item.name }}</div>
  58. <div class="item-val">
  59. {{ item.value }}<span>{{ item.unit }}</span>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. <div class="overview-file">
  65. <div class="box-title">生态评估</div>
  66. <div class="box-wrap">
  67. <div
  68. class="box-item"
  69. v-for="(item, index) in qualityBox"
  70. :key="index"
  71. @click="toggleAcitve(item.name, item.field)"
  72. :class="{ active: activeOuput === item.name }"
  73. >
  74. <div class="item-name">{{ item.name }}</div>
  75. <div class="item-val">
  76. {{ item.value }}<span>{{ item.unit }}</span>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. </template>
  85. <script setup>
  86. import eventBus from "@/api/eventBus";
  87. import { onMounted, ref } from "vue";
  88. const outputBox = ref([
  89. { id: 1, name: "产量估计", field: "cl", value: "--", unit: "斤/亩" },
  90. { id: 2, name: "高质果率", field: "spgl", value: "--", unit: "%" },
  91. { id: 3, name: "雌花比例", value: "--", unit: "%" },
  92. ]);
  93. const qualityBox = ref([
  94. { id: 5, name: "通风率", field: "tfl", value: "--", unit: "%" },
  95. { id: 6, name: "透光率", field: "tgl", value: "--", unit: "%" },
  96. { id: 7, name: "病虫等级", value: "--", unit: "级" },
  97. ]);
  98. const photoBaseData = ref([
  99. {
  100. label: "品种",
  101. value: "--",
  102. },
  103. {
  104. label: "冠幅平均表面积",
  105. value: "--",
  106. },
  107. {
  108. label: "平均总枝条",
  109. value: "--",
  110. },
  111. {
  112. label: "平均树龄",
  113. value: "--",
  114. },
  115. ]);
  116. const photoList = ref([
  117. { key: "物候", statement: "--" },
  118. { key: "病虫", statement: "--" },
  119. { key: "异常", statement: "--" },
  120. { key: "农事", statement: "--" },
  121. ]);
  122. const activeOuput = ref(1);
  123. // 品种
  124. const farmId = ref(null);
  125. onMounted(() => {
  126. eventBus.off("area:id", toggleAreaId);
  127. eventBus.on("area:id", toggleAreaId);
  128. farmId.value = sessionStorage.getItem("farmId");
  129. eventBus.off("changePointLegend", resetActive2);
  130. eventBus.on("changePointLegend", resetActive2);
  131. eventBus.off("changePointType", resetActive);
  132. eventBus.on("changePointType", resetActive);
  133. });
  134. function resetActive({colorObj}) {
  135. console.log('aaaaaaaaresetActive', colorObj);
  136. activeOuput.value = colorObj.key;
  137. }
  138. function resetActive2({colorObj}) {
  139. console.log('bbbbbbhbresetActive', colorObj);
  140. if (colorObj.name === "产量") {
  141. activeOuput.value = "产量估计"
  142. } else if (colorObj.name === "高质果率") {
  143. activeOuput.value = "高质果率"
  144. } else {
  145. activeOuput.value = colorObj.key
  146. }
  147. }
  148. const selectOptions = ref([]);
  149. const getSpeciesItemList = (farmId, regionId) => {
  150. VE_API.farm.getSpeciesItemList({ farmId, regionId }).then((res) => {
  151. selectOptions.value = res.data;
  152. selectOptions.value.unshift({ speciesItemId: "0", speciesItemName: "全部" });
  153. photoBaseData.value[0].speciesItemId = res.data[0].speciesItemId;
  154. });
  155. };
  156. function changeSelect(e) {
  157. console.log("eee", e);
  158. setFileData(e);
  159. }
  160. function toggleFileItem(name, index) {
  161. if (index !== 0) {
  162. toggleAcitve(name);
  163. }
  164. }
  165. // 产量详情
  166. function toggleAcitve(name, field) {
  167. activeOuput.value = name;
  168. console.log("产量详情产量详情产量详情", name);
  169. // eventBus.emit("change:mapPoint", name)
  170. if (name === "透光率" || name === "通风率") {
  171. eventBus.emit("handleTabItem", name)
  172. eventBus.emit("handleActive", { name, key: "生态指标", index: 1, isFile: name === "通风率" ? true : false });
  173. // eventBus.emit('handleTab',"透光率")
  174. } else {
  175. eventBus.emit("change:mapPoint", field);
  176. }
  177. }
  178. const regionId = ref(null);
  179. function toggleAreaId({ areaId, farmId }) {
  180. regionId.value = areaId;
  181. getSpeciesItemList(farmId, areaId);
  182. getFileData(farmId, areaId);
  183. }
  184. const allTypeData = ref([]);
  185. function getFileData(farmId, regionId) {
  186. VE_API.farm.getFarmFiles({ farmId, regionId: regionId ? regionId : undefined }).then(({ data }) => {
  187. allTypeData.value = data;
  188. setFileData(photoBaseData.value[0].speciesItemId);
  189. });
  190. }
  191. function setFileData(type_id) {
  192. const res = allTypeData.value.find((item) => item.type_id == type_id);
  193. photoBaseData.value[1].value = res.meta_info.avg_crown + "平方米";
  194. photoBaseData.value[2].value = res.meta_info.avg_branch_num;
  195. photoBaseData.value[3].value = res.meta_info.avg_age + "年";
  196. photoList.value[0].key = res.meta_info.phenology_info.key;
  197. photoList.value[0].statement = res.meta_info.phenology_info.statement;
  198. photoList.value[1].key = res.meta_info.dp_alert_info.key;
  199. photoList.value[1].statement = res.meta_info.dp_alert_info.statement;
  200. photoList.value[2].key = res.meta_info.grow_alert_info.key;
  201. photoList.value[2].statement = res.meta_info.grow_alert_info.statement;
  202. photoList.value[3].key = res.meta_info.prescription_info.key;
  203. photoList.value[3].statement = res.meta_info.prescription_info.statement;
  204. outputBox.value[0].value = res.production_info.production;
  205. outputBox.value[1].value = res.production_info.quality.toFixed(0);
  206. outputBox.value[2].value = res.production_info.cihua_ratio.toFixed(0);
  207. qualityBox.value[0].value = res.ecology_info.ventilation;
  208. qualityBox.value[1].value = res.ecology_info.transmittance;
  209. qualityBox.value[2].value = res.ecology_info.dp_situation;
  210. }
  211. </script>
  212. <style lang="scss" scoped>
  213. .file-wrap {
  214. margin-top: 16px;
  215. background: url("@/assets/images/home/file-bg-w.png") no-repeat top center / 100% 100%;
  216. margin-left: 12px;
  217. padding: 12px 18px 20px 16px;
  218. .file-title {
  219. font-size: 20px;
  220. color: #ffd489;
  221. }
  222. .box-wrap {
  223. display: flex;
  224. .box-r {
  225. padding-left: 24px;
  226. }
  227. }
  228. .overview-file {
  229. padding-top: 20px;
  230. .box-title {
  231. font-size: 16px;
  232. padding-left: 13px;
  233. margin-bottom: 16px;
  234. position: relative;
  235. display: flex;
  236. justify-content: space-between;
  237. color: #fff;
  238. &::before {
  239. content: "";
  240. position: absolute;
  241. left: 0;
  242. top: 3px;
  243. width: 3px;
  244. height: 16px;
  245. background: #fff;
  246. border-radius: 11px;
  247. }
  248. }
  249. .title {
  250. color: #f3c11d;
  251. font-size: 16px;
  252. font-family: "PangMenZhengDao";
  253. margin-bottom: 20px;
  254. .big {
  255. width: 13px;
  256. height: 13px;
  257. margin: -10px 0 0 4px;
  258. }
  259. .small {
  260. width: 7px;
  261. height: 7px;
  262. margin-left: -3px;
  263. }
  264. }
  265. .base-data {
  266. background: rgba(207, 207, 207, 0.1);
  267. border-radius: 4px;
  268. padding: 6px 0;
  269. display: flex;
  270. .base-item {
  271. // flex: 1;
  272. text-align: center;
  273. padding: 0 14px;
  274. .label {
  275. font-size: 12px;
  276. color: #666666;
  277. width: max-content;
  278. display: block;
  279. margin: 0 auto;
  280. padding-bottom: 2px;
  281. }
  282. .value {
  283. padding-top: 2px;
  284. font-size: 16px;
  285. color: #ffffff;
  286. width: max-content;
  287. margin: 0 auto;
  288. }
  289. .type-select {
  290. width: 72px;
  291. ::v-deep {
  292. .el-select__wrapper {
  293. background: rgba(247, 190, 90, 0.1);
  294. box-shadow: 0 0 0 1px #f7be5a inset;
  295. color: #ffd489;
  296. }
  297. .el-select__placeholder {
  298. color: #ffd489;
  299. }
  300. }
  301. }
  302. }
  303. .base-item + .base-item {
  304. border-left: 1px solid rgba(102, 102, 102, 0.42);
  305. }
  306. }
  307. .list {
  308. margin-top: 15px;
  309. width: max-content;
  310. font-size: 14px;
  311. .list-item {
  312. color: #bbbbbb;
  313. display: flex;
  314. margin-bottom: 8px;
  315. .list-name {
  316. color: #f3c11d;
  317. margin-right: 6px;
  318. img {
  319. width: 17px;
  320. height: 13px;
  321. }
  322. }
  323. }
  324. }
  325. }
  326. .overview-file + .overview-file {
  327. margin-top: 8px;
  328. }
  329. .box-wrap {
  330. display: flex;
  331. .box-item {
  332. box-sizing: border-box;
  333. min-width: 110px;
  334. display: flex;
  335. flex-direction: column;
  336. justify-content: center;
  337. align-items: center;
  338. padding: 6px 16px;
  339. background: rgba(207, 207, 207, 0.1);
  340. border-radius: 4px;
  341. border: 1px solid rgba(207, 207, 207, 0.1);
  342. cursor: pointer;
  343. .item-name {
  344. font-size: 12px;
  345. color: #666666;
  346. width: max-content;
  347. }
  348. .item-val {
  349. font-size: 18px;
  350. color: #fff;
  351. width: max-content;
  352. padding-top: 3px;
  353. span {
  354. font-size: 12px;
  355. padding-left: 2px;
  356. }
  357. }
  358. &.active {
  359. background: rgba(255, 212, 137, 0.16);
  360. border: 1px solid #ffd489;
  361. .item-name {
  362. color: #bbbbbb;
  363. }
  364. }
  365. }
  366. .box-item + .box-item {
  367. margin-left: 8px;
  368. }
  369. }
  370. }
  371. </style>