首先在列表页,添加按钮,同时赋值ID,用来通过单击事件获取选中的列表数据ID
<a class="btn btn-success btn-recyclebin" id="gaoduan" title="{:__('全自动高端打印技术')}"><i class="fa fa-id-card-o"></i> {:__('全自动高端打印技术')}</a>
再来看JS文件里面的操作,给按钮绑定单击事件,然后获取当前选中的ID,再拼接需要传值的接受的方法里面,后面拼上获取的id,进行传值。
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'shop_id', title: __('门店')},
{field: 'name', title: __('Name'), operate: 'LIKE'},
{field: 'gangw', title: __('Gangw'), operate: 'LIKE'},
{field: 'zhic', title: __('Zhic'), operate: 'LIKE'},
{field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
$("#gaoduan").click(function(){
//获取当前选中的id
var ids = Table.api.selectedids(table);
// console.log(ids);
//获取选中的条目ID集合
var url = 'mp_user/print';//弹出窗口 add.html页面的(fastadmin封装layer模态框将以iframe的方式将add输出到index页面的模态框里)
Fast.api.open(url+'?ids='+ids, __('Add'));
})
// 为表格绑定事件
Table.api.bindevent(table);