You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
181 lines
6.4 KiB
181 lines
6.4 KiB
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>点击单元格变色</title>
|
|
<link rel="stylesheet" href="../../../component/layui/css/layui.css" />
|
|
<link rel="stylesheet" href="../../../component/pear/css/module/toast.css" />
|
|
|
|
<style>
|
|
.layui-table-cell {
|
|
height: 50px;
|
|
line-height: 40px;
|
|
}
|
|
|
|
th {
|
|
color: #303133;
|
|
background-color: #f5f7fa;
|
|
}
|
|
|
|
.layui-card {
|
|
box-shadow: 0 0 0 0 rgba(0, 0, 0, 0) !important;
|
|
margin-bottom: 0 !important;
|
|
}
|
|
|
|
.layui-form-item {
|
|
margin-bottom: 0;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<form class="layui-form" action="">
|
|
<div class="layui-card">
|
|
<div class="layui-card-body">
|
|
<div class="layui-form-item layui-inline">
|
|
<label class="layui-form-label" style="width: auto;">设备名称:</label>
|
|
<div class="layui-input-inline">
|
|
<input type="text" id="personName" lay-affix="clear" lay-filter="clear"
|
|
placeholder="请输入设备名称" class="layui-input">
|
|
</div>
|
|
</div>
|
|
<div class="layui-form-item layui-inline">
|
|
<label class="layui-form-label" style="width: auto;">学科:</label>
|
|
<div class="layui-input-inline" id="kmView">
|
|
</div>
|
|
<script id="kmScript" type="text/html">
|
|
<select id="kmId" lay-filter="km">
|
|
<option value="">全部</option>
|
|
{{# layui.each(d, function(index, item){ }}
|
|
<option value="{{item.km_code}}">{{item.km_name}}</option>
|
|
{{# }); }}
|
|
</select>
|
|
</script>
|
|
</div>
|
|
<div class="layui-form-item layui-inline">
|
|
<label class="layui-form-label" style="width: auto;">分类:</label>
|
|
<div class="layui-input-inline" id="kmView">
|
|
</div>
|
|
<script id="kmScript" type="text/html">
|
|
<select id="kmId" lay-filter="km">
|
|
<option value="">全部</option>
|
|
{{# layui.each(d, function(index, item){ }}
|
|
<option value="{{item.km_code}}">{{item.km_name}}</option>
|
|
{{# }); }}
|
|
</select>
|
|
</script>
|
|
</div>
|
|
<div class="layui-form-item layui-inline">
|
|
<button class="layui-btn layui-btn-sm" lay-submit lay-filter="user-query">
|
|
<i class="layui-icon layui-icon-search"></i>
|
|
查询
|
|
</button>
|
|
</div>
|
|
|
|
<table class="layui-table" id="myTable"></table>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
|
|
<script src="../../../component/layui/layui.js"></script>
|
|
|
|
<script>
|
|
layui.extend({
|
|
toast: '../../../component/pear/module/toast' // {/}的意思即代表采用自有路径,即不跟随 base 路径
|
|
}).use(['toast'], function () {
|
|
var $ = layui.jquery;
|
|
var table = layui.table;
|
|
var toast = layui.toast;
|
|
var form = layui.form;
|
|
var laytpl = layui.laytpl;
|
|
|
|
|
|
|
|
$.ajax({
|
|
type: "GET",
|
|
async: false,
|
|
url: "/QingLong/zbdc/getKm",
|
|
success: function (res) {
|
|
var kmTpl = kmScript.innerHTML,
|
|
kmView = document.getElementById('kmView');
|
|
laytpl(kmTpl).render(res.data, function (html) {
|
|
kmView.innerHTML = html;
|
|
});
|
|
form.render();
|
|
}
|
|
});
|
|
|
|
|
|
|
|
|
|
table.render({
|
|
elem: '#myTable',
|
|
url: './data.json',
|
|
where: {
|
|
page: 1,
|
|
limit: 100,
|
|
system_id: 0
|
|
},
|
|
height: 'full-0',
|
|
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: "35%" },
|
|
{ title: '操作时间', field: 'czsj', align: 'center', width: "35%" },
|
|
{ title: '小学', templet: '<input class="layui-input aabbxx">', align: 'center', width: "20%", style: 'cursor: pointer;' },
|
|
|
|
|
|
]],
|
|
// skin: 'line',
|
|
defaultToolbar: [],
|
|
done: function (res, curr, count) {
|
|
|
|
var tempVal = '';
|
|
var options = this;
|
|
|
|
// 获取当前行数据
|
|
table.getRowData = function (tableId, elem) {
|
|
var index = $(elem).closest('tr').data('index');
|
|
return table.cache[tableId][index] || {};
|
|
};
|
|
|
|
$(".aabbxx").focus(function () {
|
|
tempVal = this.value.trim();
|
|
});
|
|
|
|
|
|
|
|
$(".aabbxx").blur(function () {
|
|
var curVal = this.value.trim();
|
|
var data = table.getRowData(options.id, this);
|
|
console.log(JSON.stringify(data), curVal, options.id);
|
|
if (tempVal != curVal) {
|
|
toast.success({
|
|
// title: '提示',
|
|
message: '数据保存成功!',
|
|
position: 'topRight',
|
|
timeout: 1200,
|
|
close: false
|
|
});
|
|
}
|
|
|
|
|
|
});
|
|
}
|
|
});
|
|
|
|
|
|
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html> |