areas.js 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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: 'areas/index' + location.search,
  8. add_url: 'areas/add',
  9. edit_url: 'areas/edit',
  10. del_url: 'areas/del',
  11. multi_url: 'areas/multi',
  12. import_url: 'areas/import',
  13. table: 'areas',
  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: 'parent_id', title: __('Parent_id')},
  27. {field: 'level_type', title: __('Level_type')},
  28. {field: 'name', title: __('Name'), operate: 'LIKE'},
  29. {field: 'short_name', title: __('Short_name'), operate: 'LIKE'},
  30. {field: 'parent_path', title: __('Parent_path'), operate: 'LIKE'},
  31. {field: 'province', title: __('Province'), operate: 'LIKE'},
  32. {field: 'city', title: __('City'), operate: 'LIKE'},
  33. {field: 'district', title: __('District'), operate: 'LIKE'},
  34. {field: 'province_short_name', title: __('Province_short_name'), operate: 'LIKE'},
  35. {field: 'city_short_name', title: __('City_short_name'), operate: 'LIKE'},
  36. {field: 'district_short_name', title: __('District_short_name'), operate: 'LIKE'},
  37. {field: 'province_pinyin', title: __('Province_pinyin'), operate: 'LIKE'},
  38. {field: 'city_pinyin', title: __('City_pinyin'), operate: 'LIKE'},
  39. {field: 'district_pinyin', title: __('District_pinyin'), operate: 'LIKE'},
  40. {field: 'city_code', title: __('City_code'), operate: 'LIKE'},
  41. {field: 'zip_code', title: __('Zip_code'), operate: 'LIKE'},
  42. {field: 'pinyin', title: __('Pinyin'), operate: 'LIKE'},
  43. {field: 'jianpin', title: __('Jianpin'), operate: 'LIKE'},
  44. {field: 'firstchar', title: __('Firstchar'), operate: 'LIKE'},
  45. {field: 'lng', title: __('Lng'), operate: 'LIKE'},
  46. {field: 'lat', title: __('Lat'), operate: 'LIKE'},
  47. {field: 'remark1', title: __('Remark1'), operate: 'LIKE'},
  48. {field: 'remark2', title: __('Remark2'), operate: 'LIKE'},
  49. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  50. ]
  51. ]
  52. });
  53. // 为表格绑定事件
  54. Table.api.bindevent(table);
  55. },
  56. add: function () {
  57. Controller.api.bindevent();
  58. },
  59. edit: function () {
  60. Controller.api.bindevent();
  61. },
  62. api: {
  63. bindevent: function () {
  64. Form.api.bindevent($("form[role=form]"));
  65. }
  66. }
  67. };
  68. return Controller;
  69. });