目 录CONTENT

文章目录
PHP

fastadmin Admin table

ABin
2023-12-30 / 0 评论 / 0 点赞 / 23 阅读 / 0 字
Table.api.init({
     //默认为卡片显示   
     cardView:true,
       
 });

var table = $("#table");

#快速搜索 搜索框内显示的文字信息 搜索其他id 控制器内 protected $searchFields = 'id,username,nickname';
$.fn.bootstrapTable.locales[Table.defaults.locale]['formatSearch'] = function(){return "手机号";};
#table 浏览模式、显示隐藏列、导出、  通用搜索功能 的隐藏

showToggle: false,
showColumns:false,
visible:false,
showExport: false,
commonSearch: false,  

#自定义行内容
formatter: function (value, row, index) {
                                if(row.user.avatar){
                                    value = '<img class="img-lg img-center" style="border-radius: 48px;height: 38px;width: 38px;" src="'+row.user.avatar+'">'
                                }
                                return value;
                            }

#table 表中的时间两行显示
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false,
formatter: Table.api.formatter.datetime,
datetimeFormat:"YYYY-MM-DD <br/> HH:mm:ss"
},

#重写image方法
api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },
	formatter: {
                image: function (value, row, index) {
                    value = value == null || value.length === 0 ? '' : value.toString();
                    value = value ? value : '/assets/img/blank.gif';
                    var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-lg img-center';
                    var url = Fast.api.cdnurl(value, true);
                    url = url.match(/^(\/|data:image\\)/) ? url : url + Config.upload.thumbstyle;
                    // console.log("Imagess",'<a href="javascript:"><img class="' + classname + '" src="' + url + '" /></a>')
                    return '<div style="overflow:hidden">  <a href="javascript:"><img class="' + classname + '" src="' + url + '" /></a></div>';
                },
                images: function (value, row, index) {
                    value = value == null || value.length === 0 ? '' : value.toString();
                    var classname = typeof this.classname !== 'undefined' ? this.classname : 'img-lg img-center';
                    var arr = value != '' ? value.split(',') : [];
                    var html = [];
                    var url;
                    $.each(arr, function (i, value) {
                        value = value ? value : '/assets/img/blank.gif';
                        url = Fast.api.cdnurl(value, true);
                        url = url.match(/^(\/|data:image\\)/) ? url : url + Config.upload.thumbstyle;
                        html.push(' <a href="javascript:"><img class="' + classname + '" src="' + url + '" /></a>');
                    });
                    return html.join(' ');
                },
            }
        }




            // 为表格绑定事件
            Table.api.bindevent(table);
            //禁用双击编辑
            table.off('dbl-click-row.bs.table');

//搜索列表渲染其他select
{field: 'create_user_id', title: __('创建人'), visible: false,addclass: 'selectpage',
							extend: 'data-source="facrm/common/selectpage/model/admin?type=children" data-field="nickname" data-orderBy="id desc"'
                        },
0

评论区