package.js 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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: 'package/index' + location.search,
  8. add_url: 'package/add',
  9. edit_url: 'package/edit',
  10. // del_url: 'package/del',
  11. multi_url: 'package/multi',
  12. import_url: 'package/import',
  13. table: 'package',
  14. dragsort_url:false
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'weigh',
  23. fixedColumns: true,
  24. fixedRightNumber: 1,
  25. search:false,
  26. columns: [
  27. [
  28. {checkbox: true},
  29. {field: 'id', title: __('Id')},
  30. {field: 'type', title: __('Type'), searchList: Config.typeList, formatter: Table.api.formatter.status},
  31. // {field: 'company_id', title: __('Company_id'), operate: false, visible:false},
  32. {field: 'company.name', title: __('Company.name'), operate: 'LIKE'},
  33. {field: 'title', title: __('Title'), operate: 'LIKE'},
  34. {field: 'info', title: __('Info'), operate: 'LIKE'},
  35. // {field: 'servicetype_id', title: __('Servicetype_id'), operate: false, visible:false},
  36. {field: 'servicetype.title', title: __('Servicetype.title'), operate: 'LIKE'},
  37. {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
  38. {field: 'price', title: __('Price'), operate:'BETWEEN'},
  39. {field: 'oldprice', title: __('Oldprice'), operate:'BETWEEN'},
  40. {field: 'num', title: __('Num'), operate:'BETWEEN'},
  41. {field: 'weigh', title: __('Weigh'), operate: false},
  42. {field: 'status', title: __('Status'), searchList: Config.statusList, formatter: Table.api.formatter.status},
  43. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  44. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  45. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
  46. buttons:[
  47. {
  48. name: 'package_gift',
  49. text: '赠送列表',
  50. title: '赠送列表',
  51. classname: 'btn btn-xs btn-primary btn-dialog',
  52. url:'packagegift/index/package_id/{ids}?dialog=1',
  53. icon: 'fa fa-list',
  54. target: '_self',
  55. extend: 'data-area=["90%","90%"]',
  56. hidden:function($row){
  57. if($row.type == 2){
  58. return false;
  59. }
  60. return true;
  61. }
  62. },
  63. ]}
  64. ]
  65. ]
  66. });
  67. // 为表格绑定事件
  68. Table.api.bindevent(table);
  69. },
  70. add: function () {
  71. Controller.api.bindevent();
  72. },
  73. edit: function () {
  74. Controller.api.bindevent();
  75. },
  76. api: {
  77. bindevent: function () {
  78. Form.api.bindevent($("form[role=form]"));
  79. }
  80. }
  81. };
  82. return Controller;
  83. });