<!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/zgqCustom/zgqCustom.js"></script>
|
<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="../../../layuiadmin/Scripts/webConfig.js"></script>
|
<script src="../../../layuiadmin/PubCustom.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="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>
|
<script type="text/html" id="toolbarDemo">
|
<div class="layui-btn-container">
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine"><i class="layui-icon layui-icon-form"></i>增加一行</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-InsertLine"><i class="layui-icon layui-icon-form"></i>插入一行</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>复制一行</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Up"><i class="layui-icon layui-icon-form"></i>上移</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Under"><i class="layui-icon layui-icon-form"></i>下移</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>列设置</button>
|
</div>
|
</script>
|
</div>
|
</div>
|
</div>
|
</form>
|
</div>
|
</div>
|
</div>
|
</body>
|
</html>
|
<!--删除按钮-->
|
<script type="text/html" id="barDemo">
|
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
|
</script>
|
<!--复选框 是否隐藏-->
|
<script type="text/html" id="HIsHide">
|
<div class="layui-input-block" style="margin-left: 20px;">
|
<input type="checkbox" name="HIsHide" lay-filter="HIsHide" id="HIsHide{{d.LAY_TABLE_INDEX+1}}" lay-skin="primary">
|
</div>
|
</script>
|
<!--复选框 是否禁用-->
|
<script type="text/html" id="HIsDisabled">
|
<div class="layui-input-block" style="margin-left: 20px;">
|
<input type="checkbox" name="HIsDisabled" lay-filter="HIsDisabled" id="HIsDisabled{{d.LAY_TABLE_INDEX+1}}" lay-skin="primary">
|
</div>
|
</script>
|
<!--复选框 是否必填-->
|
<script type="text/html" id="HIsMust">
|
<div class="layui-input-block" style="margin-left: 20px;">
|
<input type="checkbox" name="HIsMust" lay-filter="HIsMust" id="HIsMust{{d.LAY_TABLE_INDEX+1}}" lay-skin="primary">
|
</div>
|
</script>
|
<!--行下拉选择(元素ID)-->
|
<script type="text/html" id="HElementID">
|
<select name="HElementID" lay-filter="HElementID" id="HElementID{{d.LAY_TABLE_INDEX+1}}">
|
</select>
|
</script>
|
<!--行下拉选择(父级元素ID)-->
|
<script type="text/html" id="HParentElementID">
|
<select name="HParentElementID" lay-filter="HParentElementID" id="HParentElementID{{d.LAY_TABLE_INDEX+1}}">
|
</select>
|
</script>
|
<!--行下拉选择(组件类型)-->
|
<script type="text/html" id="HElementType">
|
<select name="HElementType" lay-filter="HElementType" id="HElementType{{d.LAY_TABLE_INDEX+1}}">
|
</select>
|
</script>
|
<!--行下拉选择(字段名)-->
|
<script type="text/html" id="HFieldName">
|
<select name="HFieldName" lay-filter="HFieldName" id="HFieldName{{d.LAY_TABLE_INDEX+1}}">
|
</select>
|
</script>
|
<!--行下拉选择(字段数据类型)-->
|
<script type="text/html" id="HFieldDataType">
|
<select name="HFieldDataType" lay-filter="HFieldDataType" id="HFieldDataType{{d.LAY_TABLE_INDEX+1}}">
|
</select>
|
</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 HModName = "Xt_AutoLoadBillList";
|
|
//获取参数
|
var params = getUrlVars();
|
var HSetMainModName = params[params[0]]; //表头加载模块名称
|
var HTableName = params[params[1]]; //主表名
|
var HDataViewName = params[params[2]]; //视图名
|
var HDataProcName = params[params[3]]; //存储过程名
|
var HRowElementCount = params[params[4]]; //每行元素数
|
|
var HUserName = sessionStorage["HUserName"]; //用户名
|
var HInterID = 0;
|
//元素ID与元素数据类型对照列表
|
var HFieldDataTypeForElementID = [];
|
|
//查询条件
|
var sWhere = "";
|
var option = [];
|
|
//#endregion
|
|
//#region 进入页面即加载
|
|
//页面初始化
|
set_ClearBill();
|
|
//#endregion
|
|
//#region 触发事件
|
//#region 复选框触发事件相关监听
|
//#region 是否隐藏
|
form.on('checkbox(HIsHide)', 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.HIsHide = data.elem.checked;//把选中下拉框id值赋值给表格缓存
|
}
|
});
|
});
|
//#endregion
|
|
//#region 是否禁用
|
form.on('checkbox(HIsDisabled)', 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.HIsDisabled = data.elem.checked;//把选中下拉框id值赋值给表格缓存
|
}
|
});
|
});
|
//#endregion
|
|
//#region 是否必填
|
form.on('checkbox(HIsMust)', 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.HIsMust = data.elem.checked;//把选中下拉框id值赋值给表格缓存
|
}
|
});
|
});
|
//#endregion
|
//#endregion
|
|
//#region 下拉框触发事件相关监听
|
//#region 表格行选择处理(元素ID)
|
form.on('select(HElementID)', function (data) {
|
//获取下拉框选中的值
|
var elem = data.othis.parents('tr');
|
var dataindex = elem.attr("data-index");
|
$.each(option.data, function (index, value) {
|
if (index == dataindex) {
|
value.HElementID = data.value;//把选中下拉框id值赋值给表格缓存
|
for (var i = 0; i < HFieldDataTypeForElementID.length; i++) {
|
if (value.HElementID == HFieldDataTypeForElementID[i].HElementID) {
|
value.HFieldDataType = HFieldDataTypeForElementID[i].HFieldDataType;
|
value.HElementIDAdditionalName = value.HElementID;
|
$('#HFieldDataType' + (index+1) + '').val(value.HFieldDataType);
|
form.render('select');
|
table.render(option);
|
//根据option中的数据,设置子表中的下拉列表、复选框
|
setSelectByTableRender();
|
break;
|
}
|
}
|
}
|
});
|
});
|
//#endregion
|
|
//#region 表格行选择处理(父级元素ID)
|
form.on('select(HParentElementID)', function (data) {
|
//获取下拉框选中的值
|
var elem = data.othis.parents('tr');
|
var dataindex = elem.attr("data-index");
|
$.each(option.data, function (index, value) {
|
if (index == dataindex) {
|
value.HParentElementID = data.value;//把选中下拉框id值赋值给表格缓存
|
}
|
});
|
});
|
//#endregion
|
|
//#region 表格行选择处理(组件类型)
|
form.on('select(HElementType)', function (data) {
|
//获取下拉框选中的值
|
var elem = data.othis.parents('tr');
|
var dataindex = elem.attr("data-index");
|
$.each(option.data, function (index, value) {
|
if (index == dataindex) {
|
value.HElementType = data.value;//把选中下拉框id值赋值给表格缓存
|
}
|
});
|
});
|
//#endregion
|
|
//#region 表格行选择处理(字段名)
|
form.on('select(HFieldName)', function (data) {
|
//获取下拉框选中的值
|
var elem = data.othis.parents('tr');
|
var dataindex = elem.attr("data-index");
|
$.each(option.data, function (index, value) {
|
if (index == dataindex) {
|
value.HFieldName = data.value;//把选中下拉框id值赋值给表格缓存
|
}
|
});
|
});
|
//#endregion
|
|
//#region 表格行选择处理(数据类型)
|
form.on('select(HFieldDataType)', function (data) {
|
//获取下拉框选中的值
|
var elem = data.othis.parents('tr');
|
var dataindex = elem.attr("data-index");
|
$.each(option.data, function (index, value) {
|
if (index == dataindex) {
|
value.HFieldDataType = data.value;//把选中下拉框id值赋值给表格缓存
|
}
|
});
|
});
|
//#endregion
|
//#endregion
|
|
//#region 操作按钮相关监听
|
//#region 保存提交
|
form.on('submit(btnSave)', function (data) {//提交
|
set_AddNew(data);
|
});
|
//#endregion
|
|
//#region 退出
|
form.on('submit(Exit)', function () {
|
Pub_Close(1);
|
})
|
//#endregion
|
//#endregion
|
|
//#region 子表相关监听
|
//#region 头工具栏事件
|
table.on('toolbar(mainTable)', function (obj) {
|
var checkStatus = table.checkStatus('mainTable')
|
, data = checkStatus.data;
|
//新增行表格数据
|
var NewRow = {
|
"HArrangeOrder": "0",
|
"HArrangeOrderSub": "0",
|
"HParentElementID": "",
|
"HIsHide": false,
|
"HIsDisabled": false,
|
"HIsMust": false,
|
"HElementID": "",
|
"HElementIDAdditionalName": "",
|
"HElementLabel": "",
|
"HElementType": "",
|
"HFieldMaxLength": "0",
|
"HDefaultValue": "",
|
"HFieldName": "",
|
"HFieldDataType": "",
|
"HRelateUrl": "",
|
"HSubWindowBackData": "",
|
"HSubWindowBackDataMethodName": "",
|
"HSelectContent": "",
|
};
|
|
switch (obj.event) {
|
//新增一行
|
case 'btn-AddLine': btnAddLine(NewRow);
|
break;
|
//复制一行
|
case 'btn-CopyLine': btnCopyLine(data);
|
break;
|
//指定位置下插入一行
|
case 'btn-InsertLine': btnInsertLine(NewRow)
|
break;
|
//上移
|
case 'btn-Up': btn_up();
|
break;
|
//下移
|
case 'btn-Under': btn_under();
|
break;
|
//列设置
|
case 'set_HideColumn':
|
get_HideColumn();
|
break;
|
}
|
});
|
//#endregion
|
|
//#region 行内事件
|
table.on('tool(mainTable)', function (obj) {
|
set_GridDelete(obj); //行内删除
|
set_GridCellCheck(obj); //行内快捷键筛选
|
});
|
//#endregion
|
//#endregion
|
//#endregion
|
|
//#region 页面初始化相关方法
|
//#region 获取参数
|
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
|
|
//#region 初始化界面
|
function set_ClearBill() {
|
////根据url参数获取加载页面的数据[主表名、视图名、存储过程名]
|
//getBaseDataByURLParams();
|
|
//初始化子表
|
set_InitGrid();
|
|
//查询历史设置记录,设置子表
|
if (RoadBillMain() == true) {
|
|
} else {
|
//初始化子表中的下拉列表
|
setSelectInit();
|
}
|
}
|
//#endregion
|
|
//#region 子表初始化
|
function set_InitGrid() {
|
option = {
|
elem: '#mainTable'
|
, toolbar: '#toolbarDemo'
|
, height: 420
|
, cellMinWidth: 90
|
, limit: 500
|
, cols: [[
|
{ type: 'checkbox', totalRowText: '合计行' }
|
, { type: 'numbers', title: '序号', width: 100 }
|
, { field: 'HArrangeOrder', title: '一级次序', width: 100, edit: true }
|
, { field: 'HArrangeOrderSub', title: '二级次序', width: 100, edit: true }
|
, { field: 'HParentElementID', title: '父级元素ID', width: 100, templet: '#HParentElementID' }
|
, { field: 'HIsHide', title: '隐藏', width: 100, templet: '#HIsHide' }
|
, { field: 'HIsDisabled', title: '禁用', width: 100, templet: '#HIsDisabled' }
|
, { field: 'HIsMust', title: '必填', width: 100, templet: '#HIsMust' }
|
, { field: 'HElementID', title: '元素ID', width: 100, templet: '#HElementID' }
|
, { field: 'HElementIDAdditionalName', title: '元素ID附加字段', width: 100, edit: true, event:"HElementIDAdditionalName" }
|
, { field: 'HElementLabel', title: '元素标签', width: 100, edit: true }
|
, { field: 'HElementType', title: '元素类型', width: 100, templet: '#HElementType' }
|
, { field: 'HFieldMaxLength', title: '最大长度', width: 100, edit: true }
|
, { field: 'HDefaultValue', title: '默认值', width: 100, edit: true }
|
, { field: 'HFieldName', title: '字段名', width: 100, templet: '#HFieldName' }
|
, { field: 'HFieldDataType', title: '字段数据类型', width: 100, templet: '#HFieldDataType' }
|
, { field: 'HRelateUrl', title: '路径信息', width: 100, edit: true }
|
, { field: 'HSubWindowBackData', title: '返回数据对应键值', width: 100, edit: true }
|
, { field: 'HSubWindowBackDataMethodName', title: '返回数据父级方法名', width: 100, edit: true }
|
, { field: 'HSelectContent', title: '下拉列表默认对应键值', width: 100, edit: true }
|
, { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 70 }
|
]]
|
};
|
|
var rowdata = [{
|
"HArrangeOrder": "0",
|
"HArrangeOrderSub": "0",
|
"HParentElementID": "",
|
"HIsHide": false,
|
"HIsDisabled": false,
|
"HIsMust": false,
|
"HElementID": "",
|
"HElementIDAdditionalName": "",
|
"HElementLabel": "",
|
"HElementType": "",
|
"HFieldMaxLength": "0",
|
"HDefaultValue": "",
|
"HFieldName": "",
|
"HFieldDataType": "",
|
"HRelateUrl": "",
|
"HSubWindowBackData": "",
|
"HSubWindowBackDataMethodName": "",
|
"HSelectContent": "",
|
}];
|
|
option.data = rowdata;
|
table.render(option);
|
|
//根据option中的数据,设置子表中的下拉列表、复选框
|
setSelectByTableRender();
|
}
|
//#endregion
|
|
//#region 根据url参数获取加载页面的数据
|
function getBaseDataByURLParams() {
|
$.ajax({
|
type: "get",
|
async: false,
|
url: GetWEBURL() + "/Xt_DefineBillMainSet/getDefineBillMainSet",
|
data: { "HModName": HSetMainModName, "user": sessionStorage["HUserName"] },
|
success: function (result) {
|
if (result.count == 1 && result.data.length>0) { // 说明验证成功了,
|
HTableName = result.data[0]["HTableName"];
|
HDataViewName = result.data[0]["HDataViewName"];
|
HDataProcName = result.data[0]["HDataProcName"];
|
} else {
|
|
}
|
}
|
})
|
}
|
//#endregion
|
|
//#region 查询历史设置记录,设置子表
|
function RoadBillMain() {
|
var returnResult = false;
|
var ajaxLoad = layer.load();
|
$.ajax({
|
url: GetWEBURL() + '/Xt_DefineBillMainSet/getDefineBillMainSet',
|
type: "GET",
|
async: false,
|
data: { "HModName": HSetMainModName, "user": sessionStorage["HUserName"] },
|
success: function (data1) {
|
if (data1.count == 1) {
|
var data = data1.data;
|
|
if (data.length > 0) {
|
for (var i = 0; i < data.length; i++) {
|
if (data[i].HUser == sessionStorage["HUserName"]) {
|
HInterID = data[i].HInterID;
|
}
|
|
data[i].HElementIDAdditionalName = data[i].HElementID;
|
}
|
}
|
|
option.data = data;
|
table.render(option);
|
|
|
|
//根据option中的数据,设置子表中的下拉列表、复选框
|
setSelectByTableRender();
|
layer.close(ajaxLoad);
|
|
DisPlay_HideColumn();
|
|
returnResult = true;
|
} else {
|
layer.close(ajaxLoad);
|
}
|
}, error: function () {
|
layer.close(ajaxLoad);
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
return returnResult;
|
}
|
//#endregion
|
|
//#region 下拉框初始化
|
//#region 下拉框初始化
|
function setSelectInit() {
|
setSelectInit_HElementID();
|
|
setSelectInit_HParentElementID();
|
|
setSelectInit_HElementType();
|
|
setSelectInit_HFieldDataType();
|
|
setSelectInit_HFieldName();
|
}
|
//#endregion
|
|
//#region 元素ID、元素数据类型
|
function setSelectInit_HElementID() {
|
$.ajax({
|
type: "get",
|
async: false,
|
url: GetWEBURL() + "/Xt_DefineBillMainSet/getColsListByName",
|
data: { "HName": HTableName },
|
success: function (data1) {
|
if (data1.count == 1) { // 说明验证成功了,
|
var HElementIDList = []; //元素ID下拉列表数据
|
var HFieldDataTypeList = []; //数据类型下拉列表数据
|
//获取下拉列表的列表数据
|
for (var key in data1.list) {
|
if ($.inArray(data1.list[key].ColmCols, HElementIDList) == -1) {
|
HFieldDataTypeForElementID.push({
|
"HElementID": data1.list[key].ColmCols
|
, "HFieldDataType": data1.list[key].ColmType
|
})
|
|
HElementIDList.push(data1.list[key].ColmCols);
|
if ($.inArray(data1.list[key].ColmType, HFieldDataTypeList) == -1) {
|
HFieldDataTypeList.push(data1.list[key].ColmType);
|
}
|
}
|
}
|
//根据下拉列表的列表数据,设置下拉列表的列表
|
for (var i = 0; i < option.data.length; i++) {
|
var Organization = "";
|
Organization += '<option style="color:blue;" selected="selected" value=""></option>';
|
for (var j = 0; j < HElementIDList.length; j++) {
|
Organization += '<option style="color:blue;" value="' + HElementIDList[j] + '">' + HElementIDList[j] + '</option>';
|
}
|
$('#HElementID' + (i + 1) + '').empty();
|
$('#HElementID' + (i + 1) + '').append(Organization);
|
|
var Organization1 = "";
|
Organization1 += '<option style="color:blue;" selected="selected" value=""></option>';
|
for (var j = 0; j < HFieldDataTypeList.length; j++) {
|
Organization1 += '<option style="color:blue;" value="' + HFieldDataTypeList[j] + '">' + HFieldDataTypeList[j] + '</option>';
|
}
|
$('#HFieldDataType' + (i + 1) + '').empty();
|
$('#HFieldDataType' + (i + 1) + '').append(Organization1);
|
}
|
|
form.render('select');
|
} else {
|
|
}
|
}
|
})
|
}
|
//#endregion
|
|
//#region 父级元素ID
|
function setSelectInit_HParentElementID() {
|
var HElementIDList = ["HBaseInfo", "HFileInfo","HOtherInfo"];
|
var HProTypeList = ["基本信息","附件信息","其他信息"];
|
for (var i = 0; i < option.data.length; i++) {
|
var Organization = "";
|
Organization += '<option style="color:blue;" selected="selected" value=""></option>';
|
for (var j = 0; j < HProTypeList.length; j++) {
|
Organization += '<option style="color:blue;" value="' + HElementIDList[j] + '">' + HProTypeList[j] + '</option>';
|
}
|
$('#HParentElementID' + (i + 1) + '').empty();
|
$('#HParentElementID' + (i + 1) + '').append(Organization);
|
}
|
form.render('select');
|
}
|
//#endregion
|
|
//#region 组件类型
|
function setSelectInit_HElementType() {
|
var HProTypeList = ["标题", "页签", "输入文本", "富文本框", "日期", "选择弹窗", "选择弹窗_transfer", "下拉列表"];
|
for (var i = 0; i < option.data.length; i++) {
|
var Organization = "";
|
Organization += '<option style="color:blue;" selected="selected" value=""></option>';
|
for (var j = 0; j < HProTypeList.length; j++) {
|
Organization += '<option style="color:blue;" value="' + HProTypeList[j] + '">' + HProTypeList[j] + '</option>';
|
}
|
$('#HElementType' + (i + 1) + '').empty();
|
$('#HElementType' + (i + 1) + '').append(Organization);
|
}
|
form.render('select');
|
}
|
//#endregion
|
|
//#region 字段名
|
function setSelectInit_HFieldName() {
|
$.ajax({
|
type: "get",
|
async: false,
|
url: GetWEBURL() + "/Xt_DefineBillMainSet/getColsListByName",
|
data: { "HName": HDataViewName },
|
success: function (data1) {
|
if (data1.count == 1) { // 说明验证成功了,
|
var HFieldNameList = []; //字段名下拉列表数据
|
//获取下拉列表的列表数据
|
for (var key in data1.list) {
|
if ($.inArray(data1.list[key].ColmCols, HFieldNameList) == -1) {
|
HFieldNameList.push(data1.list[key].ColmCols);
|
}
|
}
|
|
//根据下拉列表的列表数据,设置下拉列表的列表
|
for (var i = 0; i < option.data.length; i++) {
|
var Organization = "";
|
Organization += '<option style="color:blue;" selected="selected" value=""></option>';
|
for (var j = 0; j < HFieldNameList.length; j++) {
|
Organization += '<option style="color:blue;" value="' + HFieldNameList[j] + '">' + HFieldNameList[j] + '</option>';
|
}
|
$('#HFieldName' + (i + 1) + '').empty();
|
$('#HFieldName' + (i + 1) + '').append(Organization);
|
}
|
|
form.render('select');
|
} else {
|
|
}
|
}
|
})
|
}
|
//#endregion
|
|
//#region 字段数据类型
|
function setSelectInit_HFieldDataType() {
|
|
}
|
//#endregion
|
//#endregion
|
//#endregion
|
|
//#region 此页面所有的方法
|
|
//#region 操作按钮调用方法
|
//#region 保存方法
|
function set_AddNew(data) {
|
data.field.HInterID = HInterID;
|
data.field.HModName = HSetMainModName;
|
data.field.HUser = sessionStorage["HUserName"];
|
data.field.HTableName = HTableName;
|
data.field.HDataViewName = HDataViewName;
|
data.field.HDataProcName = HDataProcName;
|
data.field.HRowElementCount = HRowElementCount;
|
|
//序列化表头信息和子表信息
|
var sMainStr = JSON.stringify(data.field);
|
var sSubStr = JSON.stringify(option.data);
|
//拼接参数
|
var sMainSub = sMainStr + ';' + sSubStr + ";" + sessionStorage["HUserName"];
|
|
var index = layer.load();
|
$.ajax({
|
type: "POST",
|
url: GetWEBURL() + "/Xt_DefineBillMainSet/SaveXt_DefineBillMainSet", //方法所在页面和方法名
|
async: true,
|
data: { "msg": sMainSub },
|
dataType: "json",
|
success: function (data) {
|
if (data.count == 1) { // 说明验证成功了,
|
layer.msg(data.Message, { icon: 1 });
|
layer.close(index);
|
}
|
else {
|
layer.alert(data.Message, { icon: 5 });
|
layer.close(index);
|
}
|
},
|
error: function (err) {
|
layer.alert("错误:" + err, { icon: 5 });
|
layer.close(index);
|
}
|
});
|
}
|
//#endregion
|
//#endregion
|
|
//#region 子表相关方法
|
//#region 根据option中的数据,设置子表中的下拉列表、复选框
|
function setSelectByTableRender() {
|
//下拉框列表初始化
|
setSelectInit();
|
|
for (var i = 1; i <= option.data.length; i++) {
|
$('#HElementID' + i + '').val(option.data[i - 1].HElementID);
|
$('#HParentElementID' + i + '').val(option.data[i - 1].HParentElementID);
|
$('#HElementType' + i + '').val(option.data[i - 1].HElementType);
|
$('#HFieldName' + i + '').val(option.data[i - 1].HFieldName);
|
$('#HFieldDataType' + i + '').val(option.data[i - 1].HFieldDataType);
|
|
$('#HIsHide' + i + '').attr("checked", option.data[i - 1].HIsHide);
|
$('#HIsDisabled' + i + '').attr("checked", option.data[i - 1].HIsDisabled);
|
$('#HIsMust' + i + '').attr("checked", option.data[i - 1].HIsMust);
|
}
|
form.render('select');
|
form.render('checkbox');
|
}
|
//#endregion
|
|
//#region 上移
|
function btn_up() {
|
var checkStatus = table.checkStatus('mainTable')
|
, data = checkStatus.data;
|
if (data.length == 1) {
|
var tables = [];
|
//获取表格的全部行
|
var rowList = table.cache['mainTable'];
|
for (var i = 0; i < rowList.length; i++) { //遍历表格的行
|
if (rowList[i].LAY_CHECKED == true) { //获取选中行的位置
|
//如果是第一行上移,则失败并提醒
|
if (i == 0) {
|
layer.msg("第一行数据无法上移!");
|
return;
|
}
|
tables.push(option.data[i - 1]);
|
data[0].LAY_CHECKED = true;
|
option.data[i - 1] = data[0];
|
option.data[i] = tables[0];
|
table.render(option);
|
|
//根据option中的数据,设置子表中的下拉列表、复选框
|
setSelectByTableRender();
|
|
break;
|
}
|
}
|
} else {
|
layer.msg("请选择一行数据!");
|
}
|
}
|
//#endregion
|
|
//#region 下移
|
function btn_under() {
|
var checkStatus = table.checkStatus('mainTable')
|
, data = checkStatus.data;
|
if (data.length == 1) {
|
var tables = [];
|
//获取表格的全部行
|
var rowList = table.cache['mainTable'];
|
for (var i = 0; i < rowList.length; i++) { //遍历表格的行
|
if (rowList[i].LAY_CHECKED == true) { //获取选中行的位置
|
//如果是最后一行下移,则失败并提醒
|
if (i == option.data.length - 1) {
|
layer.msg("最后一行数据无法下移!");
|
return;
|
}
|
|
|
tables.push(option.data[i + 1]);
|
data[0].LAY_CHECKED = true;
|
option.data[i + 1] = data[0];
|
option.data[i] = tables[0];
|
table.render(option);
|
|
//根据option中的数据,设置子表中的下拉列表、复选框
|
setSelectByTableRender();
|
break;
|
}
|
}
|
} else {
|
layer.msg("请选择一行数据!");
|
}
|
}
|
//#endregion
|
|
//#region 在末尾增加一行
|
function btnAddLine(NewRow) {
|
table.cache["mainTable"].push(NewRow);
|
option.data = table.cache["mainTable"];
|
table.render(option);
|
|
//根据option中的数据,设置子表中的下拉列表、复选框
|
setSelectByTableRender();
|
//rows++;
|
//layer.msg('增加一行按钮!')
|
}
|
//#endregion
|
|
//#region 在指定行下插入一行
|
function btnInsertLine(NewRow) {
|
var checkStatus = table.checkStatus('mainTable')
|
, data = checkStatus.data;
|
if (checkStatus.data.length === 1) {
|
var tables = []; //存储插入一行后的表格数据
|
//获取表格的全部行
|
var rowList = table.cache['mainTable'];
|
for (var i = 0; i < rowList.length; i++) { //遍历表格的行
|
tables.push(option.data[i]);
|
if (rowList[i].LAY_CHECKED == true) { //获取选中行的位置
|
tables.push(NewRow);
|
}
|
}
|
option.data = tables;
|
table.render(option);
|
|
//根据option中的数据,设置子表中的下拉列表、复选框
|
setSelectByTableRender();
|
} else {
|
layer.msg('请选择一行数据编辑!');
|
}
|
}
|
//#endregion
|
|
//#region 复制一行
|
function btnCopyLine(data) {
|
var copydata = JSON.stringify(data);
|
if (data.length <= 0) {
|
layer.msg("请选择需要复制的一行!");
|
}
|
else if (data.length > 1) {
|
layer.msg("只能选择复制一行!");
|
}
|
else {
|
var copydata2 = copydata.substring(1, copydata.length);//去除首行字符'['
|
var copyrow = copydata2.substring(0, copydata2.length - 1);//去除末尾字符']'
|
table.cache["mainTable"].push(JSON.parse(copyrow));//将复制的行强转成json追加到表格上
|
option.data = table.cache["mainTable"];//将数据绑定到data上
|
//设置复制得到的记录的实际称重为0
|
option.data[option.data.length - 1].HWeight = "0";
|
|
table.render(option);//将数据渲染到表格上
|
|
//根据option中的数据,设置子表中的下拉列表、复选框
|
setSelectByTableRender();
|
}
|
}
|
//#endregion
|
|
//#region 行内删除
|
function set_GridDelete(obj) {
|
var data = obj.data;
|
var rowIndex = $(obj.tr).attr("data-index");
|
if (obj.event === 'del') {
|
layer.confirm('真的删除行吗?', function (index) {
|
console.log("索引为:" + rowIndex);
|
if (rowIndex === '0') {
|
layer.msg('首行无法删除!!!');
|
} else {
|
obj.del();
|
option.data = table.cache["mainTable"];//将数据绑定到data上
|
table.reload(option);
|
layer.close(index);
|
}
|
});
|
}
|
}
|
//#endregion
|
|
//#region 行内快捷键筛选
|
function set_GridCellCheck(obj) {
|
$(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
|
if (event.key == "F7") {
|
if (obj.event == "HMaterID") {
|
|
}
|
obj.event = "";
|
return false;
|
}
|
})
|
}
|
//#endregion
|
|
//#region 监听单元格编辑 单元格编辑后 变更
|
table.on('edit(mainTable)', function (obj) {
|
//数值格式校验工具
|
var ref = /^\d+(\.\d+)?$/; //非负数正则表达式
|
var temp = "";
|
|
// 单元格编辑之前的值
|
var oldText = $(this).prev().text();
|
var value = obj.value //得到修改后的值
|
, data = obj.data //得到所在行所有键值
|
, field = obj.field; //得到字段
|
|
switch (field) {
|
case "HElementIDAdditionalName": //元素ID附加字段
|
obj.update({
|
HElementID: ""
|
, HFieldDataType: ""
|
});
|
table.render(option);
|
//根据option中的数据,设置子表中的下拉列表、复选框
|
setSelectByTableRender();
|
break;
|
default:
|
}
|
});
|
//#endregion
|
|
//#region 子表1:隐藏列设置
|
function get_HideColumn() {
|
var colName = "";
|
var contentUrl = "";
|
for (var i = 1; i < option.cols[0].length-1; i++) {
|
colName += option.cols[0][i]["title"] + ",";
|
}
|
var urlStr = window.document.location.pathname;//获取文件路径
|
var urlLen = urlStr.split('/');
|
for (var i = 0; i < urlLen.length - 4; i++) {
|
contentUrl += "../";
|
}
|
colName = encodeURI(colName.substring(0, colName.length - 1));//对 URI 进行编码
|
|
contentUrl += '基础资料/隐藏列设置/Gy_GridView_Hide.html?HModName=' + HModName + '&colName=' + colName;
|
|
layer.open({
|
type: 2
|
, skin: "layui-layer-rim" //加上边框
|
, title: "隐藏列设置" //标题
|
, closeBtn: 1 //窗体右上角关闭 的 样式
|
, shift: 2 //弹出动画
|
, area: ["50%", "90%"] //窗体大小
|
, maxmin: true //设置最大最小按钮是否显示
|
, content: [contentUrl, "yes"]
|
, btn: ["确定", "取消"]
|
, btn1: function (index, laero) {
|
//刷新表格数据
|
DisPlay_HideColumn();
|
//更新表格缓存的数据
|
layer.close(index);//关闭弹窗
|
}
|
})
|
}
|
//#endregion
|
//#region 子表1:显示列数据
|
function DisPlay_HideColumn() {
|
$.ajax({
|
url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList',
|
async: false,
|
type: "GET",
|
data: { "HModName": HModName, "user": sessionStorage["HUserName"] },
|
async: false,
|
success: function (data1) {
|
if (data1.data.length != 0) {
|
var dataCol = []; //数据库查询出的列数据
|
var titleData = []; //不需要显示的字段 可扩展
|
|
dataCol = data1.data[0].HGridString.split(',');
|
|
for (var i = 0; i < option.cols[0].length - 2; i++) {
|
if (i >= dataCol.length) {
|
continue;
|
}
|
|
var dataCols = dataCol[i].split('|');
|
//隐藏列
|
if (dataCols[1] == 1) {
|
option.cols[0][i + 1]["hide"] = true;
|
}
|
//设置列宽
|
if (dataCols[3] > 0) {
|
option.cols[0][i + 1]["width"] = dataCols[3];
|
}
|
//设置内容字体大小
|
if (data1.data[0].HFontSize != 0) {
|
option.cols[0][i + 1]["style"] += "font-size:" + data1.data[0].HFontSize + "px;";
|
} else {
|
option.cols[0][i + 1]["style"] += "font-size:100%";
|
}
|
//设置列宽
|
//if (data1.data[0].HColumnWidth != 0) {
|
// option.cols[0][i + 1]["width"] = data1.data[0].HColumnWidth + "px;";
|
//} else {
|
// option.cols[0][i + 1]["width"] = "";
|
//}
|
//显示列
|
if (dataCols[1] == 0 && $.inArray(option.cols[0][i + 1]["title"], titleData) == -1) {
|
option.cols[0][i + 1]["hide"] = false;
|
}
|
//字体所在位置(左 居中 右)
|
switch (dataCols[2]) {
|
case "L":
|
option.cols[0][i + 1]["align"] = "left";
|
break;
|
case "M":
|
option.cols[0][i + 1]["align"] = "center";
|
break;
|
case "R":
|
option.cols[0][i + 1]["align"] = "right";
|
break;
|
}
|
//设置表格title属性显示别名
|
if (dataCols[4] != null && dataCols[4] != "") {
|
option.cols[0][i + 1]["title"] = dataCols[4];
|
}
|
}
|
|
//取消冻结列
|
for (var i = 1; i < option.cols[0].length - 1; i++) {
|
if (option.cols[0][i]["fixed"] != null) {
|
option.cols[0][i]["fixed"] = null;
|
}
|
else {
|
break;
|
}
|
}
|
//冻结列
|
if (data1.data[0].HFixCols != 0) {
|
for (var i = 0; i < data1.data[0].HFixCols; i++) {
|
if ($.inArray(option.cols[0][i + 1]["title"], titleData) != -1) {
|
data1.data[0].HFixCols += 1;
|
}
|
option.cols[0][i + 1]["fixed"] = "left";
|
}
|
}
|
table.render(option);
|
|
//根据option中的数据,设置子表中的下拉列表、复选框
|
setSelectByTableRender();
|
} else {
|
table.render(option);
|
|
//根据option中的数据,设置子表中的下拉列表、复选框
|
setSelectByTableRender();
|
}
|
}, error: function () {
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
})
|
}
|
//#endregion
|
//#endregion
|
//#endregion
|
|
});
|
|
|
</script>
|