<!DOCTYPE html>
|
<html>
|
<head>
|
<meta charset="utf-8" />
|
<title>隐藏列设置</title>
|
<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
|
<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
|
<script src="../../../layuiadmin/layui/layui.js"></script>
|
<script src="../../../layuiadmin/Scripts/json2.js"></script>
|
<script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
|
<script src="../../../../../Scripts/webConfig.js"></script>
|
<style>
|
/* 防止下拉框的下拉列表被隐藏---必须设置--- */
|
.layui-table-cell {
|
overflow: visible !important;
|
}
|
/* 使得下拉框与单元格刚好合适 */
|
td .layui-form-select {
|
margin-top: -10px;
|
margin-left: -15px;
|
margin-right: -15px;
|
}
|
</style>
|
</head>
|
<body>
|
<div class="layui-fluid" style="padding: 0;">
|
<div class="layui-card" style="padding: 2px;background-color: #efefef;">
|
<div class="layui-card-body" style="padding: 1px;">
|
<form class="layui-form" action="" lay-filter="formData" style="background-color:white;">
|
<div style="padding: 10px; ">
|
<button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="CheckAll" id="CheckAll">全选</button>
|
<button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="ClearBill" id="ClearBill">全清</button>
|
<button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="btnSave" id="btnSave">保存</button>
|
<button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="Exit" id="Exit">退出</button>
|
</div>
|
<div class="layui-collapse">
|
<div class="layui-colla-item">
|
<div class="layui-form-item" style="padding-top: 10px;">
|
<table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
|
</div>
|
</div>
|
</div>
|
<div class="layui-tab" lay-filter="tab-POStockInBill">
|
<div class="layui-tab-content">
|
<div class="layui-tab-item layui-show">
|
<div class="layui-form-item" style="padding-top: 10px;">
|
<div class="layui-row">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">冻结列</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HFixCols" lay-verify="HFixCols" id="HFixCols">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">字体大小</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HFontSize" lay-verify="HFontSize" id="HFontSize">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">列宽</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" lay-verify="HColumnWidth" name="HColumnWidth" id="HColumnWidth">
|
</div>
|
</div>
|
</div>
|
<div class="layui-row">
|
<div class="layui-inline">
|
<label class="layui-form-label">点击排序</label>
|
<div class="layui-input-block" style="margin-left: 120px;width: 184px;">
|
<select name="HSortFlag" lay-verify="HSortFlag" id="HSortFlag">
|
<option value=""></option>
|
<option value="是">是</option>
|
<option value="否">否</option>
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">选中行合计</label>
|
<div class="layui-input-block" style="margin-left: 125px;width: 184px;">
|
<select name="HSelTotal" lay-verify="HSelTotal" id="HSelTotal">
|
<option value=""></option>
|
<option value="是">是</option>
|
<option value="否">否</option>
|
</select>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</form>
|
</div>
|
</div>
|
</div>
|
</body>
|
</html>
|
<!--行下拉选择(对齐方式)-->
|
<script type="text/html" id="Alignment">
|
<select name="Alignment" lay-filter="Alignment" id="Alignment{{d.LAY_TABLE_INDEX+1}}">
|
<option value="L">左对齐</option>
|
<option value="M">居中</option>
|
<option value="R">右对齐</option>
|
</select>
|
</script>
|
<!--复选框 是否隐藏-->
|
<script type="text/html" id="IsHide">
|
<div class="layui-input-block" style="margin-left: 20px;">
|
<input type="checkbox" name="IsHide" lay-filter="IsHide" id="IsHide{{d.LAY_TABLE_INDEX+1}}" lay-skin="primary">
|
</div>
|
</script>
|
<script>
|
layui.config({
|
base: '../../../layuiadmin/' //静态资源所在路径
|
}).extend({
|
index: 'lib/index' //主入口模块
|
}).use(['index', 'form', 'laydate', 'table', 'element'], function () {
|
//#region 公共变量
|
var $ = layui.$
|
, admin = layui.admin
|
, layer = layui.layer
|
, table = layui.table
|
, form = layui.form
|
, element = layui.element;
|
//查询条件
|
var sWhere = "";
|
var option = [];
|
//#endregion
|
|
//#region 进入页面即加载
|
|
var params = getUrlVars();
|
var HModName = params[params[0]]; //模块名称
|
var colName = params[params[1]]; //列名
|
colName = decodeURI(colName);//对URI 进行解码
|
//初始化界面
|
set_ClearBill();
|
|
//#endregion
|
|
//#region 触发事件:包括form.on(){}格式的所有点击事件、选择事件等
|
|
//行选择处理(对齐方式)
|
form.on('select(Alignment)', function (data) {
|
//获取下拉框选中的值
|
var elem = data.othis.parents('tr');
|
var dataindex = elem.attr("data-index");
|
$.each(option.data, function (index, value) {
|
if (value.LAY_TABLE_INDEX == dataindex) {
|
value.Alignment = data.value;//把选中下拉框id值赋值给表格缓存
|
}
|
});
|
});
|
|
//是否隐藏
|
form.on('checkbox(IsHide)', function (data) {
|
//获取下拉框选中的值
|
var elem = data.othis.parents('tr');
|
var dataindex = elem.attr("data-index");
|
$.each(option.data, function (index, value) {
|
if (value.LAY_TABLE_INDEX == dataindex) {
|
value.IsHide = data.elem.checked;//把选中下拉框id值赋值给表格缓存
|
}
|
});
|
});
|
|
//保存
|
form.on('submit(btnSave)', function (data) {
|
set_AddNew(data);
|
});
|
|
//全选
|
form.on('submit(CheckAll)', function (data) {
|
for (var i = 0; i < table.cache["mainTable"].length; i++) {
|
table.cache["mainTable"][i].IsHide = true;
|
$('#IsHide' + (i + 1)).prop("checked", true);
|
}
|
form.render('checkbox');
|
});
|
|
//全清
|
form.on('submit(ClearBill)', function (data) {
|
for (var i = 0; i < table.cache["mainTable"].length; i++) {
|
table.cache["mainTable"][i].IsHide = false;
|
$('#IsHide' + (i + 1)).attr("checked", false);
|
}
|
form.render('checkbox');
|
});
|
|
//退出
|
form.on('submit(Exit)', function () {
|
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
|
parent.layer.close(index); //再执行关闭
|
})
|
|
//#endregion
|
|
//#region 此页面所有的方法
|
|
//初始化界面
|
function set_ClearBill() {
|
set_InitGrid();
|
get_Display();
|
}
|
|
//查询
|
function get_Display() {
|
var ajaxLoad = layer.load();
|
$.ajax({
|
url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList',
|
type: "GET",
|
data: { "HModName": HModName, "user": sessionStorage["HUserName"] },
|
success: function (data1) {
|
var colNames = [];//相对单据传过来的列名
|
var cols = [];//要传进表格的数据
|
|
colNames = colName.split(',');
|
|
if (data1.data.length != 0) {
|
//冻结列
|
$("#HFixCols").val(data1.data[0].HFixCols);
|
//字体大小
|
$("#HFontSize").val(data1.data[0].HFontSize);
|
//列宽
|
$("#HColumnWidth").val(data1.data[0].HColumnWidth);
|
|
var dataCol = [];//数据库查询出的列数据
|
|
dataCol = data1.data[0].HGridString.split(',');
|
|
//表格的数据填充
|
for (var i = 0; i < colNames.length; i++) {
|
var dataCols = dataCol[i].split('|');
|
cols.push({ "ColumnName": colNames[i], "IsHide": dataCols[1] == 1 ? true : false, "Alignment": dataCols[2], "ColumnWidth": dataCols[3]})
|
}
|
option.data = cols;
|
table.render(option);
|
|
//页面多选框 下拉框 重新渲染
|
for (var i = 0; i < colNames.length; i++) {
|
var dataCols = dataCol[i].split('|');
|
if (dataCols[1] == 1) {
|
$("#IsHide" + (i + 1)).attr("checked", true);
|
}
|
$('#Alignment' + (i + 1)).find("option[value='" + dataCols[2] + "']").attr("selected", true);
|
}
|
form.render('checkbox');
|
form.render('select');
|
layer.close(ajaxLoad);
|
} else {
|
//默认不选中 显示字体居左 表格的数据填充
|
for (var i = 0; i < colNames.length; i++) {
|
cols.push({ "ColumnName": colNames[i], "IsHide": false, "Alignment": "L", "ColumnWidth":120})
|
}
|
option.data = cols;
|
table.render(option);
|
|
//默认不选中 显示字体居左 页面多选框 下拉框 重新渲染
|
for (var i = 0; i < colNames.length; i++) {
|
$('#IsHide' + (i + 1)).prop("checked", false);
|
$('#Alignment' + (i + 1)).find("option[value='L']").attr("selected", true);
|
}
|
form.render('checkbox');
|
form.render('select');
|
layer.close(ajaxLoad);
|
}
|
}, error: function () {
|
layer.close(ajaxLoad);
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
}
|
|
//表格数据
|
function set_InitGrid() {
|
option = {
|
elem: '#mainTable'
|
//, toolbar: '#toolbarDemo'
|
, height: 420
|
, cellMinWidth: 90
|
, limit: 500
|
, cols: [[
|
{ field: 'ColumnName', title: '列名', width: 100 }
|
, { file: 'IsHide', title: '是否隐藏', width: 100, templet: '#IsHide' }
|
, { field: 'Alignment', title: '对齐方式', width: 100, templet: '#Alignment' }
|
, { field: 'ColumnWidth', title: '列宽', width: 100, edit: 'text'}
|
]]
|
};
|
}
|
|
//保存HMaker
|
function set_AddNew(data) {
|
|
var num = [];
|
for (var i = 0; i < table.cache["mainTable"].length; i++) {
|
if (table.cache["mainTable"][i] != "") {
|
table.cache["mainTable"][i].LAY_TABLE_INDEX = i;
|
num.push(table.cache["mainTable"][i])
|
}
|
}
|
|
var sMainStr = JSON.stringify(data.field);
|
var sSubStr = JSON.stringify(num);
|
var OperationType = "1";
|
var sMainSub = sMainStr + ';' + sSubStr + ';' + HModName + ';' + OperationType + ";" + sessionStorage["HUserName"];//sessionStorage["HUserName"]
|
|
var index = layer.load();
|
$.ajax({
|
type: "POST",
|
url: GetWEBURL() + "/Xt_grdAlignment_WMES/AddgrdAlignmentWMES",
|
async: true,
|
data: { "sMainSub": sMainSub },
|
dataType: "json",
|
success: function (data) {
|
if (data.count == 1) {
|
layer.close(index);
|
layer.msg("提交成功");
|
}
|
else {
|
layer.close(index);
|
layer.msg(data.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
|
}
|
},
|
error: function (err) {
|
layer.close(index);
|
layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
|
}
|
});
|
}
|
|
//获取参数
|
function getUrlVars() {
|
var vars = [], hash;
|
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
for (var i = 0; i < hashes.length; i++) {
|
hash = hashes[i].split('=');
|
vars.push(hash[0]);
|
vars[hash[0]] = hash[1];
|
}
|
return vars;
|
}
|
|
|
|
//#endregion
|
|
});
|
|
|
</script>
|