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.
klhis/hcemr/select/deGroupPro.html

138 lines
4.0 KiB

3 months ago
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<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, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="../layui/css/layui.css" media="all">
<style>
body{
font-size: 12px!important;
}
.layui-form{
background:#fff
}
.redFont{
color:red;
margin-left: 5px;
}
#button{
margin-top:10px;
position: fixed;
bottom: 10px;
}
.layui-btn+.layui-btn{
margin-left: 0px;
}
.layui-form{
max-height: 150px;
overflow-y: auto;
}
.layui-table-body{
overflow-x: hidden;
}
.layui-table-view .layui-form-radio>i{
font-size: 12px;
}
.layui-table-view .layui-table td, .layui-table-view .layui-table th{
padding:0px
}
.layui-layer-title{
padding: 0px 80px 0 10px!important;
height: 30px!important;
line-height: 30px!important;
font-size: 12px!important;
}
.layui-layer-setwin{
top:8px!important;
}
.layui-table-cell{
padding-left:5px;
height:20px!important;
line-height: 20px!important;
}
</style>
</head>
<body class="layui-form">
<table class="layui-table" id="table" lay-filter="table"></table>
<div id="button">
<span class="redFont">第一列无值时不会存储</span>
<button style="margin-left: 20px" type="button" class="layui-btn layui-btn-sm" id="addLine">新增行</button>
<button type="button" class="layui-btn layui-btn-sm" id="deleteLine">删除行</button>
<button style="margin-left: 20px" type="submit" class="layui-btn layui-btn-sm" id="submit">保存</button>
</div>
<script src="../layui/layui.all.js" charset="utf-8"></script>
<!-- 注意:如果你直接复制所有代码到本地,上述js路径需要改成你本地的 -->
<script>
let vTopData = parent.emrView.FFrmRecord.FEmrView.ActiveSectionTopLevelData()
let data = vTopData.Items[vTopData.ActiveDomain.BeginNo].FPropertys
console.log(data)
// let tableData= parent.emrView.FFrmRecord.DoNewTDictionType();
let tableData = []
let selectData;
for(let i=0;i<data.length;i++){
tableData.push(data[i])
}
layui.use('table', function(){
var table = layui.table;
table.render({
elem: '#table'
,cols: [[ //标题栏
{type:'radio'}
,{field: 'key', title: '键', edit: 'text'}
,{field: 'val', title: '值', edit: 'text'}
]]
,data: tableData
});
//监听选中
table.on('radio(table)', function(obj){
selectData= obj
});
//监听编辑
table.on('edit(table)', function(obj){
let data = obj.data //得到所在行所有键值
let rowIndex = $(obj.tr).attr("data-index");
tableData[rowIndex] = data
console.log(rowIndex)
});
let $ = layui.$, active = {
deleteData: function(){ //获取选中数据
if(selectData){
let rowIndex = selectData.tr.attr("data-index");
selectData.del()
tableData.splice(rowIndex,1)
}
},
reload: function(){
table.reload('table', {data:tableData});
}
};
//新增行按钮
$('#addLine').on('click', function(){
tableData.push({key:'',val:''})
active['reload'].call(this)
});
//删除行按钮
$('#deleteLine').on('click', function(){
active['deleteData'].call(this)
});
//提交按钮
$('#submit').on('click', function(){
// Map 结构的变量
let resProps = parent.emrView.FFrmRecord.DoNewTDictionType();
tableData.forEach((item, index) => {
resProps.setValue(item.key, item.val);
})
parent.emrView.FFrmRecord.DoDeGroupPropertyPopupSetView(resProps)
parent.layer.closeAll()
});
});
</script>
</body>
</html>