pageClass.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <div>
  3. <!-- 全局组件:页头 -->
  4. <div :class="['FixedModuleBox', { sectorBorder: this.$store.state.template.previewStatus == false }]">
  5. <headSector />
  6. </div>
  7. <!-- 全局组件:导航 -->
  8. <div :class="['FixedModuleBox', { sectorBorder: this.$store.state.template.previewStatus == false }]">
  9. <menuSector />
  10. </div>
  11. <div
  12. id="content"
  13. class="canvasBox"
  14. >
  15. <grid-layout
  16. :auto-size="true"
  17. :class="this.$store.state.template.pageData.class.length == 0 ? 'FixedMainModuleBox' : 'FixedMainModuleBoxAuto'"
  18. ref="gridlayout"
  19. :layout="this.$store.state.template.pageData.class"
  20. :layout.sync="this.$store.state.template.pageData.class"
  21. :col-num="12"
  22. :row-height="rowHeight"
  23. :margin="[0,0]"
  24. :is-draggable="true"
  25. :is-resizable="true"
  26. :key="this.$store.state.template.gridKey"
  27. >
  28. <grid-item
  29. v-for="(item, index) in this.$store.state.template.pageData.class"
  30. :key="item.i"
  31. :i="item.i"
  32. :x="item.x"
  33. :y="item.y"
  34. :w="item.w"
  35. :h="item.h"
  36. :is-resizable="false"
  37. >
  38. <div class="grid-item-content">
  39. <!--右侧悬浮按钮-->
  40. <div class="grid-tools-menu" v-if="$store.state.template.previewStatus == false">
  41. <!-- 移动板块-->
  42. <!-- <span @click="moveModule(item.i,'up')"><i class="el-icon-sort-up"></i></span>
  43. <span @click="moveModule(item.i,'down')"><i class="el-icon-sort-down"></i></span> -->
  44. <span @click="deleteModule(item.i, item.dataSort)"><i class="el-icon-close"></i></span>
  45. </div>
  46. <!-- 1.广告通栏 -->
  47. <div v-if="item.type == 'adSector'" class="moduleBox">
  48. <adSector :dataSort="item.dataSort" :id="item.i" :y="item.y" />
  49. </div>
  50. <!-- 2.频道菜单 -->
  51. <div v-if="item.type == 'channelMenu'" class="moduleBox">
  52. <channelMenu :dataSort="item.dataSort" :id="item.i" :y="item.y" />
  53. </div>
  54. <!-- 3.滚动图文组合 -->
  55. <div v-if="item.type == 'scrollTextSector'" class="moduleBox">
  56. <scrollTextSector :dataSort="item.dataSort" :id="item.i" :y="item.y" />
  57. </div>
  58. <!-- 4.新闻多图组合1 -->
  59. <div v-if="item.type == 'manyPictureSector'" class="moduleBox">
  60. <manyPictureSector :dataSort="item.dataSort" :id="item.i" :y="item.y" />
  61. </div>
  62. <!-- 5.新闻多图组合2 -->
  63. <div v-if="item.type == 'commentSector'" class="moduleBox">
  64. <commentSector :dataSort="item.dataSort" :id="item.i" :y="item.y" />
  65. </div>
  66. <!-- 6.新闻多图组合3 -->
  67. <div v-if="item.type == 'listSector'" class="moduleBox">
  68. <listSector :dataSort="item.dataSort" :id="item.i" :y="item.y" />
  69. </div>
  70. </div>
  71. </grid-item>
  72. </grid-layout>
  73. </div>
  74. <!-- 全局组件:页尾 -->
  75. <div class="FixedModuleBoxBottom">
  76. <footerSector />
  77. </div>
  78. </div>
  79. </template>
  80. <script>
  81. //页面公用组件 start------------------------------------------------------------>
  82. //引入公用样式
  83. import '@/styles/global.less';
  84. import { GridLayout, GridItem } from "vue-grid-layout";
  85. //1.页面公用组件 end------------------------------------------------------------>
  86. //引入自助建站组件 start------------------------------------------------------------>
  87. //全局组件
  88. //顶部
  89. import headSector from '../style/sector/head/1.vue';
  90. //一级菜单导肮
  91. import menuSector from '../style/sector/menu/1.vue';
  92. //底部
  93. import footerSector from '../style/sector/foot/1.vue';
  94. //通栏组件 开始:
  95. //通栏广告
  96. import adSector from '../style/sector/body/ad/1200x90/1.vue';
  97. //新闻图文组合1
  98. import manyPictureSector from '../style/sector/body/index/list/1200x470/1.vue';
  99. //新闻图文组合2
  100. import commentSector from '../style/sector/body/index/list/1200x470/2.vue';
  101. //新闻图文组合3
  102. import listSector from '../style/sector/body/index/list/1200x980/1.vue';
  103. //频道菜单
  104. import channelMenu from '../style/sector/body/class/menu/1200x100/1.vue';
  105. //滚动图文组合
  106. import scrollTextSector from '../style/sector/body/class/banner/1200x410/1.vue';
  107. //2.引入自助建站组件 end------------------------------------------------------------>
  108. export default {
  109. components: {
  110. GridLayout,//画布
  111. GridItem,//画布组件
  112. headSector,//全局页头
  113. menuSector,//全局导航
  114. adSector,//通栏广告
  115. manyPictureSector,//新闻图文组合1
  116. commentSector,//新闻图文组合2
  117. listSector,//新闻图文组合3
  118. channelMenu,//频道菜单
  119. scrollTextSector,//滚动图文组合
  120. footerSector
  121. },
  122. data() {
  123. return {
  124. //0.全局配置 start------------------------------------------------------------>
  125. windowStatus: false,
  126. rowHeight: 10,
  127. //0.全局配置 end------------------------------------------------------------>
  128. //1.编辑模块 start------------------------------------------------------------>
  129. formLabelWidth: '120px',
  130. editModule: "",//待编辑的模块
  131. //1.编辑模块 end------------------------------------------------------------>
  132. }
  133. },
  134. mounted() {
  135. //必备操作
  136. //1.获得vuex中的鼠标对象
  137. let mouseObj = this.$store.state.template.mouseXY;
  138. //2.获得gridlayout对象
  139. this.$store.commit('template/setGridlayoutObj', this.$refs.gridlayout);
  140. //3.监听鼠标按住以后的移动事件
  141. document.addEventListener("dragover", function (e, store) {
  142. mouseObj.x = e.clientX;
  143. mouseObj.y = e.clientY;
  144. // mouseXY.x = e.clientX;
  145. // mouseXY.y = e.clientY;
  146. }, false);
  147. },
  148. methods: {
  149. //0.全局操作 start ------------------------------------------------------------>
  150. //0.1上一步
  151. goStyle() {
  152. this.$router.push({
  153. path: '/templateStyle',
  154. query: {
  155. id: this.editId
  156. }
  157. });
  158. },
  159. //0.2下一步
  160. gotoList() {
  161. this.$router.push({
  162. path: '/templateList'
  163. });
  164. },
  165. //0.全局操作 end ------------------------------------------------------------>
  166. //1.模块操作 start ------------------------------------------------------------>
  167. //1.1 移动模块
  168. moveModule(i, moveType) {
  169. this.$store.commit('template/moveModule', { i: i, moveType: moveType });
  170. },
  171. //1.2 删除模块
  172. deleteModule(i, dataSort) {
  173. let data = {
  174. i: i,
  175. dataSort: dataSort
  176. }
  177. this.$store.commit('template/deleteModule', data);
  178. },
  179. //1.3 打开弹出框
  180. openWindow(item) {
  181. this.editModule = item.i;
  182. this.windowStatus = true;
  183. },
  184. //1.4 关闭弹出框
  185. closeWindow() {
  186. this.windowStatus = false;
  187. }
  188. //1.模块操作 end ------------------------------------------------------------>
  189. }
  190. }
  191. </script>
  192. <style scoped lang="less">
  193. //拖拽demo
  194. .droppable-element {
  195. width: 150px;
  196. text-align: center;
  197. background: #fdd;
  198. border: 1px solid black;
  199. margin: 10px 0;
  200. padding: 10px;
  201. }
  202. //模块 start------------------------------------------------------------>
  203. .sectorBorder {
  204. border: 2px dashed #eee;
  205. }
  206. .moduleBox {
  207. display: flex;
  208. width: 100%;
  209. height: 100%;
  210. position: relative;
  211. justify-content: space-between;
  212. box-sizing: border-box;
  213. //border: 2px dashed #eee;
  214. }
  215. .moduleBoxBorder {
  216. border: 2px dashed #eee;
  217. }
  218. //固定的模块
  219. .FixedModuleBox {
  220. width: 100%;
  221. //margin-bottom: 20px;
  222. //border: 2px dashed #eee;
  223. }
  224. .FixedModuleBoxBottom {
  225. width: 100%;
  226. }
  227. .FixedMainModuleBox {
  228. width: 100%;
  229. font-size: 18px;
  230. color: #999;
  231. text-align: center;
  232. img {
  233. margin-bottom: 20px;
  234. }
  235. padding: 100px;
  236. //background: #F5F7FB;
  237. //margin-bottom: 20px;
  238. }
  239. .FixedMainModuleBoxBorder {
  240. border: 2px dashed #eee;
  241. }
  242. //模块 end------------------------------------------------------------>
  243. //栅格布局 start------------------------------------------------------------>
  244. .grid-item-content {
  245. display: flex;
  246. align-items: center;
  247. justify-content: center;
  248. background-color: #fff;
  249. height: 100%;
  250. overflow: hidden;
  251. position: relative;
  252. .grid-tools-menu {
  253. position: absolute;
  254. top: 0;
  255. right:10px;
  256. z-index: 99;
  257. display: flex;
  258. align-items: center;
  259. justify-content: center;
  260. span {
  261. width: 38px;
  262. height: 38px;
  263. line-height: 38px;
  264. text-align: center;
  265. font-size: 30px;
  266. cursor: pointer;
  267. color: #999;
  268. border: 2px dashed #999;
  269. border-radius: 8px;
  270. background-color: #fff1cc;
  271. transition: all 0.3s;
  272. &:hover {
  273. color: #333;
  274. }
  275. }
  276. }
  277. }
  278. .grid-layout {
  279. grid-gap: 0;
  280. row-gap: 0;
  281. }
  282. //画布调整
  283. .canvasBox {
  284. margin-top: 20px;
  285. }
  286. .FixedMainModuleBox {
  287. min-height: 450px;
  288. background-color: #fff;
  289. background: url('../../../assets/template/creat.png') no-repeat center center;
  290. }
  291. .FixedMainModuleBoxAuto {
  292. min-height: 450px;
  293. background-color: #fff;
  294. }
  295. //占位元素颜色
  296. ::v-deep .vue-grid-placeholder {
  297. background: #ccc !important;
  298. opacity: 0.3;
  299. }
  300. //栅格布局 end------------------------------------------------------------>
  301. //执行v-deep穿透scope选择器 start------------------------------------------------------------>*/
  302. ::v-deep .custom-form-item>.el-form-item__label {
  303. line-height: 140px !important;
  304. }
  305. ::v-deep .custom-textarea .el-textarea__inner {
  306. resize: none;
  307. /* 禁止用户拖拽调整大小 */
  308. }
  309. ::v-deep .custom-align-right .el-form-item__label {
  310. text-align: right;
  311. /* 设置标签文字右对齐 */
  312. }
  313. ::v-deep .shadowBox .el-button--mini.is-circle {
  314. border-radius: 50% !important;
  315. }
  316. //执行v-deep穿透scope选择器 end------------------------------------------------------------>*/
  317. </style>