pageArticle.vue 11 KB

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