main
kgdxpr 1 year ago
parent 18b52111b1
commit 6ee0b2b006

@ -3,113 +3,77 @@
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="../../../component/pear/css/pear.css" />
<style>
.woo-tool-text-delimiter {
width: 1px;
height: 12px;
background: #EEEEEE;
display: inline-block;
margin: 0 6px 0 4px;
}
.woo-theme-color {
color: #2d8cf0 !important;
}
.woo-tool-span {
margin: 0 3px;
position: relative;
top: -1px;
cursor: pointer;
}
.layui-table-tool-temp {
padding-right: 0;
}
.selected-cell {
background-color: #5FB878;
/* 选中单元格后的颜色 */
}
</style>
</style>
<title>点击单元格变色</title>
<link rel="stylesheet" href="../../../component/layui/css/layui.css" />
</head>
<body class="pear-container layui-form">
<body>
<div class="layui-card">
<div class="layui-card-body">
<table id="data-table"></table>
</div>
</div>
<table class="layui-table" id="myTable">
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
</table>
<script src="../../../component/layui/layui.js"></script>
<script>
layui.use(['table', 'form', 'jquery', 'common', 'laytpl'], function () {
var table = layui.table;
var form = layui.form;
layui.use(function () {
var $ = layui.jquery;
var common = layui.common;
var laytpl = layui.laytpl;
tableRender();
function tableRender() {
table.render({
elem: '#data-table',
url: '/QingLong/view/jrgl/rzgl/data.json',
where: {
page: 1,
limit: 100,
system_id: 0
},
height: 'full-60',
page: {
limit: 15
, layout: ['count', 'prev', 'page', 'next', 'skip']
, prev: "上一页"
, next: "下一页"
},
cols: [[
{ title: '序号', align: 'center', width: "10%", type: 'numbers' },
{ title: '操作人', field: 'czr', align: 'center', width: "20%" },
{ title: '操作时间', field: 'czsj', align: 'center', width: "20%" },
{ title: '操作IP', field: 'ip', align: 'center', width: "20%" },
{ title: '行为', field: 'xw', align: 'left' }
]],
// skin: 'line',
defaultToolbar: []
});
}
var table = layui.table;
table.on('cell(data-table)', function (obj) {
console.log(obj);
table.render({
elem: '#myTable',
url: '/QingLong/view/jrgl/rzgl/data.json',
where: {
page: 1,
limit: 100,
system_id: 0
},
height: 'full-60',
page: {
limit: 15
, layout: ['count', 'prev', 'page', 'next', 'skip']
, prev: "上一页"
, next: "下一页"
},
cols: [[
{ title: '序号', align: 'center', width: "10%", type: 'numbers' },
{ title: '操作人', field: 'czr', align: 'center', width: "30%" },
{ title: '操作时间', field: 'czsj', align: 'center', width: "30%" },
{ title: '小学', templet: '<div class="xx" id="a{{= d.id }}">&nbsp;</div>', align: 'center', width: "10%", style: 'cursor: pointer;' },
{ title: '初中', templet: '<div class="cz" id="a{{= d.id }}">&nbsp;</div>', align: 'center', width: "10%", style: 'cursor: pointer;' },
{ title: '高中', templet: '<div class="gz" id="a{{= d.id }}">&nbsp;</div>', align: 'center', width: "10%", style: 'cursor: pointer;' }
]],
// skin: 'line',
defaultToolbar: [],
done: function (res, curr, count) {
// $('.layui-table').on('click', 'td', function (obj) {
// if (obj.currentTarget.cellIndex > 2) {
// console.log(obj)
// if ($(this).css('background-color') == "rgba(0, 0, 0, 0)") {
// $(this).css('background-color', '#5FB878');
// } else {
// $(this).css('background-color', 'rgba(0, 0, 0, 0)');
// }
// }
// });
// $("#a1").css('background-color', '#5FB878');
$(".xx").click(function () {
if ($(this).css('background-color') == "rgba(0, 0, 0, 0)") {
$(this).css('background-color', '#D6F2F3');
} else {
$(this).css('background-color', 'rgba(0, 0, 0, 0)');
}
// console.log($(this).attr('id'));
});
}
});
function GetQueryString(name, istop) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (typeof (istop) != "undefined") r = top.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
}
});
</script>
</body>
</html>
Loading…
Cancel
Save