<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>表单HTML布局</title>
<script src="../JavaScript/YXBase.js" type="text/javascript"></script>
<script src="../JavaScript/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="../fckeditorExt/fckeditor.js" type="text/javascript"></script>
<script src="../fckeditorExt/FCKEditorExt.js" type="text/javascript"></script>
</head>
<body onload="initFckEdit();" style="margin: 0px;">
<form id="LayoutForm" runat="server">
<div>
<table width="100%" height="100%" class="ViewForm" bgcolor="#000000" border="0" cellpadding="3"
cellspacing="1" align="center">
<colgroup>
<col width="*" />
<col width="250px" />
</colgroup>
<tbody>
<tr bgcolor="#DDDDDD" height="100%">
<td bgcolor="#DDDDDD" width="*" valign="top">
<textarea runat="server" name="layouttext" id="layouttext" style="width: 100%; height: 100%"></textarea>
</td>
<td valign="top" align="center" style="width: 250px; height: 100%" bgcolor="#ffffff">
<table class="ViewForm" cellpadding="0" cellspacing="0">
<colgroup>
<col width="50%">
<col width="50%">
</colgroup>
<tr>
<td heigth="20" align="center" colspan="2">
<b>布局类型 : </b>显示模板
</td>
</tr>
<tr>
<td class="Line2" colspan="2">
</td>
</tr>
<tr height="100%" width="100%" valign="top">
<td style="border-right: 1px #ECECEC solid" height="100%" valign="top">
<table class="ViewForm" width="120" border="0" cellspacing="1" cellpadding="3" align="center">
<tr class="Title">
<td class="field" align="center">
<b>字段显示名 </b>
</td>
</tr>
<tr>
<td class="Line2">
</td>
</tr>
<tr class="Title">
<td class="field" id="tdtablelist" name="tdtablelist" align="center">
<asp:DropDownList runat="server" ID="tablelist0" class="tablelist" AutoPostBack="false"
EnableViewState="false" onchange="onchangeformlabel(this)">
<asp:ListItem Selected="True" Text="主表" Value="-1"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="Line2">
</td>
</tr>
<tr class="Title">
<td class="field" id="tdfieldlist" name="tdfieldlist" align="center">
<%=getALLFieldLabelShowInEachSelect() %>
</td>
</tr>
<tr>
<td class="Line2">
</td>
</tr>
</table>
</td>
<td style="border-left: 1px #ECECEC solid" height="100%" valign="top">
<table class="ViewForm" width="120" border="0" cellspacing="1" cellpadding="3" align="center">
<tr class="Title">
<td class="field" align="center">
<b>表单字段</b>
</td>
</tr>
<tr>
<td class="Line2">
</td>
</tr>
<tr class="Title">
<td class="field" align="center">
<asp:DropDownList runat="server" ID="tablelist1" class="tablelist" AutoPostBack="false"
EnableViewState="false" onchange="onchangeformfield(this)">
<asp:ListItem Selected="True" Text="主表" Value="-1">
</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="Line2">
</td>
</tr>
<tr class="Title">
<td class="field" align="center">
<%=getALLFormFieldShowInEachSelect() %>
</td>
</tr>
<tr>
<td class="Line2">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td heigth="20" align="center" colspan="2">
<b>显示样式:</b>
</td>
</tr>
<tr>
<td heigth="20" align="center" colspan="2">
<input type="hidden" id="nowgroupid" name="nowgroupid" value="" />
<input type="hidden" id="nowfieldid" name="nowfieldid" value="" />
<!--节点类型 0:创建 1:审批 2:实现 3:归档-->
<div id="groupAttrDiv" name="groupAttrDiv" class="groupAttrDiv" style="display: none">
允许新增明细
<input type="checkbox" id="dtladd" name="dtladd" class="groupattrcheckbox" value="1"
onclick="onclickgroupattr(this)" />
允许修改已有明细<input type="checkbox" id="dtledit" name="dtledit" class="groupattrcheckbox"
value="1" onclick="onclickgroupattr(this)" />
允许删除已有明细<input type="checkbox" id="dtldel" name="dtldel" class="groupattrcheckbox"
value="1" onclick="onclickgroupattr(this)" />
</div>
<select id="fieldattrlist" name="fieldattrlist" class="fieldattrlist" onchange="onchangefieldattr(this)"
style="display: none">
<option value="1">只读</option>
<option value="2">可编辑</option>
<option value="3">必填</option>
</select>
</td>
</tr>
<tr>
<td class="Line2" colspan="2">
</td>
</tr>
<tr>
<td heigth="20" align="center" colspan="2">
<b>布局名称 : </b>
<input id="layoutname" runat="server" name="layoutname" class="InputStyle" value=''
temptitle="布局名称" maxlength="20" onchange="checkinput('layoutname','layoutnamespan')" />
<span id="layoutnamespan">
<%if ("".Equals(layoutname.Value)) { Response.Write("<IMG src='../images/BacoError.gif' align=absMiddle>"); }%></span>
</td>
</tr>
<tr>
<td class="Line2" colspan="2">
</td>
</tr>
<tr>
<td heigth="20" align="center" colspan="2">
每行显示字段数
<select id="colsperrow" name="colsperrow" style="width: 50px">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
</td>
</tr>
<tr>
<td class="Line2" colspan="2">
</td>
</tr>
<tr>
</tr>
<tr>
<td height="100%">
</td>
</tr>
</table>
<input type="hidden" id="layouttype" name="layouttype" value="0" />
<asp:Localize runat="server" ID="hiddenLocalize" Text=""></asp:Localize>
<%--
<%=detailGroupAttr_sb.toString()%>
<input type="hidden" id="fileFieldids" name="fileFieldids" value="<%=fileFieldids%>">
<input type="hidden" id="inputFieldids" name="inputFieldids" value="<%=inputFieldids%>">--%>
<input type="hidden" id="canFieldEdit" name="canFieldEdit" value="1" />
<div id="htmllayoutdiv" name="htmllayoutdiv" style="height: 0px; width: 0px; visibility: hidden">
</div>
</td>
</tr>
<tr>
<td>
<asp:Button runat="server" ID="SaveHTMLTempButton" Text=" 保 存 " OnClick="onSaveHTMLTempButtonClick" />
</td>
</tr>
</tbody>
</table>
</div>
</form>
<script type="text/javascript">
function openFieldAttributeDialog() {
var url = escape("/FCKEditor/editor/dialog/fck_fieldattr.jsp?wfid=1&nodeid=2");
var id = window.showModalDialog("/systeminfo/BrowserMain.jsp?url=" + url, window);
}
function funcremark() {
FCKEditorExt.initEditor("LayoutForm", "layouttext", 7, FCKEditorExt.HtmlLayout_IMAGE);
}
function initFckEdit() {
funcremark();
}
//往左边Fck编辑框里加一个字段显示名
function cool_webcontrollabel(obj) {
var nodetype = obj.options.item(obj.selectedIndex).nodetype;
var labelid = obj.value;
var labelhtml = "<input class=\"Label\" id=\"$label" + labelid + "$\" name=\"label" + labelid + "\" value=\"" + nodetype + "\"></input>";
if (labelid == "labelrequestTitle") {
labelhtml = "<input id=\"$labelrequestTitle$\" class=\"Label\" name=\"labelrequestTitle\" value=\"标题\" type=\"text\" />";
}
FCKEditorExt.insertHtml(labelhtml, "layouttext");
}
function cool_webcontrolnode(obj) {
var fckHtml = FCKEditorExt.getHtml("layouttext");
var nodetype = obj.options.item(obj.selectedIndex).nodetype;
var fieldlabel = obj.options.item(obj.selectedIndex).text;
var fieldid = obj.value;
if (fckHtml.indexOf("$node" + fieldid + "$") != -1) {
alert("该元素已经存在,不能重复添加!"); //
return;
}
var fieldhtml = "<input class=\"InputStyle\" id=\"$node" + fieldid + "$\" name=\"node" + fieldid + "\" value=\"" + fieldlabel + "\" disabled=true></input>";
FCKEditorExt.insertHtml(fieldhtml, "layouttext");
}
//往左边Fck编辑框里加一个字段
function cool_webcontrolfield(obj) {
var fckHtml = FCKEditorExt.getHtml("layouttext");
var nodetype = obj.options.item(obj.selectedIndex).nodetype;
var fieldlabel = obj.options.item(obj.selectedIndex).text;
var fieldid = obj.value;
if (fckHtml.indexOf("$field" + fieldid + "$") != -1) {
alert("该元素已经存在,不能重复添加!"); //
return;
}
if (nodetype == 0 || nodetype == 1 || nodetype == 2) {
$("#fieldattr" + fieldid).val("2"); //刚添加的都认为是编辑属性
} else {
$("#fieldattr" + fieldid).val("3"); //
}
var fieldattrStr = "可编辑"; //
if (nodetype == 0 || nodetype == 1 || nodetype == 2) {
var fieldhtml = "<input class=\"InputStyle\" id=\"$field" + fieldid + "$\" name=\"field" + fieldid + "\" value=\"[" + fieldattrStr + "]" + fieldlabel + "\"></input>";
} else {
var fieldhtml = "<input class=\"InputStyle\" id=\"$field" + fieldid + "$\" name=\"field" + fieldid + "\" value=\"[必填]" + fieldlabel + "\"></input>";
}
if (fieldid == "requestTitle") {
fieldhtml = "<input class=\"InputStyle\" id=\"$requestTitle$\" name=\"requestTitle\" value=\"[必填]标题\" type=\"text\" />";
}
FCKEditorExt.insertHtml(fieldhtml, "layouttext");
}
function fomateHtml(textStr) {
var tmpStr = "";
var hasTd = textStr.indexOf("<td");
var tdIndex = textStr.indexOf("<td");
var headIndex = textStr.indexOf("<", tdIndex + 1);
var tailIndex = textStr.indexOf(">", tdIndex);
var tailTdIndex = textStr.indexOf("> </td>", tdIndex);
while (hasTd >= 0) {
if (tdIndex >= 0 && headIndex == (tailIndex + 7) && tailTdIndex == tailIndex) {
tmpStr += textStr.substring(0, tailIndex + 1);
textStr = textStr.substring(tailTdIndex + 7, textStr.length);
} else {
tmpStr += textStr.substring(0, tdIndex + 3);
textStr = textStr.substring(tdIndex + 3, textStr.length);
}
hasTd = textStr.indexOf("<td");
tdIndex = textStr.indexOf("<td");
headIndex = textStr.indexOf("<", tdIndex + 1);
tailIndex = textStr.indexOf(">", tdIndex);
tailTdIndex = textStr.indexOf("> </td>", tdIndex);
}
tmpStr += textStr;
return tmpStr;
}
function onSave() {
FCKEditorExt.updateContent();
var textStr = document.getElementById("layouttext").value;
var tmpStr = fomateHtml(textStr);
document.getElementById("layouttext").value = tmpStr;
if (check_form(LayoutForm, "layoutname")) {
LayoutForm.submit();
enableAllmenu();
}
}
function onPrepPrintMode() {
if (confirm("是否初始化显示模板?")) {//
LayoutForm.operation.value = "preppm";
LayoutForm.submit();
}
}
function onchangeformlabel(obj) {
$(".labellist").hide();
$("#labellist" + obj.value).show();
}
function onchangeformfield(obj) {
$(".fieldlist").hide();
$("#fieldlist" + obj.value).show();
$("#nowgroupid").val(obj.value);
$("#nowfieldid").val("");
$("#groupAttrDiv").hide();
$("#fieldattrlist").hide();
$(".groupattrcheckbox").attr("checked", "");
if ($("#nowgroupid").val() != "-2" && $("#nowgroupid").val() != "-1") {
var thisGroupAttr = $("#detailgroupattr" + obj.value).val();
if (thisGroupAttr.indexOf("1") == 0) {
$("#dtladd").attr("checked", "checked");
}
if (thisGroupAttr.indexOf("1", 1) == 1) {
$("#dtledit").attr("checked", "checked");
}
if (thisGroupAttr.indexOf("1", 2) == 2) {
$("#dtldel").attr("checked", "checked");
}
if (thisGroupAttr.indexOf("1", 3) == 3) {
$("#dtlhide").attr("checked", "checked");
}
$("#groupAttrDiv").show();
}
}
function onclickgroupattr(obj) {
var nowgroupid = $("#nowgroupid").val();
var groupattr = "";
var text2 = "";
if ($("#dtladd").attr("checked") == true) {
groupattr += "1";
text2 = "<button class=\"BtnFlow\" type=\"button\" id=\"$addbutton" + nowgroupid + "$\" name=\"addbutton" + nowgroupid + "\" accessKey=\"A\" onclick=\"addRow" + nowgroupid + "(" + nowgroupid + ")\"><U>A</U>-添加</BUTTON>"; //
} else {
groupattr += "0";
}
text2 += "<button class=\"BtnFlow\" type=\"button\" id=\"$delbutton" + nowgroupid + "$\" name=\"delbutton" + nowgroupid + "\" accessKey=\"E\" onclick=\"if(isdel()){deleteRow1(" + nowgroupid + ");}\"><U>E</U>-删除</BUTTON>"; //
var fckHtml = FCKEditorExt.getHtml("layouttext");
var pos1 = fckHtml.indexOf("<div id=\"div" + nowgroupid + "button\"");
if (pos1 != -1) {
var pos2 = fckHtml.indexOf(">", pos1);
var pos3 = fckHtml.indexOf("</div>", pos2);
var text1 = fckHtml.substring(0, pos2 + 1);
var text3 = fckHtml.substring(pos3);
var text = text1 + text2 + text3;
FCKEditorExt.setHtml(text, "layouttext");
}
if ($("#dtledit").attr("checked") == true) {
groupattr += "1";
} else {
groupattr += "0";
}
if ($("#dtldel").attr("checked") == true) {
groupattr += "1";
} else {
groupattr += "0";
}
if ($("#dtlhide").attr("checked") == true) {
groupattr += "1";
} else {
groupattr += "0";
}
$("#detailgroupattr" + nowgroupid).val(groupattr);
}
function loadfieldstyle(obj) {
var nodetype = obj.options.item(obj.selectedIndex).nodeType;
//$("#nowgroupid").val("");
$("#nowfieldid").val("");
$("#groupAttrDiv").hide();
$("#fieldattrlist").hide();
$(".groupattrcheckbox").attr("checked", "");
//只有显示模板才能调整字段显示属性
var especialFieldids = $("#especialFieldids").val();
var index_eFieldids = ("," + especialFieldids + ",").indexOf("," + obj.value + ",");
if (obj.id != "fieldlist-2" && index_eFieldids == -1) {//不是节点
var fckHtml = FCKEditorExt.getHtml("layouttext");
if (fckHtml.indexOf("$field" + obj.value + "$") != -1) {//如果Fck编辑框里面没有这个字段,那么也不显示出来
if (obj.id == "fieldlist-1") {//主表
var nowfieldid = obj.value;
$("#nowfieldid").val(nowfieldid);
if (nodetype == 0 || nodetype == 1 || nodetype == 2) {
var fieldattr = $("#fieldattr" + nowfieldid).val();
$("#fieldattrlist").val(fieldattr);
$("#fieldattrlist").show();
}
else {
var nowgroupid = $("#nowgroupid").val();
var nowgroupattr = $("#detailgroupattr" + nowgroupid).val();
if (nodetype == 0 || nodetype == 1 || nodetype == 2) {
$("#fieldattrlist option").each(function () {
if ($(this).val() == "2" || $(this).val() == "3") {
$(this).remove();
}
});
}
if (nowgroupattr.indexOf("00") != 0) {
$("#fieldattrlist").append("<option value=\"2\">可编辑</option>"); //
$("#fieldattrlist").append("<option value=\"3\">必填</option>"); //
}
}
var nowfieldid = obj.value;
$("#nowfieldid").val(nowfieldid);
if (nodetype == 0 || nodetype == 1 || nodetype == 2) {
var fieldattr = $("#fieldattr" + nowfieldid).val();
$("#fieldattrlist").val(fieldattr);
$("#fieldattrlist").show();
}
}
}
}
fckHtml = FCKEditorExt.getHtml("layouttext");
//FCKEditorExt.setHtml(fckHtml,"layouttext");
}
</script>
<script type="text/javascript">
function onchangefieldattr(obj) {
var nowfieldid = $("#nowfieldid").val();
$("#fieldattr" + nowfieldid).val(obj.value);
var fckHtml = FCKEditorExt.getHtml("layouttext");
var pos1 = fckHtml.indexOf("$field" + nowfieldid + "$");
if (pos1 != -1) {
var pos2 = fckHtml.indexOf("[", pos1);
if (pos2 != -1) {
var pos3 = fckHtml.indexOf("]", pos2);
var text1 = fckHtml.substring(0, pos2 + 1);
if (obj.value == "0") {
var text1 = text1.substring(0, text1.lastIndexOf("<"));
pos3 = fckHtml.indexOf(">", pos2) + 1;
//text1 += "隐藏";如果切换成隐藏,直接删除
} else if (obj.value == "1") {
text1 += "只读"; //
} else if (obj.value == "2") {
text1 += "可编辑"; //
} else if (obj.value == "3") {
text1 += "必填"; //
}
text1 += fckHtml.substring(pos3);
FCKEditorExt.setHtml(text1, "layouttext");
}
}
else if (obj.value != "0") {
//如果本来没有,则添加进去
var nowgroupid = "-1";
if (nowfieldid.indexOf("-") == 0) {//明细字段
nowgroupid = $("#nowgroupid").val();
}
var obj2 = document.getElementById("fieldlist" + nowgroupid);
var nodetype = obj2.options.item(obj2.selectedIndex).nodeType;
var fieldlabel = obj2.options.item(obj2.selectedIndex).text;
var fieldid = nowfieldid;
var fieldattrStr = "可编辑"; //
if (obj.value == "1") {
fieldattrStr = "只读"; //
} else if (obj.value == "3") {
fieldattrStr = "必填"; //
}
var fieldhtml = "<input class=\"InputStyle\" id=\"$field" + fieldid + "$\" name=\"field" + fieldid + "\" value=\"[" + fieldattrStr + "]" + fieldlabel + "\">";
FCKEditorExt.insertHtml(fieldhtml, "layouttext");
}
}
function onchangefieldattrFromFck(fieldid, fieldShowAttr) {
var nowfieldid = $("#nowfieldid").val();
if (nowfieldid == fieldid) {
$("#fieldattrlist").val(fieldShowAttr);
}
var fckHtml = FCKEditorExt.getHtml("layouttext");
var pos1 = fckHtml.indexOf("$field" + fieldid + "$");
if (pos1 != -1) {
var pos2 = fckHtml.indexOf("[", pos1);
if (pos2 != -1) {
var pos3 = fckHtml.indexOf("]", pos2);
var text1 = fckHtml.substring(0, pos2 + 1);
if (fieldShowAttr == "0") {
var text1 = text1.substring(0, text1.lastIndexOf("<"));
pos3 = fckHtml.indexOf(">", pos2) + 1;
//text1 += "隐藏";如果切换成隐藏,直接删除
} else if (fieldShowAttr == "1") {
text1 += "只读"; //只读
} else if (fieldShowAttr == "2") {
text1 += "可编辑"; //
} else if (fieldShowAttr == "3") {
text1 += "必填";
}
text1 += fckHtml.substring(pos3);
FCKEditorExt.setHtml(text1, "layouttext");
}
}
}
</script>
</body>
</html>
后端代码
protected void onSaveHTMLTempButtonClick(object sender, EventArgs e)
{
string template = Request.Form["layouttext"];
string htmltemplateName = string.Format("htmllay{0}_{1}_0.html", formid, nodeid);
string path = Server.MapPath("~/htmllayout/" + htmltemplateName);
try
{
if (System.IO.File.Exists(path))
{
if (string.IsNullOrEmpty(template))
{
File.Move(path, Path.Combine(path, ".bak"));
}
else
{
System.IO.FileStream fs = new FileStream(path, FileMode.Truncate);
byte[] array = new byte[template.Length];
System.Text.Encoding encoding = System.Text.UTF8Encoding.UTF8;
array = encoding.GetBytes(template);
fs.Write(array, 0, array.Length);
fs.Close();
}
}
else
{
FileStream fs = new FileStream(path, FileMode.OpenOrCreate);
byte[] array = new byte[template.Length];
System.Text.Encoding encoding = System.Text.UTF8Encoding.UTF8;
array = encoding.GetBytes(template);
fs.Write(array, 0, array.Length);
fs.Close();
}
//保存模板名称
M.workflow_nodehtmllayout nodehtmllayout = nodehtmllayoutBLL.GetModelList("formid=" + formid + " and nodeid='" + nodeid + "'").FirstOrDefault();
if (nodehtmllayout != null)
{
nodehtmllayout.layoutname = layoutname.Value;
nodehtmllayoutBLL.Update(nodehtmllayout);
}
else
{
nodehtmllayout = new M.workflow_nodehtmllayout();
nodehtmllayout.formid = int.Parse(formid);
nodehtmllayout.nodeid = nodeid;
nodehtmllayout.workflowid = workflowid;
nodehtmllayout.layoutname = layoutname.Value;
nodehtmllayoutBLL.Add(nodehtmllayout);
}
}
catch (Exception ex)
{
YaXing.Common.MessageBox.ShowAndRedirectSelf(this, "模板保存失败!", this.Request.Url.ToString());
return;
}
YaXing.Common.MessageBox.ShowAndRedirectSelf(this, "模板已保存!", this.Request.Url.ToString());
}
/// <summary>
/// 字段显示名下拉框
/// </summary>
private void initialFieldNameDDL()
{
//tablelist0
List<M.workflow_billdetailtable> list = billdetailtableBLL.GetModelList(string.Format("billid = {0} order by id", formid));
if (list != null)
{
foreach (M.workflow_billdetailtable model in list)
{
tablelist0.Items.Add(new ListItem(model.tablename, model.id.ToString()));
}
}
}
private void initialFormFieldDDL()
{
//tablelist1
List<M.workflow_billdetailtable> list = billdetailtableBLL.GetModelList(string.Format("billid = {0} order by id", formid));
if (list != null)
{
foreach (M.workflow_billdetailtable model in list)
{
tablelist1.Items.Add(new ListItem(model.tablename, model.id.ToString()));
}
}
if (activityList != null)
{
tablelist1.Items.Add(new ListItem("流程 节点", "-2"));
}
}
protected void gethtmlLayout()
{
string htmltemplateName = string.Format("htmllay{0}_{1}_0.html", formid, nodeid);
string path = Server.MapPath("~/htmllayout/" + htmltemplateName);
string template = "";
if (System.IO.File.Exists(path))
{
template = string.Empty;
System.IO.StreamReader r = new StreamReader(path);
template = r.ReadToEnd();
r.Close();
}
layouttext.InnerText = template;
}
protected string getALLFieldLabelShowInEachSelect()
{
List<M.workflow_billfield> list = billfieldBLL.GetModelList(string.Format("billid = {0} order by viewtype,id", formid));
var mainfieldList = list.Where(s => s.viewtype == 0);
StringBuilder sb = new StringBuilder();
sb.Append("<select id=\"labellist-1\" name=\"labellist-1\" class=\"labellist\" size=\"15\" ondblclick=\"javascript:cool_webcontrollabel(this);\"style=\"width: 100%; display: \">\r\n");
sb.Append("<option value=\"labelrequestTitle\" nodetype=\"标题\">标题</option>\r\n");
foreach (M.workflow_billfield m in mainfieldList)
{
sb.Append(string.Format("<option value=\"{0}\" nodetype=\"{1}\">{2}</option>\r\n", m.id, m.fieldlabel, m.fieldlabel));
}
sb.Append("</select>\r\n");
List<M.workflow_billdetailtable> tablelist = billdetailtableBLL.GetModelList(string.Format("billid = {0} order by id", formid));
if (list != null)
{
foreach (M.workflow_billdetailtable model in tablelist)
{
tablelist0.Items.Add(new ListItem(model.tablename, model.id.ToString()));
sb.Append(string.Format("<select id=\"labellist{0}\" name=\"labellist{0}\" class=\"labellist\" size=\"15\" ondblclick=\"javascript:cool_webcontrollabel(this);\"style=\"width: 100%; display:none \">\r\n", model.id));
var detaillist = list.Where(l => l.detailtable == model.tablename);
foreach (M.workflow_billfield dm in detaillist)
{
sb.Append(string.Format("<option value=\"{0}\" nodetype=\"{1}\">{2}</option>\r\n", dm.id, dm.fieldlabel, dm.fieldlabel));
}
sb.Append("</select>\r\n");
}
}
return sb.ToString();
}
protected string getALLFormFieldShowInEachSelect()
{
/*
* fieldAttr_sb.append("<input type=\"hidden\" id=\"fieldattr"+fieldid_tmp+"\" nodetype=\"-1\" name=\"fieldattr"+fieldid_tmp+"\" value=\""+fieldAttr_tmp+"\">").append("\n");
String fieldSQL_tmp = Util.null2String((String)fieldSQL_hs.get("fieldsql"+fieldid_tmp));
fieldSQL_sb.append("<input type=\"hidden\" id=\"fieldsql"+fieldid_tmp+"\" name=\"fieldsql"+fieldid_tmp+"\" value=\""+fieldSQL_tmp+"\">").append("\n");
fieldid_sb.append(fieldid_tmp+",");
*/
//主表字段
//各明细表字段
//流程节点
//通通为文本框
StringBuilder fieldAttr_sb = new StringBuilder();
StringBuilder fieldSQL_sb = new StringBuilder();
StringBuilder fieldid_sb = new StringBuilder();
StringBuilder especialFieldid_sb = new StringBuilder();//链接或描述 htmltype = 7
StringBuilder detailGroupAttr_sb = new StringBuilder();
int nodetype = 0;
DataSet nodeformDS = nodeformBLL.GetList(int.Parse(formid), nodeid);
DataView dv = null;
if (nodeformDS.Tables.Count > 0)
{
dv = nodeformDS.Tables[0].DefaultView;
dv.Sort = "viewtype,orderid";
}
List<M.workflow_billfield> list = billfieldBLL.GetModelList(string.Format("billid = {0} order by viewtype,id", formid));
var mainfieldList = list.Where(s => s.viewtype == 0);
StringBuilder sb = new StringBuilder();
sb.Append("<select id=\"fieldlist-1\" name=\"fieldlist-1\" class=\"fieldlist\" size=\"15\" ondblclick=\"javascript:cool_webcontrolfield(this);\"style=\"width: 100%; display: \">\r\n");
sb.Append(string.Format("<option value=\"{0}\" nodetype=\"{1}\">{2}</option>\r\n", "requestTitle", -1, "标题"));
foreach (M.workflow_billfield m in mainfieldList)
{
dv.RowFilter = "fieldid =" + m.id;
if (dv.Count > 0)
{
if (dv[0]["ismandatory"].ToString() == "y")
{
nodetype = 3;
}
else if (dv[0]["isedit"].ToString() == "y")
{
nodetype = 2;
}
else if (dv[0]["isview"].ToString() == "y")
{
nodetype = 1;
}
}
sb.Append(string.Format("<option value=\"{0}\" nodetype=\"{1}\">{2}</option>\r\n", m.id, nodetype, m.fieldlabel));
fieldAttr_sb.Append("<input type=\"hidden\" id=\"fieldattr" + m.id + "\" nodetype=\"-1\" name=\"fieldattr" + m.id + "\" value=\"" + nodetype + "\">\r\n");
fieldSQL_sb.Append("<input type=\"hidden\" id=\"fieldsql" + m.id + "\" name=\"fieldsql" + m.id + "\" value=\"" + "\">").Append("\r\n");
fieldid_sb.Append(m.id + ",");
if (m.fieldhtmltype == "7")
{
especialFieldid_sb.Append(m.id).Append(",");
}
}
sb.Append("</select>\r\n");
List<M.workflow_billdetailtable> tablelist = billdetailtableBLL.GetModelList(string.Format("billid = {0} order by id", formid));
if (list != null)
{
foreach (M.workflow_billdetailtable model in tablelist)
{
tablelist0.Items.Add(new ListItem(model.tablename, model.id.ToString()));
sb.Append(string.Format("<select id=\"fieldlist{0}\" name=\"fieldlist{0}\" class=\"fieldlist\" size=\"15\" ondblclick=\"javascript:cool_webcontrolfield(this);\"style=\"width: 100%; display:none \">\r\n", model.id));
var detaillist = list.Where(l => l.detailtable == model.tablename);
//明细表操作属性
string detailGroupAttr = getDetailTableAttr(model);
detailGroupAttr_sb.Append("<input type=\"hidden\" id=\"detailgroupattr" + model.id + "\" name=\"detailgroupattr" + model.id + "\" value=\"" + detailGroupAttr + "\">").Append("\n");
foreach (M.workflow_billfield dm in detaillist)
{
dv.RowFilter = "fieldid =" + dm.id;
if (dv.Count > 0)
{
if (dv[0]["ismandatory"].ToString() == "y")
{
nodetype = 3;
}
else if (dv[0]["isedit"].ToString() == "y")
{
nodetype = 2;
}
else if (dv[0]["isview"].ToString() == "y")
{
nodetype = 1;
}
}
sb.Append(string.Format("<option value=\"{0}\" nodetype=\"{1}\">{2}</option>\r\n", dm.id, nodetype, dm.fieldlabel));
fieldAttr_sb.Append("<input type=\"hidden\" id=\"fieldattr" + dm.id + "\" nodetype=\"" + dm.id + "\" name=\"fieldattr" + dm.id + "\" value=\"" + nodetype + "\">\r\n");
fieldSQL_sb.Append("<input type=\"hidden\" id=\"fieldsql" + dm.id + "\" name=\"fieldsql" + dm.id + "\" value=\"" + "\">").Append("\r\n");
fieldid_sb.Append(dm.id + ",");
if (dm.fieldhtmltype == "7")
{
especialFieldid_sb.Append(dm.id).Append(",");
}
}
sb.Append("</select>\r\n");
}
}
if (activityList != null)
{
sb.Append("<select id=\"fieldlist-2\" name=\"fieldlist-2\" class=\"fieldlist\" size=\"15\" onchange=\"loadfieldstyle(this)\"ondblclick=\"javascript:cool_webcontrolnode(this);\" style=\"width: 100%; display: none\">\r\n");
foreach (M.WF_Activity a in activityList)
{
sb.Append(string.Format("<option value=\"{0}\" nodetype=\"{0}\">{1}</option>", a.ActivityID, a.ActivityName));
}
sb.Append("</select>\r\n");
}
hiddenLocalize.Text += fieldAttr_sb.ToString();
hiddenLocalize.Text += fieldSQL_sb.ToString();
hiddenLocalize.Text += detailGroupAttr_sb.ToString();
string fieldids = fieldid_sb.ToString();
if (!string.IsNullOrEmpty(fieldids))
{
if (fieldids.EndsWith(","))
{
fieldids = fieldids.Remove(fieldids.LastIndexOf(','));
}
hiddenLocalize.Text += "<input type=\"hidden\" id=\"fieldids\" name=\"fieldids\" value=\"" + fieldids + "\"/>\r\n";
}
string especialFieldids = especialFieldid_sb.ToString();
if (!string.IsNullOrEmpty(especialFieldids))
{
if (especialFieldids.EndsWith(","))
{
hiddenLocalize.Text += "<input type=\"hidden\" id=\"especialFieldids\" name=\"especialFieldids\" value=\"" + especialFieldids + "\">\r\n";
}
}
return sb.ToString();
}
private string getDetailTableAttr(M.workflow_billdetailtable model)
{
string localObject3 = "";
M.workflow_NodeFormGroup nodeformgroup = nodeformgroupBLL.GetModel(nodeid, model.id);
if (nodeformgroup != null)
{
String str4 = nodeformgroup.isadd == "y" ? "1" : "0";
string str6 = nodeformgroup.isedit == "y" ? "1" : "0"; ;
string str7 = nodeformgroup.isdelete == "y" ? "1" : "0";
string str8 = nodeformgroup.ishidenull == "y" ? "1" : "0";
if ("1".Equals(str4))
localObject3 = localObject3 + "1";
else
{
localObject3 = localObject3 + "0";
}
if ("1".Equals(str6))
localObject3 = localObject3 + "1";
else
{
localObject3 = localObject3 + "0";
}
if ("1".Equals(str7))
localObject3 = localObject3 + "1";
else
{
localObject3 = localObject3 + "0";
}
if ("1".Equals(str8))
localObject3 = localObject3 + "1";
else
{
localObject3 = localObject3 + "0";
}
}
return localObject3;
}
private void getlayoutname()
{
M.workflow_nodehtmllayout nodehtmllayout = nodehtmllayoutBLL.GetModelList("formid=" + formid + " and nodeid='" + nodeid + "'").FirstOrDefault();
if (nodehtmllayout != null)
{
layoutname.Value = nodehtmllayout.layoutname;
}
}
private string formid = "";
private string nodeid = "";
private string workflowid = "";
private List<M.WF_Activity> activityList = null;
private B.workflow_bill billBLL = new B.workflow_bill();
private B.workflow_nodeform nodeformBLL = new B.workflow_nodeform();
private B.workflow_billfield billfieldBLL = new B.workflow_billfield();
private B.WF_Activity activityBLL = new B.WF_Activity();
private B.WF_Process processBLL = new B.WF_Process();
private B.workflow_billdetailtable billdetailtableBLL = new B.workflow_billdetailtable();
private B.workflow_nodehtmllayout nodehtmllayoutBLL = new B.workflow_nodehtmllayout();
private B.workflow_NodeFormGroup nodeformgroupBLL = new B.workflow_NodeFormGroup();