pageAboutArticle.vue 9.1 KB

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