parent
030fa75bf0
commit
3238375963
@ -0,0 +1,158 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Demo</title>
|
||||
<!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
|
||||
<link href="../js/layui/css/layui.css" rel="stylesheet">
|
||||
<style>
|
||||
.woo-tool-text-delimiter {
|
||||
width: 1px;
|
||||
height: 12px;
|
||||
background: #EEEEEE;
|
||||
display: inline-block;
|
||||
margin: 0 6px 0 4px;
|
||||
}
|
||||
|
||||
.woo-theme-color {
|
||||
color: #1e9fff !important;
|
||||
}
|
||||
|
||||
.woo-tool-span {
|
||||
margin: 0 3px;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layui-card-body .layui-form {
|
||||
margin-top: 0 !important;
|
||||
}
|
||||
|
||||
.layui-form-select {
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.layui-card {
|
||||
margin-bottom: 15px;
|
||||
border-radius: 2px;
|
||||
background-color: #fff;
|
||||
box-shadow: none;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="layui-form">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<button type="button" class="layui-btn" id="getData">获取数据</button>
|
||||
<table class="layui-hide" id="ID-table-demo-data"></table>
|
||||
|
||||
<script type="text/html" id="table-bar">
|
||||
<span class="woo-tool-span woo-tool-text-span" lay-event="add"><a
|
||||
class="woo-theme-color">向下插入</a></span>
|
||||
<span class="woo-tool-span woo-tool-text-span" lay-event="delete"><a
|
||||
class="woo-theme-color">删除</a></span>
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
|
||||
<script src="../js/layui/layui.js"></script>
|
||||
<script>
|
||||
layui.use('table', function () {
|
||||
var table = layui.table;
|
||||
var $ = layui.jquery;
|
||||
|
||||
// var id = GetQueryString("id");
|
||||
|
||||
var id = "3";
|
||||
|
||||
var _data = [];
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
async: false,
|
||||
url: '/dsBase/dataease/getDataSetTable?dataset_id=' + id,
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
_data = res.data;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var _emptyData = {};
|
||||
var _cols = [];
|
||||
let keys = Object.keys(_data[0]);
|
||||
|
||||
keys.forEach((item, index) => {
|
||||
_emptyData[item] = "";
|
||||
var _obj = { field: item, title: item, edit: 'text' }
|
||||
_cols.push(_obj);
|
||||
});
|
||||
_cols.push({ title: '操作1', toolbar: '#table-bar' });
|
||||
|
||||
table.render({
|
||||
elem: '#ID-table-demo-data',
|
||||
id: 'ID-table-demo-data',
|
||||
page: false,
|
||||
cols: [_cols],
|
||||
data: _data
|
||||
});
|
||||
|
||||
table.on('tool(ID-table-demo-data)', function (obj) {
|
||||
if (obj.event === 'add') {
|
||||
_data.splice(obj.index + 1, 0, _emptyData);
|
||||
table.cache['ID-table-demo-data'] = _data;
|
||||
table.renderData('ID-table-demo-data');
|
||||
} else {
|
||||
var cacheData = table.cache['ID-table-demo-data'];
|
||||
cacheData.splice(obj.index, 1)
|
||||
table.renderData('ID-table-demo-data');
|
||||
}
|
||||
});
|
||||
|
||||
$("#getData").click(function () {
|
||||
|
||||
const cleanedData = table.cache['ID-table-demo-data'].map(item => {
|
||||
const { LAY_NUM, LAY_INDEX, ...rest } = item;
|
||||
return rest;
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
async: false,
|
||||
url: '/dsBase/dataease/saveDataSetTable',
|
||||
data: {
|
||||
"dataset_id": id,
|
||||
"data": JSON.stringify(cleanedData)
|
||||
},
|
||||
success: function (res) {
|
||||
console.log(res);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
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>
|
@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>自定义固定条示例 - Layui</title>
|
||||
<meta name="renderer" content="webkit">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="//unpkg.com/layui@2.9.18/dist/css/layui.css" rel="stylesheet">
|
||||
<style>
|
||||
.layui-fixbar li {
|
||||
height: 38px;
|
||||
line-height: 38px;
|
||||
border: 1px solid transparent;
|
||||
padding: 0 18px;
|
||||
background-color: #16baaa;
|
||||
color: #fff;
|
||||
white-space: nowrap;
|
||||
text-align: center;
|
||||
font-size: 14px !important;
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="target-test" style="position: relative; padding: 16px;">
|
||||
页<br>面<br>内<br>容<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。<br>。
|
||||
</div>
|
||||
<script src="//unpkg.com/layui@2.9.18/dist/layui.js"></script>
|
||||
<script>
|
||||
layui.use(function () {
|
||||
var util = layui.util;
|
||||
// 自定义固定条
|
||||
util.fixbar({
|
||||
default: false,
|
||||
bars: [{
|
||||
type: 'groups',
|
||||
content: '保存数据',
|
||||
style: 'font-size: 21px;'
|
||||
}],
|
||||
css: { top: 10 },
|
||||
click: function (type) {
|
||||
console.log(type);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in new issue