navigation.vue 7.1 KB

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