datadict.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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: 'stock/datadict/index',
  8. add_url: 'stock/datadict/add',
  9. edit_url: 'stock/datadict/edit',
  10. del_url: 'stock/datadict/del',
  11. multi_url: 'stock/datadict/multi',
  12. table: 'stock/datadict',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'weigh',
  21. escape: false,
  22. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id')},
  26. {field: 'name', title: __('Name'), align: 'left'},
  27. {field: 'code', title: __('Code')},
  28. {field: 'istree', title: __('Istree'), visible: false, searchList: {"1": __('Istree 1'), "0": __('Istree 0')}},
  29. {field: 'istree_text', title: __('Istree'), operate: false},
  30. {field: 'weigh', title: __('Weigh')},
  31. {field: 'remark', title: __('Remark')},
  32. {field: 'enabled', title: __('Enabled'), visible: false, searchList: {"1": __('Enabled 1'), "0": __('Enabled 0')}},
  33. {field: 'enabled_text', title: __('Enabled'), operate: false},
  34. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  35. ]
  36. ]
  37. });
  38. // 为表格绑定事件
  39. Table.api.bindevent(table);
  40. },
  41. add: function () {
  42. Controller.api.bindevent();
  43. },
  44. edit: function () {
  45. Controller.api.bindevent();
  46. },
  47. api: {
  48. formatter: {
  49. istree: function (value, row, index) {
  50. if (value == 1) {
  51. return "是";
  52. } else if (value == 0) {
  53. return "否";
  54. }
  55. }
  56. },
  57. bindevent: function () {
  58. Form.api.bindevent($("form[role=form]"));
  59. }
  60. }
  61. };
  62. return Controller;
  63. });