plusconfig.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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: 'service/config/plusconfig/index' + location.search,
  8. add_url: 'service/config/plusconfig/add',
  9. edit_url: 'service/config/plusconfig/edit',
  10. del_url: 'service/config/plusconfig/del',
  11. multi_url: 'service/config/plusconfig/multi',
  12. import_url: 'service/config/plusconfig/import',
  13. table: 'service_plus_config',
  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. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'name', title: __('Name'), operate: 'LIKE'},
  29. {field: 'daynums', title: __('Daynums')},
  30. {field: 'original_price', title: __('Original_price'), operate:'BETWEEN'},
  31. {field: 'price', title: __('Price'), operate:'BETWEEN'},
  32. {field: 'discount', title: __('Discount')},
  33. {field: 'state', title: __('State'), searchList: {"0":__('State 0'),"1":__('State 1')}, formatter: Table.api.formatter.normal},
  34. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  35. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  36. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  37. ]
  38. ]
  39. });
  40. // 为表格绑定事件
  41. Table.api.bindevent(table);
  42. },
  43. recyclebin: function () {
  44. // 初始化表格参数配置
  45. Table.api.init({
  46. extend: {
  47. 'dragsort_url': ''
  48. }
  49. });
  50. var table = $("#table");
  51. // 初始化表格
  52. table.bootstrapTable({
  53. url: 'service/config/plusconfig/recyclebin' + location.search,
  54. pk: 'id',
  55. sortName: 'id',
  56. columns: [
  57. [
  58. {checkbox: true},
  59. {field: 'id', title: __('Id')},
  60. {field: 'name', title: __('Name'), align: 'left'},
  61. {
  62. field: 'deletetime',
  63. title: __('Deletetime'),
  64. operate: 'RANGE',
  65. addclass: 'datetimerange',
  66. formatter: Table.api.formatter.datetime
  67. },
  68. {
  69. field: 'operate',
  70. width: '140px',
  71. title: __('Operate'),
  72. table: table,
  73. events: Table.api.events.operate,
  74. buttons: [
  75. {
  76. name: 'Restore',
  77. text: __('Restore'),
  78. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  79. icon: 'fa fa-rotate-left',
  80. url: 'service/config/plusconfig/restore',
  81. refresh: true
  82. },
  83. {
  84. name: 'Destroy',
  85. text: __('Destroy'),
  86. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  87. icon: 'fa fa-times',
  88. url: 'service/config/plusconfig/destroy',
  89. refresh: true
  90. }
  91. ],
  92. formatter: Table.api.formatter.operate
  93. }
  94. ]
  95. ]
  96. });
  97. // 为表格绑定事件
  98. Table.api.bindevent(table);
  99. },
  100. add: function () {
  101. Controller.api.bindevent();
  102. },
  103. edit: function () {
  104. Controller.api.bindevent();
  105. },
  106. api: {
  107. bindevent: function () {
  108. Form.api.bindevent($("form[role=form]"));
  109. }
  110. }
  111. };
  112. return Controller;
  113. });