uidsale.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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: 'uidsale/index' + location.search,
  8. add_url: 'uidsale/add',
  9. edit_url: 'uidsale/edit',
  10. // del_url: 'uidsale/del',
  11. multi_url: 'uidsale/multi',
  12. import_url: 'uidsale/import',
  13. table: 'uidsale',
  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: 'id', title: __('Id')},
  26. {field: 'new_id', title: __('New_id')},
  27. {field: 'price', title: __('Price')},
  28. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
  29. {field: 'is_show', title: __('Is_show'), searchList: {"1":__('Is_show 1'),"0":__('Is_show 0')}, formatter: Table.api.formatter.normal},
  30. {field: 'user_id', title: __('User_id')},
  31. {field: 'user.username', title: __('User.username'), operate: 'LIKE'},
  32. {field: 'saletime', title: __('Saletime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  33. // {field: 'type_id', title: __('Type_id')},
  34. {field: 'uidsaletype.type', title: __('Uidsaletype.type'), operate: 'LIKE'},
  35. {field: 'operate', title: __('Operate'), table: table,
  36. buttons:[
  37. {
  38. name:'shangjia',
  39. text:'上架',
  40. title:'上架',
  41. icon:'fa fa-exclamation-circle',
  42. classname:'btn btn-xs btn-success btn-ajax',
  43. url:'uidsale/shangjia/ids/{ids}?dialog=1',
  44. target:'_self',
  45. refresh:true,
  46. hidden:function(row){
  47. return (row.status==0 && row.is_show == 0) ? false : true;
  48. }
  49. },
  50. {
  51. name:'xiajia',
  52. text:'下架',
  53. title:'下架',
  54. icon:'fa fa-exclamation-circle',
  55. classname:'btn btn-xs btn-danger btn-ajax',
  56. url:'uidsale/xiajia/ids/{ids}?dialog=1',
  57. target:'_self',
  58. refresh:true,
  59. hidden:function(row){
  60. return (row.status==0 && row.is_show == 1) ? false : true;
  61. }
  62. },
  63. {
  64. name:'edit',
  65. text:'编辑',
  66. title:'编辑',
  67. icon:'fa fa-exclamation-circle',
  68. classname:'btn btn-xs btn-info btn-dialog',
  69. url:'uidsale/edit/ids/{ids}?dialog=1',
  70. target:'_self',
  71. refresh:true,
  72. hidden:function(row){
  73. return (row.status==0 && row.is_show == 0) ? false : true;
  74. }
  75. }
  76. ],
  77. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  78. ]
  79. ]
  80. });
  81. // 为表格绑定事件
  82. Table.api.bindevent(table);
  83. },
  84. add: function () {
  85. Controller.api.bindevent();
  86. },
  87. edit: function () {
  88. Controller.api.bindevent();
  89. },
  90. shangjia: function () {
  91. Controller.api.bindevent();
  92. },
  93. xiajia: function () {
  94. Controller.api.bindevent();
  95. },
  96. api: {
  97. bindevent: function () {
  98. Form.api.bindevent($("form[role=form]"));
  99. }
  100. }
  101. };
  102. return Controller;
  103. });