product.js 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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: '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. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'weigh',
  22. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'name', title: __('Name'), operate: 'LIKE'},
  29. // {field: 'title', title: __('Title'), operate: 'LIKE'},
  30. // {field: 'info', title: __('Info'), operate: 'LIKE'},
  31. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  32. {field: 'price', title: __('Price'), operate:'BETWEEN'},
  33. // {field: 'content', title: __('Content')},
  34. {field: 'is_show', title: __('Is_show'), searchList: {"1":__('Is_show 1'),"0":__('Is_show 0')}, formatter: Table.api.formatter.normal},
  35. // {field: 'weigh', title: __('Weigh'), operate: false},
  36. {field: 'view_number', title: __('View_number')},
  37. // {field: 'procate_id', title: __('Procate_id')},
  38. {field: 'procate.name', title: __('Procate.name'), operate: 'LIKE'},
  39. {field: 'is_recommend', title: __('Is_recommend'), searchList: {"1":__('Is_recommend 1'),"0":__('Is_recommend 0')}, formatter: Table.api.formatter.normal},
  40. {field: 'address', title: __('Address'), operate: 'LIKE'},
  41. {field: 'sell_number', title: __('Sell_number')},
  42. // {field: 'protag_id', title: __('Protag_id')},
  43. {field: 'protag.name', title: __('Protag.name'), operate: 'LIKE'},
  44. {field: 'jxtype', title: __('Jxtype'), searchList: {"0":__('Jxtype 0'),"1":__('Jxtype 1')}, formatter: Table.api.formatter.normal},
  45. {field: 'productxieyi.name', title: __('Productxieyi.name'), operate: 'LIKE'},
  46. {field: 'operate', title: __('Operate'),
  47. buttons:[
  48. {
  49. name:'jxqrcode',
  50. text:'经销商码',
  51. title:'经销商码',
  52. icon:'fa fa-exclamation-circle',
  53. classname:'btn btn-xs btn-danger btn-dialog',
  54. url:'Product/jxqrcode/id/{ids}',
  55. target:'_self',
  56. refresh:true,
  57. hidden:function($row){
  58. if($row.jxtype == 1){
  59. return false;
  60. }
  61. return true;
  62. }
  63. }
  64. ],
  65. table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  66. ]
  67. ]
  68. });
  69. // 为表格绑定事件
  70. Table.api.bindevent(table);
  71. },
  72. add: function () {
  73. Controller.api.bindevent();
  74. },
  75. edit: function () {
  76. Controller.api.bindevent();
  77. },
  78. jxqrcode: function () {
  79. Controller.api.bindevent();
  80. },
  81. api: {
  82. bindevent: function () {
  83. Form.api.bindevent($("form[role=form]"));
  84. }
  85. }
  86. };
  87. return Controller;
  88. });