文件

119 行
3.8 KiB
HTML
可执行文件

<!--[1.5.22]-->
<style>
table {
border: 1px solid #f1f1f1;
margin-top: 40px;
}
.layui-table-cell {
height: auto;
text-align: center;
}
</style>
</head>
<div id="environment" v-cloak class="goodsBox">
<if condition="$authArr['adds']">
<el-button type="primary" size="small" id="add">添加</el-button>
</if>
<table class="layui-hide" id="test" lay-filter="demo"></table>
</div>
<script type="text/html" id="barDemo">
<if condition="$authArr['delimg']">
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del" style="background-color:#bbb">删除
</button>
</if>
</script>
</body>
<script>
new Vue({
el: '#environment',
methods: {}
})
layui.use(['table'], function () {
// 日期
var table = layui.table;
//展示已知数据
table.render({
elem: '#test',
url: "{:U('getData')}",
method: 'post',
cols: [
[{
field: 'index',
title: '序号',
width: 60
}, {
field: 'image',
title: '公司环境',
style: 'height:100%;',
align: 'center',
templet: '<div><img src="{{ d.image}}" style="width: 80px;"></div>'
}, {
field: 'time',
title: '添加时间',
align: 'center'
}, {
field: 'right',
title: '操作',
align: 'center',
toolbar: '#barDemo'
}]
],
page: {
layout: ['count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
}, //是否开启分页
});
$('#Preservation').click(function () {
table.reload('test', {
page: {
curr: 1 //重新从第 1 页开始
}
, where: {
keyword: $('#keyword').val()
}
});
})
$('#add').click(function () {
layer.open({
type: 2,
content: "{:U('adds')}",
title: "添加图片",
area: ['calc(100% - 160px)', 'calc(100% - 65px)'],
offset: 'rb', //右下角弹出
btnAlign: 'c',
shade: 0,
end: function () {
table.reload('test', {});
}
})
})
table.on('tool(demo)', function (obj) {
var data = obj.data;
var layEvent = obj.event;
var tr = obj.tr;
if (layEvent === 'detail') { //查看
//do somehing
window.location.href = "{:U('shiftingdetail')}?id=" + data.id;
} else if (layEvent === 'del') { //删除
layer.confirm('确定删除这个图片吗?', function (index) {
layer.close(index);
//向服务端发送删除指令
$.ajax({
url: "{:U('delimg')}",
data: {id: data.id},
type: 'post',
success: function (res) {
if (res.status == 1) {
obj.del();
} else {
top.layer.msg(res.msg, {icon: 4, time: 1000})
}
}
})
});
}
});
})
</script>