123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- $(document).on('click', '#add_goods', function () {
- Fast.api.open('goods/select', '选择商品', {
- callback: function (data) {
- console.log(data);
- var goodsItem = data[0];
- var htmlstr = '<div><input type="hidden" name="row[goods_id][]" value="' + goodsItem.id + '"> ' +
- goodsItem.id +
- '<div>' + goodsItem.title + '</div>' +
- '<div>' + goodsItem.money + '</div>' +
- '<div>' + goodsItem.first_description + '</div>' +
- '<div>' + goodsItem.second_description + '</div>' +
- '<div>' + goodsItem.kandian + '</div>' +
- '<div>' + goodsItem.free_kandian + '</div>' +
- '<div>' + goodsItem.icon + '</div>' +
- '<div>' + goodsItem.show_type_text + '</div>' +
- '<div>--------</div>' +
- '</div>';
- $('#goods_list').append(htmlstr);
- }
- })
- });
- //活动赠送书币展示处理 选择分类
- $(document).on('change','input[name="row[category_id][]"]',function(){
- var category_selected = new Array();
- $('input[name="row[category_id][]"]:checked').each(function(){
- category_selected.push($(this).data('nickname'));
- });
- if( $.inArray('activity',category_selected) >= 0&& parseInt($('input[name="row[type]"]:checked').val()) == 1){
- $('.free_day').show();
- }else{
- $('.free_day').hide();
- }
- });
- //活动赠送书币展示处理 选择商品类型
- $(document).on('click','input[name="row[type]"]',function(){
- var type = $("input[name='row[type]']:checked").val();
- if(type==2){
- $('.day').removeAttr('style');
- $('.kandian').css('display','none');
- }
- if(type==1){
- $('.kandian').removeAttr('style');
- $('.day').css('display','none');
- }
- var category_selected = new Array();
- $('input[name="row[category_id][]"]:checked').each(function(){
- category_selected.push($(this).data('nickname'));
- });
- if( $.inArray('activity',category_selected) >= 0 && parseInt($('input[name="row[type]"]:checked').val()) == 1){
- $('.free_day').show();
- }else{
- $('.free_day').hide();
- }
- });
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'goods/index',
- add_url: 'goods/add',
- edit_url: 'goods/edit',
- del_url: 'goods/del',
- multi_url: 'goods/multi',
- table: 'goods',
- },
- showToggle:false,
- showColumns:false,
- showExport:false,
- searchFormVisible: true,
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'weigh',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id'),operate:false},
- {field: 'title', title: __('Title'),operate:false},
- {field: 'business_line', title: "业务线",searchList: Controller.api.formatter.business_search(),formatter: Controller.api.formatter.business_name,operate:'LIKE'},
- {field: 'category_id', title: __('Category_name'),searchList: $.getJSON('goods/categorylist'),formatter: Controller.api.formatter.category_name,operate:'LIKE'},
- {field: 'money', title: __('Money'),operate:false},
- {field: 'first_description', title: __('First_description'),operate:false},
- {field: 'second_description', title: __('Second_description'),operate:false},
- {field: 'type_text', title: __('Type'), operate:false},
- {field: 'kandian', title: __('Kandian'),operate:false},
- {field: 'free_kandian', title: __('Free_kandian'),operate:false},
- {field: 'day', title: __('Day'),operate:false},
- {field: 'icon', title: __('Icon'),operate:false},
- {field: 'show_type_text', title: __('Show_type'), operate:false},
- {field: 'weigh', title: __('Weigh'),operate:false},
- {field: 'updatetime', title: __('Updatetime'), formatter: Table.api.formatter.datetime,operate:false},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- Controller.api.bindevent();
- },
- select: function () {
- Table.api.init({
- extend: {
- index_url: 'goods/select' + '?goods_category=' + Config.goods_category,
- add_url: 'goods/add',
- edit_url: 'goods/edit',
- del_url: 'goods/del',
- multi_url: 'goods/multi',
- table: 'goods',
- },
- showToggle: false,
- showColumns: false,
- showExport: false,
- searchFormVisible: true,
- search: false,
- commonSearch:true,
- });
- var table = $("#table");
- //快捷充值需要过滤已充值未充值
- var searchListTmp = {'0':'全部用户','1':'已充值用户','2':'未充值用户'};
- var recharge_show_type = Fast.api.query('recharge_show_type');
- if(recharge_show_type != "undefined"){
- if(recharge_show_type == -1){
- searchListTmp = {'0':'全部用户','1':'已充值用户'};
- }else if(recharge_show_type == -2){
- searchListTmp = {'0':'全部用户','2':'未充值用户'};
- }
- }
- // 初始化表格
- table.bootstrapTable({
- queryParams: function (params) { //自定义搜索条件
- params.selected_ids = Fast.api.query('selected_ids');
- params.recharge_show_type = Fast.api.query('recharge_show_type');
- params.business_line = Config.business_line;
- return params;
- },
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'weigh',
- columns: [
- [
- {field: 'title', title: __('Title'), operate: false},
- // {field: 'business_line', title: "业务线",searchList: Controller.api.formatter.business_search(),formatter: Controller.api.formatter.business_name,operate:'LIKE'},
- // {field: 'category_id', title: __('Category_name'),searchList: $.getJSON('goods/categorylist'),formatter: Controller.api.formatter.category_name,operate:'LIKE'},
- {field: 'money', title: __('Money'), operate: false},
- {field: 'first_description', title: __('First_description'), operate: false},
- {field: 'second_description', title: __('Second_description'), operate: false},
- {field: 'type_text', title: __('Type'), operate: false},
- {field: 'kandian', title: __('Kandian'), operate: false},
- {field: 'free_kandian', title: __('Free_kandian'), operate: false},
- {field: 'icon', title: __('Icon'), operate: false},
- {field: 'show_type', title: __('Show_type'),visible:false,searchList:searchListTmp},
- {field: 'show_type_text', title: __('Show_type'), operate: false},
- {
- 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>';
- }
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- Controller.api.bindevent();
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- },
- formatter: {
- business_search:function(){
- var search = {}
- for (var key in Config.business) {
- search[key] = Config.business[key];
- }
- return search;
- },
- business_name:function(value, row, index){
- var c_name = [];
- $.each(Config.business,function(c_key,c_val){
- var ids = row.business_line.split(',');
- if(ids != undefined){
- $.each(ids,function(_,r_val){
- if(parseInt(c_key) == parseInt(r_val)){
- c_name.push(c_val);
- }
- });
- }else{
- if(parseInt(c_key) == parseInt(row.business_line)){
- c_name.push(c_val);
- }
- }
- });
- return c_name.join(',');
- },
- category_name:function (value, row, index) {
- var c_name = [];
- $.each(Config.category_list,function(_,c_val){
- var ids = row.category_id.split(',');
- $.each(ids,function(_,r_val){
- if(c_val.id == r_val){
- c_name.push(c_val.name);
- }
- });
- });
- return c_name.join(',');
- }
- }
- }
- };
- return Controller;
- });
|