pageList.vue 11 KB

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