@extends('admin/site/side_layout')
@section('header_extend')
@endsection
@section('right')
<div class="col-md-2">
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-md btn-success" onclick="units.add(0,'{{$siteId}}')"
style="margin-left: 10px;"><span class="glyphicon glyphicon-plus"></span> 添加</button>
<button type="button" class="btn btn-md btn-danger" onclick="units.del()"
style="margin-left: 10px"><span class="glyphicon glyphicon-remove"></span> 删除</button>
</span>
</div>
</div>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="table-responsive">
<table id="table" class="table table-condensed" data-mobile-responsive="true"></table>
</div>
</div>
</div>
</div>
</div>
</body>
@endsection
@section('footer_extend')
<script>
var units = {
del: function () {
var ids = units.getIdsBySelections();
if (ids.length === 0) {
layer.alert('请先选择您所要操作的对象', {icon: 0});
return;
}
layer.confirm('确定删除?', {icon: 3, title: '是否删除'}, function (index, layero) {
layer.close(index);
tips.ajax({
url: '/admin/advertise/delete-row/1',
type: 'post',
data: {ids: ids},
tableRefresh: '#table'
});
});
},
add: function (id, siteId) {
layer.open({
type: 2,
content: ['/admin/advertise/advertise-edit/' + id + '/' + siteId],
area: ['80%', '80%'],
title: '编辑'
});
},
save: function (id, siteId) {
layer.open({
type: 2,
content: ['/admin/advertise/advertise-edit/' + id + '/' + siteId],
area: ['80%', '80%'],
title: '编辑'
});
},
setting: function (id, siteId) {
layer.open({
type: 2,
content: ['/admin/advertise/setting/' + id + '/' + siteId],
area: ['100%', '100%'],
title: '设置'
});
},
getIdsBySelections: function () {
var selections = $("#table").bootstrapTable('getSelections');
var ids = [];
$.each(selections, function (inx, val) {
ids.push(val.id);
});
return ids;
}
};
var config = {};
config.url = '/admin/advertise/index/{{$siteId}}';
config.pageSize = 20;
config.showColumns = true;
config.columns = [ //字段
{checkbox: true},
{
title: '序号', align: 'center', formatter: function (value, item, index) {
return index + 1;
},
width: '10px'
},
{title: '广告代码', field: 'code', align: 'center', width: '120px'},
{title: '广告位名称', field: 'name', align: 'center'},
{title: '尺寸', field: 'size', align: 'center'},
{title: '创建时间', field: 'date', align: 'center'},
{
title: '操作', field: 'id', align: 'center',
formatter: function (value, row) {
return '<button onclick="units.save(' + row.id + ',' + "{{$siteId}}" + ')" class="btn btn-xs"><span class="glyphicon glyphicon-menu-hamburger"></span>编辑</button> ' +
'<button onclick="units.setting(' + row.id + ',' + "{{$siteId}}" + ')" class="btn btn-xs"><span class="glyphicon glyphicon-menu-hamburger"></span>设置</button>';
}
}
];
tips.bootstrapTable(config);
</script>
@endsection