main.ftl 19 KB

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