navigation.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. [
  140. {
  141. name: "处方图",
  142. id: 6,
  143. },
  144. ],
  145. ]);
  146. const toPage = () => {
  147. router.push("/authentic");
  148. };
  149. // 对比
  150. const checkedCompareChildren = ref([]);
  151. function handleCompareChange(v) {
  152. if (checkedCompareChildren.value.length) {
  153. // 对比
  154. eventBus.emit("compareTree", checkedCompareChildren.value.length > 0 ? true : false)
  155. }
  156. }
  157. </script>
  158. <style lang="scss" scoped>
  159. .navigation {
  160. position: fixed;
  161. top: 34px;
  162. // left: calc(50% - 470px);
  163. left: 50%;
  164. transform: translateX(-50%);
  165. width: calc(100% - 430px * 2);
  166. display: flex;
  167. justify-content: center;
  168. align-items: center;
  169. .select{
  170. // width: 120px;
  171. width: 226px;
  172. height: 50px;
  173. margin-right: 21px;
  174. ::v-deep{
  175. .el-select__wrapper{
  176. height: 100%;
  177. background: rgba(0, 0, 0, 0.3);
  178. box-shadow: 0 0 0 1px #F7BE5A;
  179. border-radius: 2px;
  180. text-align: center;
  181. }
  182. .el-select__placeholder{
  183. color: #F7BE5A;
  184. font-size: 20px;
  185. font-family: "PangMenZhengDao";
  186. }
  187. .el-select__caret{
  188. color: #F7BE5A;
  189. font-size: 20px;
  190. }
  191. }
  192. }
  193. .tabs {
  194. background: rgba(35, 35, 35, 0.8);
  195. border: 1px solid #555555;
  196. padding: 8px;
  197. border-radius: 8px;
  198. display: flex;
  199. justify-content: center;
  200. .tab-item {
  201. font-size: 16px;
  202. color: rgba(255, 255, 255, 0.8);
  203. padding: 7px 12px 9px 12px;
  204. font-family: "PangMenZhengDao";
  205. cursor: pointer;
  206. &.active {
  207. background: #ffd489;
  208. color: #1d1d1d;
  209. border-radius: 4px;
  210. }
  211. }
  212. .tab-item + .tab-item {
  213. margin-left: 25px;
  214. }
  215. }
  216. .tabs + .tabs {
  217. margin-left: 12px;
  218. }
  219. .checkbox-group {
  220. position: absolute;
  221. top: 74px;
  222. right: 160px;
  223. background: rgba(35, 35, 35, 0.8);
  224. border-radius: 8px;
  225. border: 1px solid #555555;
  226. padding: 10px 20px;
  227. display: flex;
  228. flex-direction: column;
  229. &.compare-btn {
  230. right: 26px;
  231. }
  232. ::v-deep {
  233. .el-checkbox {
  234. margin-right: 0;
  235. }
  236. .el-checkbox__input.is-checked + .el-checkbox__label {
  237. color: #ffd489;
  238. }
  239. .el-checkbox__input.is-checked .el-checkbox__inner {
  240. background-color: #ffd489;
  241. border-color: #ffd489;
  242. &::after {
  243. border-color: #1d1d1d;
  244. }
  245. }
  246. .el-checkbox__label {
  247. color: #fff;
  248. }
  249. }
  250. }
  251. .compare-tips {
  252. position: absolute;
  253. top: 96px;
  254. left: 50%;
  255. transform: translateX(-50%);
  256. background: rgba(4, 3, 0, 0.6);
  257. border-radius: 40px;
  258. padding: 6px 34px;
  259. font-family: 'PangMenZhengDao';
  260. font-size: 20px;
  261. span {
  262. color: #F3C11D;
  263. }
  264. }
  265. .btn {
  266. width: 80px;
  267. height: 30px;
  268. text-align: center;
  269. line-height: 28px;
  270. border-radius: 5px;
  271. cursor: pointer;
  272. background: rgba(255, 255, 255, 0.5);
  273. }
  274. }
  275. </style>