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.

331 lines
12 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>
<title>分组平铺</title>
<script src="../../Scripts/jquery-1.11.0.min.js" type="text/javascript"></script>
<script language="JavaScript" src="../../Comm/JScript.js" type="text/javascript"></script>
<script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
<script src="../../Scripts/QueryString.js" type="text/javascript"></script>
<!-- 引用通用的js文件. -->
<script type="text/javascript" src="../../Scripts/config.js"></script>
<script type="text/javascript" src="../../Comm/Gener.js"></script>
<link href="../../../DataUser/Style/ccbpm.css" rel="Stylesheet" />
<!-- 自己的系统风格统一. -->
<link href="../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />
<link href="../../Style/skin/css/Default.css" rel="stylesheet" />
<link href="../../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" />
<script type="text/javascript">
var selectedEles = null;
var en;
$(function () {
$("#Msg").html("正在加载,请稍后......");
var dot2DotEnName = GetQueryString("Dot2DotEnName"); //存储实体.
var saveFiled = GetQueryString("SaveFiled")||"";
var defaultGroupAttrKey = GetQueryString("DefaultGroupAttrKey");
var pkVal = GetQueryString("PKVal");
var en = new Entity(dot2DotEnName);
en.SetPKVal(pkVal);
en.RetrieveFromDBSources();
var val = en[saveFiled]||"";
if (val == "")
selectedEles = [];
else {
try {
selectedEles = JSON.parse(replaceAll(val, '\\\\\"', '"'));
} catch {
selectedEles = [];
}
}
if (defaultGroupAttrKey == "" || defaultGroupAttrKey == "null") {
BindListModel();
} else {
BindGroupModel();
}
});
//去重复的人员
function unique(arr) {
var result = [], isRepeated;
for (var i = 0, len = arr.length; i < len; i++) {
isRepeated = false;
for (var j = 0, len1 = result.length; j < len1; j++) {
if (arr[i].No == result[j].No) {
isRepeated = true;
break;
}
}
if (!isRepeated) {
result.push(arr[i]);
}
}
return result;
}
function Search() {
BindListModel($('#Search_Key').val());
}
function BindListModel(KeyVal) {
if (KeyVal == null && KeyVal == undefined)
KeyVal = "";
//获得列表实体, 查询全部.
var ensOfM = GetQueryString("EnsOfM"); // 主表实体. A实体.
var entities = new Entities(ensOfM);
if (KeyVal != "")
entities.RetrieveCond("No,Name", "Like", "%" + KeyVal + "%");
else
entities.RetrieveAll();
entities = unique(entities);//去重复的人员
var html = "<table class='table' >";
html += "<tr>";
html += "<th colspan=3>";
html += "<div style='float:right'>";
html += "<input type=checkbox value='全选' onclick='CheckAll(this.checked, \"CB\");' id='SelectAll' /><label for='SelectAll' >全选</label>";
html += "</div>";
html += "<div style='float:left'>";
html += "<input type=text value='" + KeyVal + "'id='Search_Key' placeholder='输入编号或者名称'/><input type=button value='查询' onclick='Search();' class='cc-btn-tab' />";
html += "</div>";
html += "</th>";
html += "</tr>";
var myNum = -1;
for (var idx = 0; idx < entities.length; idx++) {
en = entities[idx];
var isHave = false;
for (var iEle = 0; iEle < selectedEles.length; iEle++) {
var ele = selectedEles[iEle];
if (ele == null || ele == undefined)
continue;
if (ele.No == en.No) {
isHave = true;
break;
}
}
var lab = en.Name;
if (isHave)
lab = "<font color=green>" + en.Name + "</font>";
myNum++;
if (myNum == 0)
html += "<TR>";
if (isHave == true)
html += "<td><label for='CB_" + en.No + "'><input type='checkbox' class='dot2_checkbox' checked=true name='CB' data-info='" + en.Name +"' id='CB_" + en.No + "' value='" + en.No + "'/>" + lab + "</label></td>";
else
html += "<td><label for='CB_" + en.No + "'><input type='checkbox' class='dot2_checkbox' name='CB' data-info='" + en.Name +"' id='CB_" + en.No + "' value='" + en.No + "'/>" + lab + "</label></td>";
if (myNum == 2) {
html += "</tr>";
myNum = -1;
}
}
if (idx == 1) {
html += "<td colspan=2></td>";
html += "</tr>";
}
if (idx == 2) {
html += "<td></td>";
html += "</tr>";
}
html += "</table>";
$("#Msg").html("");
$("#Msg").html(html);
}
function BindGroupModel() {
//获得列表实体, 查询全部.
var ensOfM = GetQueryString("EnsOfM"); // 主表实体. A实体.
var entities = new Entities(ensOfM);
entities.RetrieveAll();
//处理
var hand = new HttpHandler("BP.WF.HttpHandler.WF_CommEntity");
hand.AddUrlData();
var groups = hand.DoMethodReturnJSON("Dot2Dot_GenerGroupEntitis");
var html = "<table class='table' >";
html += "<tr>";
html += "<th colspan=3>";
html += "<div style='float:right'>";
html += "<input type=checkbox value='全选' onclick='CheckAll(this.checked, '');' id='SelectAll' /><label for='SelectAll' >全选</label>";
html += "</div>";
html += "<div style='float:left'>";
//html += "<input type=button value='保存' onclick='Save();' id='save' class='cc-btn-tab'/>";
html += "</div>";
html += "</th>";
html += "</tr>";
for (var i = 0; i < groups.length; i++) {
var group = groups[i];
html += "<tr>";
html += "<th colspan=3>";
html += "<label for='Group_" + group.No + "'><input type='checkbox' onclick='CheckAll(this.checked, \"" + group.No + "\");' id='Group_" + group.No + "' name='Group_" + group.No + "' /> " + group.Name + "</label>";
html += "</th>";
html += "</tr>";
var myNum = -1;
for (var idx = 0; idx < entities.length; idx++) {
en = entities[idx];
var myidx = 0;
var oOfEn;
for (var obj in en) {
if (myidx == 2) {
oOfEn = obj;
break;
}
myidx++;
}
myidx = 0;
var oOfGroup;
for (var obj in en) {
if (myidx == 0) {
oOfGroup = obj;
break;
}
myidx++;
}
if (en[oOfEn] != group[oOfGroup])
continue;
var isHave = false;
for (var iEle = 0; iEle < selectedEles.length; iEle++) {
var ele = selectedEles[iEle];
if (ele == null || ele == undefined)
continue;
if (ele.No == en.No) {
isHave = true;
break;
}
}
var lab = en.Name;
if (isHave)
lab = "<font color=green>" + en.Name + "</font>";
myNum++;
if (myNum == 0)
html += "<TR>";
if (isHave == true)
html += "<td><label for='CB_" + en.No + "'><input type='checkbox' class='dot2_checkbox' checked=true name='CB_" + group.No + "' data-info='"+en.Name+"' id='CB_" + en.No + "' value='" + en.No + "' /> " + lab + "</label></td>";
else
html += "<td><label for='CB_" + en.No + "'><input type='checkbox' class='dot2_checkbox' name='CB_" + group.No + "' data-info='" + en.Name +"' id='CB_" + en.No + "' value='" + en.No + "' /> " + lab + "</label></td>";
if (myNum == 2) {
html += "</tr>";
myNum = -1;
}
}
if (idx == 1) {
html += "<td colspan=2></td>";
html += "</tr>";
}
if (idx == 2) {
html += "<td></td>";
html += "</tr>";
}
}
html += "</table>";
$("#Msg").html("");
$("#Msg").html(html);
}
//选择与取消选择.
function CheckAll(checked, no) {
//获取name=box的复选框 遍历输出复选框
var checkeds = document.getElementsByName("CB_" + no);
for (var i = 0; i < checkeds.length; i++) {
checkeds[i].checked = checked;
}
}
//保存.
function Btn_OK() {
//获得存储的值.
var cbs = $("input[type='checkbox']:checked");
var strs = [];
cbs.each(function () {
if (this.id.indexOf('CB_') == -1)
return true;
strs.push({
No: this.defaultValue,
Name: $(this).attr("data-info")
});
});
if (strs.length == 0) {
alert("请选择绑定的岗位");
return;
}
return strs;
}
/**/</script>
</head>
<body>
<div class="container-full" style="padding-top:10px;">
<table id="Table1">
</table>
<!--<input type=button id="Btn_Save" class="cc-btn-tab" onclick="Save();" style="display: none;" value="Save" />-->
<div id="Msg"> </div>
</div>
<script type="text/javascript">
$(function () {
//给全选的复选框添加事件
$("#SelectAll").click(function () {
// this 全选的复选框
var userids = this.checked;
//获取name=box的复选框 遍历输出复选框
$("input[class='dot2_checkbox']").each(function () {
this.checked = userids;
});
});
});
</script>
</body>
</html>