You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

415 lines
15 KiB
Plaintext

11 months ago
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<title>查询</title>
<!--jquery-->
<script src="../../Scripts/jquery-1.11.0.min.js" type="text/javascript"></script>
<!--公共JS-->
<script src="../../Scripts/QueryString.js" type="text/javascript"></script>
<script src="../../Scripts/config.js" type="text/javascript"></script>
<script src="../Gener.js" type="text/javascript"></script>
<link href="../../Scripts/layui/layui/css/layui.css" rel="stylesheet" />
<link href="../../Scripts/layui/style/admin.css" rel="stylesheet" />
<script src="../../Scripts/layui/layui/layui.js" type="text/javascript"></script>
<script src="../../Scripts/layui/LayuiDialog.js" type="text/javascript"></script>
<base target="_self" />
<style type="text/css">
.layui-form-label {
padding: 9px 0px;
}
.layui-form-label {
margin-bottom: 0px;
}
.layui-table th {
font-weight: bold;
}
</style>
<script language="javascript" type="text/javascript">
//页面启动函数.
var frmData = null;
var mapData = null;
var webUser = new WebUser();
var ensName = GetQueryString("EnsName");
var enName = ensName.substring(0, ensName.length - 1);
var enPK = "";
//页面设置信息
var cfg = new Entity("BP.Sys.EnCfg");
cfg.No = ensName;
cfg.RetrieveFromDBSources();
$(function () {
if (webUser.No == undefined) {
alert('登录信息丢失,请重新登录。');
return;
}
if (ensName == null || ensName == undefined) {
$("#Msg").html("必要的参数EnsName没有传入.");
return;
}
var httpHandler = new HttpHandler("BP.WF.HttpHandler.WF_CommEntity");
httpHandler.AddUrlData(); //增加参数属性.
var data = httpHandler.DoMethodReturnString("Dtl_Init");
if (data.indexOf('err@') == 0) {
$("#Msg").html(data);
return;
}
//解析json.
frmData = JSON.parse(data);
mapData = frmData["Sys_MapData"][0];
mapData = new Entity("BP.Sys.MapData", mapData);
document.title = mapData.Name;
enPK = mapData.GetPara("EntityPK");
layui.use(['table', 'laydate'], function () {
var table = layui.table,
laydate = layui.laydate;
InitToolbar();
//按钮操作
$('.toolbar').on('click', function () {
var id = this.id;
switch (id) {
case "Add":
OpenEn("");
break;
case "Exp":
Export();
break;
case "Import":
Imp();
break;
case "Setting":
Setting();
break;
default: break;
}
});
var data = frmData.Dtls;
//获取列
var cols = GetColoums(frmData);
//渲染table
//主页面数据
var vtable = table.render({
elem: '#tableSearch',
id: 'tableSearch',
data: data,
title: '数据表',
limit: Number.MAX_VALUE,
height: $(document).height() - $("#toolbar").height()-40,
cellMinWidth: 120,
cols: [cols],
page: false
});
//触发行双击事件
if (cfg.DoubleOrClickModel == 0) {
table.on('rowDouble(search)', function (obj) {
var row = obj.data;
var pkval = row[enPK];
var rowstr = JSON.stringify(row);
rowstr = encodeURIComponent(rowstr);
OpenEn(pkval, rowstr);
});
}
if (cfg.DoubleOrClickModel == 1) {
table.on('row(search)', function (obj) {
var row = obj.data;
var pkval = row[enPK];
var rowstr = JSON.stringify(row);
rowstr = encodeURIComponent(rowstr);
OpenEn(pkval, rowstr);
});
}
});
});
function InitToolbar() {
var _html = "<div class='layui-inline'>";
//权限控制.
if (mapData.GetPara("IsInsert") == 1) {
_html += "<button type='button' class='layui-btn layui-btn-radius layui-btn-sm toolbar' id='Add'>新建</button>";
}
if (mapData.GetPara("IsImp") == 1) {
_html += "<button type='button' class='layui-btn layui-btn-radius layui-btn-sm toolbar' id='Imp'>导入</button>";
}
if (mapData.GetPara("IsExp") == 1)
_html += "<button type='button' class='layui-btn layui-btn-radius layui-btn-sm toolbar' id='Exp'>导出</button>";
if (new WebUser().IsAdmin == true)
_html += "<button type='button' class='layui-btn layui-btn-radius layui-btn-sm toolbar' id='Setting'>设置</button>";
$("#toolbar").append(_html);
layui.form.render();
}
function OpenEn(pk,row) {
if (row != null && row != undefined && row != "")
row = JSON.parse(decodeURIComponent(row));
var url = "./En.htm?EnName=" + enName + "&PKVal=" + pk + "&RefPK=" + GetQueryString("RefKey") + "&RefPKVal=" + GetQueryString("RefVal");
var windowW = document.body.clientWidth*4/5;
OpenLayuiDialog(url, mapData.Name, windowW, 100, "r", true, false, false, null, function () {
//关闭弹窗时刷新本页面如果父页面时En.htm时页需要刷新
var httpHandler = new HttpHandler("BP.WF.HttpHandler.WF_CommEntity");
httpHandler.AddUrlData(); //增加参数属性.
var data = httpHandler.DoMethodReturnString("Dtl_Init");
if (data.indexOf('err@') == 0) {
$("#Msg").html(data);
return;
}
//解析json.
frmData = JSON.parse(data);
layui.table.reload('tableSearch', { data: frmData.Dtls });
if (typeof window.parent.vm != "undefined") {
var len = frmData.Dtls.length;
if (window.parent.vm.tabsList.length > window.parent.vm.selectedTabsIndex) {
//修改Tab标签
$.each(window.parent.vm.tabsList, function (i, item) {
if (i == window.parent.vm.selectedTabsIndex) {
item.name = mapData.Name + "(" + len + ")";
item.Title = item.name;
}
})
//修改树形菜单
var dd = $("dd[data-id='" + ensName + "']", window.parent.document);
dd.attr("data-name", mapData.Name + "(" + len + ")");
$(dd.find("a")[0]).find("span").html(mapData.Name + "(" + len + ")");
$.each(window.parent.vm.menuTreeData, function (i,group) {
$.each(group.children, function (k, item) {
if (item.No == ensName) {
item.name = mapData.Name + "(" + len + ")";
item.Title = item.name;
return false;
}
})
})
}
}
});
}
function GetColoums(data) {
var attrs = data.Sys_MapAttr;
// enPK = sysMapData.GetPara("PK");
if (attrs == undefined) {
alert('没有取得属性.');
return;
}
var cols = [];
var fieldColumns = {};
fieldColumns = {
title: '序',
field: '',
align: 'center',
width: 50,
type: 'numbers',
};
cols.push(fieldColumns);
for (var i = 0; i < attrs.length; i++) {
var attr = attrs[i];
if (attr.UIVisible == 0
|| attr.KeyOfEn == "OID"
|| attr.KeyOfEn == "WorkID"
|| attr.KeyOfEn == "NodeID"
|| attr.KeyOfEn == "MyNum"
|| attr.KeyOfEn == "MyPK") {
keyOfEn = attr.KeyOfEn
continue;
}
var field = attr.KeyOfEn;
var title = attr.Name;
var width = attr.Width;
if (width < 60) {
width = 60;
}
if (field == "Title") {
width = 230;
}
if (attr.UIContralType == 1) {
if (width == null || width == "" || width == undefined)
width = 180;
field = field + "Text";
fieldColumns = {
field: field,
title: title,
fixed: false,
minWidth: width,
};
cols.push(fieldColumns);
continue;
}
if (attr.UIContralType == 2) {
fieldColumns = {
field: field,
title: title,
minWidth: width,
fixed: false,
templet: function (row) {
var val = "";
if (row[this.field] == "0")
val = "否";
if (row[this.field] == "1")
val = "是";
return val;
}
};
cols.push(fieldColumns);
continue;
}
if (width == null || width == "" || width == undefined)
width = 100;
if (attr.IsRichText == "1") {
richAttrs.push(attr);
fieldColumns = {
field: field,
title: title,
width: width,
fixed: false,
templet: function (row) {
var val = row[this.field];
if (val == "")
return val;
val = htmlDecodeByRegExp(val);
return "<div>" + val + "</div>";
}
};
cols.push(fieldColumns);
continue;
}
if (attr.MyDataType == "6") {
fieldColumns = {
field: field,
title: title,
width: width,
fixed: false,
templet: function (row) {
var val = row[this.field];
if (val == null || val == undefined || val == "")
return "";
val = FormatDate(new Date(val), "yyyy-MM-dd");
return val;
}
};
cols.push(fieldColumns);
continue;
}
fieldColumns = {
field: field,
title: title,
minWidth: width,
fixed: false,
};
cols.push(fieldColumns);
continue;
}
//fieldColumns = {
// field: '_operate',
// title: '操作',
// minWidth: 200,
// align: 'center',
// templet: function (row) {
// return rowbar(dtMs, row);
// }
//}
//cols.push(fieldColumns);
return cols;
}
function Import() {
var title = mapData.Name + "导入数据";
var W = document.body.clientWidth*3/5;
var url = "../../CCForm/DtlImpByExcel.htm?EnsName=" + GetQueryString("EnsName") + "&RefPKVal=" + GetQueryString("RefVal") + "&FK_MapData=" + GetQueryString("EnName");
OpenLayuiDialog(url, title, W, 100, 'r', true);
}
//导出
function Export() {
var handler = new HttpHandler("BP.WF.HttpHandler.WF_CommEntity");
handler.AddPara("EnsName", GetQueryString("EnsName"));
handler.AddPara("RefKey", GetQueryString("RefKey"));
handler.AddPara("RefVal", GetQueryString("RefVal"));
//查询集合
var data = handler.DoMethodReturnString("Dtl_Exp");
if (data.indexOf('err@') == 0) {
alert(data);
return;
}
data = basePath + "/" + data;
window.open(data);
return;
}
//设置
function Setting() {
//先判断是否有该笔数据.
var ensName = GetQueryString("EnsName");
var en = new Entity("BP.Sys.EnCfg");
en.SetPKVal(ensName);
var i = en.RetrieveFromDBSources();
if (i == 0) {
en.No = ensName;
en.Insert();
}
var url = "./En.htm?EnName=BP.Sys.EnCfg&No=" + GetQueryString("EnsName") + "&m=" + Math.random();
//获取屏幕的长宽
var W = document.body.clientWidth*4/5;
OpenLayuiDialog(url, "", W, 100, "r", true);
}
</script>
</head>
<body>
<div class="layui-fluid">
<div class="layui-row layui-col-space30">
<!-- 内容主体区域 -->
<div class="layui-col-md12" style="padding:10px">
<div class="layui-card">
<div class="layui-card-body">
<!--查询条件-->
<div>
<form class="layui-form" id="toolbar" style="text-align:right;margin-right:20px">
</form>
</div>
<!--查询表格-->
<table class="layui-hide" id="tableSearch" lay-filter="search"></table>
</div>
</div>
</div>
</div>
</div>
</body>
</html>