gift.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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: 'egg/gift/index' + location.search,
  8. add_url: 'egg/gift/add',
  9. edit_url: 'egg/gift/edit',
  10. del_url: 'egg/gift/del',
  11. multi_url: 'egg/gift/multi',
  12. import_url: 'egg/gift/import',
  13. table: 'egg_gift',
  14. }
  15. });
  16. var table = $("#table");
  17. //当表格数据加载完成时
  18. table.on('load-success.bs.table', function (e, data) {
  19. //这里可以获取从服务端获取的JSON数据
  20. //这里我们手动设置底部的值
  21. $("#total-price").text(data.extend.total_price);
  22. });
  23. // 初始化表格
  24. table.bootstrapTable({
  25. url: $.fn.bootstrapTable.defaults.extend.index_url,
  26. pk: 'id',
  27. sortName: 'id',
  28. columns: [
  29. [
  30. {checkbox: true},
  31. {field: 'id', title: __('Id')},
  32. {field: 'gift_id', title: __('Gift_id')},
  33. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  34. {field: 'gift_name', title: __('Gift_name'), operate: 'LIKE'},
  35. {field: 'Jackpot_id', title: __('Jackpot_id')},
  36. {field: 'prize_no', title: __('Prize_no')},
  37. {field: 'price', title: __('Price')},
  38. {field: 'is_use', title: __('Is_use'), searchList: {"1":__('Is_use 1'),"0":__('Is_use 0')}, formatter: Table.api.formatter.normal},
  39. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  40. ]
  41. ]
  42. });
  43. // 为表格绑定事件
  44. Table.api.bindevent(table);
  45. },
  46. add: function () {
  47. Controller.api.bindevent();
  48. },
  49. edit: function () {
  50. Controller.api.bindevent();
  51. },
  52. api: {
  53. bindevent: function () {
  54. Form.api.bindevent($("form[role=form]"));
  55. }
  56. }
  57. };
  58. return Controller;
  59. });