|
|
<!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>
|
|
|
<!--SQL编辑器-->
|
|
|
<link href="../../../Scripts/CodeMirror/lib/codemirror.css" rel="stylesheet" />
|
|
|
<link href="../../../Scripts/CodeMirror/addon/hint/show-hint.css" rel="stylesheet" />
|
|
|
<script src="../../../Scripts/CodeMirror/lib/codemirror.js"></script>
|
|
|
<script src="../../../Scripts/CodeMirror/addon/edit/matchbrackets.js"></script>
|
|
|
<script src="../../../Scripts/CodeMirror/mode/sql/sql.js"></script>
|
|
|
<script src="../../../Scripts/CodeMirror/addon/hint/show-hint.js"></script>
|
|
|
<script src="../../../Scripts/CodeMirror/addon/hint/sql-hint.js"></script>
|
|
|
<script src="../../../Scripts/LoadSql.js"></script>
|
|
|
<!--引用样式. -->
|
|
|
<script type="text/javascript" src="../../../Scripts/bootstrap/js/jquery.min.js"></script>
|
|
|
<script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
|
|
|
<link href="../../../Scripts/easyUI145/themes/color.css" rel="stylesheet" />
|
|
|
<link href="../../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
|
|
|
<link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
|
|
|
<link href="../../../Style/skin/css/Default.css" rel="stylesheet" />
|
|
|
<link href="../../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />
|
|
|
<link href="../../../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
|
|
|
<!-- 引用通用的js文件. -->
|
|
|
<script type="text/javascript" src="../../../Scripts/config.js"></script>
|
|
|
<script type="text/javascript" src="../../../Comm/Gener.js"></script>
|
|
|
<script src="../../Admin.js"></script>
|
|
|
<script type="text/javascript">
|
|
|
var frmID = "";
|
|
|
var flowNo = GetQueryString("FK_Flow");
|
|
|
//页面启动函数.
|
|
|
$(function () {
|
|
|
|
|
|
var nodeID = flowNo + "01";
|
|
|
frmID = "ND" + parseInt(nodeID);
|
|
|
|
|
|
//定义主键值.
|
|
|
var pkval = "StartFlow_" + frmID;
|
|
|
|
|
|
var mapExt = new Entity("BP.Sys.MapExt");
|
|
|
mapExt.SetPKVal(pkval);
|
|
|
var i = mapExt.RetrieveFromDBSources();
|
|
|
if (i == 0) {
|
|
|
document.getElementById("Btn_Delete").disabled = false;
|
|
|
}
|
|
|
|
|
|
//给主键赋值.
|
|
|
var tag = FormatSQL(mapExt.Tag);
|
|
|
$("#TB_SQL").val(tag);
|
|
|
|
|
|
//求从表个数
|
|
|
var mapDtls = new Entities("BP.Sys.MapDtls");
|
|
|
mapDtls.Retrieve("FK_MapData", frmID, "FK_Node", 0);
|
|
|
var sqls = mapExt.Tag1.split('*');
|
|
|
|
|
|
var html = "<table style='width:100%;'>";
|
|
|
for (var i = 0; i < mapDtls.length; i++) {
|
|
|
var mapDtl = mapDtls[i];
|
|
|
|
|
|
html += "<tr>";
|
|
|
html += "<th> 填充从表: <font color=red><b>" + mapDtl.No + " " + mapDtl.Name + "</b></font></th>";
|
|
|
html += "<td><font color=green>" + GenerFields(mapDtl.No) + "</font></td>";
|
|
|
html += "</tr>";
|
|
|
|
|
|
var sqlVal = '';
|
|
|
|
|
|
for (var idx = 0; idx < sqls.length; idx++) {
|
|
|
|
|
|
var sql = sqls[idx];
|
|
|
if (sql == null || sql == "")
|
|
|
continue;
|
|
|
|
|
|
var key = sql.substring(0, sql.indexOf('='));
|
|
|
if (key == mapDtl.No) {
|
|
|
sqlVal = sql.substring(sql.indexOf('=') + 1);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
sqlVal = FormatSQL(sqlVal);
|
|
|
|
|
|
html += "<tr>";
|
|
|
html += "<td colspan=2><textarea id='TB_" + mapDtl.No + "' style='width:99%;' >" + sqlVal + "</textarea></td>";
|
|
|
html += "</tr>";
|
|
|
|
|
|
// html += "<br>填充方式:<select id='DDL_" + mapDtl.No + "' ><option value='0' >每次打开的时候填充</option></select>";
|
|
|
// html += "<option value='0' >每次打开的时候填充</option></select>";
|
|
|
}
|
|
|
|
|
|
$("#dtls").html(html);
|
|
|
|
|
|
//给field赋值.
|
|
|
|
|
|
$("#fields").html(GenerFields(frmID));
|
|
|
|
|
|
});
|
|
|
function GenerFields(frmID) {
|
|
|
|
|
|
var mapAttrs = new Entities("BP.Sys.MapAttrs");
|
|
|
mapAttrs.Retrieve("FK_MapData", frmID);
|
|
|
|
|
|
var strs = "<b>可用字段</b>:";
|
|
|
for (var i = 0; i < mapAttrs.length; i++) {
|
|
|
var en = mapAttrs[i];
|
|
|
if (en.KeyOfEn == "OID" || en.KeyOfEn == "RDT" || en.KeyOfEn == "CDT" || en.KeyOfEn == "FID")
|
|
|
continue;
|
|
|
|
|
|
strs += "" + en.KeyOfEn + ",";
|
|
|
}
|
|
|
|
|
|
return strs;
|
|
|
}
|
|
|
//执行保存
|
|
|
function Save() {
|
|
|
|
|
|
//var frmID = GetQueryString("FK_MapData");
|
|
|
|
|
|
//定义主键值.
|
|
|
var pkval = "StartFlow_" + frmID;
|
|
|
//求从表个数
|
|
|
var mapDtls = new Entities("BP.Sys.MapDtls");
|
|
|
mapDtls.Retrieve("FK_MapData", frmID, "FK_Node", 0);
|
|
|
var err = "";
|
|
|
var mapExt = new Entity("BP.Sys.MapExt");
|
|
|
mapExt.SetPKVal(pkval);
|
|
|
mapExt.Tag = editor.getValue();
|
|
|
if (mapExt.Tag != null && mapExt.Tag != "" && CheckIsSQL(mapExt.Tag) == false) {
|
|
|
alert('请输入合法的查询SQL\t\n' + mapExt.Tag);
|
|
|
return;
|
|
|
}
|
|
|
if (mapExt.Tag.indexOf('Starter') == -1)
|
|
|
err + "\t\n 查询语句必须包含Starter列,并且区分大小写.";
|
|
|
|
|
|
if (mapExt.Tag.indexOf('MainPK') == -1)
|
|
|
err + "\t\n 查询语句必须包含MainPK列,并且区分大小写.";
|
|
|
|
|
|
mapExt.FK_MapData = frmID;
|
|
|
mapExt.ExtType = "StartFlow";
|
|
|
|
|
|
//求从表信息.
|
|
|
|
|
|
var sqls = "";
|
|
|
for (var i = 0; i < mapDtls.length; i++) {
|
|
|
var mapDtl = mapDtls[i];
|
|
|
var val = $("#TB_" + mapDtl.No).val();
|
|
|
|
|
|
if (val != null && val != "" && CheckIsSQL(val) == false) {
|
|
|
alert('请输入合法的查询SQL' + val);
|
|
|
return; n
|
|
|
}
|
|
|
|
|
|
sqls += "*" + mapDtl.No + "=" + val;
|
|
|
}
|
|
|
|
|
|
mapExt.Tag1 = sqls;
|
|
|
mapExt.Save();
|
|
|
|
|
|
alert("保存成功.");
|
|
|
|
|
|
}
|
|
|
function Delete() {
|
|
|
|
|
|
if (confirm('您确认要删除吗?') == false)
|
|
|
return;
|
|
|
|
|
|
//定义主键值.
|
|
|
var pkval = "StartFlow_" + frmID;
|
|
|
|
|
|
var mapExt = new Entity("BP.Sys.MapExt");
|
|
|
mapExt.SetPKVal(pkval);
|
|
|
mapExt.RetrieveFromDBSources();
|
|
|
mapExt.Delete();
|
|
|
|
|
|
Reload();
|
|
|
}
|
|
|
|
|
|
function Back() {
|
|
|
var url = "../../AttrFlow/AutoStart/2.ByTimeData.htm?FK_Flow=" + flowNo;
|
|
|
SetHref(url);
|
|
|
}
|
|
|
|
|
|
function Help() {
|
|
|
var url = "http://ccbpm.mydoc.io/?v=5404&t=17088&s2=" + flowNo;
|
|
|
window.open(url);
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
<base target="_self" />
|
|
|
</head>
|
|
|
<body>
|
|
|
<div class="container-full">
|
|
|
|
|
|
<div id="titleH4" class="attrnode-bar-header">
|
|
|
<span class="pull-right">
|
|
|
<button id="Btn_Save" class="cc-btn-tab btn-save" onclick="Save();">保存</button>
|
|
|
<button id="Btn_Delete" class="cc-btn-tab btn-delete" onclick="Delete();">删除</button>
|
|
|
<button id="Btn_Back" class="cc-btn-tab btn-back" onclick="Back();">返回</button>
|
|
|
<button id="Btn_Help" class="cc-btn-tab btn-hlep" onclick="Help();">帮助</button>
|
|
|
</span>
|
|
|
<strong>自动发起按照SQL设置数据源 </strong>
|
|
|
</div>
|
|
|
<form method="post" action="" id="form1">
|
|
|
|
|
|
|
|
|
<fieldset>
|
|
|
<legend>主表SQL设置</legend>
|
|
|
<div class="pd15">
|
|
|
<textarea name="TB_SQL" class="SQL" rows="7" cols="70" id="TB_SQL" style="width: 99%;"></textarea>
|
|
|
<font color="green"><div id="fields"></div> </font>
|
|
|
</div>
|
|
|
</fieldset>
|
|
|
<fieldset>
|
|
|
|
|
|
<legend>从表SQL设置</legend>
|
|
|
<div class="pd15">
|
|
|
<div id="dtls">
|
|
|
</div>
|
|
|
</div>
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
|
<fieldset>
|
|
|
<legend id="Help">帮助</legend>
|
|
|
<ul>
|
|
|
<li> 填充主表的 sql 必须有MainPK, 字段, 可以有ToNode,ToEmps 字段。</li>
|
|
|
<li> 关于MainPK 字段:它可以是一个订单号、事故号、单据号、或者字符组合的不重复的编号,如果MainPK已经存在,就不在发起了。</li>
|
|
|
<li> 主表的每行记录都可以是一个, 可以有ToNode,ToEmps 字段。</li>
|
|
|
</ul>
|
|
|
</fieldset>
|
|
|
|
|
|
|
|
|
<!--<legend>说明:</legend>
|
|
|
<ul>
|
|
|
<li> 设置一个查询SQL, </li>
|
|
|
<li> SQL里面必须有一个@MainPK 变量 </li>
|
|
|
</ul>-->
|
|
|
|
|
|
|
|
|
|
|
|
</form>
|
|
|
</div>
|
|
|
</body>
|
|
|
</html>
|