jiuyezixun.js 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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: 'jiuyezixun/index' + location.search,
  8. add_url: 'jiuyezixun/add',
  9. edit_url: 'jiuyezixun/edit',
  10. del_url: 'jiuyezixun/del',
  11. multi_url: 'jiuyezixun/multi',
  12. import_url: 'jiuyezixun/import',
  13. table: 'jiuyezixun',
  14. dragsort_url: false,
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'weigh',
  23. search: false,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
  29. {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  30. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  31. // {field: 'content', title: __('Content')},
  32. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  33. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  34. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
  35. {field: 'weigh', title: __('Weigh'), operate: false},
  36. {field: 'operate', title: __('Operate'), table: table,
  37. buttons:[
  38. {
  39. name:'yulan',
  40. text:'预览',
  41. title:'预览',
  42. icon:'fa fa-exclamation-circle',
  43. classname:'btn btn-xs btn-info btn-yulan btn-dialog',
  44. url:'jiuyezixun/yulan/id/{ids}?dialog=1',
  45. target:'_self',
  46. },
  47. ],
  48. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  49. ]
  50. ],
  51. onLoadSuccess:function(){
  52. // 这里就是数据渲染结束后的回调函数
  53. $(".btn-yulan").data("area", ['25%','80%']);
  54. }
  55. });
  56. // 为表格绑定事件
  57. Table.api.bindevent(table);
  58. },
  59. add: function () {
  60. Controller.api.bindevent();
  61. },
  62. edit: function () {
  63. Controller.api.bindevent();
  64. },
  65. yulan: function () {
  66. Controller.api.bindevent();
  67. },
  68. api: {
  69. bindevent: function () {
  70. Form.api.bindevent($("form[role=form]"));
  71. }
  72. }
  73. };
  74. return Controller;
  75. });