download.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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/download/index',
  9. add_url: 'wwh/download/add',
  10. edit_url: 'wwh/download/edit',
  11. del_url: 'wwh/download/del',
  12. multi_url: 'wwh/download/multi',
  13. table: 'wwh_download',
  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: 'download.id',
  23. height: $(window).height() - 97,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id'), },
  28. {field: 'downloadcategory.name', title: __('Downloadcategory')},
  29. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  30. {field: 'downloadname', title: __('Downloadname')},
  31. {field: 'time', title: __('Time'), operate:'RANGE', addclass:'datetimerange'},
  32. {field: 'weigh', title: __('Weigh')},
  33. {field: 'attachfile', title: __('Attachfile')},
  34. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  35. ]
  36. ],
  37. queryParams: function (params) {
  38. return params;
  39. },
  40. onPostBody: function () {
  41. $(".btn-detailone").data("area", ['90%', '90%']);
  42. }
  43. });
  44. // 为表格绑定事件
  45. Table.api.bindevent(table);
  46. require(['jstree'], function () {
  47. //全选和展开
  48. $(document).on("click", "#checkall", function () {
  49. $("#channeltree").jstree($(this).prop("checked") ? "check_all" : "uncheck_all");
  50. });
  51. $(document).on("click", "#expandall", function () {
  52. $("#channeltree").jstree($(this).prop("checked") ? "open_all" : "close_all");
  53. });
  54. $('#channeltree').on("changed.jstree", function (e, data) {
  55. console.log(data);
  56. console.log(data.selected);
  57. var options = table.bootstrapTable('getOptions');
  58. options.pageNumber = 1;
  59. options.queryParams = function (params) {
  60. params.filter = JSON.stringify(data.selected.length > 0 ? {downloadcategoryid: data.selected.join(",")} : {});
  61. params.op = JSON.stringify(data.selected.length > 0 ? {downloadcategoryid: 'in'} : {});
  62. return params;
  63. };
  64. table.bootstrapTable('refresh', {});
  65. return false;
  66. });
  67. $('#channeltree').jstree({
  68. "themes": {
  69. "stripes": true
  70. },
  71. "checkbox": {
  72. "keep_selected_style": false,
  73. },
  74. "types": {
  75. "channel": {
  76. "icon": "fa fa-th",
  77. },
  78. "list": {
  79. "icon": "fa fa-list",
  80. },
  81. "link": {
  82. "icon": "fa fa-link",
  83. },
  84. "disabled": {
  85. "check_node": false,
  86. "uncheck_node": false
  87. }
  88. },
  89. 'plugins': ["types", "checkbox"],
  90. "core": {
  91. "multiple": true,
  92. 'check_callback': true,
  93. "themes":{
  94. "icons":false,
  95. },
  96. "data": {
  97. url: "wwh/downloadcategory/getjsTree",
  98. }
  99. }
  100. });
  101. });
  102. },
  103. add: function () {
  104. Controller.api.bindevent();
  105. },
  106. edit: function () {
  107. Controller.api.bindevent();
  108. },
  109. api: {
  110. bindevent: function () {
  111. Form.api.bindevent($("form[role=form]"));
  112. }
  113. },
  114. };
  115. return Controller;
  116. });