unit.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/unit/index' + location.search,
  8. add_url: 'qingdongams/product/unit/add',
  9. edit_url: 'qingdongams/product/unit/edit',
  10. del_url: 'qingdongams/product/unit/del',
  11. table: 'qingdongams_product_unit',
  12. }
  13. });
  14. var table = $("#table");
  15. // 初始化表格
  16. table.bootstrapTable({
  17. url: $.fn.bootstrapTable.defaults.extend.index_url,
  18. pk: 'id',
  19. sortName: 'sort',
  20. columns: [
  21. [
  22. {checkbox: true},
  23. {field: 'name', title: __('名称'), operate: 'LIKE'},
  24. {field: 'sort', title: __('权重'), operate: false},
  25. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  26. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  27. ]
  28. ],
  29. search:false,
  30. //启用普通表单搜索
  31. commonSearch : true,
  32. searchFormVisible:true,
  33. showSearch : true,
  34. pageSize : 10,
  35. onLoadSuccess:function(){
  36. // 这里就是数据渲染结束后的回调函数
  37. $('.btn-editone').html('编辑');
  38. $('.fa-pencil').remove();
  39. $('.btn-delone').html('删除');
  40. $('.fa-trash').remove();
  41. $('.btn-editone').removeClass('btn-success')
  42. $('.btn-editone').removeClass('btn')
  43. $('.btn-delone').removeClass('btn')
  44. $('.btn-delone').removeClass('btn-danger')
  45. }
  46. });
  47. // 为表格绑定事件
  48. Table.api.bindevent(table);
  49. },
  50. add: function () {
  51. Controller.api.bindevent();
  52. },
  53. edit: function () {
  54. Controller.api.bindevent();
  55. },
  56. api: {
  57. bindevent: function () {
  58. Form.api.bindevent($("form[role=form]"));
  59. }
  60. }
  61. };
  62. return Controller;
  63. });