homeFile.vue 14 KB

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