special_issue.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. //设置弹窗宽高
  3. Fast.config.openArea = ['80%', '80%'];
  4. var Controller = {
  5. index: function () {
  6. // 初始化表格参数配置
  7. Table.api.init({
  8. extend: {
  9. index_url: 'cms/special_issue/index',
  10. add_url: '',
  11. edit_url: '',
  12. del_url: 'cms/special_issue/del',
  13. multi_url: 'cms/special_issue/multi',
  14. table: 'cms_special_issue',
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'id',
  23. fixedColumns: true,
  24. fixedRightNumber: 1,
  25. exportTypes: ['excel'],
  26. columns: [
  27. [
  28. {checkbox: true},
  29. {field: 'id', title: __('Id')},
  30. {field: 'user.nickname', title: __('Nickname'), operate: false},
  31. {field: 'journal.name', title: __('Journal'), formatter: Table.api.formatter.search, operate: 'like'},
  32. {field: 'editor', title: __('Editor'), operate: 'like'},
  33. {field: 'issue_name', title: __('Issue name'), operate: false},
  34. {field: 'publication_cycle', title: __('Publication cycle'), operate: false},
  35. {field: 'statement_type', title: __('Statement type'), operate: false},
  36. {field: 'status', title: __('Status'), searchList: {"review": __('Review'), "Fault": __('Fault'), "Correct": __('Correct')}, formatter: Table.api.formatter.status},
  37. {field: 'createtime', title: __('Createtime'), sortable: true, operate: 'RANGE', addclass: 'datetimerange', formatter: Table.api.formatter.datetime},
  38. {
  39. field: 'operate',
  40. title: __('Operate'),
  41. clickToSelect: false,
  42. table: table,
  43. events: Table.api.events.operate,
  44. formatter: function (value, row, index) {
  45. var that = $.extend({}, this);
  46. var table = $(this.table).clone(true);
  47. that.table = table;
  48. return Table.api.formatter.operate.call(that, value, row, index);
  49. },
  50. buttons:[
  51. {
  52. name: 'detail',
  53. classname: 'btn btn-xs btn-warning btn-dialog',
  54. icon: 'fa fa-list',
  55. title: __('Detail'),
  56. text: __('Detail'),
  57. url: function (row) {
  58. return 'cms/special_issue/edit?ids=' + row.id;
  59. },
  60. },
  61. {
  62. name: 'pass',
  63. text: __('Correct'),
  64. title: __('Correct'),
  65. classname: 'btn btn-xs btn-success btn-view btn-ajax',
  66. icon: 'fa fa-check',
  67. url: function (row) {
  68. return 'cms/special_issue/is_adopt?status=correct&ids=' + row.id;
  69. },
  70. visible: function(row){
  71. if(row.status == 'fault' || row.status == 'review'){
  72. return true; //显示
  73. } else {
  74. return false; //隐藏
  75. }
  76. },
  77. refresh: true
  78. },
  79. {
  80. name: 'fault',
  81. text: __('Fault'),
  82. title: __('Fault'),
  83. classname: 'btn btn-xs btn-danger btn-view btn-ajax',
  84. icon: 'fa fa-times',
  85. url: function (row) {
  86. return 'cms/special_issue/is_adopt?status=fault&ids=' + row.id;
  87. },
  88. visible: function(row){
  89. if(row.status == 'fault'){
  90. return false; //不显示
  91. } else if (row.status == 'review') {
  92. return true;
  93. } else {
  94. return true;
  95. }
  96. },
  97. refresh: true
  98. }
  99. ]
  100. }
  101. ]
  102. ]
  103. });
  104. // 为表格绑定事件
  105. Table.api.bindevent(table);
  106. },
  107. add: function () {
  108. Controller.api.bindevent();
  109. },
  110. edit: function () {
  111. Form.api.bindevent($("form[role=form]"));
  112. // 关闭弹窗
  113. $(document).on('click', '.btn-close', function () {
  114. Fast.api.close();
  115. });
  116. Controller.api.bindevent();
  117. },
  118. api: {
  119. bindevent: function () {
  120. Form.api.bindevent($("form[role=form]"));
  121. }
  122. }
  123. };
  124. return Controller;
  125. });