cases.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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/cases/index',
  9. add_url: 'wwh/cases/add',
  10. edit_url: 'wwh/cases/edit',
  11. del_url: 'wwh/cases/del',
  12. multi_url: 'wwh/cases/multi',
  13. table: 'wwh_cases',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'cases.id',
  22. height: $(window).height() - 97,
  23. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'id', title: __('Id'), },
  27. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  28. {field: 'casescategory.name', title: __('Casescategory')},
  29. {field: 'casesname', title: __('Casesname')},
  30. {field: 'c_keywords', title: __('C_keywords')},
  31. {field: 'c_description', title: __('C_description')},
  32. {field: 'indent_image', title: __('Indent_image'), events: Table.api.events.image, formatter: Table.api.formatter.image},
  33. {field: 'time', title: __('Time'), operate:'RANGE', addclass:'datetimerange'},
  34. {field: 'views', title: __('Views')},
  35. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  36. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  37. ]
  38. ],
  39. queryParams: function (params) {
  40. return params;
  41. },
  42. onPostBody: function () {
  43. $(".btn-detailone").data("area", ['90%', '90%']);
  44. }
  45. });
  46. $(function () {
  47. $("#channeltree").jstree({
  48. "themes": {
  49. "stripes": true
  50. },
  51. "checkbox": {
  52. "keep_selected_style": false,
  53. },
  54. "types": {
  55. "channel": {
  56. "icon": "fa fa-th",
  57. },
  58. "list": {
  59. "icon": "fa fa-list",
  60. },
  61. "link": {
  62. "icon": "fa fa-link",
  63. },
  64. "disabled": {
  65. "check_node": false,
  66. "uncheck_node": false
  67. }
  68. },
  69. 'plugins': ["types", "checkbox"],
  70. "core": {
  71. "multiple": false,
  72. 'check_callback': true,
  73. "themes":{
  74. "icons":false,
  75. },
  76. "data": {
  77. url: "wwh/casescategory/getjsTree",
  78. }
  79. }
  80. }).on("select_node.jstree deselect_node.jstree", function (e, data) {
  81. $("#table").bootstrapTable("refresh", {query: {categoryids: data.selected.join(",")}});
  82. });
  83. });
  84. // 为表格绑定事件
  85. Table.api.bindevent(table);
  86. },
  87. add: function () {
  88. Controller.api.bindevent();
  89. },
  90. edit: function () {
  91. Controller.api.bindevent();
  92. },
  93. api: {
  94. bindevent: function () {
  95. Form.api.bindevent($("form[role=form]"));
  96. }
  97. },
  98. };
  99. return Controller;
  100. });