main.ftl 15 KB

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