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.

291 lines
12 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 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>
<link rel="stylesheet" href="../../Scripts/codemirror/doc/docs.css" />
<link rel="stylesheet" href="../../Scripts/codemirror/lib/codemirror.css" />
<link rel="stylesheet" href="../../Scripts/codemirror/theme/eclipse.css" />
<link rel="stylesheet" href="../../Scripts/codemirror/theme/elegant.css" />
<link rel="stylesheet" href="../../Scripts/codemirror/theme/erlang-dark.css" />
<link rel="stylesheet" href="../../Scripts/codemirror/theme/idea.css" />
<script src="../../Scripts/codemirror/lib/codemirror.js"></script>
<script src="../../Scripts/codemirror/mode/javascript/javascript.js" type="text/javascript"></script>
<script src="../../Scripts/codemirror/addon/selection/active-line.js" type="text/javascript"></script>
<script src="../../Scripts/codemirror/addon/edit/matchbrackets.js" type="text/javascript"></script>
<link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
<script src="../../Scripts/QueryString.js" type="text/javascript"></script>
<script type="text/javascript" src="../../Scripts/config.js"></script>
<script type="text/javascript" src="../../Comm/Gener.js"></script>
<base target="_self" />
<script type="text/javascript">
function Esc() {
if (event.keyCode == 27)
window.close();
return true;
}
window.addEventListener("keydown", function (e) {
//可以判断是不是mac如果是mac,ctrl变为花键
//event.preventDefault() 方法阻止元素发生默认的行为。
if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
e.preventDefault();
Save();
// Process event...
//document.getElementById("test").innerHTML = "ctrl+s成功";
}
}, false);
//页面启动函数.
var en = null;
var docsLast = null; //最后的code内容用于判断是否发生了变化
var currFuncType = 0;
var funcstr = "";
$(function () {
//$.base64.utf8encode = true;
var no = GetQueryString("No");
en = new Entity("BP.CCBill.Template.MethodFunc", no);
GenerBindEnumKey("DDL_WhatAreYouTodo", "WhatAreYouTodo", en.WhatAreYouTodo);
//给控件赋值.
GenerFullAllCtrlsVal(en);
currFuncType = en.MethodDocTypeOfFunc;
//设置内容.
FullDoc();
//生成参数内容.
var attrs = new Entities("BP.Sys.MapAttrs", "FK_MapData", myPK);
var html = "<font color=yellow ><b>//自定义方法名:" + en.Name + ",共有:" + attrs.length + "参数;&nbsp;";
for (var i = 0; i < attrs.length; i++) {
var attr = attrs[i];
html += "" + attr.Name + "," + attr.KeyOfEn + ";&nbsp;";
}
html += "</b></font>";
html += "<br><font color=yellow ><b> function </b></font> <font color=red ><b>" + en.MethodID + "</b></font> <font color=yellow ><b>(</b></font>";
funcstr = "function " + en.MethodID + "(";
for (var i = 0; i < attrs.length; i++) {
var attr = attrs[i];
if (i == attrs.length - 1) {
html += "<font color=PINK ><b>&nbsp;" + attr.KeyOfEn + "</b></font>";
funcstr += attr.KeyOfEn;
}else{
html += "<font color=PINK ><b>&nbsp;" + attr.KeyOfEn + "</b></font><font color=yellow ><b>,</b></font>";
funcstr += attr.KeyOfEn+",";
}
}
html += "<font color=yellow ><b>)</b></font>&nbsp;<font color=yellow font-size='12px'><b>{</b></font>";
funcstr += "){";
$("#paras").html(html);
//输出实体的其他信息,方便用户更改.
var attrs = new Entities("BP.Sys.MapAttrs", "FK_MapData", en.FrmID);
var mapData = new Entity("BP.Sys.MapData", en.FrmID);
html = "<table style='width:100%;'>";
html += "<caption>表单:" + mapData.Name + ",表单ID:" + mapData.No + ",表:" + mapData.PTable + "</caption>";
html += "<tr>";
html += "<th>#</th>";
html += "<th>字段</th>";
html += "<th>字段名</th>";
html += "<th>类型</th>";
html += "</tr>";
for (var i = 0; i < attrs.length; i++) {
var attr = attrs[i];
html += "<tr>";
html += "<td>" + (i + 1) + "</td>";
html += "<td>" + attr.KeyOfEn + "</td>";
html += "<td>" + attr.Name + "</td>";
html += "<td>" + attr.MyDataType + "</td>";
html += "</tr>";
}
html += "</table>";
html += "UPDATE " + mapData.PTable + " SET xxx=xx,XXX=11 WHERE OID=@OID";
$("#FrmDocs").html(html);
});
function FullDoc() {
var funcType = $('input[name="RB_MethodDocTypeOfFunc"]:checked').val();
en.MethodDocTypeOfFunc = funcType;
var txt = editor.getValue();
if (docsLast != null && docsLast != txt) {
// if (window.confirm('您需要保存吗?') == true) {
//返回上一次的设置.
document.getElementById("RB_MethodDocTypeOfFunc_" + currFuncType).checked = true;
Save(); //执行保存.
document.getElementById("RB_MethodDocTypeOfFunc_" + funcType).checked = true;
//}
}
//设置当前的状态.
currFuncType = funcType;
//根据选择获取变化内容.
var handler = new HttpHandler("BP.CCBill.WF_CCBill_Admin");
handler.AddPara("TypeOfFunc", funcType);
handler.AddPara("No", en.No);
var data = handler.DoMethodReturnString("MethodDoc_GetScript");
editor.setValue(data);
docsLast = data; //记录最后的值,用于判断是否更改.
}
function DemoSQL() {
var url = "MethodDocDemoSQL.htm?No=" + GetQueryString("No");
WinOpen(url);
}
function DemoJS() {
var url = "MethodDocDemoJS.htm?No=" + GetQueryString("No");
WinOpen(url);
}
function Save() {
//执行选择类型的保存.
var selectFuncType = $('input[name="RB_MethodDocTypeOfFunc"]:checked').val();
var handler = new HttpHandler("BP.CCBill.WF_CCBill_Admin");
handler.AddUrlData();
var doc = editor.getValue();
doc = doc.replace(/-/g, "/$");
doc = doc.replace(/[+]/g, "/#");
// alert(doc);
handler.AddPara("doc", doc); //不知道是否可以存储.
handler.AddPara("TypeOfFunc", selectFuncType);
handler.AddPara("funcstr", funcstr+doc+"\r\n");//拼上function部分
var data = handler.DoMethodReturnString("MethodDoc_SaveScript");
docsLast = editor.getValue(); //记录最后的值,用于判断是否更改.
alert(data);
reload();
funcstr="";
}
function ToMethodParas() {
SetHref("MethodParas.htm?No=" + GetQueryString("No"));
}
</script>
</head>
<body onkeypress="Esc();" >
<form id="cc">
<table id="Table1" style="width: 100%">
<caption>
定义方法执行内容 - <a href="javascript:ToMethodParas()">定义执行方法的参数</a>
</caption>
<tr>
<td>
方法类型:
<label>
<input type="radio" value="0" name="RB_MethodDocTypeOfFunc" id="RB_MethodDocTypeOfFunc_0"
onclick="FullDoc();" />SQL
</label>
<label>
<input type="radio" value="1" name="RB_MethodDocTypeOfFunc" id="RB_MethodDocTypeOfFunc_1"
onclick="FullDoc();" />javascript
</label>
<label>
<input type="radio" value="2" name="RB_MethodDocTypeOfFunc" id="RB_MethodDocTypeOfFunc_2"
onclick="FullDoc();" />URL模式
</label>
执行完毕后干啥?
<select id="DDL_WhatAreYouTodo" name="DDL_WhatAreYouTodo"> </select>
<input type="button" value="保存" onclick="Save()" id="Btn_Save" name="Btn_Save" />
<input type="button" value="内容编辑demo for javascript" onclick="DemoJS()" id="Button1"
name="Btn_D1" />
<input type="button" value="内容编辑demo for SQL" onclick="DemoSQL()" id="Button2" name="Btn_D2" />
更换主题:
<select onchange="selectTheme()" id="select">
<option>eclipse</option>
<option>elegant</option>
<option selected="selected">erlang-dark</option>
<option>idea</option>
</select>
</th>
</td>
</tr>
<tr>
<td style="background-color: Background">
<div id="paras">
</div>
</td>
</tr>
<tr>
<td style="margin: 0px;">
<textarea id="tb_doc" style="width: 100%; height: 100%;" rows="100"> </textarea>
</td>
</tr>
<tr style="background-color: Background">
<td style="margin: 0px;">
<font color="yellow" font-size='12px'><b>}</b></font> <font color="yellow">
<b>
//您需要把方法写入编辑器里.
你可以使用jQuery使用Gener.js里面的实体类进行数据的增删改查.
</b>
</font>
</td>
</tr>
</table>
<script type="text/javascript">
var editor = CodeMirror.fromTextArea(document.getElementById("tb_doc"), {
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
theme: "erlang-dark"
});
var input = document.getElementById("select");
function selectTheme() {
var theme = input.options[input.selectedIndex].textContent;
editor.setOption("theme", theme);
location.hash = "#" + theme;
}
/*
var choice = (location.hash && location.hash.slice(1)) ||
(document.location.search &&
decodeURIComponent(document.location.search.slice(1)));
if (choice) {
input.value = choice;
editor.setOption("theme", choice);
}
CodeMirror.on(window, "hashchange", function() {
var theme = location.hash.slice(1);
if (theme) { input.value = theme; selectTheme(); }
});*/
</script>
</form>
<a href="javascript:ShowHidden('h_title')">
<img src='../../Img/Help.png' />实体的其他信息.
</a>
<div id="h_title" style="color: Gray; display: none">
<div id="FrmDocs">
</div>
</div>
</body>
</html>