navigation.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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="handleTab(item)"
  10. :class="{ active: active === item.id }"
  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.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 class="btn" @click="toPage">农场确权</div> -->
  29. <!-- 对比 -->
  30. <el-checkbox-group
  31. class="checkbox-group compare-btn"
  32. v-model="checkedCompareChildren"
  33. @change="handleCompareChange"
  34. >
  35. <el-checkbox label="指标对比" value="1">
  36. 指标对比
  37. </el-checkbox>
  38. </el-checkbox-group>
  39. <div class="compare-tips" v-show="checkedCompareChildren.length">
  40. <span>提示:</span>请在底图上点选 <span>两棵树</span>,才可以进行对比
  41. </div>
  42. </div>
  43. </template>
  44. <script setup>
  45. import { useRouter } from "vue-router";
  46. import { onMounted, onUnmounted, ref } from "vue";
  47. import eventBus from "@/api/eventBus";
  48. const router = useRouter();
  49. const areaId = ref("");
  50. const options = ref([]);
  51. eventBus.off('garden:organId', gardenOrganId)
  52. eventBus.on('garden:organId',gardenOrganId)
  53. const organId = ref(null)
  54. function gardenOrganId(farmId){
  55. organId.value = farmId
  56. VE_API.region.list({farmId}).then(res =>{
  57. options.value = res.data
  58. options.value.unshift({
  59. id:0,
  60. name:'全部区域'
  61. })
  62. areaId.value = res.data[0].id
  63. eventBus.emit('area:id',{areaId:areaId.value,farmId})
  64. sessionStorage.setItem('regionId',areaId.value)
  65. })
  66. }
  67. const changeSelect = (e) =>{
  68. eventBus.emit('area:id',{areaId:areaId.value,farmId:organId.value})
  69. sessionStorage.setItem('regionId',e)
  70. }
  71. onMounted(()=>{
  72. gardenOrganId(sessionStorage.getItem('farmId')*1)
  73. eventBus.on('handleActive',handleActive)
  74. eventBus.on('quitCompare', handleQuitCompare)
  75. })
  76. onUnmounted(()=>{
  77. eventBus.off('handleActive',handleActive)
  78. eventBus.off('quitCompare', handleQuitCompare)
  79. })
  80. const emit = defineEmits(["handleTab","handleTabItem"])
  81. const checkedChildren = ref([]);
  82. const childrenData = ref([]);
  83. const handleCheckedChange = (e) => {
  84. if(e.length){
  85. checkedChildren.value = [e[e.length -1]];
  86. emit('handleTabItem',checkedChildren.value[0])
  87. eventBus.emit('handleTabItem',checkedChildren.value[0])
  88. }
  89. };
  90. function handleActive({name,key}){
  91. childrenData.value = []
  92. const arr = list.value[0].filter(item =>item.name===key)
  93. active.value = arr[0].id;
  94. childrenData.value = arr[0].children
  95. checkedChildren.value = [name]
  96. emit('handleTab',{name:arr[0].name,id:active.value,isUpdate:true,params:name})
  97. }
  98. const active = ref(0);
  99. const handleTab = ({ id, name,children }) => {
  100. active.value = id;
  101. childrenData.value = []
  102. if(children){
  103. childrenData.value = children;
  104. checkedChildren.value = [children[0]];
  105. }
  106. emit('handleTab',{name,id})
  107. eventBus.emit('handleTab',name)
  108. };
  109. const list = ref([
  110. [
  111. {
  112. name: "果园总览",
  113. id: 0,
  114. },
  115. // {
  116. // name: "基本指标",
  117. // id: 1,
  118. // children: ["树高", "冠幅"],
  119. // },
  120. // {
  121. // name: "物候指标",
  122. // id: 2,
  123. // children: ["花穗长度", "单树花穗率"],
  124. // },
  125. {
  126. name: "生态指标",
  127. id: 3,
  128. children: ["通风率", "清园程度","益草覆盖度"],
  129. },
  130. {
  131. name: "生长指标",
  132. id: 4,
  133. children: ["生长缓慢", "花量大","花带叶"],
  134. },
  135. {
  136. name: "病虫指标",
  137. id: 5,
  138. children: ["病害比例", "虫害比例"],
  139. },
  140. {
  141. name: "农事处方",
  142. id: 1,
  143. },
  144. ],
  145. // [
  146. // {
  147. // name: "指标对比",
  148. // id: 11,
  149. // },
  150. // ],
  151. ]);
  152. const toPage = () => {
  153. router.push("/authentic");
  154. };
  155. // 对比
  156. const checkedCompareChildren = ref([]);
  157. function handleCompareChange(v) {
  158. eventBus.emit("compareTree", checkedCompareChildren.value.length > 0 ? true : false)
  159. }
  160. // 退出对比
  161. function handleQuitCompare() {
  162. checkedCompareChildren.value = []
  163. }
  164. </script>
  165. <style lang="scss" scoped>
  166. .navigation {
  167. position: fixed;
  168. top: 34px;
  169. left: calc(50% - 70px);
  170. // left: 50%;
  171. transform: translateX(-50%);
  172. width: calc(100% - 430px * 2);
  173. display: flex;
  174. justify-content: center;
  175. align-items: center;
  176. .select{
  177. // width: 120px;
  178. width: 166px;
  179. height: 50px;
  180. margin-right: 21px;
  181. ::v-deep{
  182. .el-select__wrapper{
  183. height: 100%;
  184. background: rgba(0, 0, 0, 0.3);
  185. box-shadow: 0 0 0 1px #F7BE5A;
  186. border-radius: 2px;
  187. text-align: center;
  188. }
  189. .el-select__placeholder{
  190. color: #F7BE5A;
  191. font-size: 20px;
  192. font-family: "PangMenZhengDao";
  193. }
  194. .el-select__caret{
  195. color: #F7BE5A;
  196. font-size: 20px;
  197. }
  198. }
  199. }
  200. .tabs {
  201. background: rgba(35, 35, 35, 0.8);
  202. border: 1px solid #555555;
  203. padding: 8px;
  204. border-radius: 8px;
  205. display: flex;
  206. justify-content: center;
  207. .tab-item {
  208. font-size: 16px;
  209. color: rgba(255, 255, 255, 0.8);
  210. padding: 7px 12px 9px 12px;
  211. font-family: "PangMenZhengDao";
  212. cursor: pointer;
  213. &.active {
  214. background: #ffd489;
  215. color: #1d1d1d;
  216. border-radius: 4px;
  217. }
  218. }
  219. .tab-item + .tab-item {
  220. margin-left: 25px;
  221. }
  222. }
  223. .tabs + .tabs {
  224. margin-left: 12px;
  225. }
  226. .checkbox-group {
  227. position: absolute;
  228. top: 74px;
  229. right: 26px;
  230. background: rgba(35, 35, 35, 0.8);
  231. border-radius: 8px;
  232. border: 1px solid #555555;
  233. padding: 10px 20px;
  234. display: flex;
  235. flex-direction: column;
  236. &.compare-btn {
  237. right: 26px;
  238. top: 0px;
  239. }
  240. ::v-deep {
  241. .el-checkbox {
  242. margin-right: 0;
  243. }
  244. .el-checkbox__input.is-checked + .el-checkbox__label {
  245. color: #ffd489;
  246. }
  247. .el-checkbox__input.is-checked .el-checkbox__inner {
  248. background-color: #ffd489;
  249. border-color: #ffd489;
  250. &::after {
  251. border-color: #1d1d1d;
  252. }
  253. }
  254. .el-checkbox__label {
  255. color: #fff;
  256. }
  257. }
  258. }
  259. .compare-tips {
  260. position: absolute;
  261. top: 96px;
  262. left: 50%;
  263. transform: translateX(-50%);
  264. background: rgba(4, 3, 0, 0.6);
  265. border-radius: 40px;
  266. padding: 6px 34px;
  267. font-family: 'PangMenZhengDao';
  268. font-size: 20px;
  269. span {
  270. color: #F3C11D;
  271. }
  272. }
  273. .btn {
  274. width: 80px;
  275. height: 30px;
  276. text-align: center;
  277. line-height: 28px;
  278. border-radius: 5px;
  279. cursor: pointer;
  280. background: rgba(255, 255, 255, 0.5);
  281. }
  282. }
  283. </style>