ophost.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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: {"0":__('Isdefault 0'),"1":__('Isdefault 1')}},
  29. {field: 'isdefault_text', title: __('Isdefault'), operate:false},
  30. {field: 'status', title: __('Status'), visible:false, searchList: {"0":__('Status 0'),"1":__('Status 1')}},
  31. {field: 'status_text', title: __('Status'), operate:false},
  32. {
  33. field: 'allow_changed',
  34. title: __('AllowChanged'),
  35. operate: '=',
  36. searchList: {"0": __('AllowChanged0'), "1": __('AllowChanged1')},
  37. formatter: function (value) {
  38. if (value == '1') {
  39. return '是';
  40. } else {
  41. return '否';
  42. }
  43. }
  44. },
  45. {field: 'p_desc', title: __('描述'), operate:false},
  46. {field: 'download', title: __('渠道信息下载'), formatter:function(value){return '<a href="'+value+'">下载</a>';}},
  47. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  48. ]
  49. ]
  50. });
  51. // 为表格绑定事件
  52. Table.api.bindevent(table);
  53. },
  54. add: function () {
  55. Controller.api.isdefault();
  56. Controller.api.bindevent();
  57. },
  58. edit: function () {
  59. Controller.api.isdefault();
  60. Controller.api.bindevent();
  61. },
  62. api: {
  63. bindevent: function () {
  64. Form.api.bindevent($("form[role=form]"));
  65. },
  66. isdefault:function (){
  67. $("#c-isdefault").change(function(){
  68. if($(this).val()==1){
  69. if(!confirm("确定修改为默认吗?")){
  70. $(this).val(0);
  71. }
  72. }
  73. });
  74. }
  75. }
  76. };
  77. return Controller;
  78. });