basedata.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'basedata/index' + location.search,
  8. add_url: 'basedata/add',
  9. edit_url: 'basedata/edit',
  10. del_url: 'basedata/del',
  11. multi_url: 'basedata/multi',
  12. import_url: 'basedata/import',
  13. table: 'basedata',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'id',
  22. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id')},
  26. {field: 'name', title: __('Name'), operate: 'LIKE'},
  27. {field: 'key', title: __('Key'), operate: 'LIKE'},
  28. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  29. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  30. {field: 'operate', title: __('Operate'), table: table,
  31. buttons:[
  32. {
  33. name:'del',
  34. text:'删除',
  35. title:'删除',
  36. icon:'fa fa-exclamation-circle',
  37. classname:'btn btn-xs btn-danger btn-ajax',
  38. url:'basedata/del/ids/{ids}?dialog=1',
  39. target:'_self',
  40. refresh:true,
  41. hidden:function(row){
  42. return row.id > 4 ? false : true;
  43. }
  44. }
  45. ],
  46. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  47. ]
  48. ]
  49. });
  50. // 为表格绑定事件
  51. Table.api.bindevent(table);
  52. },
  53. add: function () {
  54. Controller.api.bindevent();
  55. },
  56. edit: function () {
  57. Controller.api.bindevent();
  58. },
  59. api: {
  60. bindevent: function () {
  61. Form.api.bindevent($("form[role=form]"));
  62. }
  63. }
  64. };
  65. return Controller;
  66. });