navigation.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <div class="navigation yes-events">
  3. <el-select class="select" v-model="areaId" size="large" @change="changeSelect" popper-class="focus-farm-select">
  4. <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id" />
  5. </el-select>
  6. <div class="tabs" v-for="(ele, idx) in list" :key="idx">
  7. <div
  8. class="tab-item"
  9. @click="handleHomeTab(item)"
  10. :class="{ active: active === item.name }"
  11. v-for="(item, index) in ele"
  12. :key="index"
  13. >
  14. {{ item.name }}
  15. </div>
  16. </div>
  17. <el-checkbox-group
  18. v-show="childrenData && childrenData.length"
  19. class="checkbox-group"
  20. v-model="checkedChildren"
  21. @change="handleCheckedChange"
  22. :min="1"
  23. >
  24. <el-checkbox v-for="item in childrenData" :key="item" :label="item" :value="item">
  25. {{ item }}
  26. </el-checkbox>
  27. </el-checkbox-group>
  28. </div>
  29. </template>
  30. <script setup>
  31. import { useRouter } from "vue-router";
  32. import { onMounted, onUnmounted, ref, computed } from "vue";
  33. import { useStore } from "vuex";
  34. import eventBus from "@/api/eventBus";
  35. const router = useRouter();
  36. const store = useStore();
  37. const areaId = ref("");
  38. const options = ref([]);
  39. eventBus.off('garden:organId', gardenOrganId)
  40. eventBus.on('garden:organId',gardenOrganId)
  41. const organId = ref()
  42. function gardenOrganId(farmId){
  43. organId.value = farmId
  44. VE_API.region.list({farmId}).then(res =>{
  45. options.value = res.data
  46. options.value.unshift({
  47. id:0,
  48. name:'全部区域'
  49. })
  50. areaId.value = res.data[0].id
  51. eventBus.emit('area:id',{areaId:areaId.value,farmId})
  52. sessionStorage.setItem('regionId',areaId.value)
  53. })
  54. }
  55. const changeSelect = (e) =>{
  56. eventBus.emit('area:id',{areaId:areaId.value,farmId:organId.value})
  57. sessionStorage.setItem('regionId',e)
  58. eventBus.emit('handleTab',)
  59. active.value = "果园总览"
  60. }
  61. onMounted(()=>{
  62. // gardenOrganId(sessionStorage.getItem('farmId')*1)
  63. eventBus.on('handleActive',handleActive)
  64. })
  65. const mainMenuArr = computed(() => store.state.home.mainMenu);
  66. onUnmounted(()=>{
  67. eventBus.off('handleActive',handleActive)
  68. })
  69. const emit = defineEmits(["handleTab","handleTabItem"])
  70. const checkedChildren = ref([]);
  71. const childrenData = ref([]);
  72. const handleCheckedChange = (e) => {
  73. if(e.length){
  74. checkedChildren.value = [e[e.length -1]];
  75. emit('handleTabItem',checkedChildren.value[0])
  76. eventBus.emit('handleTabItem',checkedChildren.value[0])
  77. }
  78. };
  79. function handleActive({name,key}){
  80. childrenData.value = []
  81. const menuItem = mainMenuArr.value.find(item =>item.name===key)
  82. active.value = menuItem.name;
  83. childrenData.value = menuItem.btnGroup
  84. checkedChildren.value = [name]
  85. emit('handleTab',{name:menuItem.name,id:active.value,isUpdate:true,params:name, legend: menuItem?.legend, colorObj: menuItem?.colorObj})
  86. }
  87. const active = ref("");
  88. const handleHomeTab = ({ id, name }) => {
  89. active.value = name;
  90. childrenData.value = []
  91. const menuItem = mainMenuArr.value.find(item =>item.name===name)
  92. if(menuItem){
  93. childrenData.value = menuItem.btnGroup
  94. checkedChildren.value = [menuItem.btnGroup[0]];
  95. }
  96. emit('handleTab',{name,id, legend: menuItem?.legend, colorObj: menuItem?.colorObj})
  97. // eventBus.emit("changePointType", {legend: menuItem?.legend, colorObj: menuItem?.colorObj})
  98. eventBus.emit('handleTab',name)
  99. };
  100. const list = ref([
  101. [
  102. // {
  103. // name: "果园总览",
  104. // id: 0,
  105. // },
  106. // {
  107. // name: "基本指标",
  108. // id: 1,
  109. // children: ["树高", "冠幅"],
  110. // },
  111. // {
  112. // name: "物候指标",
  113. // id: 2,
  114. // children: ["花穗长度", "单树花穗率"],
  115. // },
  116. {
  117. name: "风畅气顺",
  118. id: 3,
  119. children: [],
  120. },
  121. {
  122. name: "光透照匀",
  123. id: 4,
  124. children: [],
  125. },
  126. {
  127. name: "益草覆盖",
  128. id: 5,
  129. children: [],
  130. },
  131. {
  132. name: "古树名木",
  133. id: 1,
  134. },
  135. ],
  136. // [
  137. // {
  138. // name: "指标对比",
  139. // id: 11,
  140. // },
  141. // ],
  142. ]);
  143. const toPage = () => {
  144. router.push("/authentic");
  145. };
  146. </script>
  147. <style lang="scss" scoped>
  148. .navigation {
  149. position: fixed;
  150. top: 34px;
  151. left: 50%;
  152. // left: 50%;
  153. transform: translateX(-50%);
  154. width: calc(100% - 430px * 2);
  155. display: flex;
  156. justify-content: center;
  157. align-items: center;
  158. .select{
  159. // width: 120px;
  160. width: 166px;
  161. height: 50px;
  162. margin-right: 21px;
  163. ::v-deep{
  164. .el-select__wrapper{
  165. height: 100%;
  166. background: rgba(0, 0, 0, 0.3);
  167. box-shadow: 0 0 0 1px #F7BE5A;
  168. border-radius: 2px;
  169. text-align: center;
  170. }
  171. .el-select__placeholder{
  172. color: #F7BE5A;
  173. font-size: 20px;
  174. font-family: "PangMenZhengDao";
  175. }
  176. .el-select__caret{
  177. color: #F7BE5A;
  178. font-size: 20px;
  179. }
  180. }
  181. }
  182. .tabs {
  183. background: rgba(35, 35, 35, 0.8);
  184. border: 1px solid #555555;
  185. padding: 8px;
  186. border-radius: 8px;
  187. display: flex;
  188. justify-content: center;
  189. .tab-item {
  190. font-size: 16px;
  191. color: rgba(255, 255, 255, 0.8);
  192. padding: 7px 12px 9px 12px;
  193. font-family: "PangMenZhengDao";
  194. cursor: pointer;
  195. &.active {
  196. background: #ffd489;
  197. color: #1d1d1d;
  198. border-radius: 4px;
  199. }
  200. }
  201. .tab-item + .tab-item {
  202. margin-left: 25px;
  203. }
  204. }
  205. .tabs + .tabs {
  206. margin-left: 12px;
  207. }
  208. .checkbox-group {
  209. position: absolute;
  210. top: 74px;
  211. right: 26px;
  212. background: rgba(35, 35, 35, 0.8);
  213. border-radius: 8px;
  214. border: 1px solid #555555;
  215. padding: 10px 20px;
  216. display: flex;
  217. flex-direction: column;
  218. &.compare-btn {
  219. right: 26px;
  220. top: 0px;
  221. }
  222. ::v-deep {
  223. .el-checkbox {
  224. margin-right: 0;
  225. }
  226. .el-checkbox__input.is-checked + .el-checkbox__label {
  227. color: #ffd489;
  228. }
  229. .el-checkbox__input.is-checked .el-checkbox__inner {
  230. background-color: #ffd489;
  231. border-color: #ffd489;
  232. &::after {
  233. border-color: #1d1d1d;
  234. }
  235. }
  236. .el-checkbox__label {
  237. color: #fff;
  238. }
  239. }
  240. }
  241. .compare-tips {
  242. position: absolute;
  243. top: 96px;
  244. left: 50%;
  245. transform: translateX(-50%);
  246. background: rgba(4, 3, 0, 0.6);
  247. border-radius: 40px;
  248. padding: 6px 34px;
  249. font-family: 'PangMenZhengDao';
  250. font-size: 20px;
  251. span {
  252. color: #F3C11D;
  253. }
  254. }
  255. .btn {
  256. width: 80px;
  257. height: 30px;
  258. text-align: center;
  259. line-height: 28px;
  260. border-radius: 5px;
  261. cursor: pointer;
  262. background: rgba(255, 255, 255, 0.5);
  263. }
  264. }
  265. </style>