gift.js 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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: 'Jackpot_id', title: __('Jackpot_id')},
  33. {field: 'eggjackpot.name', title: __('Eggjackpot.name'), operate: 'LIKE'},
  34. {field: 'eggjackpot.type', title: __('Eggjackpot.type'), searchList: {"1":__('Eggjackpot.type 1'),"2":__('Eggjackpot.type 2'),"3":__('Eggjackpot.type 3')}, formatter: Table.api.formatter.normal},
  35. {field: 'gift_id', title: __('Gift_id')},
  36. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  37. // {field: 'special', title: __('Special'), operate: 'LIKE'},
  38. {field: 'gift_name', title: __('Gift_name'), operate: 'LIKE'},
  39. // {field: 'prize_no', title: __('Prize_no')},
  40. {field: 'price', title: __('Price')},
  41. {field: 'is_use', title: __('Is_use'), searchList: {"1":__('Is_use 1'),"0":__('Is_use 0')}, formatter: Table.api.formatter.normal},
  42. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  43. // {field: 'starttime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  44. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  45. ]
  46. ]
  47. });
  48. // 为表格绑定事件
  49. Table.api.bindevent(table);
  50. },
  51. add: function () {
  52. Controller.api.bindevent();
  53. },
  54. edit: function () {
  55. Controller.api.bindevent();
  56. },
  57. api: {
  58. bindevent: function () {
  59. Form.api.bindevent($("form[role=form]"));
  60. }
  61. }
  62. };
  63. return Controller;
  64. });