ophost.js 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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: 'ophost/index',
  8. add_url: 'ophost/add',
  9. edit_url: 'ophost/edit',
  10. // del_url: 'ophost/del',
  11. multi_url: 'ophost/multi',
  12. table: 'ophost',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'id',
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {field: 'id', title: __('Id')},
  25. {field: 'platform_id', title: __('Platform_id'),formatter:function(value,row,index){return value+"<br>"+row.platform.name;}},
  26. {field: 'host', title: __('Host')},
  27. {field: 'hostfile', title: __('Hostfile')},
  28. {field: 'isdefault', title: __('Isdefault'), visible:false, searchList: {"isdefault 0":__('Isdefault 0'),"isdefault 1":__('Isdefault 1')}},
  29. {field: 'isdefault_text', title: __('Isdefault'), operate:false},
  30. {field: 'status', title: __('Status'), visible:false, searchList: {"status 0":__('Status 0'),"status 1":__('Status 1')}},
  31. {field: 'status_text', title: __('Status'), operate:false},
  32. {field: 'p_desc', title: __('描述'), operate:false},
  33. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  34. ]
  35. ]
  36. });
  37. // 为表格绑定事件
  38. Table.api.bindevent(table);
  39. },
  40. add: function () {
  41. Controller.api.isdefault();
  42. Controller.api.bindevent();
  43. },
  44. edit: function () {
  45. Controller.api.isdefault();
  46. Controller.api.bindevent();
  47. },
  48. api: {
  49. bindevent: function () {
  50. Form.api.bindevent($("form[role=form]"));
  51. },
  52. isdefault:function (){
  53. $("#c-isdefault").change(function(){
  54. if($(this).val()==1){
  55. if(!confirm("确定修改为默认吗?")){
  56. $(this).val(0);
  57. }
  58. }
  59. });
  60. }
  61. }
  62. };
  63. return Controller;
  64. });