GardenMenu.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <div class="yse-events city_menu">
  3. <div class="name">{{hideZnxy ? '选择果园' : name}}</div>
  4. <!-- <div class="cascader">-->
  5. <!-- <el-cascader-->
  6. <!-- filterable-->
  7. <!-- v-model="selecteValue"-->
  8. <!-- size="small"-->
  9. <!-- :options="options"-->
  10. <!-- :props="props"-->
  11. <!-- clearable-->
  12. <!-- placeholder="切换"-->
  13. <!-- @change="handleChange"-->
  14. <!-- style="width: 88%"-->
  15. <!-- />-->
  16. <!-- </div>-->
  17. <div class="btn">
  18. <span>全部</span>
  19. <div class="switch" @click="changeGarden">
  20. <el-icon color="#fff" size="11px"><Switch /></el-icon>
  21. </div>
  22. </div>
  23. </div>
  24. </template>
  25. <script setup>
  26. import { ref } from "vue";
  27. import { useStore } from 'vuex';
  28. const store = useStore()
  29. const gardenId = store.getters.userinfo.curGardenId;
  30. const options = ref([]);
  31. const selecteValue = ref([]);
  32. const props = {
  33. expandTrigger: "hover",
  34. checkStrictly: true,
  35. value: "organId",
  36. label: "name",
  37. hideZnxy: {
  38. type:Boolean,
  39. default:false,
  40. },
  41. };
  42. const name = ref('');
  43. const emit = defineEmits(["handleChange","changeGarden"]);
  44. const initList = async () => {
  45. const { code, data } = await VE_API.organ.gardenData();
  46. options.value = data;
  47. // options.value.push({name:'荔枝博览园',organId:766})
  48. const curName = options.value.find((i) => gardenId == i.organId)
  49. name.value = curName.name
  50. selecteValue.value.push(gardenId)
  51. };
  52. const handleChange = async (val) => {
  53. let data = { organId: val[0], areaId: val[1] };
  54. let organ = options.value.find((value) => data.organId == value.organId);
  55. name.value = organ.name
  56. let user = JSON.parse(sessionStorage.getItem('userinfo'))
  57. // 更新果园信息
  58. const res = await VE_API.organ.updateGarden({gardenId:data.organId,userId:user.userId});
  59. if(res.code===0) {
  60. const resData = res.data
  61. user.curGardenId = resData.curGardenId
  62. user.curGardenName = resData.curGardenName
  63. user.location = resData.location
  64. store.commit('app/SET_USER_INFO',JSON.stringify(user))
  65. // 添加自定义事件
  66. window.dispatchEvent(new CustomEvent('storageChanged', { detail: data.organId }));
  67. }
  68. let area = null;
  69. // if(data.areaId){
  70. // area = organ.children.find(value => data.areaId == value.organId)
  71. // }
  72. // emit("handleChange", {organ,area})
  73. // emit("handleChange", { organ });
  74. }
  75. function changeGarden(){
  76. emit("changeGarden")
  77. }
  78. initList();
  79. defineExpose({});
  80. </script>
  81. <style lang="scss" scope>
  82. .city_menu {
  83. background-image: url(@/assets/img/input_bg1.png);
  84. background-repeat: no-repeat;
  85. background-size: 100% 13px;
  86. background-position: 0 100%;
  87. padding-bottom: 5px;
  88. box-sizing: border-box;
  89. width: 240px;
  90. height: 100%;
  91. display: flex;
  92. align-items: flex-end;
  93. justify-content: flex-end;
  94. // ::v-deep{
  95. // .el-input__wrapper{
  96. // box-shadow: none;
  97. // }
  98. // .el-input__wrapper.is-focus{
  99. // box-shadow: none;
  100. // }
  101. // .el-cascader .el-input.is-focus .el-input__wrapper{
  102. // box-shadow: none;
  103. // }
  104. // }
  105. .name {
  106. font-weight: 500;
  107. font-size: 15px;
  108. color: #ffffff;
  109. }
  110. .cascader {
  111. width: 40%;
  112. margin-right: 2px;
  113. display: flex;
  114. margin-left: 10px;
  115. }
  116. .btn {
  117. margin-right: 20px;
  118. width: 61px;
  119. height: 23px;
  120. background: #024155;
  121. border-radius: 5px;
  122. border: 1px solid rgba(0, 255, 240, 0.5);
  123. font-weight: 500;
  124. font-size: 13px;
  125. color: #00fff0;
  126. display: flex;
  127. align-items: center;
  128. justify-content: space-evenly;
  129. cursor: pointer;
  130. .switch{
  131. background: #00FFF0;
  132. border-radius: 50%;
  133. width: 18px;
  134. height: 18px;
  135. display: flex;
  136. align-items: center;
  137. justify-content: center;
  138. }
  139. }
  140. }
  141. .city_menu .el-input__wrapper {
  142. background: transparent;
  143. width: 200px;
  144. }
  145. .city_menu .el-input--small {
  146. border-color: transparent;
  147. }
  148. .city_menu .el-input--small .el-input__inner {
  149. color: #ffffff;
  150. border: none;
  151. }
  152. .el-input.el-input--small.el-input--suffix {
  153. border: none;
  154. background: none;
  155. }
  156. </style>