resource.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. function goodsShowStatus(type) {
  3. if (type == '1') {//书币充值
  4. $('.js_vip_group').hide();
  5. $('.js_kandian_group').show();
  6. } else if (type == '2') {//VIP充值
  7. $('.js_vip_group').show();
  8. $('.js_kandian_group').hide();
  9. }
  10. }
  11. goodsType = $('.js_selected_goods_type').val();
  12. goodsShowStatus(goodsType);
  13. $(document).on('click', '.js_choose_goods', function () {
  14. Fast.api.open('goods/select?goods_category=activity&business_line=' + Config.business_line, '选择商品', {
  15. callback: function (data) {
  16. console.log(data);
  17. var goodsItem = data[0];
  18. $('.js_selected_goods_show_type_text').text(goodsItem.show_type_text);
  19. $('.js_selected_goods_type_text').text(goodsItem.type_text);
  20. $('.js_selected_goods_money').text(goodsItem.money);
  21. $('.js_selected_goods_kandian').text(goodsItem.kandian);
  22. $('.js_selected_goods_free_kandian').text(goodsItem.free_kandian);
  23. $('.js_selected_goods_icon').text(goodsItem.icon);
  24. $('.js_selected_goods_id').val(goodsItem.id);
  25. $('.js_selected_goods_free_day').text(goodsItem.free_day);
  26. $('.js_selected_goods_day').text(goodsItem.day);
  27. goodsShowStatus(goodsItem.type);
  28. // if (goodsItem.type == '1') {//书币充值
  29. // $('.js_vip_group').hide();
  30. // $('.js_kandian_group').show();
  31. // } else if (goodsItem.type == '2') {//VIP充值
  32. // $('.js_vip_group').show();
  33. // $('.js_kandian_group').hide();
  34. // }
  35. }
  36. });
  37. });
  38. var Controller = {
  39. index: function () {
  40. // 初始化表格参数配置
  41. Table.api.init({
  42. extend: {
  43. index_url: 'resource/index?aid='+Config.aid+'&resource_type='+Config.resource_type,
  44. add_url: 'resource/add?aid='+Config.aid+'&resource_type='+Config.resource_type+'&business_line='+Config.business_line,
  45. edit_url: 'resource/edit?aid='+Config.aid+'&resource_type='+Config.resource_type,
  46. table: 'resource',
  47. },
  48. showToggle: false,
  49. showColumns: false,
  50. showExport: false,
  51. commonSearch: false,
  52. operate: false,
  53. search:false,
  54. });
  55. var table = $("#table");
  56. // 初始化表格
  57. table.bootstrapTable({
  58. url: $.fn.bootstrapTable.defaults.extend.index_url,
  59. pk: 'id',
  60. sortName: 'weigh',
  61. columns: [Controller.api.showIndex(table)]
  62. });
  63. // 为表格绑定事件
  64. Table.api.bindevent(table);
  65. },
  66. add: function () {
  67. Controller.api.bindevent();
  68. },
  69. edit: function () {
  70. Controller.api.bindevent();
  71. },
  72. select:function(){
  73. // 初始化表格参数配置
  74. Table.api.init({
  75. extend: {
  76. index_url: 'resource/select?aid='+Config.aid+'&resource_type='+Config.resource_type,
  77. },
  78. showColumns: false,
  79. showToggle: false,
  80. showExport: false,
  81. searchFormVisible: false,
  82. search: false,
  83. });
  84. var table = $("#table");
  85. // 初始化表格
  86. table.bootstrapTable({
  87. url: $.fn.bootstrapTable.defaults.extend.index_url,
  88. pk: 'id',
  89. sortName: 'id desc',
  90. sortOrder: '',
  91. columns: [Controller.api.showSelect()]
  92. });
  93. // 为表格绑定事件
  94. Table.api.bindevent(table);
  95. //获取选中数据
  96. $(document).on('click', "#btn-chooseone", function () {
  97. Fast.api.close(table.bootstrapTable('getSelections'));
  98. });
  99. },
  100. api: {
  101. bindevent: function () {
  102. Form.api.bindevent($("form[role=form]"));
  103. },
  104. status:function(value,row,index){
  105. if(value==1){
  106. return '开启';
  107. }else{
  108. return '关闭';
  109. }
  110. },
  111. showIndex:function(table){
  112. var arr = new Array();
  113. arr.push({checkbox: true});
  114. arr.push({field: 'id', title: __('Id')});
  115. arr.push({field: 'show_type', title: __('Show_type'), visible:false, searchList: {"show_type 0":__('Show_type 0'),"show_type 1":__('Show_type 1'),"show_type 2":__('Show_type 2'),"show_type 3":__('Show_type 3')}});
  116. arr.push({
  117. field: 'show_type_text',
  118. title: __('Show_type'),
  119. formatter: Controller.api.show_type,
  120. operate: false
  121. });
  122. arr.push({field: 'name', title: __('Name')});
  123. arr.push({field: 'type', title: __('Type'), visible:false, searchList: {"type 0":__('Type 0'),"type 1":__('Type 1'),"2":__('Type 2')}});
  124. arr.push({field: 'type_text', title: __('Type'), formatter: Controller.api.type, operate: false});
  125. if(Config.resource_type != 3){
  126. arr.push({field: 'money', title: __('Money'), formatter: Controller.api.money, operate: 'BETWEEN'});
  127. arr.push({field: 'day', title: __('vip天数'), formatter: Controller.api.day, operate: false});
  128. arr.push({
  129. field: 'kandian',
  130. title: __('Kandian'),
  131. formatter: Controller.api.kandian,
  132. operate: false
  133. });
  134. }
  135. arr.push({
  136. field: 'free_kandian',
  137. title: __('Free_kandian'),
  138. formatter: Controller.api.free_kandian,
  139. operate: false
  140. });
  141. arr.push({field: 'free_day', title: __('Free_day'), formatter: Controller.api.free_day,operate:false});
  142. arr.push({field: 'warning1', title: __('Warning1'), operate:false});
  143. arr.push({field: 'warning2', title: __('Warning2'), operate:false});
  144. arr.push({field: 'icon', title: __('Icon'), formatter: Controller.api.icon, operate:false});
  145. arr.push({field: 'bgimage', title: __('Bgimage'), formatter: Table.api.formatter.image, operate:false});
  146. arr.push({field: 'payimage', title: __('Payimage'), formatter: Table.api.formatter.image, operate:false});
  147. arr.push({field: 'bannerimage', title: __('Bannerimage'), formatter: Table.api.formatter.image, operate:false});
  148. arr.push({field: 'bgcolor', title: __('Bgcolor'), operate:false});
  149. arr.push({field: 'paycolor', title: __('Paycolor'), operate:false});
  150. arr.push({field: 'atimecolor', title: __('Atimecolor'), operate:false});
  151. arr.push({field: 'warningcolor', title: __('Warningcolor'), operate:false});
  152. /*arr.push({field: 'status', title: __('弹窗状态'), operate:false, formatter: Controller.api.status});*/
  153. arr.push({field: 'popimage', title: __('Popimage'), formatter: Table.api.formatter.image, operate:false});
  154. /*arr.push({field: 'pop_range', title: __('Pop_range'), visible:false, searchList: {"pop_range 0":__('Pop_range 0'),"pop_range 1":__('Pop_range 1'),"pop_range 2":__('Pop_range 2'),"pop_range 3":__('Pop_range 3'),"pop_range 4":__('Pop_range 4'),"pop_range 5":__('Pop_range 5'),"pop_range 6":__('Pop_range 6')}});
  155. arr.push({field: 'pop_range_text', title: __('Pop_range'), operate:false, formatter: Table.api.formatter.label});*/
  156. arr.push({field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime, operate:false});
  157. arr.push({field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime, operate:false});
  158. arr.push({field: 'weigh', title: __('Weigh'), operate:false});
  159. arr.push({field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate});
  160. return arr;
  161. },
  162. showSelect:function(){
  163. var arr = new Array();
  164. arr.push({checkbox: true});
  165. arr.push({field: 'id', title: __('Id')});
  166. arr.push({field: 'name', title: __('Name')});
  167. arr.push({field: 'type', title: __('Type'), visible:false, searchList: {"type 0":__('Type 0'),"type 1":__('Type 1'),"2":__('Type 2')}});
  168. arr.push({field: 'type_text', title: __('Type'), formatter: Controller.api.type, operate: false});
  169. if(Config.resource_type != 3){
  170. arr.push({field: 'money', title: __('Money'), formatter: Controller.api.money, operate: 'BETWEEN'});
  171. arr.push({field: 'day', title: __('vip天数'), formatter: Controller.api.day, operate: false});
  172. arr.push({
  173. field: 'kandian',
  174. title: __('Kandian'),
  175. formatter: Controller.api.kandian,
  176. operate: false
  177. });
  178. }
  179. arr.push({
  180. field: 'free_kandian',
  181. title: __('Free_kandian'),
  182. formatter: Controller.api.free_kandian,
  183. operate: false
  184. });
  185. arr.push({field: 'free_day', title: __('Free_day'),formatter: Controller.api.free_day, operate:false});
  186. arr.push({
  187. field: 'operate', title: __('Operate'), events: {
  188. 'click .btn-chooseone': function (e, value, row, index) {
  189. Fast.api.close(row);
  190. },
  191. }, formatter: function () {
  192. return '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Choose') + '</a>';
  193. }
  194. });
  195. return arr;
  196. },
  197. show_type: function (value, row, index) {
  198. if (row.g_show_type == null) {
  199. return value;
  200. } else {
  201. switch (row.g_show_type) {
  202. case '0':
  203. return '全部用户';
  204. case '1':
  205. return '普通付费';
  206. case '2':
  207. return '未付费';
  208. default:
  209. return '';
  210. }
  211. }
  212. },
  213. type: function (value, row, index) {
  214. if (row.g_type == null) {
  215. return value;
  216. } else {
  217. switch (row.g_type) {
  218. case '1':
  219. return '书币充值';
  220. case '2':
  221. return 'VIP充值';
  222. default:
  223. return '';
  224. }
  225. }
  226. },
  227. money: function (value, row, index) {
  228. return row.g_money == null ? value : row.g_money;
  229. },
  230. kandian: function (value, row, index) {
  231. return row.g_kandian == null ? value : row.g_kandian;
  232. },
  233. free_kandian: function (value, row, index) {
  234. return row.g_free_kandian == null ? value : row.g_free_kandian;
  235. },
  236. icon: function (value, row, index) {
  237. return row.g_icon == null ? value : row.g_icon;
  238. },
  239. day: function (value, row, index) {
  240. return row.g_day == null ? value : row.g_day;
  241. },
  242. free_day:function (value, row, index) {
  243. return row.g_free_day == null ? value : row.g_free_day;
  244. }
  245. }
  246. };
  247. return Controller;
  248. });