school.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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: 'unishop/school/index' + location.search,
  8. add_url: 'unishop/school/add',
  9. edit_url: 'unishop/school/edit',
  10. del_url: 'unishop/school/del',
  11. multi_url: 'unishop/school/multi',
  12. table: 'school',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'id',
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {field: 'id', title: __('Id')},
  25. {field: 'area.name', title: __('所属区县')},
  26. {field: 'name', title: __('Name')},
  27. {field: 'operate', title: __('Operate'),
  28. buttons: [{
  29. name: '',
  30. title:'配送详情',
  31. text: '配送详情',
  32. icon: '',
  33. classname: 'btn btn-xs btn-info btn-dialog',
  34. url: 'unishop/school/data',
  35. }],
  36. table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  37. ]
  38. ]
  39. });
  40. // 为表格绑定事件
  41. Table.api.bindevent(table);
  42. },
  43. add: function () {
  44. Controller.api.bindevent();
  45. $("#c-area_id").on("cp:updated", function() {
  46. var citypicker = $(this).data("citypicker");
  47. var code = citypicker.getCode("district");
  48. $("#c-area_id").val(code);
  49. $("#c-name").val("");
  50. });
  51. },
  52. edit: function () {
  53. Controller.api.bindevent();
  54. $("#c-area_id").on("cp:updated", function() {
  55. var citypicker = $(this).data("citypicker");
  56. var code = citypicker.getCode("district");
  57. $("#c-area_id").val(code);
  58. $("#c-name").val("");
  59. });
  60. },
  61. api: {
  62. bindevent: function () {
  63. Form.api.bindevent($("form[role=form]"));
  64. }
  65. }
  66. };
  67. return Controller;
  68. });