bookchargesetting.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'selectpage'], function ($, undefined, Backend, Table, Form,Selectpage) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'bookchargesetting/index',
  8. add_url: 'bookchargesetting/add',
  9. edit_url: 'bookchargesetting/edit',
  10. del_url: 'bookchargesetting/del',
  11. multi_url: 'bookchargesetting/multi',
  12. table: 'book_charge_setting',
  13. },
  14. search: false
  15. });
  16. $(document).on('click','.layer-open',function () {
  17. Fast.api.open($(this).attr('href'), $(this).data('title')?$(this).data('title'):'配置公共信息', {});
  18. return false;
  19. });
  20. var table = $("#table");
  21. // 初始化表格
  22. table.bootstrapTable({
  23. url: $.fn.bootstrapTable.defaults.extend.index_url,
  24. pk: 'id',
  25. sortName: 'id',
  26. columns: [
  27. [
  28. {checkbox: true},
  29. {field: 'id', title: __('Id'), operate: false},
  30. {field: 'chapter_charge_start', title: __('Chapter_charge_start'), operate: false},
  31. {field: 'chapter_kandian', title: __('Chapter_kandian'), operate: false},
  32. {field: 'book_id', title: __('Book_id')},
  33. {field: 'name', title: '书籍名称', operate: false},
  34. {
  35. field: 'status',
  36. title: __('Status'),
  37. visible: false,
  38. searchList: {"normal": __('status normal'), "hide": __('status hide')}
  39. },
  40. {field: 'status_text', title: __('Status'), operate: false},
  41. {
  42. field: 'createtime',
  43. title: __('Createtime'),
  44. operate: false,
  45. formatter: Table.api.formatter.datetime
  46. },
  47. {
  48. field: 'updatetime',
  49. title: __('Updatetime'),
  50. operate: false,
  51. formatter: Table.api.formatter.datetime
  52. },
  53. {
  54. field: 'operate',
  55. title: __('Operate'),
  56. table: table,
  57. events: Table.api.events.operate,
  58. formatter: Table.api.formatter.operate
  59. }
  60. ]
  61. ]
  62. });
  63. // 为表格绑定事件
  64. Table.api.bindevent(table);
  65. },
  66. add: function () {
  67. var selectdata = '';
  68. $('#c-book_book_name').selectPage({
  69. eAjaxSuccess : function(d){
  70. if(selectdata && JSON.stringify(selectdata) != JSON.stringify(d)){
  71. $('#c-book_id').val('');
  72. }
  73. selectdata = d;
  74. return d ? d : '';
  75. },
  76. eSelect : function(d){
  77. selectdata = '';
  78. $('#c-book_book_name').val(d.name);
  79. $('#c-book_id').val(d.id);
  80. },
  81. eClear : function(){
  82. $('#c-book_id').val('');
  83. }
  84. });
  85. Controller.api.bindevent();
  86. },
  87. edit: function () {
  88. var selectdata = '';
  89. $('#c-book_book_name').selectPage({
  90. eAjaxSuccess : function(d){
  91. if(selectdata && JSON.stringify(selectdata) != JSON.stringify(d)){
  92. $('#c-book_id').val('');
  93. }
  94. selectdata = d;
  95. return d ? d : '';
  96. },
  97. eSelect : function(d){
  98. selectdata = '';
  99. $('#c-book_book_name').val(d.name);
  100. $('#c-book_id').val(d.id);
  101. },
  102. eClear : function(){
  103. $('#c-book_id').val('');
  104. }
  105. });
  106. if(Config.bnotin.length>0){
  107. if(Config.bnotin.indexOf(parseInt($('#c-book_id').val())) != -1){
  108. $('#c-book_id').val('');
  109. $('#c-book_book_name').val('');
  110. }
  111. }
  112. Controller.api.bindevent();
  113. },
  114. setting: function () {
  115. Controller.api.bindevent();
  116. },
  117. api: {
  118. bindevent: function () {
  119. Form.api.bindevent($("form[role=form]"));
  120. }
  121. }
  122. };
  123. return Controller;
  124. });