main.ftl 21 KB

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