panel.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <div class="panelBoxWarp">
  3. <div class="panelBox" :class="{'on':sidebarShow}">
  4. <!--<div class="componentList">-->
  5. <!--<ul>-->
  6. <!--<li v-for="(item, index) of componentList" :key="index" :class="{'on':componentActive == index}" @click="componentActive=index">-->
  7. <!--<i class="iconfont icon-fangkuai"></i>-->
  8. <!--<span>{{item}}</span>-->
  9. <!--</li>-->
  10. <!--</ul>-->
  11. <!--</div>-->
  12. <div class="categoryList">
  13. <div class="itemBox" v-for="(item, index) of panelShowList" :key="index">
  14. <h3>{{item.title}}</h3>
  15. <div class="childList">
  16. <draggable
  17. class="dragArea list-group"
  18. :list="item.classList"
  19. :clone="cloneItem"
  20. :group="{ name: 'pageEdit', pull: 'clone', put: false }"
  21. :options="{sort:false}"
  22. >
  23. <div @mouseover="hoverItem (classItem)" @mouseout="hoverItemOut" class="childItem list-group-item" v-for="(classItem, index) of item.classList" :key="index">
  24. <div class="childItemWarp">
  25. <div class="contentBox">
  26. <i class="iconfont" :class="classItem.iconClass"></i>
  27. <span>{{classItem.title}}</span>
  28. </div>
  29. <div class="cloneText">
  30. 组件放置区域
  31. </div>
  32. </div>
  33. </div>
  34. </draggable>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="btnToggle" @click="sidebarShow=!sidebarShow" :class="{'on':sidebarShow}">
  40. <i class="iconfont icon-arrow-right"></i>
  41. <i class="iconfont icon-arrow-left"></i>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. // 默认配置文件
  47. import panelList from './panelList'
  48. import draggable from 'vuedraggable'
  49. import { mapGetters } from 'vuex'
  50. export default {
  51. name: 'panel',
  52. components: {
  53. draggable
  54. },
  55. data () {
  56. return {
  57. sidebarShow: true,
  58. componentActive: 0,
  59. componentList: ['组件', '组件'],
  60. panelList: panelList,
  61. isHover: ''
  62. }
  63. },
  64. methods: {
  65. hoverItem (classItem) {
  66. this.isHover = classItem.title
  67. },
  68. hoverItemOut () {
  69. this.isHover = ''
  70. },
  71. cloneItem (item) {
  72. return JSON.parse(JSON.stringify(item))
  73. }
  74. },
  75. computed: {
  76. ...mapGetters([
  77. 'terminal',
  78. 'typeId'
  79. ]),
  80. panelShowList(){
  81. // terminal: 4, // 画布设备 1 小程序,2 H5,3 App 4 电脑
  82. // typeId: 3, // 画布类型 1 平台画布,2 自定义页面,3 商家店铺装修
  83. let _this = this
  84. var _panelList = JSON.parse(JSON.stringify(this.panelList))
  85. var mewPaneList = _panelList.filter(parent=>{
  86. let children = parent.classList.filter(child=>{
  87. // 是否只用于app onlyApp terminal == 4
  88. // 是否只用于平台端 onlyAdmin typeId == 3
  89. // 是否只用于商家端 onlyMerchant typeId == 1
  90. console.log(child.title,!(child.onlyApp && _this.terminal==4),!(child.onlyAdmin && _this.typeId==3),!(child.onlyMerchant && _this.typeId==1))
  91. return !(child.onlyApp && _this.terminal==4) && !(child.onlyAdmin && _this.typeId==3) && !(child.onlyMerchant && _this.typeId==1)
  92. })
  93. parent.classList = children
  94. return parent
  95. })
  96. console.log(this.panelList, 123)
  97. return mewPaneList
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .panelBoxWarp{
  104. position: relative;
  105. height: 100%;
  106. }
  107. .panelBox {
  108. width: 0px;
  109. min-height: 100%;
  110. display: flex;
  111. overflow: hidden;
  112. transition: 0.2s width ease;
  113. &.on{
  114. width: 200px;
  115. }
  116. .componentList{
  117. width: 64px;
  118. padding: 17px 0;
  119. text-align: center;
  120. li{
  121. position: relative;
  122. margin-bottom: 18px;
  123. .iconfont{
  124. font-size: 24px;
  125. }
  126. span{
  127. font-size: 12px;
  128. display: block;
  129. }
  130. &.on,&:hover{
  131. color: $mainColor;
  132. :after{
  133. content: '';
  134. position: absolute;
  135. left: 0;
  136. top: 0;
  137. width: 2px;
  138. height: 100%;
  139. background-color: $mainColor;
  140. }
  141. }
  142. }
  143. }
  144. .categoryList {
  145. border-left: 1px solid #F0F3F4;
  146. width: 186px;
  147. padding: 20px 0 20px 10px;
  148. .itemBox {
  149. h3 {
  150. padding-left: 20px;
  151. height: 35px;
  152. line-height: 35px;
  153. font-size: 16px;
  154. color: #333333;
  155. position: relative;
  156. &:before{
  157. content: '';
  158. border-left:5px solid $mainColor;
  159. border-top:4px solid transparent;
  160. border-bottom:4px solid transparent;
  161. position: absolute;
  162. left: 10px;
  163. top: 50%;
  164. margin-top: -4px;
  165. }
  166. }
  167. .childList {
  168. font-size: 14px;
  169. color: #333333;
  170. padding: 20px 10px;
  171. .list-group{
  172. display: flex;
  173. flex-wrap: wrap;
  174. :hover {
  175. background: #FF7800;
  176. color: #ffffff;
  177. border-radius: 3px;
  178. //cursor: move;
  179. }
  180. .childItemWarp{
  181. height: 80px;
  182. }
  183. .childItem {
  184. width: 50%;
  185. .contentBox{
  186. height: 100%;
  187. display: flex;
  188. flex-flow: column;
  189. align-items: center;
  190. justify-content: center;
  191. cursor: move;
  192. .iconfont{
  193. font-size: 30px;
  194. }
  195. span {
  196. margin-top: 5px;
  197. }
  198. }
  199. .cloneText{
  200. display: none;
  201. }
  202. }
  203. }
  204. }
  205. }
  206. }
  207. }
  208. .btnToggle{
  209. width: 20px;
  210. height: 66px;
  211. background-color: #fff;
  212. border-radius: 0 20px 20px 0;
  213. position: absolute;
  214. right: -20px;
  215. top: 50%;
  216. margin-top: -33px;
  217. display: flex;
  218. align-items: center;
  219. cursor: pointer;
  220. z-index: 9;
  221. .icon-arrow-left{
  222. display: none;
  223. }
  224. &.on{
  225. .icon-arrow-left{
  226. display: block;
  227. }
  228. .icon-arrow-right{
  229. display: none;
  230. }
  231. }
  232. }
  233. </style>