navigation.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. })
  75. onUnmounted(()=>{
  76. eventBus.off('handleActive',handleActive)
  77. })
  78. const emit = defineEmits(["handleTab","handleTabItem"])
  79. const checkedChildren = ref([]);
  80. const childrenData = ref([]);
  81. const handleCheckedChange = (e) => {
  82. if(e.length){
  83. checkedChildren.value = [e[e.length -1]];
  84. emit('handleTabItem',checkedChildren.value[0])
  85. eventBus.emit('handleTabItem',checkedChildren.value[0])
  86. }
  87. };
  88. function handleActive({name,key}){
  89. childrenData.value = []
  90. const arr = list.value[0].filter(item =>item.name===key)
  91. active.value = arr[0].id;
  92. childrenData.value = arr[0].children
  93. checkedChildren.value = [name]
  94. emit('handleTab',{name:arr[0].name,id:active.value,isUpdate:true,params:name})
  95. }
  96. const active = ref(0);
  97. const handleTab = ({ id, name,children }) => {
  98. active.value = id;
  99. childrenData.value = []
  100. if(children){
  101. childrenData.value = children;
  102. checkedChildren.value = [children[0]];
  103. }
  104. emit('handleTab',{name,id})
  105. eventBus.emit('handleTab',name)
  106. };
  107. const list = ref([
  108. [
  109. {
  110. name: "果园总览",
  111. id: 0,
  112. },
  113. // {
  114. // name: "基本指标",
  115. // id: 1,
  116. // children: ["树高", "冠幅"],
  117. // },
  118. // {
  119. // name: "物候指标",
  120. // id: 2,
  121. // children: ["花穗长度", "单树花穗率"],
  122. // },
  123. {
  124. name: "生态指标",
  125. id: 3,
  126. children: ["通风率", "清园程度","益草覆盖度"],
  127. },
  128. {
  129. name: "生长指标",
  130. id: 4,
  131. children: ["生长缓慢", "花量大","花带叶"],
  132. },
  133. {
  134. name: "病虫指标",
  135. id: 5,
  136. children: ["病害比例", "虫害比例"],
  137. },
  138. {
  139. name: "农事处方",
  140. id: 1,
  141. },
  142. ],
  143. // [
  144. // {
  145. // name: "指标对比",
  146. // id: 11,
  147. // },
  148. // ],
  149. ]);
  150. const toPage = () => {
  151. router.push("/authentic");
  152. };
  153. // 对比
  154. const checkedCompareChildren = ref([]);
  155. function handleCompareChange(v) {
  156. console.log('cc', v);
  157. eventBus.emit("compareTree", checkedCompareChildren.value.length > 0 ? true : false)
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .navigation {
  162. position: fixed;
  163. top: 34px;
  164. left: calc(50% - 70px);
  165. // left: 50%;
  166. transform: translateX(-50%);
  167. width: calc(100% - 430px * 2);
  168. display: flex;
  169. justify-content: center;
  170. align-items: center;
  171. .select{
  172. // width: 120px;
  173. width: 166px;
  174. height: 50px;
  175. margin-right: 21px;
  176. ::v-deep{
  177. .el-select__wrapper{
  178. height: 100%;
  179. background: rgba(0, 0, 0, 0.3);
  180. box-shadow: 0 0 0 1px #F7BE5A;
  181. border-radius: 2px;
  182. text-align: center;
  183. }
  184. .el-select__placeholder{
  185. color: #F7BE5A;
  186. font-size: 20px;
  187. font-family: "PangMenZhengDao";
  188. }
  189. .el-select__caret{
  190. color: #F7BE5A;
  191. font-size: 20px;
  192. }
  193. }
  194. }
  195. .tabs {
  196. background: rgba(35, 35, 35, 0.8);
  197. border: 1px solid #555555;
  198. padding: 8px;
  199. border-radius: 8px;
  200. display: flex;
  201. justify-content: center;
  202. .tab-item {
  203. font-size: 16px;
  204. color: rgba(255, 255, 255, 0.8);
  205. padding: 7px 12px 9px 12px;
  206. font-family: "PangMenZhengDao";
  207. cursor: pointer;
  208. &.active {
  209. background: #ffd489;
  210. color: #1d1d1d;
  211. border-radius: 4px;
  212. }
  213. }
  214. .tab-item + .tab-item {
  215. margin-left: 25px;
  216. }
  217. }
  218. .tabs + .tabs {
  219. margin-left: 12px;
  220. }
  221. .checkbox-group {
  222. position: absolute;
  223. top: 74px;
  224. right: 160px;
  225. background: rgba(35, 35, 35, 0.8);
  226. border-radius: 8px;
  227. border: 1px solid #555555;
  228. padding: 10px 20px;
  229. display: flex;
  230. flex-direction: column;
  231. &.compare-btn {
  232. right: 26px;
  233. top: 0px;
  234. }
  235. ::v-deep {
  236. .el-checkbox {
  237. margin-right: 0;
  238. }
  239. .el-checkbox__input.is-checked + .el-checkbox__label {
  240. color: #ffd489;
  241. }
  242. .el-checkbox__input.is-checked .el-checkbox__inner {
  243. background-color: #ffd489;
  244. border-color: #ffd489;
  245. &::after {
  246. border-color: #1d1d1d;
  247. }
  248. }
  249. .el-checkbox__label {
  250. color: #fff;
  251. }
  252. }
  253. }
  254. .compare-tips {
  255. position: absolute;
  256. top: 96px;
  257. left: 50%;
  258. transform: translateX(-50%);
  259. background: rgba(4, 3, 0, 0.6);
  260. border-radius: 40px;
  261. padding: 6px 34px;
  262. font-family: 'PangMenZhengDao';
  263. font-size: 20px;
  264. span {
  265. color: #F3C11D;
  266. }
  267. }
  268. .btn {
  269. width: 80px;
  270. height: 30px;
  271. text-align: center;
  272. line-height: 28px;
  273. border-radius: 5px;
  274. cursor: pointer;
  275. background: rgba(255, 255, 255, 0.5);
  276. }
  277. }
  278. </style>