gg.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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: 'gg/index' + location.search,
  8. add_url: 'gg/add',
  9. edit_url: 'gg/edit',
  10. del_url: 'gg/del',
  11. multi_url: 'gg/multi',
  12. import_url: 'gg/import',
  13. table: 'gg',
  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. search:false,
  25. columns: [
  26. [
  27. {checkbox: true},
  28. {field:'id', title: __('序号'),formatter: function(value, row, index){return ++index;}, operate: false},
  29. // {field: 'content', title: __('Content'), operate: 'LIKE'},
  30. // {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  31. {field: 'title', title: __('标题')},
  32. {field: 'image', title: __('配图'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
  33. {field: 'type', title: __('Type'), searchList: {"1":__('纯图'),"2":__('图文')}, formatter: Table.api.formatter.status},
  34. {field: 'switch', title: __('Switch'), table: table, formatter: Table.api.formatter.toggle},
  35. {field: 'sort', title: __('Sort')},
  36. {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  37. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  38. ]
  39. ]
  40. });
  41. // 为表格绑定事件
  42. Table.api.bindevent(table);
  43. },
  44. add: function () {
  45. $(document).on('change', "#c-type_text", function () {
  46. var that = this;
  47. if ($(that).val() == '纯图') {
  48. $("#c-imagess").attr("style","display:block;");
  49. $("#c-contents").attr("style","display:none;");
  50. } else {
  51. $("#c-contents").attr("style","display:block;");
  52. $("#c-imagess").attr("style","display:none;");
  53. // alert(222)
  54. }
  55. });
  56. Form.api.bindevent($("form[role=form]"));
  57. },
  58. edit: function () {
  59. var type = Config.type;
  60. if (type == 2) {
  61. $("#c-contents").attr("style","display:block;");
  62. } else {
  63. $("#c-imagess").attr("style","display:block;");
  64. }
  65. $(document).on('change', "#c-type_text", function () {
  66. var that = this;
  67. if ($(that).val() == '纯图') {
  68. $("#c-imagess").attr("style","display:block;");
  69. $("#c-contents").attr("style","display:none;");
  70. } else {
  71. $("#c-contents").attr("style","display:block;");
  72. $("#c-imagess").attr("style","display:none;");
  73. // alert(222)
  74. }
  75. });
  76. Form.api.bindevent($("form[role=form]"));
  77. },
  78. api: {
  79. bindevent: function () {
  80. Form.api.bindevent($("form[role=form]"));
  81. }
  82. }
  83. };
  84. return Controller;
  85. });