index.ftl 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>文章</title>
  6. <#include "../../include/head-file.ftl">
  7. <#include "/cms/content/form.ftl">
  8. <#include "/cms/content/list.ftl">
  9. </head>
  10. <body style="overflow: hidden">
  11. <div id="index" v-cloak>
  12. <!--左侧-->
  13. <el-container class="index-menu">
  14. <div class="left-tree" style="position:relative;">
  15. <el-scrollbar style="height: 100%;">
  16. <el-tree
  17. ref="treeRef"
  18. :indent="5"
  19. node-key="id"
  20. v-loading="loading"
  21. highlight-current
  22. :expand-on-click-node="false"
  23. default-expand-all
  24. :empty-text="emptyText"
  25. :data="treeData"
  26. :props="defaultProps"
  27. @node-click="handleNodeClick"
  28. style="padding: 10px;height: 100%;">
  29. <template #default="{ node, data }" >
  30. <span class="custom-tree-node" >
  31. <span :style="data.categoryType == '3' ? 'color: #dcdfe6' : ''" :title="data.categoryTitle">{{ data.categoryTitle }}</span>
  32. </span>
  33. </template>
  34. </el-tree>
  35. </el-scrollbar>
  36. </div>
  37. <content-list v-if="action=='list'" :category-id="categoryId" :leaf=leaf @form="form"></content-list>
  38. <content-form v-else :category-id="categoryId" :category-type="categoryType" :id="id" @back="back"></content-form>
  39. </el-container>
  40. </div>
  41. </body>
  42. </html>
  43. <script>
  44. var indexVue = new _Vue({
  45. el: "#index",
  46. components:{
  47. "content-list": contentList,
  48. "content-form": contentForm
  49. },
  50. data: function () {
  51. return {
  52. action: 'list',
  53. categoryId:'', //栏目id
  54. categoryType:'2', //1列表,2单篇
  55. leaf:true, //true子栏目
  56. id:null,//文章编号
  57. defaultProps: {
  58. children: 'children',
  59. label: 'categoryTitle'
  60. },
  61. treeData: [],
  62. loading: true,
  63. emptyText: '',
  64. historyKey:"cms_content_history"
  65. }
  66. },
  67. watch:{
  68. },
  69. methods: {
  70. handleNodeClick: function (data) {
  71. if(data.id == 0) { //全部
  72. this.action = 'list';
  73. this.categoryId = 0;
  74. this.leaf = true;
  75. } else if (data.categoryType == '1') {
  76. this.action = 'list';
  77. this.categoryId = data.id;
  78. this.leaf = data.leaf;
  79. } else if(data.categoryType == '3'){
  80. this.$refs.treeRef.setCurrentKey(null);
  81. return;
  82. } else {
  83. this.id = null;
  84. this.action = 'form';
  85. this.categoryId = data.id;
  86. this.categoryType = data.categoryType;
  87. }
  88. //新增数据重置到列表第一页
  89. sessionStorage.setItem(this.historyKey,JSON.stringify({form:{}, page: {pageNo:1}}));
  90. },
  91. form: function(id) {
  92. this.action = 'form';
  93. this.id = id;
  94. this.categoryType = "1"; //列表
  95. },
  96. back: function(id) {
  97. this.action = 'list';
  98. },
  99. treeList: function () {
  100. var that = this;
  101. this.loadState = false;
  102. this.loading = true;
  103. ms.http.get(ms.manager + "/cms/category/list.do").then(function (res) {
  104. if (that.loadState) {
  105. that.loading = false;
  106. } else {
  107. that.loadState = true;
  108. }
  109. if (!res.result || res.data.total <= 0) {
  110. that.emptyText = '暂无数据';
  111. that.treeData = [];
  112. } else {
  113. that.emptyText = '';
  114. that.treeData = res.data.rows;
  115. that.treeData = ms.util.treeData(that.treeData, 'id', 'categoryId', 'children');
  116. that.treeData = [{
  117. id: 0,
  118. categoryTitle: '全部',
  119. children: that.treeData
  120. }];
  121. }
  122. });
  123. setTimeout(function () {
  124. if (that.loadState) {
  125. that.loading = false;
  126. } else {
  127. that.loadState = true;
  128. }
  129. }, 500);
  130. }
  131. },
  132. mounted: function () {
  133. this.treeList();
  134. },
  135. created:function (){
  136. //默认列表第一页
  137. sessionStorage.setItem(this.historyKey,JSON.stringify({form:{}, page: {pageNo:1}}));
  138. },
  139. });
  140. </script>
  141. <style scoped>
  142. #index .index-menu {
  143. height: 100vh;
  144. min-height: 100vh;
  145. min-width: 140px;
  146. }
  147. #index .ms-iframe-style {
  148. width: 100%;
  149. height: 100vh;
  150. border: 0;
  151. }
  152. /*脚手架需要此样式*/
  153. #index >>> .ms-iframe-style {
  154. height: 92vh;
  155. }
  156. #index >>> .ms-index {
  157. height: 100vh;
  158. }
  159. #index .left-tree{
  160. min-height: 100vh;
  161. background: #fff;
  162. width: 220px;
  163. border-right: solid 1px #e6e6e6;
  164. flex-shrink: 0;
  165. }
  166. #index .index-menu .el-main .index-menu-menu .el-menu-item {
  167. min-width: 140px;
  168. width: 100%;
  169. }
  170. #index .index-menu .el-main .index-material-item {
  171. min-width: 100% !important
  172. }
  173. #index .index-menu-menu-item , .el-submenu__title {
  174. height: 40px !important;
  175. line-height: 46px !important;
  176. }
  177. #index .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content {
  178. background-color: rgb(137 140 145);
  179. color: #fff;
  180. border-radius: 2px;
  181. }
  182. body{
  183. overflow: hidden;
  184. }
  185. </style>