specs.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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: 'qingdongams/product/specs/index' + location.search,
  8. add_url: 'qingdongams/product/specs/add',
  9. edit_url: 'qingdongams/product/specs/edit',
  10. del_url: 'qingdongams/product/specs/del',
  11. multi_url: 'qingdongams/product/specs/multi',
  12. import_url: 'qingdongams/product/specs/import',
  13. table: 'qingdongams_specs',
  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: 'pname', title: __('上级'), operate:false},
  26. {field: 'name', title: __('规格名称'), operate: 'LIKE'},
  27. {field: 'status', title: __('启用状态'), formatter: Table.api.formatter.status, searchList: {0: __('隐藏'), 1: __('正常')}},
  28. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  29. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  30. ]
  31. ],
  32. //启用普通表单搜索
  33. search:false,
  34. commonSearch: true,
  35. searchFormVisible: true,
  36. onLoadSuccess:function(){
  37. // 这里就是数据渲染结束后的回调函数
  38. $('.btn-editone').html('编辑');
  39. $('.fa-pencil').remove();
  40. $('.btn-delone').html('删除');
  41. $('.fa-trash').remove();
  42. $('.btn-editone').removeClass('btn-success')
  43. $('.btn-editone').removeClass('btn')
  44. $('.btn-delone').removeClass('btn')
  45. $('.btn-delone').removeClass('btn-danger')
  46. }
  47. });
  48. // 为表格绑定事件
  49. Table.api.bindevent(table);
  50. },
  51. recyclebin: function () {
  52. // 初始化表格参数配置
  53. Table.api.init({
  54. extend: {
  55. 'dragsort_url': ''
  56. }
  57. });
  58. var table = $("#table");
  59. // 初始化表格
  60. table.bootstrapTable({
  61. url: 'qingdongams/product/specs/recyclebin' + location.search,
  62. pk: 'id',
  63. sortName: 'id',
  64. columns: [
  65. [
  66. {checkbox: true},
  67. {field: 'id', title: __('Id')},
  68. {field: 'name', title: __('Name'), align: 'left'},
  69. {
  70. field: 'deletetime',
  71. title: __('Deletetime'),
  72. operate: 'RANGE',
  73. addclass: 'datetimerange',
  74. formatter: Table.api.formatter.datetime
  75. },
  76. {
  77. field: 'operate',
  78. width: '130px',
  79. title: __('Operate'),
  80. table: table,
  81. events: Table.api.events.operate,
  82. buttons: [
  83. {
  84. name: 'Restore',
  85. text: __('Restore'),
  86. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  87. icon: 'fa fa-rotate-left',
  88. url: 'qingdongams/product/specs/restore',
  89. refresh: true
  90. },
  91. {
  92. name: 'Destroy',
  93. text: __('Destroy'),
  94. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  95. icon: 'fa fa-times',
  96. url: 'qingdongams/product/specs/destroy',
  97. refresh: true
  98. }
  99. ],
  100. formatter: Table.api.formatter.operate
  101. }
  102. ]
  103. ]
  104. });
  105. // 为表格绑定事件
  106. Table.api.bindevent(table);
  107. },
  108. add: function () {
  109. Controller.api.bindevent();
  110. },
  111. edit: function () {
  112. Controller.api.bindevent();
  113. },
  114. api: {
  115. bindevent: function () {
  116. Form.api.bindevent($("form[role=form]"));
  117. }
  118. }
  119. };
  120. return Controller;
  121. });