|
|
<!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 http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
|
<title>执行批量操作</title>
|
|
|
<link href="../../Comm/Style/CommStyle.css" rel="stylesheet" type="text/css" />
|
|
|
<link href="../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
|
|
|
<link href="../../Scripts/easyUI/themes/icon.css" rel="stylesheet" type="text/css" />
|
|
|
<script src="../../Scripts/easyUI/jquery-1.8.0.min.js" type="text/javascript"></script>
|
|
|
<script src="../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
|
|
|
<link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
|
|
|
<link href="../../Comm/Style/Tabs.css" rel="stylesheet" type="text/css" />
|
|
|
<!-- 引用通用的js文件. -->
|
|
|
<script type="text/javascript" src="../../Scripts/config.js"></script>
|
|
|
<script type="text/javascript" src="../../Comm/Gener.js"></script>
|
|
|
<script type="text/javascript" src="../../Scripts/QueryString.js"></script>
|
|
|
<script src="../Admin.js"></script>
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
var keyofen = GetQueryString('KeyOfEn');
|
|
|
//从url参数中截取出流程编号
|
|
|
var fk_mapdata = GetQueryString('FK_MapData');
|
|
|
var fk_flow = fk_mapdata.substring(2);
|
|
|
|
|
|
fk_flow = fk_flow.substring(0, fk_flow.length - 2);
|
|
|
|
|
|
if (fk_flow.length == 1)
|
|
|
fk_flow = '00' + fk_flow;
|
|
|
|
|
|
if (fk_flow.length == 2)
|
|
|
fk_flow = '0' + fk_flow;
|
|
|
|
|
|
|
|
|
//声明一个行对象数组,用于初始化表格数据
|
|
|
var enArr = new Array();
|
|
|
|
|
|
/*
|
|
|
获取实体对象方法
|
|
|
1.从WF_Node表中获取所有当前流程所包含的节点
|
|
|
2.通过第一步获取的节点NodeId加上ND标识作为参数从Sys_MapData表中取出节点对应No和Name,组成对象,放入数组;
|
|
|
3.根据批量操作的不同(copy\update\delete),拿生成的数组与Sys_MapAttr表中对应项进行比较,过滤掉数组中相应的元素,求的不同的操作对应的不同数组;
|
|
|
*/
|
|
|
function getEns(para) {
|
|
|
|
|
|
//获取流程对应的所有节点
|
|
|
var nodes = new Entities("BP.WF.Nodes", "FK_Flow", fk_flow);
|
|
|
nodes.Retrieve("FK_Flow", fk_flow);
|
|
|
|
|
|
// alert(nodes.length);
|
|
|
|
|
|
|
|
|
if (nodes.length == 0) {
|
|
|
return "";
|
|
|
}
|
|
|
for (var j = 0; j < nodes.length; j++) {
|
|
|
//组装查询MapData的No
|
|
|
var mapdataon = ("ND" + nodes[j].NodeID);
|
|
|
//获取MapData对象,(目的是从中取出节点名称和编号等)
|
|
|
// if (mapdataon == fk_mapdata) //去掉当前节点,因为当前节点为操作的原数据.不应该出现在列表中.
|
|
|
// continue;
|
|
|
var en = new Entity('BP.Sys.MapData', mapdataon);
|
|
|
if (en != null) {
|
|
|
var rowObj = {};
|
|
|
rowObj.No = en.No;
|
|
|
rowObj.Name = en.Name;
|
|
|
enArr.push(rowObj);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var mapattrs = new Entities("BP.Sys.MapAttrs", "KeyOfEn", keyofen);
|
|
|
switch (para) {
|
|
|
case "copy":
|
|
|
|
|
|
for (var i = 0; i < mapattrs.length; i++) {
|
|
|
var en = mapattrs[i];
|
|
|
for (var m in enArr) {
|
|
|
if (en.FK_MapData == enArr[m].No) {
|
|
|
delete enArr[m];
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
case "update":
|
|
|
var tempArr = new Array();
|
|
|
for (var i = 0; i < mapattrs.length; i++) {
|
|
|
var en = mapattrs[i];
|
|
|
for (var m in enArr) {
|
|
|
if (en.FK_MapData == enArr[m].No && en.FK_MapData != fk_mapdata) {
|
|
|
tempArr.push(enArr[m]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
enArr = [];
|
|
|
enArr = tempArr;
|
|
|
break;
|
|
|
case "delete":
|
|
|
var tempArr = new Array();
|
|
|
for (var i = 0; i < mapattrs.length; i++) {
|
|
|
var en = mapattrs[i];
|
|
|
for (var m in enArr) {
|
|
|
if (en.FK_MapData == enArr[m].No) {
|
|
|
tempArr.push(enArr[m]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
enArr = [];
|
|
|
enArr = tempArr;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return enArr;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
生成表方法
|
|
|
1.调用获取实体对象方法,获得实体数组
|
|
|
2.根据数组对象,动态生成行插入到列表中
|
|
|
*/
|
|
|
function generTable(para) {
|
|
|
|
|
|
//隐藏说明性质的DIV标签
|
|
|
$('#tip').hide();
|
|
|
|
|
|
getEns(para);
|
|
|
|
|
|
//用html标对en对象属性进行包装
|
|
|
var htmlObj = new Object();
|
|
|
var htmlArr = new Array();
|
|
|
if (enArr.length > 0) {
|
|
|
for (var index in enArr) {
|
|
|
var htmlObj = new Object();
|
|
|
htmlObj.col1 = "<input type='checkbox' name='' " + "id='" + enArr[index].No + "'>" + "<label for=''>" + enArr[index].No + "</label>"
|
|
|
htmlObj.col2 = enArr[index].Name;
|
|
|
htmlArr.push(htmlObj);
|
|
|
}
|
|
|
}
|
|
|
//先清除行,防止多次点击的重复添加;
|
|
|
$("#Table1 tr").eq(1).nextAll().remove();
|
|
|
//增加行
|
|
|
for (var i = 0; i < htmlArr.length; i++) {
|
|
|
//var en = data[i];
|
|
|
var newRow = "";
|
|
|
|
|
|
newRow = "<tr><td>" + htmlArr[i].col1 + "</td>";
|
|
|
newRow += "<td>" + htmlArr[i].col2 + "</td>";
|
|
|
newRow += "<td>" + "" + "</td>";
|
|
|
|
|
|
newRow += "</tr>";
|
|
|
|
|
|
$("#Table1 tr:last").after(newRow);
|
|
|
}
|
|
|
//清空全局变量enArr;
|
|
|
enArr = [];
|
|
|
//修改按钮id属性和名称
|
|
|
var bName = document.getElementById(para).innerText;
|
|
|
$('input[name="batch"]').attr('id', para).attr('value', "执行[" + bName + "]操作");
|
|
|
|
|
|
}
|
|
|
/*
|
|
|
执行批量处理
|
|
|
1.获取页面上所选的多选框
|
|
|
2.根据批量操作的类型不同(copy\update\delete),对表Sys_MapAttr行进行操作
|
|
|
3.完成后重新调用生成表方法,以便用户的进一步操作
|
|
|
*/
|
|
|
function runBatch(para) {
|
|
|
//获取所有已选的checkbox的id组成数组
|
|
|
var idArr = new Array();
|
|
|
$.each($('input:checkbox:checked'), function () {
|
|
|
idArr.push($(this).attr('id'));
|
|
|
});
|
|
|
|
|
|
if (idArr.length == 0) {
|
|
|
return;
|
|
|
}
|
|
|
switch (para) {
|
|
|
case "copy":
|
|
|
for (var index in idArr) {
|
|
|
var mattr = new Entity('BP.Sys.MapAttr', fk_mapdata + '_' + keyofen);
|
|
|
mattr.FK_MapData = idArr[index];
|
|
|
mattr.Insert();
|
|
|
}
|
|
|
break;
|
|
|
case "update":
|
|
|
for (var index in idArr) {
|
|
|
var mattrOld = new Entity('BP.Sys.MapAttr', idArr[index] + '_' + keyofen);
|
|
|
var gID = mattrOld.GroupID;
|
|
|
var mattr = new Entity('BP.Sys.MapAttr', fk_mapdata + '_' + keyofen);
|
|
|
mattr.FK_MapData = idArr[index];
|
|
|
mattr.GroupID = gID;
|
|
|
mattr.Update();
|
|
|
}
|
|
|
break;
|
|
|
case "delete":
|
|
|
for (var index in idArr) {
|
|
|
var mattr = new Entity('BP.Sys.MapAttr', idArr[index] + '_' + keyofen);
|
|
|
mattr.Delete();
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
generTable(para);
|
|
|
}
|
|
|
</script>
|
|
|
</head>
|
|
|
<body>
|
|
|
<div class="container-full">
|
|
|
<form method="post" action="" id="form1">
|
|
|
<fieldset>
|
|
|
<legend>批量操作 </legend>
|
|
|
<ul class='navlist'>
|
|
|
<li>
|
|
|
<a id="copy" href="javascript:void(0);" onclick="generTable(this.id)">
|
|
|
批量复制
|
|
|
</a>
|
|
|
</li>
|
|
|
<li>
|
|
|
<a id="update" href="javascript:void(0);" onclick="generTable(this.id)">
|
|
|
批量更新
|
|
|
</a>
|
|
|
</li>
|
|
|
<li>
|
|
|
<a id="delete" href="javascript:void(0);" onclick="generTable(this.id)">
|
|
|
批量删除
|
|
|
</a>
|
|
|
</li>
|
|
|
</ul>
|
|
|
</fieldset>
|
|
|
|
|
|
<fieldset>
|
|
|
<legend>选择批量操作的节点</legend>
|
|
|
<div style="padding:10px;">
|
|
|
<table id="Table1" class='table'>
|
|
|
|
|
|
<tr>
|
|
|
<th style='width: 140px'>
|
|
|
表单ID
|
|
|
</th>
|
|
|
<th style='width: 140px'>
|
|
|
名称
|
|
|
</th>
|
|
|
<th>
|
|
|
操作
|
|
|
</th>
|
|
|
</tr>
|
|
|
</table>
|
|
|
|
|
|
<input type="button" id="temp" name="batch" class="cc-btn-tab" value="批量执行" onclick="runBatch(this.id)" />
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<legend> 表单元素的批量处理</legend>
|
|
|
<ul>
|
|
|
<li>仅用节点表单,它包括如下几种处理方式 </li>
|
|
|
<li>1,批量更新元素属性。 </li>
|
|
|
<li>2,批量增加。 </li>
|
|
|
<li>3、批量删除。 </li>
|
|
|
</ul>
|
|
|
</fieldset>
|
|
|
|
|
|
</form>
|
|
|
</div>
|
|
|
</body>
|
|
|
</html>
|