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.

597 lines
23 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<html>
<head>
<title>驰骋工作流</title>
<link href="../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../Scripts/bootstrap/js/jquery.min.js"></script>
<script src="../Scripts/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<link href="../Scripts/bootstrap/bootstrap-paginator/css/bootstrapv3.css" rel="stylesheet"
type="text/css" />
<link href="../Scripts/bootstrap/DatePicker/bootstrap-datepicker.min.css" rel="stylesheet"
type="text/css" />
<script src="../Scripts/bootstrap/bootstrap-paginator/js/bootstrap-paginator.js"
type="text/javascript"></script>
<script src="../Scripts/bootstrap/DatePicker/bootstrap-datepicker.min.js" type="text/javascript"></script>
<script src="../Scripts/bootstrap/DatePicker/bootstrap-datepicker.zh-CN.min.js" type="text/javascript"></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>
<script src="../../DataUser/JSLibData/CCFormRef.js" type="text/javascript"></script>
<style type="text/css">
.keyWordInput
{
border-top-right-radius: 5px;
border-top-left-radius: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
height: 30px;
}
.menuGroup
{
float: left;
}
.menuGroup a
{
margin-left:10px;
}
.menuGroupSelected
{
color: Blue; /* 文字颜色 */
font-weight: bold;
text-decoration: none;
padding-bottom:5px;
border-bottom: 3px solid Blue;
}
.searchpanellabel
{
font-size:13px;
margin-left:5px;
margin-right:5px;
}
#searchDiv
{
padding-top:5px;
padding-bottom:5px;
}
</style>
<script type="text/javascript" language="javascript">
//扩展设置信息
var mapExt = null;
//查询条件集合
var condtionsArry = [];
//查询条件,按照条件字段长度排序后
var condtionFieldsArry = [];
//页面启动函数.
$(function () {
//重置页面内容
ResetHtml();
//实体参数.
var ensName = GetQueryString("EnsName");
mapExt = new Entity("BP.Sys.MapExt");
mapExt.MyPK = "DtlImp_" + ensName + "_Table" ;
var i = mapExt.RetrieveFromDBSources();
if (i == 0) {
alert("没有配置导入数据相关参数。");
return;
}
if (mapExt.Tag2 == "") {
alert("参数配置错误,请联系管理员。");
return;
}
//生成查询条件
InitQueryParameters();
//绑定事件
$('.menuGroup a').each(function () {
var aLabel = $(this);
aLabel.click(function () {
$('.menuGroup a').each(function () {
$(this).removeClass("menuGroupSelected");
});
$(this).toggleClass("menuGroupSelected");
});
});
//关键字输入提示
var SearchTip = mapExt.GetPara("SearchTip");
if (SearchTip == undefined) {
SearchTip = "请输入关键字进行搜索";
}
$("#TB_Key").attr("placeholder", SearchTip);
$('#TB_Key').bind('keypress', function (event) {
if (event.keyCode == 13)
InputKeyWordData();
});
//输入关键字查询数据
InputKeyWordData();
//设置表格内容高度
SetTableSize();
});
//设置表格高度
function SetTableSize() {
var height = $(window).innerHeight();
height = height - 100;
if (condtionsArry && condtionsArry.length > 0) {
//展现方式,0平铺、1下拉
var selectType = mapExt.GetPara("SelectType");
if (selectType == "0") {
height = height + 50;
}
if (condtionsArry.length >= 3) {
var TB_Key = $("#TB_Key");
TB_Key.css("width", "260px");
height = height - 40;
}
if (condtionsArry.length > 6) {
height = height - 40;
}
} else {
$("#groupTr").remove();
}
//表格内容高度
$("#tableContent").height(height);
}
//初始化查询条件
function InitQueryParameters() {
var ifcData = null;
//$Para=Dept#Label=所在班级#ListURL=/DataUser/Handler.ashx?DoType=DtlImpReqAll
var condtions = mapExt.Tag1;
if (condtions == "")
return;
//组合查询条件数组
var tempArry = condtions.split("$");
$.each(tempArry, function (i, obj) {
CondtionArryPush(obj);
});
//复制查询条件,排序
condtionFieldsArry = jQuery.extend(true, [], condtionsArry);
//利用js中的sort方法
condtionFieldsArry.sort(function (a, b) {
return b.FieldKey.length - a.FieldKey.length;
});
//生成查询条件控件
CreateCondtionCtrls();
}
//根据条件数组生成查询控件
function CreateCondtionCtrls() {
//生成查询条件控件
var searchPanel = $("#searchDiv");
//展现方式,0平铺、1下拉
var selectType = mapExt.GetPara("SelectType");
if (selectType == "1") {
$("#groupTr").remove();
}
//平铺取第一个下拉框
if (selectType == "0") {
var groupItems = $.grep(condtionsArry, function (condtion) {
return condtion.CtrlType == "ListURL" || condtion.CtrlType == "ListSQL" || condtion.CtrlType == "EnumKey";
});
CreateGroupPanel(groupItems);
}
//关键字后面的查询条件
var noFirstRow = false;
$.each(condtionsArry, function (i, condtion) {
//第一行条件个数
var countRow = 3;
//如果不是第一行,条件的个数
if (noFirstRow == true) {
countRow = 4;
}
if (i !=0 && !(i % countRow)) {
searchPanel.append("<br/><br/>");
noFirstRow = true;
}
//排除已创建分组条件
var groupField = $("#HD_GroupField").val();
if (groupField != "" && condtion.FieldKey == groupField) {
return;
}
var label = $("<label>" + condtion.Label + "</label>");
label.addClass("searchpanellabel");
searchPanel.append(label);
switch (condtion.CtrlType) {
case "ListURL":
case "ListSQL":
var dbTyep = condtion.CtrlType == "ListSQL" ? 0 : 1;
var select = $("<select></select>");
select.attr("id", condtion.FieldKey);
select.attr("name", condtion.FieldKey);
searchPanel.append(select);
var ifcData = DBAccess.RunDBSrc(condtion.Val, dbTyep);
if (ifcData && ifcData.length > 0) {
var oKeys = [];
for (var key in ifcData[0]) {
oKeys.push(key);
}
GenerBindDDL(condtion.FieldKey, ifcData, oKeys[0], oKeys[1], "");
$("#" + condtion.FieldKey).change(function () {
InputKeyWordData();
});
}
break;
case "EnumKey":
var select = $("<select></select>");
select.attr("id", condtion.FieldKey);
select.attr("name", condtion.FieldKey);
searchPanel.append(select);
GenerBindEnumKey(condtion.FieldKey, condtion.Val, "");
$("#" + condtion.FieldKey).change(function () {
InputKeyWordData();
});
break;
default:
var defVal = condtion.Val;
defVal = defVal.replace('<br/>', '');
defVal = defVal.replace('@Now', "(new Date())");
defVal = new Date(cceval(defVal));
defVal = FormatDate(defVal, "yyyy-MM-dd");
var inputDate = $("<input type='text'/>");
inputDate.attr("id", condtion.FieldKey);
inputDate.attr("name", condtion.FieldKey);
inputDate.val(defVal);
searchPanel.append(inputDate);
$("#" + condtion.FieldKey).datepicker({
language: "zh-CN",
autoclose: true,
startView: 0,
format: "yyyy-mm-dd",
clearBtn: true,
todayBtn: false,
endDate: new Date()
}).on('changeDate', function (ev) {
InputKeyWordData();
});
return;
}
});
//重新计算高度
SetTableSize();
}
//创建分组面板
function CreateGroupPanel(groupItems) {
$("#groupDiv").html("");
if (groupItems.length == 0) {
return;
}
var groupItem = groupItems[0];
var dbTyep = groupItem.CtrlType == "ListSQL" ? 0 : 1;
var ifcData = DBAccess.RunDBSrc(groupItem.Val, dbTyep,mapExt.FK_DBSrc);
$("#HD_GroupField").val(groupItem.FieldKey);
$("#groupDiv").append("<a id='all' class='menuGroupSelected' href='javascript:void(0);'>全部</a>");
var hd_GroupValue = $("<input type='hidden' value='' />");
hd_GroupValue.attr("id",groupItem.FieldKey);
$("#groupDiv").append(hd_GroupValue);
if (ifcData && ifcData.length > 0) {
var oKeys = [];
var noKey = "";
var nameKey = "";
for (var key in ifcData[0]) {
oKeys.push(key);
}
noKey = oKeys[0];
nameKey = oKeys[1];
$.each(ifcData, function (i, dataObj) {
var no = dataObj[noKey];
var name = dataObj[nameKey];
$("#groupDiv").append("<a id='" + no + "' href='javascript:void(0);'>" + name + "</a>");
});
}
$("#groupDiv a").unbind("click").bind("click", function () {
var value = this.id;
var groupField = $("#HD_GroupField").val();
$("#" + groupField).val(value);
InputKeyWordData();
});
}
//添加查询条件到数组
function CondtionArryPush(condtion) {
if (condtion == "") {
return;
}
var paras = condtion.split("#");
if (paras.length != 3) {
return;
}
var item = {};
var paraKey = "", labelText = "";
var ctrType = "Date", ctrValue = "";
$.each(paras, function (j, para) {
if (para.indexOf("Para=") > -1) {
paraKey = para.replace("Para=", "");
}
if (para.indexOf("Label=") > -1) {
labelText = para.replace("Label=", "");
}
if (para.indexOf("ListURL=") > -1) {
ctrValue = para.replace("ListURL=", "");
ctrType = "ListURL";
}
if (para.indexOf("ListSQL=") > -1) {
ctrValue = para.replace("ListSQL=", "");
ctrType = "ListSQL";
}
if (para.indexOf("EnumKey=") > -1) {
ctrValue = para.replace("EnumKey=", "");
ctrType = "EnumKey";
}
if (para.indexOf("DefVal=") > -1) {
ctrValue = para.replace("DefVal=", "");
}
});
item.CtrlType = ctrType;
item.FieldKey = paraKey;
item.Label = labelText;
item.Val = ctrValue;
condtionsArry.push(item);
}
//输入关键字进行查询
function InputKeyWordData() {
var data = null;
var UserNo = GetQueryString("UserNo");
var RefPKVal = GetQueryString("RefPKVal");
var keyWord = $("#TB_Key").val();
var dbSrc = mapExt.Tag2;
var reg = new RegExp("@Key", "g");
dbSrc = dbSrc.replace(reg, keyWord);
//处理SQL
//替换表达式常用的用户信息
var webUser = new WebUser();
dbSrc = dbSrc.replace('@WebUser.No', webUser.No);
dbSrc = dbSrc.replace('@WebUser.Name', webUser.Name);
dbSrc = dbSrc.replace("@WebUser.FK_DeptNameOfFull", webUser.FK_DeptNameOfFull);
dbSrc = dbSrc.replace('@WebUser.FK_DeptName', webUser.FK_DeptName);
dbSrc = dbSrc.replace('@WebUser.FK_Dept', webUser.FK_Dept);
//替换
$.each(condtionFieldsArry, function (i, obj) {
var regC = new RegExp("@" + obj.FieldKey, "g");
var value = $("#" + obj.FieldKey).val();
if (value == null || value == "null") value = "";
dbSrc = dbSrc.replace(regC, value);
});
data = DBAccess.RunDBSrc(dbSrc, mapExt.DBType, mapExt.FK_DBSrc);
$("#jsonDataTable").html("");
//if (data && data.length > 0) {
InitTableByData(data);
//}
}
//数据返回Table
function InitTableByData(dataTable) {
//获取数据列名
var columns = [];
var texts = [];
var heads = [];
if (mapExt.Tag.length > 0) {
texts = mapExt.Tag.split(',');
}
for (var col in dataTable[0]) {
columns.push(col);
}
//以中文个数为表格显示列的个数
if (texts && texts.length > 0) {
$.each(texts, function (i, column) {
if (column == "")
return;
var columns = column.split("=");
if (columns.length == 2) {
var column = {};
column.No = columns[0];
column.Name = columns[1];
heads.push(column);
}
});
} else {
$.each(columns, function (i, col) {
var column = {};
column.No = col;
column.Name = col;
heads.push(column);
});
}
//表头
var thread = $('<thead></thead>');
var threadTr = $('<tr></tr>');
//复选框
var thFirst = $("<th style='width:35px;'></th>");
var ckBox = $("<input type='checkbox' onclick='CheckAll()' id='CB_CheckAll' >");
thFirst.append(ckBox);
threadTr.append(thFirst);
$.each(heads, function (i, head) {
var th = $("<th></th>");
th.text(head.Name);
th.data(head);
threadTr.append(th);
});
thread.append(threadTr);
$("#jsonDataTable").append(thread);
if (dataTable && dataTable.length == 0) {
$("#jsonDataTable").append('<tbody><tr><td colspan=' + parseInt(heads.length+1)+'>没有查询到数据</td></tr></tbody>');
return;
}
//生成表格体
var tbody = $('<tbody></tbody>');
$.each(dataTable, function (i, dataObj) {
var tbodyTr = $('<tr></tr>');
var tdFirst = $("<td></td>");
//第一列为主键
var refPK = heads[0].No;
var no = dataObj[refPK];
var ckBox = $("<input type='checkbox' onclick='changeSta(this)'/>");
ckBox.attr("id", "CB_" + no);
ckBox.data(dataObj);
tdFirst.append(ckBox);
tbodyTr.append(tdFirst);
//字段列
$.each(heads, function (i, head) {
var td = $("<td></td>");
var text = "";
if (head.No && head.No != "") {
text = dataObj[head.No];
}
td.text(text);
tbodyTr.append(td);
});
tbody.append(tbodyTr);
});
$("#jsonDataTable").append(tbody);
}
//重置标签
function ResetHtml() {
$("#groupDiv").html("");
$("#jsonDataTable").html("");
}
//全选
function CheckAll() {
var checked = document.getElementById('CB_CheckAll').checked;
$.each($(":checkbox"), function () {
this.checked = checked;
});
}
function changeSta(obj) {
if (obj.checked == false)
document.getElementById('CB_CheckAll').checked = false;
}
//确定按钮,导入数据
function DalogModelOK() {
//实体参数.
var EnsName = GetQueryString("EnsName");
var refPKVal = GetQueryString("RefPKVal");
var PWorkID = GetQueryString("PWorkID");
var FK_Node = GetQueryString("FK_Node");
var FID = GetQueryString("FID");
var UserNo = GetQueryString("UserNo");
var paraDatas = [];
$.each($(":checkbox"), function (i, cb) {
if (cb.checked) {
var data = $(cb).data();
if (data && cb.id != "CB_CheckAll") {
paraDatas.push(data);
}
}
});
if (paraDatas.length == 0) {
alert("没有选择导入数据,请选择!");
return;
}
//插入明细表数据
var pks = mapExt.Tag4;
//默认导入从表附件方法
//获取从表附件的属性 是否为自定义
var frmAth = new Entity("BP.Sys.FrmUI.FrmAttachmentExt");
frmAth.SetPKVal(EnsName + "_" + FK_Node + "_AthMDtl");
var count = frmAth.RetrieveFromDBSources();
if (count == 0) {
frmAth.SetPKVal(EnsName + "_AthMDtl");
frmAth.RetrieveFromDBSources();
}
var handler = new HttpHandler("BP.WF.HttpHandler.WF_CCForm");
$.each(paraDatas, function (i, data) {
//循环导入数据
handler.Clear();
handler.AddPara("EnsName", EnsName);
handler.AddPara("RefPKVal", refPKVal);
handler.AddPara("PWorkID", PWorkID);
handler.AddPara("FK_Node", FK_Node);
handler.AddPara("FID", FID);
handler.AddPara("PKs", pks);
handler.AddPara("UserNo", UserNo);
handler.AddJson(data);
//返回导入的从表的OID
var newdata = handler.DoMethodReturnString("DtlImpBySQl_Imp");
if (newdata.indexOf("err@") != 0 && newdata != "") {
//FK_MapData,附件属性RefPK,FK_Node
afterDtlImp(EnsName, frmAth, newdata, FK_Node, data["oldOID"], data["oldFK_MapData"]);
}
});
//执行完毕关闭弹窗
DalogModelCose();
}
//取消,关闭弹出层
function DalogModelCose() {
if (window.parent && window.parent.CloseBootstrapDialog) {
window.parent.CloseBootstrapDialog("取消");
}
window.close();
}
</script>
</head>
<body>
<form id="cc">
<table style="border: 0px; width: 99%;table-layout: fixed;">
<tr>
<td>
<div id="searchDiv" style='text-align: left;'>
<input type="text" id="TB_Key" value="" class="keyWordInput" style="width: 50%;" placeholder="请输入关键字进行搜索"/>
<label style="font-weight:normal;color:#cccccc;font-size:12px">回车执行查询</label>
<input id="hiddenText" type="text" style="display:none" />
</div>
</td>
</tr>
<tr id="groupTr">
<td style="height: 60px; text-align: left;">
<div id="groupDiv" class="menuGroup">
</div>
</td>
</tr>
<tr>
<td style="border: 1px #FF8000 solid;">
<div id="tableContent" style="overflow:auto;">
<div>
<table class="table table-striped" id='jsonDataTable'></table>
</div>
<div style="text-align: left;">
<ul id="examplePagetions"></ul>
</div>
</div>
</td>
</tr>
<tr>
<td style="float:right;">
<div style="margin-top:10px; margin-right:10px;">
<input type="button" class="btn" onclick="DalogModelCose()" value="取消" />
<input type="button" class="btn btn-danger" onclick="DalogModelOK()" value="确定" />
</div>
</td>
</tr>
</table>
</form>
<input type="hidden" id="HD_GroupField" value="" />
</body>
</html>