specs.js 5.3 KB

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