guideagent.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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: 'guideagent/index',
  8. add_url: 'guideagent/add',
  9. edit_url: 'guideagent/edit',
  10. del_url: 'guideagent/del',
  11. multi_url: 'guideagent/multi',
  12. table: 'guide_relation',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'gr.updatetime desc',
  21. sortOrder:'',
  22. search: false,
  23. searchFormVisible: true,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. // {field: 'id', title: __('Id'), operate: 'LIKE %...%'},
  28. {field: 'admin_id', title: __('Admin_id'), operate: 'LIKE %...%'},
  29. {field: 'a.username', title: __('Admin_username'), operate: 'LIKE %...%',formatter:function(value, row, index){
  30. return row.username;
  31. }},
  32. {field: 'a.nickname', title: __('Admin_nickname'), operate: 'LIKE %...%',formatter:function(value, row, index){
  33. return row.nickname;
  34. }},
  35. {field: 'ae.create_by', title: __('开户人ID'), operate: 'LIKE %...%',formatter:function(value, row, index){
  36. return row.create_by;
  37. }},
  38. {field: 'a2.username', title: __('开户人账户'), operate: 'LIKE %...%',formatter:function(value, row, index){
  39. return row.create_username;
  40. }},
  41. {field: 'a2.nickname', title: __('开户人昵称'), operate: 'LIKE %...%',formatter:function(value, row, index){
  42. return row.create_nickname;
  43. }},
  44. {field: 'gd.id', title: __('Domain_host')+"ID", operate: 'LIKE %...%',formatter:function(value, row, index){
  45. return (new String(row.hostid_concat)).split(",").join("<br/>");
  46. }},
  47. {field: 'gd.host', title: __('Domain_host'), operate: 'LIKE %...%',formatter:function(value, row, index){
  48. return (new String(row.host_concat)).split(",").join("<br/>");
  49. }},
  50. {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime,type: 'datetime', operate: 'RANGE',addclass:'datetimerange',formatter:function(value, row, index){
  51. return (new String(row.createtime_concat)).split(",").join("<br/>");
  52. }},
  53. {field: 'updatetime', title: __('Updatetime'), formatter: Table.api.formatter.datetime,type: 'datetime', operate: 'RANGE',addclass:'datetimerange',formatter:function(value, row, index){
  54. return (new String(row.updatetime_concat)).split(",").join("<br/>");
  55. }},
  56. {field: 'operate', title: '操作', table: table, events: Table.api.events.operate,formatter: Table.api.formatter.buttons, buttons:[
  57. {name: 'del', text: '', icon: 'fa fa-trash',classname: 'btn btn-xs btn-danger btn-ajax', url: $.fn.bootstrapTable.defaults.extend.del_url,confirm:'确定删除此项?',success:function (data){
  58. table.bootstrapTable('refresh');
  59. }},
  60. ]}
  61. ]
  62. ]
  63. });
  64. // 为表格绑定事件
  65. Table.api.bindevent(table);
  66. },
  67. add: function () {
  68. $(":checkbox[name='btSelectAll']").click(function(){
  69. $(this).closest("table").find(":checkbox").prop("checked", $(this).prop("checked"));
  70. });
  71. Controller.api.bindevent();
  72. },
  73. edit: function () {
  74. Controller.api.bindevent();
  75. },
  76. api: {
  77. bindevent: function () {
  78. Form.api.bindevent($("form[role=form]"));
  79. }
  80. }
  81. };
  82. return Controller;
  83. });