这个问题困扰我好几天了,百度都没有,因为我一直百度的关键字fastadmin,我知道fastadmin的表格采用的是bootstrap-table.
于是我就看了bootstrap-table 的教程,终于让我找到了答案记录一下

        // 初始化表格
           table.bootstrapTable({
               url: $.fn.bootstrapTable.defaults.extend.index_url,
               pk: 'id',
               sortName: 'id',
               columns: [
                   [
                       {checkbox: true},
                       {field: 'id', title: __('Id')},
                       {field: 'admin_id', title: __('Admin_id')},
                       {field: 'admin.username', title: '登录账号'},
                       {field: 'admin.nickname', title: '合伙人名称'},
                       {field: 'timelimit_id', title:__('Timelimit_id')},
                       {field: 'settlperiod', title:__('Settlperiod')},
                       {field: 'phone', title: __('Phone')},
                       {field: 'joinip', title: __('Joinip')},
                       {field: 'servicecharge', title: __('Servicecharge'), operate:'BETWEEN'},
                       {field: 'totalcollectmoney', title: __('Totalcollectmoney'), operate:'BETWEEN'},
                       {field: 'totalrechargemoney', title: __('Totalrechargemoney'), operate:'BETWEEN'},
                       {field: 'creditvalue', title: __('Creditvalue'), operate:'BETWEEN'},
                       {field: 'leftmoney', title: __('Leftmoney'), operate:'BETWEEN'},
                       {field: 'freezemoney', title: __('Freezemoney'), operate:'BETWEEN'},
                       {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status},
                       {
                           field: 'status',
                           title: '切换状态',
                           align: 'center',
                           formatter: Table.api.formatter.toggle,
                           operate:false
                       },
                       {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                       {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {
                               if(row.admin_id == Config.admin.id){
                                   return '';
                               }
                               return Table.api.formatter.operate.call(this, value, row, index);
                           }
                       }
                   ]
               ],
               responseHandler: function(res){
                   $('#count').text(res.count);
                   $('#ordernum').text(res.ordernum);
                   return res;
               }
           });

responseHandler 那个属性,res 就是返回的所有数据,记得要return 哦,否则无法渲染表格

Last modification:May 7th, 2020 at 05:47 pm
如果觉得我的文章对你有用,请随意赞赏