main.ftl 19 KB

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