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.

282 lines
11 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.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="renderer" content="webkit" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<title>执行有参数的方法</title>
<link href="../../Scripts/layui/layui/css/layui.css" rel="stylesheet" />
<script src="../../Scripts/jquery-1.11.0.min.js" type="text/javascript"></script>
<script src="../../Scripts/QueryString.js" type="text/javascript"></script>
<script src="../../Scripts/config.js" type="text/javascript"></script>
<script src="../../Scripts/QueryString.js" type="text/javascript"></script>
<script src="../../Comm/Gener.js" type="text/javascript"></script>
<script src="../../Comm/JScript.js" type="text/javascript"></script>
<script src="../Opt/DoMethodPara.js" type="text/javascript"></script>
<script src="../../Scripts/layui/layui/layui.js" type="text/javascript"></script>
<style type="text/css">
.layui-row {
margin-bottom: 4px;
}
</style>
<script type="text/javascript">
var mypk = GetQueryString("FuncNo");//方法的主键
var fromPage = GetQueryString("From");
fromPage = fromPage == null || fromPage == undefined ? "" : fromPage;
var methodFunc = null;
var attrs = null; //参数的属性.
var frmData = null;
$(function () {
methodFunc = new Entity("BP.CCBill.Sys.Func", mypk);
attrs = new Entities("BP.Sys.MapAttrs");
attrs.Retrieve("FK_MapData", mypk);
//初始化表单的数据. JSON.
//frmData = new Entity(methodFunc.FrmID, workid);
document.title = methodFunc.Name;
$("#Btn_DoIt").html("执行:" + methodFunc.Name);
$(".layui-btn-container").css("margin-left", (window.innerWidth - 150) + "px");
var html = "";
html += InitMapAttr(attrs, null);
$("#docs").html(html);
layui.form.render();
layui.form.on('submit(DoMethod)', function (data) {
//提交信息的校验
DoIt();
return false;
});
});
function closeIt() {
window.close();
}
//执行方法.
function DoIt() {
if (methodFunc.WarningMsg == "")
methodFunc.WarningMsg = "确定要执行吗";
layer.confirm(methodFunc.WarningMsg, function (index) {
layer.close(index);
var data;
switch (methodFunc.MethodDocTypeOfFunc) {
case 0://执行SQL
var handler = new HttpHandler("BP.CCBill.WF_CCBill");
handler.AddUrlData();
handler.AddFormData();
data = handler.DoMethodReturnString("DoMethodPara_ExeSQL");
if (data.indexOf('err@') >= 0) {
layer.alert('系统错误:' + data);
return;
}
break;
case 1:
Skip.addJs('../../../DataUser/JSLibData/Method/' + mypk + '.js');
data = ExecScript(methodFunc)
break;
case 2://执行URL
var handler = new HttpHandler("BP.CCBill.WF_CCBill");
handler.AddUrlData();
handler.AddFormData();
data = handler.DoMethodReturnString("DoMethodPara_ExeUrl");
break;
}
//执行的结果. 根据执行成功后的配置,来处理“ 执行完毕后干啥?”
//直接关闭窗口.
if (methodFunc.WhatAreYouTodo == 0 || fromPage == "Search") {
layer.alert(data, function (index) {
//执行完方法后关闭页面
var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
parent.layer.close(index); //再执行关闭
layer.close(index);
});
return;
}
layer.alert(data);
//关闭提示窗口并刷新.
if (methodFunc.WhatAreYouTodo == 1) {
//$("#Msg").html(data);
Reload();
return;
}
//转入到Search.htm页面上去.
if (methodFunc.WhatAreYouTodo == 2) {
SetHref("SearchDict.htm?FrmID=" + GetQueryString("FrmID"));
return;
}
})
}
//执行的SCRIPT.
function ExecScript(func) {
//生成参数.
var paras = "";
for (var i = 0; i < attrs.length; i++) {
var attr = attrs[i];
var val = "";
if (attr.UIContralType == 0)
val = $("#TB_" + attr.KeyOfEn).val();
if (attr.UIContralType == 1)
val = $("#DDL_" + attr.KeyOfEn).val();
if (attr.UIContralType == 2)
val = $("#CB_" + attr.KeyOfEn).val();
if (i == attrs.length - 1) {
if (attr.MyDataType == 2 || attr.MyDataType == 3 || attr.MyDataType == 4 || attr.MyDataType == 5 || attr.MyDataType == 8) {
if (val == "" || val == undefined)
val = 0;
paras += val;
}
else
paras += "'" + val + "'";
}
else {
if (attr.MyDataType == 2 || attr.MyDataType == 3 || attr.MyDataType == 4 || attr.MyDataType == 5 || attr.MyDataType == 8) {
if (val == "" || val == undefined)
val = 0;
paras += val + ",";
}
else
paras += "'" + val + "',";
}
}
//执行这个 script.
try {
var data = cceval(func.MethodID + "(" + paras + ")");
// debugger
if (data == undefined || data == "")
data = "执行成功";
layer.alert(data);
return data;
} catch (e) {
layer.alert("执行JavaScript错误" + e);
return;
}
}
//解析表单字段 MapAttr.
function InitMapAttr(attrs) {
var html = "";
var isDropTR = true;
for (var i = 0; i < attrs.length; i++) {
var attr = attrs[i];
var enable = attr.UIIsEnable == "1" ? "" : " ui-state-disabled";
var defval = attr.DefVal;
var lab = "";
if (attr.UIContralType == 0 || attr.UIContralType == 8)
lab = "<label id=Lab_" + attr.KeyOfEn + "' for='TB_" + attr.KeyOfEn + "' class='layui-form-label " + (attr.UIIsInput == 1 ? "mustInput" : "") + "'>" + attr.Name + "</label>";
if (attr.UIContralType == 1)
lab = "<label id=Lab_" + attr.KeyOfEn + "' for='DDL_" + attr.KeyOfEn + "' class='layui-form-label " + (attr.UIIsInput == 1 ? "mustInput" : "") + "'>" + attr.Name + "</label>";
if (attr.UIIsInput == 1 && attr.UIIsEnable == 1) {
lab += " <span style='color:red' class='mustInput' data-keyofen='" + attr.KeyOfEn + "' >*</span>";
}
if (attr.UIContralType == 3)
lab = "<label id=Lab_" + attr.KeyOfEn + "' for='RB_" + attr.KeyOfEn + "' class='layui-form-label " + (attr.UIIsInput == 1 ? "mustInput" : "") + "'>" + attr.Name + "</label>";
//线性展示并且colspan=3
if (attr.ColSpan == 3 || (attr.ColSpan == 4 && attr.UIHeight < 40)) {
isDropTR = true;
html += "<div class='layui-row'>";
html += "<div class='layui-col-xs2' style='width:120px;'>" + lab + "</div>";
html += "<div class='layui-col-xs10' id='TD_" + attr.KeyOfEn + "'>";
html += InitMapAttrOfCtrl(attr, enable, defval);
html += "</div>";
html += "</div>";
continue;
}
//线性展示并且colspan=4
if (attr.ColSpan == 4) {
isDropTR = true;
html += "<div class='layui-row'>";
html += "<div class='layui-col-xs12' id='TD_" + attr.KeyOfEn + ">";
html += lab + "</br>";
html += InitMapAttrOfCtrl(attr, enable, defval);
html += "</div>";
html += "</div>";
continue;
}
if (isDropTR == true) {
html += "<div class='layui-row'>";
html += "<div class='layui-col-xs2'>" + lab + "</div>";
html += "<div class='layui-col-xs4' id='TD_" + attr.KeyOfEn + "'>";
html += InitMapAttrOfCtrl(attr, enable, defval);
html += "</div>";
isDropTR = !isDropTR;
continue;
}
if (isDropTR == false) {
html += "<div class='layui-col-xs2'>" + lab + "</div>";
html += "<div class='layui-col-xs4' id='TD_" + attr.KeyOfEn + "'>";
html += InitMapAttrOfCtrl(attr, enable, defval);
html += "</div>";
html += "</div>";
isDropTR = !isDropTR;
continue;
}
}
if (isDropTR == false) {
html += "<div class='layui-col-xs6'></div>";
html += "</div>";
}
return html;
}
function ConvertDefVal(defVal) {
return defVal;
}
</script>
</head>
<body>
<form id="cc" enctype="multipart/form-data" method="post" class="layui-form">
<!--表单内部信息-->
<div class="layui-fluid">
<div class="layui-row">
<!-- 内容主体区域 -->
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<div id="docs">
<!--加载表单的信息-->
</div>
<div class="layui-btn-container">
<button type="button" id="Btn_DoIt" class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="" lay-filter="DoMethod">执行</button>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</body>
</html>