Toolbar.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <div
  3. class="app-view-toolbar"
  4. :class="{ unable: !canEdit }"
  5. app-border
  6. dir-top
  7. >
  8. <div class="clip-center">
  9. <tabList :list="info.catalogRoot" @clickItem="item=>{taboneActive = item}" :hiddenHover="true" :active="taboneActive" :id="'rand11'" :subId="'rand111'">
  10. </tabList>
  11. <tabList v-if="childTab.length > 1" :list="childTab" :hiddenHover="true" @clickItem="item=>{tabtowActive = item}"
  12. :active="tabtowActive" :id="'subrand11'" :subId="'subrand111'">
  13. </tabList>
  14. <div class="pano-con clip-scroller">
  15. <ul ref="clip" v-if="scenes.length>0">
  16. <li
  17. v-for="(item, i) in scenes"
  18. @click="activeItem = item"
  19. :class="{ 'li-active': item.sceneCode == activeItem.sceneCode }"
  20. :key="i"
  21. >
  22. <div class="typeli">
  23. <i
  24. class="iconfont iconedit_type_3d"
  25. :class="{ iconedit_type_panorama: item.type !== 'house' }"
  26. ></i>
  27. </div>
  28. <div class="img">
  29. <img v-if="item.icon" :src="item.icon+`?${Math.random()}`" alt="" />
  30. </div>
  31. <div class="ui-title">
  32. <span>{{ item.sceneTitle }}</span>
  33. </div>
  34. </li>
  35. </ul>
  36. <div class="no-record" v-else>
  37. 当前分组下暂无全景图
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import { mapGetters } from "vuex";
  45. import tabList from "@/components/tablist";
  46. let frame;
  47. let $scroll = null;
  48. export default {
  49. name: 'whatisthis',
  50. components: {tabList},
  51. data() {
  52. return {
  53. taboneActive: { children: [] },
  54. tabtowActive: "",
  55. type: "building",
  56. activeItem: "",
  57. canEdit: true,
  58. hasCheck: false,
  59. loadList:true,
  60. childTab:[],
  61. scenes:[],
  62. };
  63. },
  64. computed: {
  65. ...mapGetters({
  66. info: "info",
  67. backupInfo: "backupInfo"
  68. })
  69. },
  70. methods: {
  71. undateScroll(){
  72. this.$nextTick(() => {
  73. if ($scroll == null) {
  74. $scroll = $(".clip-scroller")[0];
  75. frame = new PerfectScrollbar($scroll, {
  76. useBothWheelAxes: true,
  77. suppressScrollY: true,
  78. wheelSpeed: 0.8,
  79. });
  80. $($scroll).data("scrollbar", frame);
  81. }
  82. });
  83. },
  84. updateInfo(){
  85. let iidx = this.info.scenes.findIndex(item=>this.activeItem.sceneCode == item.sceneCode)
  86. if (iidx>-1) {
  87. this.info.scenes[iidx] = {
  88. ...this.activeItem
  89. }
  90. }
  91. this.$store.commit("SetInfo", this.info);
  92. }
  93. },
  94. created() {},
  95. watch: {
  96. taboneActive: {
  97. deep:true,
  98. handler: function (newVal,oldVal) {
  99. let temp = []
  100. newVal.children && newVal.children.forEach(item=>{
  101. this.info.catalogs.forEach(sub=>{
  102. if (item==sub.id) {
  103. temp.push(sub)
  104. }
  105. })
  106. })
  107. this.childTab = temp
  108. if (this.childTab.length == 1 || newVal!=oldVal) {
  109. this.tabtowActive = this.childTab[0]
  110. }
  111. },
  112. },
  113. tabtowActive: {
  114. immediate:true,
  115. handler: function (newVal) {
  116. if (!newVal) {
  117. this.tabtowActive = this.childTab[0]
  118. } else{
  119. let arr = this.info.scenes.filter(item=>{
  120. return newVal.id == item.category && item.type!='4dkk'
  121. })
  122. this.scenes = arr.sort((a,b)=>a.weight-b.weight)
  123. this.activeItem = this.scenes[0]
  124. }
  125. }
  126. },
  127. '$route.meta.loadScene':{
  128. deep: true,
  129. immediate: true,
  130. handler: function (newVal) {
  131. if (newVal) {
  132. if (this.loadList) {
  133. this.taboneActive = { children: [] };
  134. setTimeout(() => {
  135. this.taboneActive = this.info.catalogRoot[0] || { children: [] };
  136. this.loadList = false
  137. });
  138. }
  139. }
  140. }
  141. },
  142. activeItem: {
  143. handler: function(newVal) {
  144. this.$bus.emit("currentPcode", newVal);
  145. this.$store.commit("SetActiveItem", newVal || "");
  146. this.updateInfo()
  147. if (newVal) {
  148. this.$bus.emit("initView", newVal.icon||'');
  149. }
  150. },
  151. },
  152. type() {
  153. this.hasCheck = true;
  154. },
  155. },
  156. mounted() {
  157. this.undateScroll()
  158. this.$bus.on("setListThumb", (data) => {
  159. this.activeItem.icon = data.icon;
  160. this.activeItem.initVisual = JSON.stringify(data.initVisual);
  161. });
  162. this.$bus.on("canEdit", (data) => {
  163. this.canEdit = data;
  164. });
  165. this.$bus.on("scenesChange", ()=> {
  166. this.loadList = true;
  167. this.undateScroll()
  168. });
  169. },
  170. };
  171. </script>
  172. <style lang="less" scoped>
  173. .app-view-toolbar {
  174. overflow: visible;
  175. a {
  176. color: #fff;
  177. text-decoration: none;
  178. }
  179. .clip-center {
  180. flex: 1;
  181. display: flex;
  182. overflow: hidden;
  183. flex-direction: column;
  184. padding-top: 10px;
  185. margin: 0 10px;
  186. .pano-con {
  187. width: 100%;
  188. padding: 0;
  189. background: none;
  190. > ul {
  191. flex-wrap: unset;
  192. display: inline-block;
  193. white-space: nowrap;
  194. > li {
  195. display: inline-block;
  196. height: 128px;
  197. width: 128px;
  198. margin-top: 0;
  199. margin-right: 0;
  200. cursor: pointer;
  201. &:first-of-type {
  202. margin-left: 0;
  203. }
  204. }
  205. }
  206. }
  207. .clip-scroller {
  208. width: 100%;
  209. height: 100%;
  210. position: relative;
  211. padding-right: 20px;
  212. }
  213. }
  214. .no-record{
  215. width: 100%;
  216. height: 100%;
  217. display: flex;
  218. align-items: center;
  219. justify-content: center;
  220. }
  221. }
  222. .unable {
  223. &::before {
  224. content: "";
  225. z-index: 22;
  226. position: absolute;
  227. width: 100%;
  228. top: -10px;
  229. height: calc(100% + 10px);
  230. background: rgba(0, 0, 0, 0.4);
  231. }
  232. }
  233. </style>