lists.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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: 'policy/lists/index' + location.search,
  8. add_url: 'policy/lists/add',
  9. edit_url: 'policy/lists/edit',
  10. del_url: 'policy/lists/del',
  11. multi_url: 'policy/lists/multi',
  12. import_url: 'policy/lists/import',
  13. table: 'policy_lists',
  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. showExport:false,
  23. // commonSearch:false,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field:'id', title: __('序号'),formatter: function(value, row, index){
  28. return ++index;
  29. }, operate: false},
  30. {field: 't_id', title: __('Policytype.name'),sortable:true, searchList: $.getJSON("policy/type/indexxx"),formatter:function (value,row,index) {
  31. console.log(row)
  32. return row.policytype.name;
  33. }},
  34. {field: 'title', title: __('Title')},
  35. // {field: 'content', title: __('Content')},
  36. {field: 'switch', title: __('Switch'), table: table, formatter: Table.api.formatter.toggle,operate:false},
  37. {field: 'sort', title: __('Sort'),operate:false},
  38. {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  39. {
  40. field: 'buttons',
  41. width: "120px",
  42. title: __('入驻情况'),
  43. table: table,
  44. events: Table.api.events.operate,
  45. buttons: [
  46. {
  47. name: 'detail',
  48. text: __('查看入驻人员'),
  49. title: __('查看入驻人员'),
  50. classname: 'btn btn-xs btn-primary btn-dialog',
  51. icon: 'fa fa-list',
  52. url: 'policy/ruzhu/index',
  53. callback: function (data) {
  54. Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  55. },
  56. visible: function (row) {
  57. //返回true时按钮显示,返回false隐藏
  58. return true;
  59. }
  60. },
  61. ],
  62. formatter: Table.api.formatter.buttons
  63. },
  64. // {field: 'policytype.name', title: __('Policytype.name'), operate: 'LIKE'},
  65. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  66. ]
  67. ]
  68. });
  69. // 为表格绑定事件
  70. Table.api.bindevent(table);
  71. },
  72. add: function () {
  73. Controller.api.bindevent();
  74. },
  75. edit: function () {
  76. Controller.api.bindevent();
  77. },
  78. api: {
  79. bindevent: function () {
  80. Form.api.bindevent($("form[role=form]"));
  81. }
  82. }
  83. };
  84. return Controller;
  85. });