shortchannel.js 5.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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: 'shortchannel/index',
  8. add_url: 'shortchannel/add',
  9. edit_url: 'shortchannel/edit',
  10. del_url: 'shortchannel/del',
  11. multi_url: 'shortchannel/multi',
  12. table: 'short_relation',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'sr.updatetime desc',
  21. sortOrder:'',
  22. search: false,
  23. searchFormVisible: true,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. // {field: 'id', title: __('Id'), operate: false},
  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: __('开户人'), visible:false, operate: '=', searchList:{}},//仅用于搜索
  36. {field: 'ae.create_by', title: __('开户人ID'), operate: false,formatter:function(value, row, index){
  37. return row.create_by;
  38. }},
  39. {field: 'a2.username', title: __('开户人账户'), operate: false,formatter:function(value, row, index){
  40. return row.create_username;
  41. }},
  42. {field: 'a2.nickname', title: __('开户人昵称'), operate: false,formatter:function(value, row, index){
  43. return row.create_nickname;
  44. }},
  45. {field: 'sd.id', title: __('Domain_host')+"ID", operate: 'LIKE %...%',formatter:function(value, row, index){
  46. return (new String(row.hostid_concat)).split(",").join("<br/>");
  47. }},
  48. {field: 'sd.host', title: __('Domain_host'), operate: 'LIKE %...%',formatter:function(value, row, index){
  49. return (new String(row.host_concat)).split(",").join("<br/>");
  50. }},
  51. {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime,type: 'datetime', operate: 'RANGE',addclass:'datetimerange',formatter:function(value, row, index){
  52. return (new String(row.createtime_concat)).split(",").join("<br/>");
  53. }},
  54. {field: 'updatetime', title: __('Updatetime'), formatter: Table.api.formatter.datetime,type: 'datetime', operate: 'RANGE',addclass:'datetimerange',formatter:function(value, row, index){
  55. return (new String(row.updatetime_concat)).split(",").join("<br/>");
  56. }},
  57. {field: 'operate', title: '操作', table: table, events: Table.api.events.operate,formatter: Table.api.formatter.buttons, buttons:[
  58. {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){
  59. table.bootstrapTable('refresh');
  60. }},
  61. ]}
  62. ]
  63. ],
  64. onLoadSuccess: function (data) {
  65. //配置搜索栏"开户人"下拉列表
  66. var formControlCreateBy = $(".form-control[name='ae.create_by']");
  67. if(formControlCreateBy.children("option").length<=1){
  68. $.each(data.create_list, function (index, row) {
  69. formControlCreateBy.append('<option value="'+ row.id +'">'+ row.username +' | '+ row.nickname +'</option>');
  70. });
  71. }
  72. }
  73. });
  74. // 为表格绑定事件
  75. Table.api.bindevent(table);
  76. },
  77. add: function () {
  78. $(":checkbox[name='btSelectAll']").click(function(){
  79. $(this).closest("table").find(":checkbox").prop("checked", $(this).prop("checked"));
  80. });
  81. Controller.api.bindevent();
  82. },
  83. edit: function () {
  84. Controller.api.bindevent();
  85. },
  86. api: {
  87. bindevent: function () {
  88. Form.api.bindevent($("form[role=form]"));
  89. }
  90. }
  91. };
  92. return Controller;
  93. });