main.ftl 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>文章主体</title>
  5. <#include "../../include/head-file.ftl">
  6. <#include "../../include/increase-search.ftl">
  7. </head>
  8. <body>
  9. <div id="main" class="ms-index" v-cloak>
  10. <ms-search ref="search" @search="search" :condition-data="conditionList" :conditions="conditions"></ms-search>
  11. <el-header class="ms-header" height="50px">
  12. <el-col :span="12">
  13. <@shiro.hasPermission name="cms:content:save">
  14. <el-button type="primary" icon="el-icon-plus" size="mini" @click="save()">新增</el-button>
  15. </@shiro.hasPermission>
  16. <@shiro.hasPermission name="cms:content:del">
  17. <el-button type="danger" icon="el-icon-delete" size="mini" @click="del(selectionList)" :disabled="!selectionList.length">删除</el-button>
  18. </@shiro.hasPermission>
  19. </el-col>
  20. </el-header>
  21. <div class="ms-search">
  22. <el-row>
  23. <el-form :model="form" ref="searchForm" label-width="120px" size="mini">
  24. <el-row>
  25. <el-col :span="8">
  26. <el-form-item label="文章标题" prop="contentTitle">
  27. <el-input v-model="form.contentTitle"
  28. :disabled="false"
  29. :style="{width: '100%'}"
  30. :clearable="true"
  31. placeholder="请输入文章标题">
  32. </el-input>
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="8">
  36. <el-form-item label="文章类型" prop="contentType">
  37. <el-select v-model="form.contentType"
  38. :style="{width: '100%'}"
  39. :filterable="false"
  40. :disabled="false"
  41. :multiple="true" :clearable="true"
  42. placeholder="请选择文章类型">
  43. <el-option v-for='item in contentTypeOptions' :key="item.dictValue" :value="item.dictValue"
  44. :label="item.dictLabel"></el-option>
  45. </el-select>
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="8" style="text-align: right;padding-right: 10px;">
  49. <el-button type="primary" icon="el-icon-search" size="mini" @click="form.sqlWhere=null;currentPage=1;list()">查询</el-button>
  50. <el-button @click="rest" icon="el-icon-refresh" size="mini">重置</el-button>
  51. <el-button type="primary"size="mini" @click="$refs.search.open()"><i class="iconfont icon-shaixuan"></i>筛选</el-button>
  52. </el-col>
  53. </el-row>
  54. </el-form>
  55. </el-row>
  56. </div>
  57. <el-main class="ms-container">
  58. <el-table height="calc(100vh - 68px)" v-loading="loading" ref="multipleTable" border :data="dataList" tooltip-effect="dark" @selection-change="handleSelectionChange">
  59. <template slot="empty">
  60. {{emptyText}}
  61. </template>
  62. <el-table-column type="selection" width="40"></el-table-column>
  63. <el-table-column label="栏目名" align="left" prop="contentCategoryId" :formatter="contentCategoryIdFormat" width="100">
  64. </el-table-column>
  65. <el-table-column label="文章标题" align="left" prop="contentTitle" show-overflow-tooltip>
  66. </el-table-column>
  67. <el-table-column label="作者" align="left" prop="contentAuthor" width="100" show-overflow-tooltip>
  68. </el-table-column>
  69. <el-table-column label="排序" width="55" align="right" prop="contentSort">
  70. </el-table-column>
  71. <el-table-column label="点击" width="55" align="right" prop="contentHit">
  72. <template slot-scope="scope">
  73. {{scope.row.contentHit?scope.row.contentHit:0}}
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="发布时间" align="center" prop="contentDatetime" :formatter="dateFormat" width="120">
  77. </el-table-column>
  78. <el-table-column label="操作" width="120" align="center">
  79. <template slot-scope="scope">
  80. <@shiro.hasPermission name="cms:content:update">
  81. <el-link type="primary" :underline="false" @click="save(scope.row.id)">编辑</el-link>
  82. </@shiro.hasPermission>
  83. <@shiro.hasPermission name="cms:content:del">
  84. <el-link type="primary" :underline="false" @click="del([scope.row])">删除</el-link>
  85. </@shiro.hasPermission>
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. <el-pagination
  90. background
  91. :page-sizes="[10,20,30,40,50,100]"
  92. layout="total, sizes, prev, pager, next, jumper"
  93. :current-page="currentPage"
  94. :page-size="pageSize"
  95. :total="total"
  96. class="ms-pagination"
  97. @current-change='currentChange'
  98. @size-change="sizeChange">
  99. </el-pagination>
  100. </el-main>
  101. </div>
  102. </body>
  103. </html>
  104. <script>
  105. var indexVue = new Vue({
  106. el: '#main',
  107. data:{
  108. conditionList:[
  109. {action:'and', field: 'content_title', el: 'eq', model: 'contentTitle', name: '文章标题', type: 'input'},
  110. {action:'and', field: 'content_category_id', el: 'eq', model: 'contentCategoryId', name: '所属栏目', type: 'cascader', multiple: false},
  111. {action:'and', field: 'content_type', el: 'eq', model: 'contentType', name: '文章类型', type: 'checkbox', label: false, multiple: true},
  112. {action:'and', field: 'content_display', el: 'eq', model: 'contentDisplay', name: '是否显示', type: 'radio', label: true, multiple: false},
  113. {action:'and', field: 'content_author', el: 'eq', model: 'contentAuthor', name: '文章作者', type: 'input'},
  114. {action:'and', field: 'content_source', el: 'eq', model: 'contentSource', name: '文章来源', type: 'input'},
  115. {action:'and', field: 'content_datetime', model: 'contentDatetime', el: 'gt', name: '发布时间', type: 'date'},
  116. {action:'and', field: 'content_sort', el: 'eq', model: 'contentSort', name: '自定义顺序', type: 'number'},
  117. {action:'and', field: 'content_description', el: 'eq', model: 'contentDescription', name: '描述', type: 'textarea'},
  118. {action:'and', field: 'content_keyword', el: 'eq', model: 'contentKeyword', name: '关键字', type: 'textarea'},
  119. {action:'and', field: 'content_details', el: 'like', model: 'contentDetails', name: '文章内容', type: 'input'},
  120. {action:'and', field: 'content_url', el: 'eq', model: 'contentUrl', name: '文章跳转链接地址', type: 'input'},
  121. {action:'and', field: 'appid', el: 'eq', model: 'appid', name: '文章管理的应用id', type: 'number'},
  122. {action:'and', field: 'create_date', el: 'eq', model: 'createDate', name: '创建时间', type: 'date'},
  123. {action:'and', field: 'update_date', el: 'eq', model: 'updateDate', name: '修改时间', type: 'date'},
  124. ],
  125. conditions:[],
  126. contentCategoryIdOptions:[],
  127. dataList: [], //文章列表
  128. selectionList:[],//文章列表选中
  129. total: 0, //总记录数量
  130. pageSize: 10, //页面数量
  131. currentPage:1, //初始页
  132. manager: ms.manager,
  133. loadState:false,
  134. loading: true,//加载状态
  135. emptyText:'',//提示文字
  136. contentTypeOptions:[],
  137. contentDisplayOptions:[{"value":"0","label":"是"},{"value":"1","label":"否"}],
  138. //搜索表单
  139. form:{
  140. sqlWhere:null,
  141. // 文章标题
  142. contentTitle:null,
  143. // 文章类型
  144. contentType:null,
  145. contentCategoryId:'',
  146. },
  147. },
  148. methods:{
  149. //查询列表
  150. list: function() {
  151. var that = this;
  152. that.loading = true;
  153. that.loadState = false;
  154. var page={
  155. pageNo: that.currentPage,
  156. pageSize : that.pageSize
  157. }
  158. var form = JSON.parse(JSON.stringify(that.form))
  159. if(form.contentType.length > 0){
  160. form.contentType = form.contentType.join(',');
  161. }
  162. for (key in form){
  163. if(!form[key]){
  164. delete form[key]
  165. }
  166. }
  167. history.replaceState({form:form,page:page},"");
  168. ms.http.post(ms.manager+"/cms/content/list.do",form.sqlWhere?{
  169. sqlWhere:form.sqlWhere,
  170. ...page
  171. }:{...form,
  172. ...page
  173. }).then(
  174. function(res) {
  175. if(that.loadState){
  176. that.loading = false;
  177. }else {
  178. that.loadState = true
  179. }
  180. if (!res.result||res.data.total <= 0) {
  181. that.emptyText = '暂无数据'
  182. that.dataList = [];
  183. that.total = 0;
  184. } else {
  185. that.emptyText = '';
  186. that.total = res.data.total;
  187. that.dataList = res.data.rows;
  188. }
  189. }).catch(function(err) {
  190. that.loading = false;
  191. console.log(err);
  192. });
  193. setTimeout(()=>{
  194. if(that.loadState){
  195. that.loading = false;
  196. }else {
  197. that.loadState = true
  198. }
  199. }, 500);
  200. },
  201. //文章列表选中
  202. handleSelectionChange:function(val){
  203. this.selectionList = val;
  204. },
  205. //删除
  206. del: function(row){
  207. var that = this;
  208. that.$confirm('此操作将永久删除所选内容, 是否继续?', '提示', {
  209. confirmButtonText: '确定',
  210. cancelButtonText: '取消',
  211. type: 'warning'
  212. }).then(() => {
  213. ms.http.post(ms.manager+"/cms/content/delete.do", row.length?row:[row],{
  214. headers: {
  215. 'Content-Type': 'application/json'
  216. }
  217. }).then(
  218. function(res){
  219. if (res.result) {
  220. that.$notify({
  221. type: 'success',
  222. message: '删除成功!'
  223. });
  224. //删除成功,刷新列表
  225. that.list();
  226. }
  227. });
  228. }).catch(() => {
  229. that.$notify({
  230. type: 'info',
  231. message: '已取消删除'
  232. });
  233. });
  234. },
  235. //新增
  236. save:function(id){
  237. if(id){
  238. location.href=this.manager+"/cms/content/form.do?id="+id;
  239. }else {
  240. location.href=this.manager+"/cms/content/form.do";
  241. }
  242. },
  243. //表格数据转换
  244. contentCategoryIdFormat(row, column, cellValue, index){
  245. var value="";
  246. if(cellValue){
  247. var data = this.contentCategoryIdOptions.find(function(value){
  248. return value.id==cellValue;
  249. })
  250. if(data&&data.categoryTitle){
  251. value = data.categoryTitle;
  252. }
  253. }
  254. return value;
  255. },
  256. dateFormat: function(row, column, cellValue, index){
  257. if(cellValue){
  258. return ms.util.date.fmt(cellValue,'yyyy-MM-dd');
  259. } else {
  260. return ''
  261. }
  262. },
  263. contentDisplayFormat(row, column, cellValue, index){
  264. var value="";
  265. if(cellValue){
  266. var data = this.contentDisplayOptions.find(function(value){
  267. return value.value==cellValue;
  268. })
  269. if(data&&data.label){
  270. value = data.label;
  271. }
  272. }
  273. return value;
  274. },
  275. //pageSize改变时会触发
  276. sizeChange:function(pagesize) {
  277. this.loading = true;
  278. this.pageSize = pagesize;
  279. this.list();
  280. },
  281. //currentPage改变时会触发
  282. currentChange:function(currentPage) {
  283. this.loading = true;
  284. this.currentPage = currentPage;
  285. this.list();
  286. },
  287. search(data){
  288. this.form.sqlWhere = JSON.stringify(data);
  289. this.list();
  290. },
  291. //重置表单
  292. rest(){
  293. this.form.sqlWhere = null;
  294. this.$refs.searchForm.resetFields();
  295. this.list();
  296. },
  297. //获取contentCategoryId数据源
  298. contentCategoryIdOptionsGet() {
  299. var that = this;
  300. ms.http.get(ms.manager+"/cms/category/list.do",{pageSize:9999}).then(function(res){
  301. if(res.result){
  302. that.contentCategoryIdOptions = res.data.rows;
  303. }
  304. that.list();
  305. }).catch(function(err){
  306. console.log(err);
  307. });
  308. },
  309. //获取contentType数据源
  310. contentTypeOptionsGet() {
  311. var that = this;
  312. ms.http.get(ms.base+'/mdiy/dict/list.do', {dictType:'文章属性',pageSize:99999}).then(function (data) {
  313. that.contentTypeOptions = data.rows;
  314. }).catch(function (err) {
  315. console.log(err);
  316. });
  317. },
  318. },
  319. mounted(){
  320. this.contentCategoryIdOptionsGet();
  321. this.contentTypeOptionsGet();
  322. this.form.contentCategoryId = ms.util.getParameter("categoryId")
  323. if(history.state){
  324. this.form = history.state.form;
  325. this.currentPage = history.state.page.pageNo;
  326. this.pageSize = history.state.page.pageSize;
  327. }
  328. },
  329. })
  330. </script>
  331. <style>
  332. #main .ms-search {
  333. padding: 20px 0 0;
  334. }
  335. #main .ms-container {
  336. height: calc(100vh - 141px);
  337. }
  338. body{
  339. overflow: hidden;
  340. }
  341. </style>