active.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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: 'active/index' + location.search,
  8. add_url: 'active/add',
  9. edit_url: 'active/edit',
  10. del_url: 'active/del',
  11. multi_url: 'active/multi',
  12. import_url: 'active/import',
  13. table: 'active',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'weigh desc, id desc',
  22. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
  29. {field: 'title', title: __('Title'), operate: 'LIKE'},
  30. {field: 'desc', title: __('Desc'), operate: 'LIKE'},
  31. {field: 'remark', title: __('Remark'), operate: 'LIKE'},
  32. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  33. {field: 'price', title: __('Price'), operate: 'LIKE'},
  34. {field: 'starttime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  35. {field: 'endtime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  36. {field: 'collectionplace', title: __('Collectionplace'), operate: 'LIKE'},
  37. {field: 'collectiontime', title: __('Collectiontime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'insurance', title: __('Insurance'), operate: 'LIKE'},
  39. {field: 'leader', title: __('Leader'), operate: 'LIKE'},
  40. {field: 'maxperson', title: __('Maxperson')},
  41. {field: 'minperson', title: __('最低成行人数')},
  42. {field: 'currentperson', title: __('Currentperson')},
  43. {field: 'signupendtime', title: __('Signupendtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  44. {field: 'refundendtime', title: __('Refundendtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  45. {field: 'is_free', title: __('Is_free'), searchList: {"0":__('Is_free 0'),"1":__('Is_free 1')}, formatter: Table.api.formatter.normal},
  46. {field: 'is_overlying', title: __('Is_overlying'), searchList: {"0":__('Is_overlying 0'),"1":__('Is_overlying 1')}, formatter: Table.api.formatter.normal},
  47. {field: 'girldiscount', title: __('Girldiscount')},
  48. {field: 'minage', title: __('Minage')},
  49. {field: 'maxage', title: __('Maxage')},
  50. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3')}, formatter: Table.api.formatter.status},
  51. {field: 'showstatus', title: __('Showstatus'), searchList: {"0":__('Showstatus 0'),"1":__('Showstatus 1')}, formatter: Table.api.formatter.status},
  52. {field: 'is_autoshow', title: __('Is_autoshow'), searchList: {"0":__('Is_autoshow 0'),"1":__('Is_autoshow 1')}, formatter: Table.api.formatter.status},
  53. {field: 'showtime', title: __('Showtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  54. {field: 'is_banner', title: __('Is_banner'), searchList: {"0":__('Is_banner 0'),"1":__('Is_banner 1')}, formatter: Table.api.formatter.status},
  55. {field: 'weigh', title: __('Weigh'), operate: false},
  56. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  57. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  58. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
  59. buttons: [
  60. {
  61. name: 'activeorder',
  62. text: '活动订单',
  63. title: __('活动订单'),
  64. extend: 'data-area=\'["85%", "85%"]\'',
  65. classname: 'btn btn-xs btn-success btn-dialog',
  66. icon: 'fa fa-list',
  67. url: 'activeorder/index',
  68. // callback: function (data) {
  69. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  70. // }
  71. // success: function (data, ret) {
  72. // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
  73. // Layer.alert(ret.msg);
  74. // //如果需要阻止成功提示,则必须使用return false;
  75. // return false;
  76. // },
  77. // error: function (data, ret) {
  78. // // console.log(data, ret);
  79. // Layer.alert(ret.msg);
  80. // return false;
  81. // },
  82. // callback: function (data) {
  83. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  84. // },
  85. // visible: function (row) {
  86. // if (row.status == 1 && row.purpose == 3) {
  87. // return true;
  88. // } else {
  89. // return false;
  90. // }
  91. // }
  92. },
  93. {
  94. name: 'activeorder',
  95. text: '报名人员',
  96. title: __('报名人员'),
  97. extend: 'data-area=\'["85%", "85%"]\'',
  98. classname: 'btn btn-xs btn-success btn-dialog',
  99. icon: 'fa fa-list',
  100. url: 'activepeople/index',
  101. // callback: function (data) {
  102. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  103. // }
  104. // success: function (data, ret) {
  105. // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
  106. // Layer.alert(ret.msg);
  107. // //如果需要阻止成功提示,则必须使用return false;
  108. // return false;
  109. // },
  110. // error: function (data, ret) {
  111. // // console.log(data, ret);
  112. // Layer.alert(ret.msg);
  113. // return false;
  114. // },
  115. // callback: function (data) {
  116. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  117. // },
  118. // visible: function (row) {
  119. // if (row.status == 1 && row.purpose == 3) {
  120. // return true;
  121. // } else {
  122. // return false;
  123. // }
  124. // }
  125. },
  126. {
  127. name: 'edit',
  128. text: '',
  129. title: __('编辑'),
  130. // extend: 'data-area=\'["85%", "85%"]\'',
  131. classname: 'btn btn-xs btn-success btn-editone',
  132. icon: 'fa fa-pencil',
  133. // confirm: '确认删除?',
  134. url: 'active/edit',
  135. refresh: true,
  136. // success: function (data, ret) {
  137. // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
  138. // Layer.alert(ret.msg);
  139. // //如果需要阻止成功提示,则必须使用return false;
  140. // return false;
  141. // },
  142. // error: function (data, ret) {
  143. // // console.log(data, ret);
  144. // Layer.alert(ret.msg);
  145. // return false;
  146. // },
  147. // callback: function (data) {
  148. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  149. // },
  150. // visible: function (row) {
  151. // if (row.status == 0) {
  152. // return true;
  153. // } else {
  154. // return false;
  155. // }
  156. // }
  157. },
  158. {
  159. name: 'del',
  160. text: '',
  161. title: __('删除'),
  162. extend: 'data-area=\'["85%", "85%"]\'',
  163. classname: 'btn btn-xs btn-danger btn-delone',
  164. icon: 'fa fa-trash',
  165. confirm: '确认删除?',
  166. url: 'active/del',
  167. refresh: true,
  168. // success: function (data, ret) {
  169. // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
  170. // Layer.alert(ret.msg);
  171. // //如果需要阻止成功提示,则必须使用return false;
  172. // return false;
  173. // },
  174. // error: function (data, ret) {
  175. // // console.log(data, ret);
  176. // Layer.alert(ret.msg);
  177. // return false;
  178. // },
  179. // callback: function (data) {
  180. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  181. // },
  182. visible: function (row) {
  183. if (row.status == 0) {
  184. return true;
  185. } else {
  186. return false;
  187. }
  188. }
  189. },
  190. {
  191. name: 'dragsort',
  192. text: '',
  193. title: __('拖动'),
  194. extend: 'data-area=\'["85%", "85%"]\'',
  195. classname: 'btn btn-xs btn-danger btn-delone',
  196. icon: 'fa fa-trash',
  197. confirm: '确认删除?',
  198. url: 'active/del',
  199. refresh: true,
  200. // success: function (data, ret) {
  201. // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
  202. // Layer.alert(ret.msg);
  203. // //如果需要阻止成功提示,则必须使用return false;
  204. // return false;
  205. // },
  206. // error: function (data, ret) {
  207. // // console.log(data, ret);
  208. // Layer.alert(ret.msg);
  209. // return false;
  210. // },
  211. // callback: function (data) {
  212. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  213. // },
  214. visible: function (row) {
  215. return false;
  216. }
  217. }
  218. ]
  219. }
  220. ]
  221. ]
  222. });
  223. // 为表格绑定事件
  224. Table.api.bindevent(table);
  225. },
  226. add: function () {
  227. Controller.api.bindevent();
  228. },
  229. edit: function () {
  230. Controller.api.bindevent();
  231. },
  232. api: {
  233. bindevent: function () {
  234. Form.api.bindevent($("form[role=form]"));
  235. }
  236. }
  237. };
  238. return Controller;
  239. });