158 行
4.9 KiB
HTML
可执行文件
158 行
4.9 KiB
HTML
可执行文件
<!--[1.5.22]-->
|
|
<style>
|
|
|
|
table {
|
|
border: 1px solid #f1f1f1;
|
|
margin-top: 40px;
|
|
}
|
|
|
|
.layui-table-cell {
|
|
height: auto;
|
|
text-align: center;
|
|
}
|
|
|
|
.layui-laypage .layui-laypage-curr .layui-laypage-em {
|
|
background-color: #409EFF;
|
|
}
|
|
|
|
.layui-table-page .layui-laypage a:hover, .layui-table-page .layui-laypage span:hover {
|
|
color: #409EFF;
|
|
}
|
|
|
|
.layui-btn {
|
|
background-color: transparent;
|
|
color: #409EFF;
|
|
}
|
|
|
|
.layui-btn-danger {
|
|
color: #999;
|
|
}
|
|
|
|
.layui-btn:hover{
|
|
opacity: 0.8;
|
|
color: #409EFF!important;
|
|
}
|
|
</style>
|
|
<div id="contact">
|
|
<if condition="$authArr['add'] eq true">
|
|
<el-button type="primary" size="small" id="add">添加联系方式</el-button>
|
|
</if>
|
|
<table class="layui-hide" id="test" lay-filter="demo"></table>
|
|
<script type="text/html" id="barDemo">
|
|
<if condition="$authArr['update'] eq true">
|
|
<button class="layui-btn layui-btn-xs" lay-event="edit">编辑</button>
|
|
</if>
|
|
<if condition="$authArr['del'] eq true">
|
|
<button class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">删除</button>
|
|
</if>
|
|
</script>
|
|
</div>
|
|
<script>
|
|
new Vue({
|
|
el: '#contact',
|
|
methods: {}
|
|
})
|
|
layui.use(['form', 'table'], function () {
|
|
var table = layui.table;
|
|
//展示已知数据
|
|
table.render({
|
|
elem: '#test',
|
|
url: "{:U('getData')}",
|
|
method: 'post',
|
|
cols: [
|
|
[{
|
|
field: 'id',
|
|
title: '序号',
|
|
width: 60
|
|
}, {
|
|
field: 'name',
|
|
title: '联系人',
|
|
align: 'center'
|
|
}, {
|
|
field: 'tell',
|
|
title: '联系电话',
|
|
align: 'center'
|
|
}, {
|
|
field: 'qq',
|
|
title: 'QQ',
|
|
align: 'center'
|
|
}, {
|
|
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()
|
|
}
|
|
});
|
|
})
|
|
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('del')}",
|
|
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})
|
|
}
|
|
}
|
|
})
|
|
});
|
|
} else if (layEvent === 'edit') { //编辑
|
|
console.log(data.id);
|
|
top.layer.open({
|
|
type: 2,
|
|
content: "{:U('update')}?id=" + data.id,
|
|
title: "编辑",
|
|
area: ["700px", '400px'],
|
|
btnAlign: 'c',
|
|
end: function () {
|
|
MenuApp.refreshWindow();
|
|
}
|
|
})
|
|
}
|
|
});
|
|
$('#add').click(function () {
|
|
top.layer.open({
|
|
type: 2,
|
|
content: "{:U('add')}",
|
|
title: "添加联系方式",
|
|
area: ["700px", '400px'],
|
|
btnAlign: 'c',
|
|
end: function () {
|
|
MenuApp.refreshWindow();
|
|
}
|
|
})
|
|
|
|
})
|
|
})
|
|
</script>
|