templateCreat.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <div class="mainBox" v-loading="this.$store.state.template.loading==true" element-loading-text="请稍等">
  3. <!-- 顶部菜单 start ---------------------------------------->
  4. <div class="topMenuBox">
  5. <div>
  6. <el-button icon="el-icon-refresh" type="primary" @click="randomTemplate">
  7. <span v-if="this.$store.state.template.pageStatus == 1">随机生成首页模板</span>
  8. <span v-if="this.$store.state.template.pageStatus == 2">随机生成频道页模板</span>
  9. <span v-if="this.$store.state.template.pageStatus == 3">随机生成列表页模板</span>
  10. <span v-if="this.$store.state.template.pageStatus == 4">随机生成详情页模板</span>
  11. <span v-if="this.$store.state.template.pageStatus == 5">随机生成搜索页模板</span>
  12. <span v-if="this.$store.state.template.pageStatus == 6">随机生成底部列表页模板</span>
  13. <span v-if="this.$store.state.template.pageStatus == 7">随机生成底部详情页模板</span>
  14. </el-button>
  15. </div>
  16. <div class="topMenuRightBox">
  17. <img src="@/assets/template/preview.png" class="previewImg" @click="setPreviewStatus" v-if="this.$store.state.template.previewStatus==false"/>
  18. <img src="@/assets/template/close.png" class="previewImg" @click="setPreviewStatus" v-else/>
  19. <el-button type="primary" @click="saveTemplate">保存</el-button>
  20. <el-button type="info" @click="goStyle">上一步</el-button>
  21. </div>
  22. </div>
  23. <!-- 顶部菜单 end ---------------------------------------->
  24. <!-- 画布 start ---------------------------------------->
  25. <div class="websiteBox">
  26. <div class="pageTabsBox">
  27. <div v-if="this.$store.state.template.showPage.index==true" :class="['pageTabsItem', this.$store.state.template.pageStatus === 1 ? 'active' : '']" @click="openPage(1)">首页</div>
  28. <div v-if="this.$store.state.template.showPage.class==true" :class="['pageTabsItem', this.$store.state.template.pageStatus === 2 ? 'active' : '']" @click="openPage(2)">频道页</div>
  29. <div v-if="this.$store.state.template.showPage.list==true" :class="['pageTabsItem', this.$store.state.template.pageStatus === 3 ? 'active' : '']" @click="openPage(3)">列表页</div>
  30. <div v-if="this.$store.state.template.showPage.article==true" :class="['pageTabsItem', this.$store.state.template.pageStatus === 4 ? 'active' : '']" @click="openPage(4)">详情页</div>
  31. <div v-if="this.$store.state.template.showPage.search==true" :class="['pageTabsItem', this.$store.state.template.pageStatus === 5 ? 'active' : '']" @click="openPage(5)">搜索页</div>
  32. <div v-if="this.$store.state.template.showPage.aloneList==true" :class="['pageTabsItem', this.$store.state.template.pageStatus === 6 ? 'active' : '']" @click="openPage(6)">自定义列表页</div>
  33. <div v-if="this.$store.state.template.showPage.aloneArticle==true" :class="['pageTabsItem', this.$store.state.template.pageStatus === 7 ? 'active' : '']" @click="openPage(7)">自定义详情页</div>
  34. </div>
  35. <pageIndex v-if="this.$store.state.template.pageStatus == 1"/>
  36. <pageList v-if="this.$store.state.template.pageStatus == 3"/>
  37. <pageArticle v-if="this.$store.state.template.pageStatus == 4"/>
  38. </div>
  39. <!-- 画布 end ---------------------------------------->
  40. <!-- 弹出框 start ---------------------------------------->
  41. <!-- 这里我去掉了:visible.sync 因为弹出框的关闭事件需要手动触发 -->
  42. <el-dialog title="编辑组件信息" :visible="this.$store.state.template.editWindowStatus" :close-on-click-modal="false" @close="closeEditWindow" @open="addWindowKey">
  43. <editWindow />
  44. </el-dialog>
  45. <el-dialog title="更换组件样式" :visible="this.$store.state.template.editComponentWindowStatus" :close-on-click-modal="false" @close="closeComponentStyleWindow">
  46. <componentWindow />
  47. </el-dialog>
  48. <el-dialog title="模板检查" :visible="this.$store.state.template.editWebsiteTemplateJsonWindow" :close-on-click-modal="false" @close="closeEditWebsiteTemplateJsonWindow">
  49. <!-- <div class="editWebsiteTemplateJsonBox">
  50. <pre>{{this.$store.state.template.webSiteData}}</pre>
  51. </div>
  52. <div slot="footer" class="dialog-footer">
  53. <div class="footerBtnbox">
  54. <el-button type="primary" @click="gotoList">保存并退出</el-button>
  55. </div>
  56. </div> -->
  57. <checkWindow />
  58. </el-dialog>
  59. <!-- 弹出框 start ---------------------------------------->
  60. </div>
  61. </template>
  62. <script>
  63. //页面公用组件 start------------------------------------------------------------>
  64. import '@/styles/global.less';
  65. import editWindow from './public/editWindow.vue';
  66. import componentWindow from './public/componentWindow.vue';
  67. import checkWindow from './public/checkWindow.vue';
  68. //页面公用组件 end------------------------------------------------------------>
  69. //页面组件 start------------------------------------------------------------>
  70. import pageIndex from './page/pageIndex.vue';
  71. import pageList from './page/pageList.vue';
  72. import pageArticle from './page/pageArticle.vue';
  73. //页面组件 end------------------------------------------------------------>
  74. export default {
  75. components: {
  76. //引入页面组件
  77. pageIndex,
  78. pageList,
  79. pageArticle,
  80. editWindow,
  81. componentWindow,
  82. checkWindow
  83. },
  84. data() {
  85. return {
  86. //0.全局配置 start------------------------------------------------------------>
  87. windowStatus: false,
  88. editPageStatus:1,//当前正在配置的页面 0 首页 1 分类页 2 列表页 3 详情页
  89. websiteId:0,//网站id
  90. style:0,//网站风格
  91. rowHeight:10,
  92. pageStatus:[],
  93. //0.全局配置 end------------------------------------------------------------>
  94. //1.编辑模块 start------------------------------------------------------------>
  95. formLabelWidth: '120px',
  96. //1.编辑模块 end------------------------------------------------------------>
  97. }
  98. },
  99. methods: {
  100. //0.全局操作 start ------------------------------------------------------------>
  101. //上一步
  102. goStyle(){
  103. this.$confirm('返回上一步会导致当前页面数据丢失, 是否继续?', '提示', {
  104. confirmButtonText: '确定',
  105. cancelButtonText: '取消',
  106. type: 'warning'
  107. }).then(() => {
  108. this.$router.push({
  109. path: '/templateStyle',
  110. query: {
  111. website_id:this.$route.query.website_id,
  112. step:this.$route.query.step
  113. }
  114. });
  115. })
  116. },
  117. //保存模板
  118. saveTemplate(){
  119. this.$store.commit('template/saveTemplate');
  120. },
  121. //打开弹出框
  122. openWindow(item) {
  123. this.editModule = item.i;
  124. this.windowStatus = true;
  125. },
  126. //关闭弹出框
  127. closeWindow() {
  128. this.windowStatus = false;
  129. },
  130. //切换编辑的页面
  131. openPage(num){
  132. this.$store.commit('template/setPageStatus',num);
  133. },
  134. //关闭编辑弹出框
  135. closeEditWindow(){
  136. this.$store.commit('template/closeEditWindowStatus');
  137. },
  138. //关闭选择组件样式弹出框
  139. closeComponentStyleWindow(){
  140. this.$store.commit('template/closeComponentStyleStatus');
  141. },
  142. //关闭提交数据弹出框
  143. closeEditWebsiteTemplateJsonWindow(){
  144. this.$store.commit('template/closeEditWebsiteTemplateJsonWindow');
  145. },
  146. //增加级联选择器key
  147. addWindowKey(){
  148. this.$store.commit('template/addWindowKey');
  149. },
  150. //设置预览状态
  151. setPreviewStatus(){
  152. this.$store.commit('template/setPreviewStatus');
  153. },
  154. //随机生成模板
  155. randomTemplate(){
  156. this.$store.commit('template/randomTemplate');
  157. },
  158. //0.全局操作 end ------------------------------------------------------------>
  159. },
  160. mounted(){
  161. //1.设置网站id并且保存到vuex
  162. this.websiteId = this.$route.query.website_id;
  163. this.$store.commit('template/setEditWebsiteId',this.websiteId);
  164. //2.设置网站风格并且保存到vuex
  165. this.style = this.$route.query.style;
  166. this.$store.commit('template/setClassNumber',this.style);
  167. //3.获取网站导航池
  168. this.$store.dispatch('template/getSiteCategory',{website_id:this.websiteId});
  169. //4.获取网站详情
  170. this.$store.dispatch('template/getAdminSiteInfo',{website_id:this.websiteId});
  171. //5.获取网站底部信息
  172. this.$store.dispatch('template/getAdminWebsiteFootAll',{website_id:this.websiteId});
  173. }
  174. }
  175. </script>
  176. <style scoped lang="less">
  177. //顶部菜单
  178. .topMenuBox {
  179. padding: 20px 30px 20px 30px;
  180. display: flex;
  181. align-items: center;
  182. justify-content: space-between;
  183. background: #fff;
  184. .topMenuRightBox {
  185. display: flex;
  186. align-items: center;
  187. cursor: pointer;
  188. .previewImg {
  189. margin-right: 20px;
  190. }
  191. }
  192. }
  193. //拖拽布局容器
  194. .websiteBox {
  195. margin: 60px 30px 30px 30px;
  196. background: #fff;
  197. border: 1px solid #E9EDF7;
  198. -webkit-box-sizing: border-box;
  199. box-sizing: border-box;
  200. position: relative;
  201. /*构建的页面类型*/
  202. .pageTabsBox {
  203. position: absolute;
  204. border-top:1px solid #E9EDF7;
  205. border-left:1px solid #E9EDF7;
  206. border-right:1px solid #E9EDF7;
  207. display: flex;
  208. align-items: center;
  209. top: -37px;
  210. left: -1px;
  211. .pageTabsItem {
  212. padding: 10px 20px;
  213. background: #fff;
  214. font-size: 14px;
  215. color: #666;
  216. border-bottom:1px solid #E9EDF7;
  217. cursor: pointer;
  218. border-right:1px solid #E9EDF7;
  219. }
  220. .active {
  221. border-bottom:1px solid #fff;
  222. background: #fff;
  223. border-right:1px solid #E9EDF7;
  224. }
  225. }
  226. }
  227. //菜单 start------------------------------------------------------------>
  228. // .layerTabsBox {
  229. // margin: 30px;
  230. // border-radius: 20px;
  231. // background: #fff;
  232. // border: 1px solid #d3d3d3;
  233. // -webkit-box-sizing: border-box;
  234. // box-sizing: border-box;
  235. // display: flex;
  236. // align-items: center;
  237. // justify-content: space-between;
  238. // overflow: hidden;
  239. // .layerTabsItem {
  240. // width: 33.33%; /* 每个占3分之一的空间 */
  241. // padding: 10px 20px;
  242. // cursor: pointer;
  243. // text-align: center;
  244. // font-size: 14px;
  245. // border-right: 1px solid #d3d3d3;
  246. // background: #fff;
  247. // }
  248. // .active {
  249. // background: #5570F1;
  250. // color: #fff;
  251. // }
  252. // }
  253. // .layerBox {
  254. // padding-bottom: 10px;
  255. // }
  256. //菜单 end------------------------------------------------------------>
  257. //模块 start------------------------------------------------------------>
  258. .moduleBox {
  259. display: flex;
  260. width: 100%;
  261. height: 100%;
  262. position: relative;
  263. justify-content: space-between;
  264. box-sizing: border-box;
  265. border: 2px dashed #19499F;
  266. }
  267. //模块 end------------------------------------------------------------>
  268. //栅格布局 start------------------------------------------------------------>
  269. .grid-item-content {
  270. display: flex;
  271. align-items: center;
  272. justify-content: center;
  273. background-color: #fff;
  274. height: 100%;
  275. overflow: hidden;
  276. }
  277. .grid-layout {
  278. grid-gap: 0;
  279. row-gap: 0;
  280. }
  281. .vue-grid-placeholder {
  282. background-color: #f0f0f0 !important; /* 更改为你想要的颜色 */
  283. opacity: 0.8;
  284. border: 2px dashed #f0f0f0;
  285. }
  286. //栅格布局 end------------------------------------------------------------>
  287. //执行v-deep穿透scope选择器 start------------------------------------------------------------>*/
  288. ::v-deep .custom-form-item > .el-form-item__label {
  289. line-height: 140px !important;
  290. }
  291. ::v-deep .custom-textarea .el-textarea__inner {
  292. resize: none; /* 禁止用户拖拽调整大小 */
  293. }
  294. ::v-deep .custom-align-right .el-form-item__label {
  295. text-align: right; /* 设置标签文字右对齐 */
  296. }
  297. ::v-deep .shadowBox .el-button--mini.is-circle {
  298. border-radius: 50% !important;
  299. }
  300. //执行v-deep穿透scope选择器 end------------------------------------------------------------>*/
  301. </style>