123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- function goodsShowStatus(type) {
- if (type == '1') {//书币充值
- $('.js_vip_group').hide();
- $('.js_kandian_group').show();
- } else if (type == '2') {//VIP充值
- $('.js_vip_group').show();
- $('.js_kandian_group').hide();
- }
- }
- goodsType = $('.js_selected_goods_type').val();
- goodsShowStatus(goodsType);
- $(document).on('click', '.js_choose_goods', function () {
- Fast.api.open('goods/select?goods_category=activity&business_line=' + Config.business_line, '选择商品', {
- callback: function (data) {
- console.log(data);
- var goodsItem = data[0];
- $('.js_selected_goods_show_type_text').text(goodsItem.show_type_text);
- $('.js_selected_goods_type_text').text(goodsItem.type_text);
- $('.js_selected_goods_money').text(goodsItem.money);
- $('.js_selected_goods_kandian').text(goodsItem.kandian);
- $('.js_selected_goods_free_kandian').text(goodsItem.free_kandian);
- $('.js_selected_goods_icon').text(goodsItem.icon);
- $('.js_selected_goods_id').val(goodsItem.id);
- $('.js_selected_goods_free_day').text(goodsItem.free_day);
- $('.js_selected_goods_day').text(goodsItem.day);
-
- goodsShowStatus(goodsItem.type);
- // if (goodsItem.type == '1') {//书币充值
- // $('.js_vip_group').hide();
- // $('.js_kandian_group').show();
- // } else if (goodsItem.type == '2') {//VIP充值
- // $('.js_vip_group').show();
- // $('.js_kandian_group').hide();
- // }
- }
- });
- });
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'resource/index?aid='+Config.aid+'&resource_type='+Config.resource_type,
- add_url: 'resource/add?aid='+Config.aid+'&resource_type='+Config.resource_type+'&business_line='+Config.business_line,
- edit_url: 'resource/edit?aid='+Config.aid+'&resource_type='+Config.resource_type,
- table: 'resource',
- },
- showToggle: false,
- showColumns: false,
- showExport: false,
- commonSearch: false,
- operate: false,
- search:false,
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'weigh',
- columns: [Controller.api.showIndex(table)]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- select:function(){
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'resource/select?aid='+Config.aid+'&resource_type='+Config.resource_type,
- },
- showColumns: false,
- showToggle: false,
- showExport: false,
- searchFormVisible: false,
- search: false,
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id desc',
- sortOrder: '',
- columns: [Controller.api.showSelect()]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- //获取选中数据
- $(document).on('click', "#btn-chooseone", function () {
- Fast.api.close(table.bootstrapTable('getSelections'));
- });
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- status:function(value,row,index){
- if(value==1){
- return '开启';
- }else{
- return '关闭';
- }
- },
- showIndex:function(table){
- var arr = new Array();
- arr.push({checkbox: true});
- arr.push({field: 'id', title: __('Id')});
- 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')}});
- arr.push({
- field: 'show_type_text',
- title: __('Show_type'),
- formatter: Controller.api.show_type,
- operate: false
- });
- arr.push({field: 'name', title: __('Name')});
- arr.push({field: 'type', title: __('Type'), visible:false, searchList: {"type 0":__('Type 0'),"type 1":__('Type 1'),"2":__('Type 2')}});
- arr.push({field: 'type_text', title: __('Type'), formatter: Controller.api.type, operate: false});
- if(Config.resource_type != 3){
- arr.push({field: 'money', title: __('Money'), formatter: Controller.api.money, operate: 'BETWEEN'});
- arr.push({field: 'day', title: __('vip天数'), formatter: Controller.api.day, operate: false});
- arr.push({
- field: 'kandian',
- title: __('Kandian'),
- formatter: Controller.api.kandian,
- operate: false
- });
- }
- arr.push({
- field: 'free_kandian',
- title: __('Free_kandian'),
- formatter: Controller.api.free_kandian,
- operate: false
- });
- arr.push({field: 'free_day', title: __('Free_day'), formatter: Controller.api.free_day,operate:false});
- arr.push({field: 'warning1', title: __('Warning1'), operate:false});
- arr.push({field: 'warning2', title: __('Warning2'), operate:false});
- arr.push({field: 'icon', title: __('Icon'), formatter: Controller.api.icon, operate:false});
- arr.push({field: 'bgimage', title: __('Bgimage'), formatter: Table.api.formatter.image, operate:false});
- arr.push({field: 'payimage', title: __('Payimage'), formatter: Table.api.formatter.image, operate:false});
- arr.push({field: 'bannerimage', title: __('Bannerimage'), formatter: Table.api.formatter.image, operate:false});
- arr.push({field: 'bgcolor', title: __('Bgcolor'), operate:false});
- arr.push({field: 'paycolor', title: __('Paycolor'), operate:false});
- arr.push({field: 'atimecolor', title: __('Atimecolor'), operate:false});
- arr.push({field: 'warningcolor', title: __('Warningcolor'), operate:false});
- /*arr.push({field: 'status', title: __('弹窗状态'), operate:false, formatter: Controller.api.status});*/
- arr.push({field: 'popimage', title: __('Popimage'), formatter: Table.api.formatter.image, operate:false});
- /*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')}});
- arr.push({field: 'pop_range_text', title: __('Pop_range'), operate:false, formatter: Table.api.formatter.label});*/
- arr.push({field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime, operate:false});
- arr.push({field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime, operate:false});
- arr.push({field: 'weigh', title: __('Weigh'), operate:false});
- arr.push({field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate});
- return arr;
- },
- showSelect:function(){
- var arr = new Array();
- arr.push({checkbox: true});
- arr.push({field: 'id', title: __('Id')});
- arr.push({field: 'name', title: __('Name')});
- arr.push({field: 'type', title: __('Type'), visible:false, searchList: {"type 0":__('Type 0'),"type 1":__('Type 1'),"2":__('Type 2')}});
- arr.push({field: 'type_text', title: __('Type'), formatter: Controller.api.type, operate: false});
- if(Config.resource_type != 3){
- arr.push({field: 'money', title: __('Money'), formatter: Controller.api.money, operate: 'BETWEEN'});
- arr.push({field: 'day', title: __('vip天数'), formatter: Controller.api.day, operate: false});
- arr.push({
- field: 'kandian',
- title: __('Kandian'),
- formatter: Controller.api.kandian,
- operate: false
- });
- }
- arr.push({
- field: 'free_kandian',
- title: __('Free_kandian'),
- formatter: Controller.api.free_kandian,
- operate: false
- });
- arr.push({field: 'free_day', title: __('Free_day'),formatter: Controller.api.free_day, operate:false});
- arr.push({
- field: 'operate', title: __('Operate'), events: {
- 'click .btn-chooseone': function (e, value, row, index) {
- Fast.api.close(row);
- },
- }, formatter: function () {
- return '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Choose') + '</a>';
- }
- });
- return arr;
- },
- show_type: function (value, row, index) {
- if (row.g_show_type == null) {
- return value;
- } else {
- switch (row.g_show_type) {
- case '0':
- return '全部用户';
- case '1':
- return '普通付费';
- case '2':
- return '未付费';
- default:
- return '';
- }
- }
- },
- type: function (value, row, index) {
- if (row.g_type == null) {
- return value;
- } else {
- switch (row.g_type) {
- case '1':
- return '书币充值';
- case '2':
- return 'VIP充值';
- default:
- return '';
- }
- }
- },
- money: function (value, row, index) {
- return row.g_money == null ? value : row.g_money;
- },
- kandian: function (value, row, index) {
- return row.g_kandian == null ? value : row.g_kandian;
- },
- free_kandian: function (value, row, index) {
- return row.g_free_kandian == null ? value : row.g_free_kandian;
- },
- icon: function (value, row, index) {
- return row.g_icon == null ? value : row.g_icon;
- },
- day: function (value, row, index) {
- return row.g_day == null ? value : row.g_day;
- },
- free_day:function (value, row, index) {
- return row.g_free_day == null ? value : row.g_free_day;
- }
- }
- };
- return Controller;
- });
|