templateBase.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div class="mainBox">
  3. <div class="layerBox">
  4. <tableTitle :name="templateStepTitle" />
  5. <step :activeNumber="1" />
  6. </div>
  7. <el-form ref="form" :model="form" class="login-form" autocomplete="on" label-position="left" label-width="120px">
  8. <div class="layerBox">
  9. <tableTitle :name="templateBaseTitle" />
  10. <div class="formDiv">
  11. <el-form-item label="常规模板类型:" :label-width="formLabelWidth" prop="role_id"
  12. class="custom-align-right">
  13. <div class="formLabelFloatBox">
  14. <el-checkbox-group v-model="form.page_type">
  15. <el-checkbox label="1" disabled>首页</el-checkbox>
  16. <el-checkbox label="2" disabled>频道页</el-checkbox>
  17. <el-checkbox label="3" disabled>列表页</el-checkbox>
  18. <el-checkbox label="4" disabled>详情页</el-checkbox>
  19. <el-checkbox label="5">搜索页</el-checkbox>
  20. </el-checkbox-group>
  21. </div>
  22. </el-form-item>
  23. <el-form-item :label="null" :label-width="formLabelWidth" class="custom-align-right">
  24. <div class="formLabelFloatBox">
  25. <div class="labelTitleStyle">
  26. 单页模板类型:
  27. <el-tooltip class="item" effect="dark" content="该类型仅供底部导航栏使用" placement="top">
  28. <i class="el-icon-question"></i>
  29. </el-tooltip>
  30. </div>
  31. <el-checkbox-group v-model="form.page_type">
  32. <el-checkbox label="6" disabled>底部菜单列表页</el-checkbox>
  33. <el-checkbox label="7" disabled>底部菜单详情页</el-checkbox>
  34. </el-checkbox-group>
  35. </div>
  36. </el-form-item>
  37. </div>
  38. </div>
  39. <div class="layerBox">
  40. <tableTitle :name="templateInfoTitle" />
  41. <div class="formDiv">
  42. <el-form-item :label="null" :label-width="formLabelWidth" prop="role_id"
  43. class="custom-align-right">
  44. <div class="formLabelFloatBox">
  45. <div class="labelTitleStyle">
  46. 底部导航菜单展示:
  47. <el-tooltip class="item" effect="dark" content="如需修改,请去其他设置-单页中进行修改/添加。" placement="top">
  48. <i class="el-icon-question"></i>
  49. </el-tooltip>
  50. </div>
  51. <el-checkbox-group v-model="form.singlePage">
  52. <el-checkbox label="1" disabled v-for="item in pageData.footer_category">{{item.name}}</el-checkbox>
  53. </el-checkbox-group>
  54. </div>
  55. </el-form-item>
  56. </div>
  57. </div>
  58. <div class="layerBox">
  59. <tableTitle :name="templateInfoTitle2" />
  60. <div class="formDiv">
  61. <el-form-item :label="null" :label-width="formLabelWidth" prop="role_id"
  62. class="custom-align-right">
  63. <div class="formLabelFloatBox">
  64. <div class="labelTitleStyle">
  65. 友情链接:
  66. <el-tooltip class="item" effect="dark" content="如需修改,请去其他设置-友情链接中进行修改/添加。" placement="top">
  67. <i class="el-icon-question"></i>
  68. </el-tooltip>
  69. </div>
  70. <el-checkbox-group v-model="form.singlePage" class="linkBox">
  71. <div class="linkItem" v-for="(item,index) in pageData.friend_link" :key="index">
  72. <div><el-checkbox :label="index" :checked="true" disabled>{{item.title}}</el-checkbox></div>
  73. <img :src="item.logo_url">
  74. <div class="linkUrl">{{item.url}}</div>
  75. </div>
  76. </el-checkbox-group>
  77. </div>
  78. </el-form-item>
  79. </div>
  80. </div>
  81. </el-form>
  82. <div class="bottomBtnBox">
  83. <el-button type="info" @click="goToWebsite">退出</el-button>
  84. <el-button type="primary" @click="addData">下一步</el-button>
  85. </div>
  86. </div>
  87. </template>
  88. <script>
  89. // 引入公用样式
  90. import '@/styles/global.less';
  91. //表格标题
  92. import tableTitle from './public/tableTitle';
  93. //步骤条
  94. import step from './public/step';
  95. export default {
  96. components: {
  97. tableTitle,//表格标题
  98. step//步骤条
  99. },
  100. data() {
  101. // 配置验证规则:用于表单验证
  102. const validateEmpty = (rule, value, callback) => {
  103. if (value.length == 0) {
  104. callback(new Error('该项不能为空!'))
  105. } else {
  106. callback()
  107. }
  108. }
  109. return {
  110. templateStepTitle: "仅需四步,即可完成模板创建",
  111. templateBaseTitle: "网站页面类型设置",
  112. templateInfoTitle: "单页设置",
  113. templateInfoTitle2: "友情链接设置",
  114. formLabelWidth: "120px",
  115. editId: "",
  116. form: {
  117. website_id: "",//网站id
  118. page_type: ["1", "2", "3", "4", "6", "7"],//页面类型
  119. singlePage: ["1", "2", "3", "4", "5"],//单页类型
  120. },
  121. pageData:{}
  122. };
  123. },
  124. methods: {
  125. //0.全局操作 start ------------------------------------------------------------>
  126. //上一步
  127. goToWebsite() {
  128. this.$router.push({
  129. path: '/templateList'
  130. });
  131. },
  132. //下一步
  133. goToStyle() {
  134. //先判断表达能否提交
  135. this.$refs.form.validate(valid => {
  136. if (valid) {
  137. }
  138. })
  139. this.$router.push({
  140. path: '/templateStyle',
  141. query: {
  142. id: this.editId
  143. }
  144. });
  145. },
  146. //0.全局操作 end ------------------------------------------------------------>
  147. //1.提交表单 start ------------------------------------------------------------>
  148. //1.1提交表单
  149. addData() {
  150. let data = {}
  151. //判断form.page_type中是否含有5
  152. if (this.form.page_type.includes("5")) {
  153. console.log("含有5")
  154. data.website_id = this.$route.query.website_id,
  155. data.is_search = 1;
  156. }else{
  157. console.log("不含有5")
  158. data.website_id = this.$route.query.website_id,
  159. data.is_search = 0;
  160. }
  161. this.$store.dispatch('template/addWebPageType',data).then(res => {
  162. if (res.code == 200) {
  163. this.$router.push({
  164. path: '/templateStyle',
  165. query: {
  166. website_id: this.$route.query.website_id
  167. }
  168. });
  169. } else {
  170. this.$message.error(res.message);
  171. }
  172. })
  173. },
  174. //1.2回显数据
  175. getWebsiteBase(website_id) {
  176. this.$store.dispatch('template/getWebPageType', { website_id: this.$route.query.website_id }).then(res => {
  177. if (res.code == 200) {
  178. this.pageData = res.data;
  179. if(res.data.page_type==0){
  180. console.log("用户未使用搜索页!")
  181. this.form.page_type = ["1", "2", "3", "4", "6", "7"];
  182. }else{
  183. console.log("用户已启用搜索页!")
  184. this.form.page_type = ["1", "2", "3", "4", "5", "6", "7"];
  185. }
  186. } else {
  187. this.$message.error(res.message);
  188. }
  189. })
  190. },
  191. //1.提交表单 end ------------------------------------------------------------>
  192. },
  193. mounted() {
  194. //1.展示步骤
  195. this.$store.commit('template/showStepStatus');
  196. //2.判断是新建还是回显
  197. this.getWebsiteBase();
  198. }
  199. };
  200. </script>
  201. <style scoped lang="less">
  202. .labelTitleStyle {
  203. font-size: 14px;
  204. color: #606266;
  205. font-weight: bold;
  206. }
  207. .exampleBox {
  208. border: 1px solid #ccc;
  209. }
  210. .formDiv {
  211. background: #F5F7FB;
  212. padding: 10px 20px 10px 20px;
  213. }
  214. .uploaderBox .avatar-uploader {
  215. background: #fff;
  216. }
  217. .linkBox {
  218. display: flex;
  219. align-items: center;
  220. .linkItem:nth-child(1) {
  221. text-align: left;
  222. width: 160px;
  223. .linkUrl {
  224. text-align: left;
  225. }
  226. img {
  227. display: block;
  228. width: 120px;
  229. height: 50px;
  230. margin-left: 0;
  231. }
  232. }
  233. .linkItem {
  234. text-align: center;
  235. width: 200px;
  236. padding-right: 20px;
  237. .linkUrl {
  238. font-size: 12px;
  239. color: #999;
  240. text-align: center;
  241. }
  242. img {
  243. display: block;
  244. width: 120px;
  245. height: 50px;
  246. margin: 0 auto;
  247. }
  248. }
  249. }
  250. ::v-deep .formDiv .el-form-item:last-child {
  251. margin-bottom: 0 !important;
  252. }
  253. ::v-deep .formDiv .el-form-item__content {
  254. margin-left: 0 !important;
  255. }
  256. ::v-deep .formDiv .el-form-item__label {
  257. float: none;
  258. }
  259. //执行v-deep穿透scope选择器 start------------------------------------------------------------>*/
  260. ::v-deep .custom-form-item>.el-form-item__label {
  261. line-height: 140px !important;
  262. }
  263. ::v-deep .custom-textarea .el-textarea__inner {
  264. resize: none;
  265. /* 禁止用户拖拽调整大小 */
  266. }
  267. ::v-deep .custom-align-right .el-form-item__label {
  268. text-align: right;
  269. /* 设置标签文字右对齐 */
  270. }
  271. ::v-deep .el-select {
  272. width: 100%;
  273. /* 禁止用户拖拽调整大小 */
  274. }
  275. //执行v-deep穿透scope选择器 end------------------------------------------------------------>*/
  276. </style>