news.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'jstree'], function ($, undefined, Backend, Table, Form, jstree) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-detail").data("area", ['90%', '90%']);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'wwh/news/index',
  9. add_url: 'wwh/news/add',
  10. edit_url: 'wwh/news/edit',
  11. del_url: 'wwh/news/del',
  12. multi_url: 'wwh/news/multi',
  13. table: 'wwh_news',
  14. dragsort_url:'',
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'news.id',
  23. height: $(window).height() - 97,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id'), },
  28. {field: 'newscategory.name', title: __('Newscategory')},
  29. {field: 'newsname', title: __('Newsname')},
  30. {field: 'n_keywords', title: __('N_keywords')},
  31. {field: 'n_description', title: __('N_description')},
  32. {
  33. field: 'summary', sortable: false, title: __('Summary'), formatter: function (value, row, index) {
  34. var width = this.width != undefined ? this.width : 250;
  35. return "<div style='white-space: nowrap; text-overflow:ellipsis; overflow: hidden; max-width:" + width + "px;'>" + value + "</div>";
  36. }
  37. },
  38. {field: 'tjdata', title: __('Tjdata'), searchList: {"0":__('Tjdata 0'),"1":__('Tjdata 1')}, formatter: Table.api.formatter.normal},
  39. {field: 'image', title: __('Image'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
  40. {field: 'weigh', title: __('Weigh'), sortable: true,cellStyle: function () {return {css: {"min-width": "65px"}}}},
  41. {field: 'time', title: __('Time'), operate:'RANGE', addclass:'datetimerange', sortable: true},
  42. {field: 'views', title: __('Views')},
  43. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  44. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  45. ]
  46. ],
  47. queryParams: function (params) {
  48. return params;
  49. },
  50. onPostBody: function () {
  51. $(".btn-detailone").data("area", ['90%', '90%']);
  52. }
  53. });
  54. $(function () {
  55. $("#channeltree").jstree({
  56. "themes": {
  57. "stripes": true
  58. },
  59. "checkbox": {
  60. "keep_selected_style": false,
  61. },
  62. "types": {
  63. "channel": {
  64. "icon": "fa fa-th",
  65. },
  66. "list": {
  67. "icon": "fa fa-list",
  68. },
  69. "link": {
  70. "icon": "fa fa-link",
  71. },
  72. "disabled": {
  73. "check_node": false,
  74. "uncheck_node": false
  75. }
  76. },
  77. 'plugins': ["types", "checkbox"],
  78. "core": {
  79. "multiple": false,
  80. 'check_callback': true,
  81. "themes":{
  82. "icons":false,
  83. },
  84. "data": {
  85. url: "wwh/newscategory/getjsTree",
  86. }
  87. }
  88. }).on("select_node.jstree deselect_node.jstree", function (e, data) {
  89. $("#table").bootstrapTable("refresh", {query: {categoryids: data.selected.join(",")}});
  90. });
  91. });
  92. // 为表格绑定事件
  93. Table.api.bindevent(table);
  94. },
  95. add: function () {
  96. Controller.api.bindevent();
  97. },
  98. edit: function () {
  99. Controller.api.bindevent();
  100. },
  101. api: {
  102. bindevent: function () {
  103. Form.api.bindevent($("form[role=form]"));
  104. }
  105. },
  106. };
  107. return Controller;
  108. });