food_meal.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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: 'food_meal/index' + location.search,
  8. add_url: 'food_meal/add',
  9. edit_url: 'food_meal/edit',
  10. del_url: 'food_meal/del',
  11. multi_url: 'food_meal/multi',
  12. import_url: 'food_meal/import',
  13. table: 'food_meal',
  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. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id')},
  26. {field: 'staple_food', title: __('Staple_food'), operate: 'LIKE'},
  27. {field: 'menu', title: __('Menu'), operate: 'LIKE'},
  28. {field: 'type1', title: __('Type1'), searchList: {"晚餐":__('晚餐'),"午餐":__('午餐'),"早餐":__('早餐')}, formatter: Table.api.formatter.normal},
  29. {field: 'jiucan_count', title: __('Jiucan_count')},
  30. {field: 'liandui_count', title: __('Liandui_count')},
  31. {field: 'wailai_count', title: __('Wailai_count')},
  32. {field: 'mianfen', title: __('Mianfen')},
  33. {field: 'dami', title: __('Dami')},
  34. {field: 'rolei', title: __('Rolei')},
  35. {field: 'yulei', title: __('Yulei')},
  36. {field: 'youlei', title: __('Youlei')},
  37. {field: 'huangdo', title: __('Huangdo')},
  38. {field: 'suchai', title: __('Suchai')},
  39. {field: 'shuiguo', title: __('Shuiguo')},
  40. {field: 'tang', title: __('Tang')},
  41. {field: 'ranliao', title: __('Ranliao')},
  42. {field: 'tiaoliao', title: __('Tiaoliao')},
  43. {field: 'food_id', title: __('Food_id')},
  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. });