product.js 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form','editable'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'product/index' + location.search,
  8. add_url: 'product/add',
  9. edit_url: 'product/edit',
  10. del_url: 'product/del',
  11. multi_url: 'product/multi',
  12. import_url: 'product/import',
  13. table: 'product',
  14. earchFormVisible: true
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'id',
  23. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'id', title: __('Id')},
  27. {field: 'sort', title: __('Sort'),editable: true},
  28. {field: 'name', title: __('Name'), operate: 'LIKE'},
  29. {field: 'category.name', title: '保险分类',operate:'LIKE'},
  30. {field: 'company.name', title: '保险公司',operate: 'LIKE'},
  31. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  32. {field: 'p_image', title: __('P_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  33. {field: 'status', title: __('Status')},
  34. {field: 'attribute', title: '在售状态', searchList: {"新上架产品":__('新上架产品'),"在售产品":__('在售产品'),"停售产品":__('停售产品')}, formatter: Table.api.formatter.normal},
  35. {field: 'operate', title: __('Operate'), table: table,
  36. events: Table.api.events.operate,
  37. formatter:Table.api.formatter.operate
  38. // formatter:function (value, row, index) {
  39. // var that = $.extend({}, this);
  40. // var table = $(that.table).clone(true);
  41. // // operate-edit编辑 perate-del删除
  42. // //判断什么时候显示什么时候不显示
  43. // if (row.status === 0) {
  44. // $(table).data("operate-edit", null); // 列表页面隐藏 .编辑operate-edit - 删除按钮operate-del
  45. // }
  46. // that.table = table;
  47. // return Table.api.formatter.operate.call(that, value, row, index);
  48. // }
  49. }
  50. ]
  51. ]
  52. });
  53. // 为表格绑定事件
  54. Table.api.bindevent(table);
  55. },
  56. add: function () {
  57. Controller.api.bindevent();
  58. },
  59. edit: function () {
  60. Controller.api.bindevent();
  61. },
  62. api: {
  63. bindevent: function () {
  64. Form.api.bindevent($("form[role=form]"));
  65. }
  66. }
  67. };
  68. return Controller;
  69. });