navigation.vue 7.7 KB

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