navigation.vue 6.5 KB

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