index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <Bg></Bg>
  3. <Header>
  4. <template v-slot:right-slot>
  5. <div class="slot-right">
  6. <div class="switch yse-events">
  7. <span>果园级信息</span>
  8. <el-switch @change="handleSwitch('Garden')" v-model="switchValue" />
  9. </div>
  10. <div class="switch yse-events">
  11. <span>果树级信息</span>
  12. <el-switch @change="handleSwitch('tree')" v-model="switchValue1" />
  13. </div>
  14. </div>
  15. </template>
  16. </Header>
  17. <div class="container2">
  18. <div class="mainDiv">
  19. <div class="leftBox">
  20. <div class="name">{{btnName}}</div>
  21. <div class="btn" :style="{borderColor:subName.length>0?'#309195':'transparent'}">{{subName}}</div>
  22. <div class="map" ref="mapRef"></div>
  23. </div>
  24. <div class="rightBox">
  25. <div class="box-content">
  26. <Title :title="switchValue ? '果园级信息' : '果树级信息'"></Title>
  27. <div class="box-body">
  28. <div class="btn-row">
  29. <div
  30. :class="['btn-col', 'yse-events', { active: active === index }]"
  31. v-for="(item, index) in btnList"
  32. :key="index"
  33. @click="handleAct(index,item)"
  34. >
  35. {{ item.name }}
  36. </div>
  37. </div>
  38. <div class="card">
  39. <div class="card-btn" v-if="btnItemList.length > 0">
  40. <div
  41. :class="[
  42. 'btn-item',
  43. 'yse-events',
  44. { active: activeItem === index },
  45. ]"
  46. v-for="(item, index) in btnItemList"
  47. :key="index"
  48. @click="handleItemAct(index,item)"
  49. >
  50. {{ item.name }}
  51. </div>
  52. </div>
  53. <div class="list-border">
  54. <div
  55. class="list-item"
  56. v-for="(item, index) in listItem"
  57. :key="index"
  58. >
  59. <template v-if="btnItemList.length > 0">
  60. <div
  61. v-if="btnItemList[activeItem].style !== 'star'"
  62. :class="btnItemList[activeItem].style"
  63. :style="iconStyle(btnItemList[activeItem].style, index, item)"
  64. ></div>
  65. <el-icon v-else size="18px" class="star" color="#d63f3c"
  66. ><StarFilled
  67. /></el-icon>
  68. </template>
  69. <template v-else>
  70. <div
  71. v-if="btnList[active].style !== 'star'"
  72. :class="btnList[active].style"
  73. :style="iconStyle(btnList[active].style, index, item)"
  74. ></div>
  75. <el-icon v-else size="18px" class="star" color="#d63f3c"
  76. ><StarFilled
  77. /></el-icon>
  78. </template>
  79. <!-- <span v-if="item.type=='1'" class="item-txt">{{ item.maxVal }}</span> -->
  80. <!-- <span v-else class="item-txt">{{ item.minVal }}-{{ item.maxVal }}</span> -->
  81. <span class="item-txt">{{ item.name }}</span>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </template>
  91. <script setup>
  92. import Header from "@/views/components/Header.vue";
  93. import Bg from "../Bg";
  94. import Title from "../components/title";
  95. import { useRouter } from "vue-router";
  96. import { reactive, toRefs, ref, onMounted } from "vue";
  97. import { useStore } from "vuex";
  98. import RegionalInformationMap from "./RegionalInformationMap";
  99. const router = useRouter();
  100. const store = useStore();
  101. const state = reactive({
  102. btnList: [],
  103. btnItemList: [],
  104. baseData: [],
  105. listItem: [],
  106. btnName:'基本信息',
  107. subName:''
  108. });
  109. const { btnList, btnItemList, listItem,btnName ,subName} = toRefs(state);
  110. const iconStyle = (type, index, item) => {
  111. if (type === "triangle") {
  112. return { borderBottomColor: item.color };
  113. }
  114. if (type === "bar") {
  115. return { background: item.color };
  116. }
  117. if (type === "circular") {
  118. return { background: item.color };
  119. }
  120. };
  121. const active = ref(0);
  122. const handleAct = (e, v) => {
  123. activeType.value = v.type
  124. // 果园级 & type为字段值
  125. if (v.type == 1 && switchValue.value) {
  126. kmap.handleLayerColor(v, v.key)
  127. }
  128. if (switchValue.value) {
  129. kmap.switchType(activeType.value)
  130. }
  131. active.value = e;
  132. btnName.value = v.name
  133. updateData(e);
  134. };
  135. const activeItem = ref(0);
  136. const activeType = ref(null);
  137. const handleItemAct = (e, v) => {
  138. activeItem.value = e;
  139. subName.value = v.name
  140. if (v.type == 1) {
  141. kmap.switchTreeLegend(curGardenId.value, v)
  142. }else if(v.type == 2){
  143. kmap.addGargendImg(curGardenId.value, state.baseData[active.value].children[e])
  144. }
  145. if (state.baseData[active.value].children.length > 0) {
  146. state.listItem = state.baseData[active.value].children[e].items;
  147. }
  148. };
  149. const initData = async () => {
  150. let url = "aPictureGarden";
  151. if (!switchValue.value) {
  152. url = "aPictureTree";
  153. }
  154. const { code, data } = await VE_API.regionalInformation[url]({
  155. gardenId: curGardenId.value,
  156. });
  157. const dataValue = data.data;
  158. state.baseData = dataValue;
  159. state.btnList = dataValue;
  160. btnName.value = dataValue[active.value].name
  161. updateData(active.value);
  162. };
  163. const updateData = (index) => {
  164. state.btnItemList = state.baseData[index].children;
  165. if (state.baseData[index].children.length > 0) {
  166. subName.value = state.baseData[index].children[activeItem.value].name
  167. state.listItem = state.baseData[index].children[activeItem.value].items;
  168. } else {
  169. subName.value = ''
  170. state.listItem = state.baseData[index].items;
  171. }
  172. const legend = state.baseData[index].type
  173. // 果园级图片
  174. if (switchValue.value && legend === 0) {
  175. kmap.addGargendImg(curGardenId.value, state.baseData[index].children[activeItem.value])
  176. }
  177. if (switchValue1.value) {
  178. if (legend === 0) {
  179. // 0一级菜单 1字段值 2 图层
  180. kmap.switchTreeLegend(curGardenId.value, state.baseData[index].children[activeItem.value])
  181. } else if (legend === 1) {
  182. kmap.switchTreeLegend(curGardenId.value, state.baseData[index])
  183. }
  184. }
  185. };
  186. const switchValue = ref(true);
  187. const switchValue1 = ref(false);
  188. const handleSwitch = (type) => {
  189. if (type === "Garden") {
  190. switchValue1.value = !switchValue1.value;
  191. } else {
  192. switchValue.value = !switchValue.value;
  193. }
  194. if (!switchValue.value) {
  195. // 果园级为false时隐藏果园级的图层
  196. kmap.switchType(0)
  197. kmap.clearImgLayer()
  198. } else {
  199. kmap.clearCluster()
  200. }
  201. activeItem.value = 0;
  202. active.value = 0;
  203. initData();
  204. };
  205. // 地图初始化
  206. const mapRef = ref(null);
  207. const kmap = new RegionalInformationMap();
  208. const location = store.getters.userinfo.location;
  209. const curGardenId = ref(store.getters.userinfo.curGardenId);
  210. onMounted(() => {
  211. initData();
  212. kmap.initMap(location, mapRef.value);
  213. // kmap.initArea(curGardenId.value)
  214. kmap.initSubArea(curGardenId.value)
  215. // kmap.addSingleSelect(selectTree)
  216. });
  217. </script>
  218. <style lang="scss" scoped>
  219. @import "../../styles/index.scss";
  220. .slot-right {
  221. display: flex;
  222. .switch {
  223. margin-right: 55px;
  224. display: flex;
  225. align-items: center;
  226. span {
  227. margin-right: 19px;
  228. }
  229. }
  230. }
  231. .container2 {
  232. height: 100%;
  233. width: 100%;
  234. z-index: 2;
  235. position: absolute;
  236. .mainDiv {
  237. position: absolute;
  238. top: 100px;
  239. bottom: 65px;
  240. left: 20px;
  241. right: 20px;
  242. .leftBox {
  243. float: left;
  244. width: calc(100% - 500px - 12px);
  245. height: 100%;
  246. border-radius: 4px;
  247. box-sizing: border-box;
  248. background: url("@/assets/img/regionalInformation/map_border_bg.png")
  249. no-repeat center center / 100% 100%;
  250. padding: 10px 20px;
  251. .name {
  252. font-size: 23px;
  253. color: #ffffff;
  254. font-style: italic;
  255. font-weight: normal;
  256. }
  257. .btn {
  258. margin-top: 18px;
  259. font-weight: 500;
  260. font-size: 21px;
  261. color: #ffffff;
  262. width: 130px;
  263. height: 45px;
  264. border: 1px solid #309195;
  265. display: flex;
  266. justify-content: center;
  267. align-items: center;
  268. border-radius: 5px;
  269. }
  270. .map {
  271. margin-top: 15px;
  272. @include wh(calc(100%), calc(100% - 20px - 18px - 45px - 40px));
  273. }
  274. }
  275. .rightBox {
  276. float: right;
  277. width: 500px;
  278. height: calc(100%);
  279. display: flex;
  280. flex-direction: column;
  281. justify-content: space-between;
  282. .box-content {
  283. height: 49%;
  284. border: 1px solid rgba(81, 233, 240, 0.6);
  285. border-top-left-radius: 5px;
  286. border-top-right-radius: 5px;
  287. box-sizing: border-box;
  288. .box-body {
  289. width: 100%;
  290. height: calc(100% - 44px);
  291. box-sizing: border-box;
  292. padding: 10px 8px;
  293. .btn-row {
  294. width: 100%;
  295. height: 46px;
  296. color: #fff;
  297. font-weight: 500;
  298. font-size: 19px;
  299. display: flex;
  300. .btn-col {
  301. width: 103px;
  302. height: 100%;
  303. background: url("@/assets/img/regionalInformation/btn_bg.png")
  304. no-repeat center center / 100% 100%;
  305. display: flex;
  306. align-items: center;
  307. justify-content: center;
  308. cursor: pointer;
  309. &.active {
  310. background: url("@/assets/img/regionalInformation/btn_bg_act.png")
  311. no-repeat center center / 100% 100%;
  312. position: relative;
  313. &::before {
  314. content: "";
  315. background: url("@/assets/img/regionalInformation/arrow_top.png")
  316. no-repeat center center / 100% 100%;
  317. position: absolute;
  318. width: 35px;
  319. height: 18px;
  320. bottom: -20px;
  321. }
  322. }
  323. }
  324. }
  325. .card {
  326. width: 100%;
  327. height: calc(100% - 46px - 19px);
  328. background: rgba(14, 76, 93, 0.5);
  329. box-sizing: border-box;
  330. margin-top: 19px;
  331. border-radius: 4px;
  332. padding: 15px 8px;
  333. .card-btn {
  334. color: #fff;
  335. width: 100%;
  336. height: 38px;
  337. display: flex;
  338. .btn-item {
  339. cursor: pointer;
  340. display: flex;
  341. align-items: center;
  342. justify-content: center;
  343. width: 94px;
  344. height: 100%;
  345. margin-right: 9px;
  346. background: url("@/assets/img/regionalInformation/btn_item_bg.png")
  347. no-repeat center center / 100% 100%;
  348. &.active {
  349. background: url("@/assets/img/regionalInformation/btn_item_bg_act.png")
  350. no-repeat center center / 100% 100%;
  351. }
  352. }
  353. }
  354. .list-border {
  355. width: 100%;
  356. box-sizing: border-box;
  357. margin-top: 15px;
  358. max-height: calc(100% - 38px);
  359. overflow: hidden;
  360. background: url("@/assets/img/regionalInformation/list_bg.png")
  361. no-repeat center center / 100% 100%;
  362. display: flex;
  363. flex-wrap: wrap;
  364. padding-bottom: 15px;
  365. .list-item {
  366. color: #fff;
  367. display: flex;
  368. align-items: center;
  369. padding: 22px 0 0 18px;
  370. width: 35%;
  371. .bar {
  372. width: 44px;
  373. height: 15px;
  374. background: #b0e000;
  375. border-radius: 20px;
  376. // border: 1px solid #d2ff6d;
  377. margin-right: 8px;
  378. }
  379. .circular {
  380. width: 15px;
  381. height: 15px;
  382. border-radius: 50px;
  383. margin-right: 8px;
  384. background: #b0e000;
  385. }
  386. .triangle {
  387. width: 0;
  388. height: 0;
  389. margin-right: 8px;
  390. border-left: 7px solid transparent; /* 左边框设置为透明 */
  391. border-right: 7px solid transparent; /* 右边框设置为透明 */
  392. border-bottom: 14px solid #d63f3c; /* 下边框设置为你想要的颜色和大小,这将形成三角形的底部 */
  393. }
  394. .star {
  395. margin-right: 8px;
  396. }
  397. }
  398. }
  399. }
  400. }
  401. }
  402. }
  403. }
  404. }
  405. </style>