active.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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: 'currentperson', title: __('Currentperson')},
  42. {field: 'signupendtime', title: __('Signupendtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  43. {field: 'refundendtime', title: __('Refundendtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  44. {field: 'is_free', title: __('Is_free'), searchList: {"0":__('Is_free 0'),"1":__('Is_free 1')}, formatter: Table.api.formatter.normal},
  45. {field: 'is_overlying', title: __('Is_overlying'), searchList: {"0":__('Is_overlying 0'),"1":__('Is_overlying 1')}, formatter: Table.api.formatter.normal},
  46. {field: 'girldiscount', title: __('Girldiscount')},
  47. {field: 'minage', title: __('Minage')},
  48. {field: 'maxage', title: __('Maxage')},
  49. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3')}, formatter: Table.api.formatter.status},
  50. {field: 'weigh', title: __('Weigh'), operate: false},
  51. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  52. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  53. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
  54. buttons: [
  55. {
  56. name: 'activeorder',
  57. text: '活动订单',
  58. title: __('活动订单'),
  59. extend: 'data-area=\'["85%", "85%"]\'',
  60. classname: 'btn btn-xs btn-success btn-dialog',
  61. icon: 'fa fa-list',
  62. url: 'activeorder/index',
  63. // callback: function (data) {
  64. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  65. // }
  66. // success: function (data, ret) {
  67. // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
  68. // Layer.alert(ret.msg);
  69. // //如果需要阻止成功提示,则必须使用return false;
  70. // return false;
  71. // },
  72. // error: function (data, ret) {
  73. // // console.log(data, ret);
  74. // Layer.alert(ret.msg);
  75. // return false;
  76. // },
  77. // callback: function (data) {
  78. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  79. // },
  80. // visible: function (row) {
  81. // if (row.status == 1 && row.purpose == 3) {
  82. // return true;
  83. // } else {
  84. // return false;
  85. // }
  86. // }
  87. },
  88. {
  89. name: 'activeorder',
  90. text: '报名人员',
  91. title: __('报名人员'),
  92. extend: 'data-area=\'["85%", "85%"]\'',
  93. classname: 'btn btn-xs btn-success btn-dialog',
  94. icon: 'fa fa-list',
  95. url: 'activepeople/index',
  96. // callback: function (data) {
  97. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  98. // }
  99. // success: function (data, ret) {
  100. // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
  101. // Layer.alert(ret.msg);
  102. // //如果需要阻止成功提示,则必须使用return false;
  103. // return false;
  104. // },
  105. // error: function (data, ret) {
  106. // // console.log(data, ret);
  107. // Layer.alert(ret.msg);
  108. // return false;
  109. // },
  110. // callback: function (data) {
  111. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  112. // },
  113. // visible: function (row) {
  114. // if (row.status == 1 && row.purpose == 3) {
  115. // return true;
  116. // } else {
  117. // return false;
  118. // }
  119. // }
  120. },
  121. {
  122. name: 'edit',
  123. text: '',
  124. title: __('编辑'),
  125. // extend: 'data-area=\'["85%", "85%"]\'',
  126. classname: 'btn btn-xs btn-success btn-editone',
  127. icon: 'fa fa-pencil',
  128. // confirm: '确认删除?',
  129. url: 'active/edit',
  130. refresh: true,
  131. // success: function (data, ret) {
  132. // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
  133. // Layer.alert(ret.msg);
  134. // //如果需要阻止成功提示,则必须使用return false;
  135. // return false;
  136. // },
  137. // error: function (data, ret) {
  138. // // console.log(data, ret);
  139. // Layer.alert(ret.msg);
  140. // return false;
  141. // },
  142. // callback: function (data) {
  143. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  144. // },
  145. // visible: function (row) {
  146. // if (row.status == 0) {
  147. // return true;
  148. // } else {
  149. // return false;
  150. // }
  151. // }
  152. },
  153. {
  154. name: 'del',
  155. text: '',
  156. title: __('删除'),
  157. extend: 'data-area=\'["85%", "85%"]\'',
  158. classname: 'btn btn-xs btn-danger btn-delone',
  159. icon: 'fa fa-trash',
  160. confirm: '确认删除?',
  161. url: 'active/del',
  162. refresh: true,
  163. // success: function (data, ret) {
  164. // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
  165. // Layer.alert(ret.msg);
  166. // //如果需要阻止成功提示,则必须使用return false;
  167. // return false;
  168. // },
  169. // error: function (data, ret) {
  170. // // console.log(data, ret);
  171. // Layer.alert(ret.msg);
  172. // return false;
  173. // },
  174. // callback: function (data) {
  175. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  176. // },
  177. visible: function (row) {
  178. if (row.status == 0) {
  179. return true;
  180. } else {
  181. return false;
  182. }
  183. }
  184. },
  185. {
  186. name: 'dragsort',
  187. text: '',
  188. title: __('拖动'),
  189. extend: 'data-area=\'["85%", "85%"]\'',
  190. classname: 'btn btn-xs btn-danger btn-delone',
  191. icon: 'fa fa-trash',
  192. confirm: '确认删除?',
  193. url: 'active/del',
  194. refresh: true,
  195. // success: function (data, ret) {
  196. // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
  197. // Layer.alert(ret.msg);
  198. // //如果需要阻止成功提示,则必须使用return false;
  199. // return false;
  200. // },
  201. // error: function (data, ret) {
  202. // // console.log(data, ret);
  203. // Layer.alert(ret.msg);
  204. // return false;
  205. // },
  206. // callback: function (data) {
  207. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  208. // },
  209. visible: function (row) {
  210. return false;
  211. }
  212. }
  213. ]
  214. }
  215. ]
  216. ]
  217. });
  218. // 为表格绑定事件
  219. Table.api.bindevent(table);
  220. },
  221. add: function () {
  222. Controller.api.bindevent();
  223. },
  224. edit: function () {
  225. Controller.api.bindevent();
  226. },
  227. api: {
  228. bindevent: function () {
  229. Form.api.bindevent($("form[role=form]"));
  230. }
  231. }
  232. };
  233. return Controller;
  234. });