/**
* 傻瓜表单的解析
* @param {any} wn
*/
var frmData;
function GenerFoolFrm(wn, isComPare) {
if (isComPare == null || isComPare == undefined || isComPare == "")
isComPare = false;
frmData = wn;
var mapData = frmData.Sys_MapData[0]; //表单属性
var tableCol = getTableCol(mapData.TableCol); //表单列数
var frmShowType = mapData.FrmShowType; //表单展示方式 普通方式、页签方式
var Sys_GroupFields = frmData.Sys_GroupField; //分组信息
var frmName = mapData.Name; //表单名称
var node = frmData.WF_Node; //节点属性
node = node != null && node != undefined ? node[0] : null;
frmShowType = frmShowType == null || frmShowType == undefined || frmShowType == "" ? 0 : frmShowType;
var _html = "";
//表头
_html += "
";
_html += "
";
_html += "
" + frmName + "
";
var imgbath = "../DataUser/";
if (GetHrefUrl().indexOf("/CCBill") != -1 || GetHrefUrl().indexOf("CCForm") != -1)
imgsrc = "../../DataUser/";
if (GetHrefUrl().indexOf("/AdminFrm.htm") != -1)
imgsrc = "../../../DataUser/";
var imgsrc = imgbath + "ICON/logoFrm.png";
_html += '
';
_html += "
";
_html += "
";
//普通方式
if (frmShowType == 0)
_html += ShowFoolByTable(frmData, tableCol, Sys_GroupFields, node, isComPare);
// 页签显示
if (frmShowType == 1)
_html += ShowFoolByTab(frmData, tableCol, Sys_GroupFields, node, isComPare);
$("#CCForm").html(_html);
//表格附件
if (frmData.Sys_FrmAttachment && frmData.Sys_FrmAttachment.length != 0) {
$.each(frmData.Sys_FrmAttachment, function (idex, ath) {
if ($("#Div_" + ath.MyPK).length == 1)
AthTable_Init(ath, "Div_" + ath.MyPK);
});
}
//字段附件
var aths = $(".athModel");
$.each(aths, function (idx, ath) {
//获取ID
var name = $(ath).attr('id');
var keyOfEn = name.replace("athModel_", "");
$("#Lab_" + keyOfEn).html("" + $("#Lab_" + keyOfEn).text() + "
");
});
$.each($(".layui-attr-btn"), function (idx, item) {
$(this).on("click", function () {
var keyOfEn = item.id.substring(4);
var mapAttr = $.grep(frmData.Sys_MapAttr, function (attr) {
return attr.KeyOfEn == keyOfEn;
})[0];
var tag = mapAttr.Tag || "";
if (tag != "")
tag = DealExp(tag);
if (mapAttr.UIIsEnable == 1) {
//执行js
DBAccess.RunUrlReturnString(tag);
}
if (mapAttr.UIIsEnable == 2)
DBAccess.RunFunctionReturnStr(tag);
if (mapAttr.UIIsEnable != 0 && isReadonly != true)
FullIt("", mapAttr.MyPK + "_FullData", "Btn_" + mapAttr.KeyOfEn, 0);
})
})
};
/**
* 普通方式的解析
*/
function ShowFoolByTable(frmData, tableCol, Sys_GroupFields, node, isComPare) {
var _html = "";
var gfLabHtml = "";
Sys_GroupFields.filter(gf=>gf.ShowType!=2).forEach(function (gf) {
var ctrlType = gf.CtrlType;
ctrlType = ctrlType == null ? "" : ctrlType;
_html += "";
if (ctrlType == "FWC")
gfLabHtml = "
"
else
gfLabHtml = "
"
gfLabHtml += "
";
gfLabHtml += gf.Lab;
gfLabHtml += "
";
gfLabHtml += "
";
switch (ctrlType) {
case "Ath": //附件
if (gf.CtrlID == "")
break;
if (frmData.Sys_FrmAttachment == undefined || frmData.Sys_FrmAttachment.length == 0)
break;
//创建附件描述信息.
var aths = $.grep(frmData.Sys_FrmAttachment, function (ath) { return ath.MyPK == gf.CtrlID });
var ath = aths.length > 0 ? aths[0] : null;
//附件分组不显示或者是审核组件中的附件
if (ath != null && (ath.IsVisable == "0" || ath.NoOfObj == "FrmWorkCheck"))
break;
//增加附件分组
_html += gfLabHtml;
_html += "
"
_html += "
";
if (ath == null)
_html += "附件" + gf.CtrlID + "信息丢失";
else
_html += "
";
_html += "
";
_html += "
";
break;
case "Dtl"://从表
if (frmData.Sys_MapDtl == undefined || frmData.Sys_MapDtl.length == 0)
break;
var dtls = $.grep(frmData.Sys_MapDtl, function (dtl) {
return dtl.No == gf.CtrlID && dtl.IsView != 0;
});
var dtl = dtls.length > 0 ? dtls[0] : null;
if (dtl == null)
break;
_html += gfLabHtml;
_html += "
"
_html += "
";
if (dtl == null)
_html += "从表" + gf.CtrlID + "信息丢失";
else
_html += "
" + Ele_Dtl(dtl, isComPare) + "
";
_html += "
";
_html += "
";
break;
case "FWC"://审核组件
if (node == null || node.FWCSta == 0)
break;
if (frmData.WF_FrmNode != undefined && frmData.WF_FrmNode.length != 0) {
if (frmData.WF_FrmNode[0].MyPK != "" && frmData.WF_FrmNode[0].IsEnableFWC == 0) {
break;
}
}
if (GetHrefUrl().indexOf("AdminFrm.htm") != -1)
break;
//如何有签批字段就不解析
_html += gfLabHtml;
_html += "
"
_html += "
";
_html += "
";
_html += "
";
_html += "
";
break;
case "Frame": //框架.
_html += gfLabHtml;
_html += "
"
_html += "
";
var frames = frmData.Sys_MapFrame;
if (frames == undefined || frames.length == 0)
_html += "获取框架信息丢失";
else {
frames = frames.filter(frame => frame.MyPK === gf.CtrlID);
if (frames == undefined || frames.length == 0)
_html += "获取框架信息丢失";
else
_html += Ele_Frame(frames[0]);
}
_html += "
";
_html += "
";
break;
case "SubFlow": //父子流程.
Skip.addJs("./WorkOpt/SubFlow.js");
_html += gfLabHtml;
_html += "
"
_html += "
";
//说明是累加表单.
if (gf.FrmID.indexOf(node.NodeID) == -1) {
var myNodeID = gf.FrmID.substring(2);
var myNode = new Entity("BP.WF.Node", myNodeID);
_html += "
" + SubFlow_Init(myNode) + "
";
}
else {
_html += "
" + SubFlow_Init(node) + "
";
}
_html += "
";
_html += "
";
break;
default://普通字段
if (gf.ShowType == 2) //0显示 1 PC折叠 2 隐藏
break;
_html += gfLabHtml;
_html += InitMapAttr(frmData, tableCol, gf.OID);
break;
}
_html += "
";
});
return _html;
}
/**
* Tab页签的方式显示
*/
function ShowFoolByTab(frmData, tableCol, Sys_GroupFields, node, isComPare) {
var _html = "";
_html += '
';
_html += '
';
var i = 0;
var gfs = [];
$.each(Sys_GroupFields, function (i, gf) {
if (gf.CtrlType == 'Ath') {
var aths = $.grep(frmData.Sys_FrmAttachment, function (ath) {
return ath.MyPK == gf.CtrlID && ath.IsVisable != "0" && ath.NoOfObj != "FrmWorkCheck";
});
if (aths.length == 0)
return true;
gf.Ath = aths[0];
}
if (gf.CtrlType == 'Dtl') {
var dtls = $.grep(frmData.Sys_MapDtl, function (dtl) {
return dtl.No == gf.CtrlID && dtl.IsView != 0;
});
if (dtls.length == 0)
return true;
gf.Dtl = dtls[0];
}
if (gf.CtrlType == 'FWC') {
if (node == null || node.FWCSta == 0)
return true;
if (frmData.WF_FrmNode != undefined && frmData.WF_FrmNode.length != 0) {
if (frmData.WF_FrmNode[0].MyPK != "" && frmData.WF_FrmNode[0].IsEnableFWC == 0) {
return true;
}
}
if (GetHrefUrl().indexOf("AdminFrm.htm") != -1)
return true;
}
gfs.push(gf);
});
$.each(gfs, function (i, gf) {
if (i == 0)
_html += "" + gf.Lab + " ";
else
_html += "" + gf.Lab + " ";
});
_html += ' ';
_html += '
';
$.each(gfs, function (i, gf) {
var contHtml = "";
if (i == 0)
contHtml += "
";
else
contHtml += "
";
var ctrlType = gf.CtrlType;
ctrlType = ctrlType == null ? "" : ctrlType;
switch (ctrlType) {
case "Ath": //附件
//增加附件分组
contHtml += "
"
contHtml += "
";
if (gf.Ath == null)
contHtml += "附件" + gf.CtrlID + "信息丢失";
else
contHtml += "
";
contHtml += "
";
contHtml += "
";
break;
case "Dtl"://从表
contHtml += "
"
contHtml += "
";
if (gf.Dtl == null)
contHtml += "从表" + gf.CtrlID + "信息丢失";
else
contHtml += "
" + Ele_Dtl(gf.Dtl, isComPare) + "
";
contHtml += "
";
contHtml += "
";
break;
case "FWC"://审核组件
//如何有签批字段就不解析
contHtml += "
"
contHtml += "
";
contHtml += "
";
contHtml += "
";
contHtml += "
";
break;
case "Frame"://框架
contHtml += "
"
contHtml += "
";
var frames = frmData.Sys_MapFrame;
if (frames == undefined || frames.length == 0)
contHtml += "获取框架信息丢失";
else {
frames = frames.filter(frame => frame.MyPK === gf.CtrlID);
if (frames == undefined || frames.length == 0)
contHtml += "获取框架信息丢失";
else
contHtml += Ele_Frame(frames[0]);
}
contHtml += "
";
contHtml += "
";
break;
case "SubFlow"://父子流程
Skip.addJs("./WorkOpt/SubFlow.js");
contHtml += gfLabHtml;
contHtml += "
"
contHtml += "
";
//说明是累加表单.
if (gf.FrmID.indexOf(node.NodeID) == -1) {
var myNodeID = gf.FrmID.substring(2);
var myNode = new Entity("BP.WF.Node", myNodeID);
contHtml += "
" + SubFlow_Init(myNode) + "
";
}
else {
contHtml += "
" + SubFlow_Init(node) + "
";
}
contHtml += "
";
contHtml += "
";
break;
default://普通字段
if (gf.ShowType == 2) //0显示 1 PC折叠 2 隐藏
break;
contHtml += InitMapAttr(frmData, tableCol, gf.OID);
break;
}
contHtml += "
";
_html += contHtml;
});
_html += '
';
_html += '
';
if ($("#SubFlow").length == 0 && node.SFSta != 0) {
Skip.addJs(basePath + "/WF/WorkOpt/SubFlow.js");
_html += gfLabHtml;
_html += "
"
_html += "
";
_html += "
" + SubFlow_Init(node) + "
";
_html += "
";
_html += "
";
}
return _html;
return _html;
}
/**
* 解析基本字段
* @param {any} groupID
*/
function InitMapAttr(frmData, tableCol, groupID) {
var Sys_MapAttr = $.grep(frmData.Sys_MapAttr, function (mapAttr) { return mapAttr.GroupID == groupID; });
var html = "";
var isDropTR = true;
var colSpan = 1;
var LabelColSpan = 1;
var textWidth = "";
var colWidth = "";
var useColSpan = 0;
for (var i = 0; i < Sys_MapAttr.length; i++) {
var attr = Sys_MapAttr[i];
if (attr.UIVisible == 0)
continue;
//单元格和标签占的列数
colSpan = attr.ColSpan;
LabelColSpan = attr.LabelColSpan;
//单元格和标签占的列数对应的class
colWidth = getColSpanClass(colSpan, tableCol);
textWidth = getLabelColSpanClass(LabelColSpan, tableCol);
//大文本备注信息 独占一行
if (attr.UIContralType == 60) {
if (isDropTR == false) {
html += "
";
isDropTR = true;
}
textWidth = getLabelColSpanClass(tableCol, tableCol);
//获取文本信息
var mapExts = frmData.Sys_MapExt || [];
var myExts = $.grep(mapExts, function (item) {
var mypk = "HtmlText_" + attr.MyPK;
return item.MyPK == mypk;
});
var str = "";
if (myExts.length > 0) {
var mapExt = new Entity("BP.Sys.MapExt", myExts[0]);
mapExt.MyPK = myExts[0].MyPK;
str = mapExt.DoMethodReturnString("ReadBigNoteHtmlText");
}
html += "
";
html += "
" + str + "
";
html += "
";
isDropTR = true;
continue;
}
//跨列设置(显示的是文本)
if (colSpan == 0) {
if (LabelColSpan >= tableCol) {
if (isDropTR == false) {
html += "
";
isDropTR = true;
}
textWidth = getLabelColSpanClass(tableCol, tableCol);
html += "";
html += "
" + GetLab(attr, frmData) + "
";
html += "
";
isDropTR = true;
continue;
}
//线性展示都跨一个单元格
//换行的情况
if (isDropTR == true) {
useColSpan = LabelColSpan;
html += "";
html += "
" + GetLab(attr, frmData) + "
";
if (useColSpan == tableCol) {
isDropTR = true;
html += "
";
}
else
isDropTR = false;
continue;
}
if (isDropTR == false) {
useColSpan += LabelColSpan;
if (useColSpan > tableCol) {
useColSpan = LabelColSpan;
//自动换行
html += "";
html += "";
}
if (attr.UIContralType == 18)
html += "
" + GetLab(attr, frmData) + "
";
else
html += "
" + GetLab(attr, frmData) + "
";
if (useColSpan == tableCol) {
isDropTR = true;
html += "
";
}
else
isDropTR = false;
continue;
}
}
//标签为0
if (LabelColSpan == 0) {
if (colSpan >= tableCol) {
if (isDropTR == false) {
html += "";
isDropTR = true;
}
colWidth = getColSpanClass(colSpan, tableCol);
html += "";
html += "
" + InitMapAttrOfCtrlFool(frmData, attr) + "
";
html += "
";
isDropTR = true;
continue;
}
//线性展示都跨一个单元格
//换行的情况
if (isDropTR == true) {
useColSpan = colSpan;
html += "";
html += "
" + InitMapAttrOfCtrlFool(frmData, attr) + "
";
if (useColSpan == tableCol) {
isDropTR = true;
html += "
";
}
else
isDropTR = false;
continue;
}
if (isDropTR == false) {
useColSpan += colSpan;
if (useColSpan > tableCol) {
useColSpan = colSpan;
//自动换行
html += "";
html += "";
}
html += "
" + InitMapAttrOfCtrlFool(frmData, attr) + "
";
if (useColSpan == tableCol) {
isDropTR = true;
html += "
";
}
else
isDropTR = false;
continue;
}
}
//解析占一行的情况
if (colSpan == tableCol) {
if (isDropTR == false) {
html += "";
isDropTR = true;
}
useColSpan = 0;
//自动换行
html += "";
html += "
" + GetLab(attr, frmData) + "
";
if (attr.UIContralType != 12)
html += "
" + InitMapAttrOfCtrlFool(frmData, attr) + "
";
html += "
"
continue;
}
var sumColSpan = colSpan + LabelColSpan;
if (sumColSpan >= tableCol) {
if (isDropTR == false) {
html += "";
isDropTR = true;
}
useColSpan = 0;
if (sumColSpan > tableCol)
colWidth = getColSpanClass(tableCol - LabelColSpan, tableCol)
//colWidth = textWidth.replace("layui-col-md", "").replace(" layui-col-xs4");
//colWidth = "layui-col-md" + (12 - parseInt(colWidth)) +" layui-col-xs8" ;
html += "";
if (attr.MyDataType == 1 && attr.LGType == 0 && (attr.IsSupperText == 1 || attr.UIHeight > 40))
html += "
" + GetLab(attr, frmData) + "
";
//html += "
" + GetLab(attr, frmData) + "
";
else
html += "
" + GetLab(attr, frmData) + "
";
if (attr.UIContralType != 12)
html += "
" + InitMapAttrOfCtrlFool(frmData, attr) + "
";
html += "
";
continue;
}
//换行的情况
if (isDropTR == true) {
useColSpan = LabelColSpan + colSpan;
html += "";
if (attr.UIContralType == 18) {
textWidth = getLabelColSpanClass(attr.LabelColSpan + attr.ColSpan, tableCol);
html += "
" + GetLab(attr, frmData) + "
";
} else {
html += "
" + GetLab(attr, frmData) + "
";
if (attr.UIContralType != 12)
html += "
" + InitMapAttrOfCtrlFool(frmData, attr) + "
";
}
if (useColSpan >= tableCol) {
isDropTR = true;
html += "
";
}
else
isDropTR = false;
continue;
}
if (isDropTR == false) {
useColSpan += LabelColSpan + colSpan;
if (useColSpan > tableCol) {
useColSpan = LabelColSpan + colSpan;
//自动换行
html += "";
html += "";
if (attr.UIContralType == 18) {
textWidth = getLabelColSpanClass(attr.LabelColSpan + attr.ColSpan, tableCol);
html += "
" + GetLab(attr, frmData) + "
";
} else {
html += "
" + GetLab(attr, frmData) + "
";
if (attr.UIContralType != 12)
html += "
" + InitMapAttrOfCtrlFool(frmData, attr) + "
";
}
} else {
if (attr.UIContralType == 18) {
textWidth = getLabelColSpanClass(attr.LabelColSpan + attr.ColSpan, tableCol);
html += "
" + GetLab(attr, frmData) + "
";
} else {
html += "
" + GetLab(attr, frmData) + "
";
if (attr.UIContralType != 12)
html += "
" + InitMapAttrOfCtrlFool(frmData, attr) + "
";
}
}
if (useColSpan == tableCol) {
isDropTR = true;
html += "
";
}
else
isDropTR = false;
continue;
}
}
if (isDropTR == false)
html += "";
return html;
}
/**
* 获取单元格显示的内容
* @param {any} mapAttr
*/
function InitMapAttrOfCtrlFool(frmData, mapAttr) {
var ccsCtrl = mapAttr.CSSCtrl;
ccsCtrl = ccsCtrl == null || ccsCtrl == undefined || ccsCtrl == "0" ? "" : ccsCtrl;
var suffix = GetPara(mapAttr.AtPara, "suffix");
suffix = suffix == null || suffix == undefined ? "" : suffix;
var eleHtml = "";
//下拉框 外键和外部数据源
if ((mapAttr.LGType == "0" && mapAttr.MyDataType == "1" && mapAttr.UIContralType == 1)
|| (mapAttr.LGType == "2" && mapAttr.MyDataType == "1")) {
var css = "";
if (mapAttr.LGType == "0")
css = "class='ddl-ext'";
var disabled = "";
if (mapAttr.UIIsEnable == 0 || pageData.IsReadonly == 1)
disabled = "disabled='disabled'";
return " " + InitDDLOperation(frmData, mapAttr, "") + " " + suffix + "
";
}
//枚举 单选枚举和下拉框枚举
if (mapAttr.LGType == 1) {
var ses = frmData[mapAttr.KeyOfEn];
if (ses == undefined)
ses = frmData[mapAttr.UIBindKey];
if (ses == undefined) {
//枚举类型的.
if (mapAttr.LGType == 1) {
ses = frmData.Sys_Enum;
ses = $.grep(ses, function (value) {
return value.EnumKey == mapAttr.UIBindKey;
});
}
}
if (mapAttr.UIContralType == 1) {//下拉框显示
var operations = "";
$.each(ses, function (i, obj) {
operations += "" + obj.Lab + " ";
});
var disabled = "";
if (mapAttr.UIIsEnable == 0 || pageData.IsReadonly == 1)
disabled = "disabled='disabled'";
return "" + operations + " " + suffix + "
";
}
if (mapAttr.UIContralType == 2) {//复选框
var rbHtmls = "";
//显示方式,默认为 0=横向展示 3=横向..
var RBShowModel = 0;
if (mapAttr.AtPara.indexOf('@RBShowModel=3') >= 0)
RBShowModel = 3;
for (var i = 0; i < ses.length; i++) {
var se = ses[i];
var br = "";
if (RBShowModel == 0)
br = " ";
var checked = "";
//if (se.IntKey == mapAttr.DefVal)
// checked = " checked=true ";
rbHtmls += " ";
}
return "" + rbHtmls + "
";
}
if (mapAttr.UIContralType == 3) {//单选按钮显示
var rbHtmls = "";
//显示方式,默认为 0=横向展示 3=横向..
var RBShowModel = 0;
if (mapAttr.AtPara.indexOf('@RBShowModel=3') >= 0)
RBShowModel = 3;
for (var i = 0; i < ses.length; i++) {
var se = ses[i];
var br = "";
if (RBShowModel == 0)
br = " ";
var checked = "";
if (se.IntKey == mapAttr.DefVal)
checked = " checked=true ";
rbHtmls += " " + br;
}
return "" + rbHtmls + "
";
}
}
//普通字段
if (mapAttr.LGType == 0) {
switch (parseInt(mapAttr.MyDataType)) {
case 1://普通文本
//获取到当前字段值
var val = ConvertDefVal(frmData, mapAttr.DefVal, mapAttr.KeyOfEn);
switch (parseInt(mapAttr.UIContralType)) {
case 4: //地图
//如果是地图,并且可以编辑
var eleHtml = "";
if (mapAttr.UIIsEnable == 1 && isReadonly == false) {
eleHtml += "选择 ";
eleHtml += " ";
} else {
eleHtml += "选择 ";
eleHtml += " ";
}
eleHtml += "
";
return eleHtml;
case 6://字段附件
return getFieldAth(mapAttr,frmData.Sys_FrmAttachment);
case 8://写字板
var imgPath = "../";
if (currentURL.indexOf("CCBill") != -1 || currentURL.indexOf("CCForm") != -1)
imgPath = "../../";
if (currentURL.indexOf("AdminFrm.htm") != -1)
imgPath = "../../../";
var imgSrc = imgPath + "DataUser/Siganture/UnName.jpg";
//如果是图片签名,并且可以编辑
var ondblclick = ""
if (mapAttr.UIIsEnable == 1 && isReadonly == false) {
ondblclick = " ondblclick='figure_Template_HandWrite(\"" + mapAttr.KeyOfEn + "\",\"" + val + "\")'";
}
val = val || "";
if (val.indexOf("data:image/")==-1)
val = imgPath + val.substring(val.indexOf("DataUser")); var html = " ";
eleHtml += " " + html;
return eleHtml;
case 9://超链接
var val = mapAttr.Tag2;
//替换@符号的数据
val = DealJsonExp(frmData.MainTable[0], val);
return "" + mapAttr.Name + " ";
case 13://身份证
if (mapAttr.KeyOfEn == "IDCardAddress") {
eleHtml = "";
eleHtml += " ";
if (mapAttr.UIIsEnable == 1 && isReadonly == false)
eleHtml += " 上传身份证 ";
eleHtml += "
";
return eleHtml;
}
return "
";
break;
case 16://系统定位
eleHtml = "";
eleHtml += " ";
eleHtml += "
";
return eleHtml;
//return " ";
case 50://工作进度
return "
";
case 101://评分标准
val = val == null || val == undefined || val == "" ? 0 : val;
//如果编辑
var eleHtml = "";
if (mapAttr.UIIsEnable == 1 && isReadonly == false)
eleHtml += "
";
else
eleHtml += "";
var num = mapAttr.Tag2;
var baseUrl = "./";
if (currentURL.indexOf("CCForm") != -1 || currentURL.indexOf("CCBill") != -1)
baseUrl = "../";
if (currentURL.indexOf("AdminFrm.htm") != -1)
baseUrl = "../../";
for (var i = 0; i < val; i++) {
eleHtml += " ";
}
for (var j = 0; j < num - val; j++) {
eleHtml += " ";
}
eleHtml += " " + val + " 分 ";
eleHtml += " ";
eleHtml += " ";
return eleHtml;
case 110: //公文组件
eleHtml = "";
eleHtml += " ";
eleHtml += " ";
eleHtml += "
";
return eleHtml;
default:
//判断是不是富文本编辑器
if (mapAttr.TextModel == 3) {
if (mapAttr.UIIsEnable == "0" || isReadonly == true) {
//使用div展示
var defValue = ConvertDefVal(frmData, mapAttr.DefVal, mapAttr.KeyOfEn);
defValue = defValue.replace(/white-space: nowrap;/g, "");
return "" + defValue + "
";
}
if (richTextType == "tinymce")
return "";
var defValue = ConvertDefVal(frmData, mapAttr.DefVal, mapAttr.KeyOfEn);
//设置一个默认高度
if (mapAttr.UIHeight < 180) {
mapAttr.UIHeight = 180;
}
//设置编辑器的默认样式
var styleText = "text-align:left;font-size:12px;";
styleText += "width:100%;";
var height = parseInt(mapAttr.UIHeight) - 54;
styleText += "height:" + height + "px;";
//注意这里 name 属性是可以用来绑定表单提交时的字段名字的 id 是特殊约定的.
return "";
}
//判断是不是大块文本
if (mapAttr.TextModel == 2) {
return ""
}
var baseUrl = "../";
if (currentURL.indexOf("AdminFrm.htm") != -1)
baseUrl = "../../../";
if (currentURL.indexOf("CCBill") != -1 || currentURL.indexOf("CCForm") != -1)
baseUrl = "../../";
if (mapAttr.IsSigan == "1" && mapAttr.UIIsEnable == 1 && isReadonly != 0) {
var html = " ";
//是否签过
var sealData = new Entities("BP.Tools.WFSealDatas");
sealData.Retrieve("OID", pageData.OID, "FK_Node", GetQueryString("FK_Node"), "SealData", GetQueryString("UserNo"));
if (sealData.length > 0) {
eleHtml += " " + html;
isSigantureChecked = true;
}
else {
eleHtml += " " + html;
}
return eleHtml;
}
//如果不可编辑,并且是图片名称
if (mapAttr.IsSigan == "1") {
var val = ConvertDefVal(frmData, mapAttr.DefVal, mapAttr.KeyOfEn);
var html = " ";
eleHtml += " " + html;
return eleHtml;
}
return "
";
}
break;
case 2://整数
var _html = "";
var minNum = GetPara(mapAttr.AtPara, "NumMin") || "";
var maxNum = GetPara(mapAttr.AtPara, "NumMax") || "";
var dataInfo = "";
if (minNum != "")
dataInfo = " data-min='" + minNum + "'";
if (maxNum != "")
dataInfo += " data-max='" + maxNum + "'";
if (suffix != "") {
_html += " ";
_html += "" + suffix + " ";
} else {
_html += " ";
}
_html += "
";
return _html;
case 4: //复选框
if (mapAttr.UIIsEnable == 0) {
enableAttr = "disabled='disabled'";
} else {
enableAttr = "";
}
return "
";
case 3://浮点
case 5://双精度
var _html = "";
var attrdefVal = mapAttr.DefVal;
var bit;
if (attrdefVal != null && attrdefVal !== "" && attrdefVal.indexOf(".") >= 0)
bit = attrdefVal.substring(attrdefVal.indexOf(".") + 1).length;
else
bit = 2;
var minNum = GetPara(mapAttr.AtPara, "NumMin") || "";
var maxNum = GetPara(mapAttr.AtPara, "NumMax") || "";
var dataInfo = "";
if (minNum != "")
dataInfo = " data-min='" + minNum + "'";
if (maxNum != "")
dataInfo += " data-max='" + maxNum + "'";
if (suffix != "") {
_html += " ";
_html += "" + suffix + " ";
} else {
_html += " ";
}
_html += "
";
return _html;
case 6://日期类型
case 7://时间类型
//生成中间的部分.
var enableAttr = '';
var frmDate = mapAttr.IsSupperText; //获取日期格式
var dateFmt = '';
var dateType = "";
if (frmDate == 0) {
dateFmt = "yyyy-MM-dd";
dateType = "date"
} else if (frmDate == 1) {
dateFmt = "yyyy-MM-dd HH:mm";
dateType = "datetime";
} else if (frmDate == 2) {
dateFmt = "yyyy-MM-dd HH:mm:ss";
dateType = "datetime";
} else if (frmDate == 3) {
dateFmt = "yyyy-MM";
dateType = "month";
} else if (frmDate == 4) {
dateFmt = "HH:mm";
dateType = "time";
} else if (frmDate == 5) {
dateFmt = "HH:mm:ss";
dateType = "time";
} else if (frmDate == 6) {
dateFmt = "MM-dd";
dateType = "date";
}
else if (frmDate == 7) {
dateFmt = "yyyy";
dateType = "year";
}
if (mapAttr.UIIsEnable == 0)
enableAttr = "disabled='disabled' ";
return "
";
case 8://金额
//获取DefVal,根据默认的小数点位数来限制能输入的最多小数位数
var _html = "";
var attrdefVal = mapAttr.DefVal;
var bit;
if (attrdefVal != null && attrdefVal !== "" && attrdefVal.indexOf(".") >= 0)
bit = attrdefVal.substring(attrdefVal.indexOf(".") + 1).length;
else
bit = 2;
var minNum = GetPara(mapAttr.AtPara, "NumMin") || "";
var maxNum = GetPara(mapAttr.AtPara, "NumMax") || "";
var dataInfo = "";
if (minNum != "")
dataInfo = " data-min='" + minNum + "'";
if (maxNum != "")
dataInfo += " data-max='" + maxNum + "'";
if (suffix != "") {
_html += " ";
_html += "" + suffix + " ";
} else {
_html += " ";
}
_html += "
";
return _html;
default: break;
}
}
}
/**
* 获取字段标签
* @param {any} attr
* @param {any} frmData
*/
function GetLab(attr, frmData) {
var lab = "";
var forID = "TB_" + attr.KeyOfEn;
var contralType = attr.UIContralType;
var ccsLab = attr.CSSLabel;
ccsLab = ccsLab == null || ccsLab == undefined || ccsLab == "0" ? "" : ccsLab;
switch (parseInt(contralType)) {
case 0://文本
case 1://下拉框
case 2://复选框
case 3://单选按钮
case 4://地图
case 6://字段附件
case 8://手写签字版
case 13://身份证号
case 14://签批字段
case 50: //流程进度图
case 101://评分
if (contralType == 1)//外键下拉框
forID = "DDL_" + attr.KeyOfEn;
if (contralType == 3)//枚举
forID = "RB_" + attr.KeyOfEn;
if (contralType == 2)//枚举复选框
forID = "CB_" + attr.KeyOfEn;
ccsLab += " layui-form-label"
if (attr.UIIsInput == 1 && attr.UIIsEnable == 1) {
lab = " * ";
ccsLab += " mustInput ";
}
lab += "" + attr.Name + " ";
return lab;
case 9://超链接
var url = attr.Tag2;
//替换URL中的参数
var pageParams = getQueryString();
$.each(pageParams, function (i, pageParam) {
var pageParamArr = pageParam.split('=');
url = url.replace("@" + pageParamArr[0], pageParamArr[1]);
});
//替换表单中的参数
$.each(frmData.Sys_MapAttr, function (i, obj) {
if (url != null && url.indexOf('@' + obj.KeyOfEn) > 0) {
url = url.replace('@' + obj.KeyOfEn, frmData.MainTable[0][obj.KeyOfEn]);
}
});
url = url.indexOf("?") == -1 ? url + "?1=1" : url;
if (url.indexOf("Search.htm") != -1)
url = url + "&FK_Node=" + pageData.FK_Node + "&FK_Flow=" + pageData.FK_Flow + "&UserNo=" + webUser.No + "&Token=" + webUser.Token;
else
url = url + "&UserNo=" + webUser.No + "&Token=" + webUser.Token;
if (url.indexOf('OID=') == -1)
url += "&OID=" + frmData.MainTable[0].OID;
if (url.indexOf('WorkID=') == -1)
url += "&WorkID=" + frmData.MainTable[0].OID;
if (url.indexOf('FrmID=') == -1)
url += "&FrmID=" + attr.FK_MapData;
return '' + attr.Name + ' ';
case 11://图片(只显示)
//获取图片控件的信息
var frmImg = new Entity("BP.Sys.FrmUI.ExtImg");
frmImg.SetPKVal(attr.MyPK);
var count = frmImg.RetrieveFromDBSources();
if (count == 0) {
layer.alert("主键为" + attr.MyPK + "名称为" + attr.Name + "的图片控件信息丢失,请联系管理员111");
return "";
}
//解析图片
if (frmImg.ImgAppType == 0) { //图片类型
//数据来源为本地.
var imgSrc = '';
if (frmImg.ImgSrcType == 0) {
//替换参数
var frmPath = frmImg.ImgPath;
frmPath = frmPath.replace('@', '@');
frmPath = frmPath.replace('@basePath', basePath);
frmPath = frmPath.replace('@basePath', basePath);
imgSrc = DealJsonExp(frmData.MainTable[0], frmPath);
}
//数据来源为指定路径.
if (frmImg.ImgSrcType == 1) {
var url = frmImg.ImgURL;
url = url.replace('@', '@');
url = url.replace('@basePath', basePath);
imgSrc = DealJsonExp(frmData.MainTable[0], url);
}
// 由于火狐 不支持onerror 所以 判断图片是否存在放到服务器端
if (imgSrc == "" || imgSrc == null)
imgSrc = "../DataUser/ICON/CCFlow/LogBig.png";
var style = "text-align:center;";
if (attr.UIWidth == 0)
style += "width:100%;";
else
style += "width:" + attr.UIWidth + "px;";
if (attr.UIHeight == 0)
style += "Height:100%;";
else
style += "Height:" + attr.UIHeight + "px;";
return " ";
}
break;
case 12://单图片附件(可以上传)
//获取图片控件的信息
if (frmData.Sys_FrmImgAth == undefined || frmData.Sys_FrmImgAth.length == 0)
return;
var frmImgs = $.grep(frmData.Sys_FrmImgAth, function (item, i) {
return item.MyPK == attr.MyPK;
});
if (frmImgs.length == 0) {
alert("主键为" + attr.MyPK + "名称为" + attr.Name + "的图片控件信息丢失,请联系管理员");
return "";
}
var frmImg = frmImgs[0];
var imgSrc = basePath + "/DataUser/ICON/CCFlow/LogBig.png";
//获取数据
if (frmImg.FK_MapData.indexOf("ND") != -1)
imgSrc = basePath + "/DataUser/ImgAth/Data/" + frmImg.CtrlID + "_" + pageData.WorkID + ".png";
else
imgSrc = basePath + "/DataUser/ImgAth/Data/" + frmImg.FK_MapData + "_" + frmImg.CtrlID + "_" + pageData.WorkID + ".png";
var _html = "";
if (frmImg.IsEdit == "1" && pageData.IsReadonly != "1") {
var url = dynamicHandler + "?DoType=HttpHandler&DoMethod=FrmImgAthDB_Upload&HttpHandlerName=BP.WF.HttpHandler.WF_CCForm&FK_MapData=" + frmData.Sys_MapData[0].No + "&CtrlID=" + frmImg.CtrlID + "&RefPKVal=" + pageData.WorkID
_html += "";
_html += "
";
_html += "";
_html += ' 修改图片123
';
_html += " ";
_html += " ";
_html += " ";
_html += "
";
return _html;
} else {
_html += "";
_html += "
";
_html += "
";
return _html;
}
break;
case 18://按钮
return "" + attr.Name + " "
default:
return "";
}
}
//初始化 框架
function Ele_Frame(frmData, gf) {
var frame = null;
try {
frame = new Entity("BP.Sys.MapFrame", gf.CtrlID);
} catch (e) {
layer.alert("没有找到框架的定义,请与管理员联系。");
return;
}
if (frame == null)
return;
//获取框架的类型 0 自定义URL 1 地图开发 2流程轨迹表 3流程轨迹图
var urlType = frame.UrlSrcType;
var eleHtml = '';
var url = "";
if (urlType == 0) {
url = frame.URL;
if (url.indexOf('?') == -1)
url += "?1=2";
if (url.indexOf("@basePath") == 0)
url = url.replace("@basePath", basePath);
//2.替换@参数
var pageParams = getQueryString();
$.each(pageParams, function (i, pageParam) {
var pageParamArr = pageParam.split('=');
url = url.replace("@" + pageParamArr[0], pageParamArr[1]);
});
//3.替换表单中的参数
var src = url.replace(new RegExp(/(:)/g), ':');
if (src.indexOf("?") > 0) {
var params = getQueryStringFromUrl(src);
if (params != null && params.length > 0) {
$.each(params, function (i, param) {
if (param.indexOf('@') != -1) {//是需要替换的参数
paramArr = param.split('=');
if (paramArr.length == 2 && paramArr[1].indexOf('@') == 0) {
if (paramArr[1].indexOf('@WebUser.') == 0)
url = url.replace(paramArr[1], flowData.MainTable[0][paramArr[1].substr('@WebUser.'.length)]);
else
url = url.replace(paramArr[1], flowData.MainTable[0][paramArr[1].substr(1)]);
}
}
});
}
}
//处理URL需要的参数
//1.拼接参数
var paras = this.pageData;
var strs = "";
for (var str in paras) {
if (str == "EnsName" || str == "RefPKVal" || str == "IsReadonly")
continue
else
strs += "&" + str + "=" + paras[str];
}
url = url + strs + "&IsReadonly=0";
//4.追加GenerWorkFlow AtPara中的参数
var gwf = frmData.WF_GenerWorkFlow;
if (gwf != null && gwf != undefined) {
gwf = gwf[0];
var atPara = gwf.AtPara;
if (atPara != null && atPara != "") {
atPara = atPara.replace(/@/g, '&');
url = url + atPara;
}
}
}
var baseUrl = "./";
if (currentURL.indexOf("AdminFrm.htm") != -1)
baseUrl = "../../";
if (currentURL.indexOf("CCBill") != -1 || currentURL.indexOf("CCForm") != -1)
baseUrl = "../";
if (urlType == 2) //轨迹表
url = baseUrl + "WorkOpt/OneWork/Table.htm?FK_Node=" + pageData.FK_Node + "&FK_Flow=" + pageData.FK_Flow + "&WorkID=" + pageData.WorkID + "&FID=" + pageData.FID;
if (urlType == 3)//轨迹图
url = baseUrl + "WorkOpt/OneWork/TimeBase.htm?FK_Node=" + pageData.FK_Node + "&FK_Flow=" + pageData.FK_Flow + "&WorkID=" + pageData.WorkID + "&FID=" + pageData.FID;
eleHtml += "" + '';
return eleHtml;
}
//初始化从表
function Ele_Dtl(frmDtl, isComPare) {
if (isComPare == true)
return "";
var src = "";
var href = GetHrefUrl();
var urlParam = href.substring(href.indexOf('?') + 1, href.length);
urlParam = urlParam.replace('&DoType=', '&DoTypeDel=xx');
var ensName = frmDtl.No;
if (ensName == undefined) {
layer.alert('系统错误,请找管理员联系');
return;
}
var baseUrl = "./CCForm/";
if (currentURL.indexOf("AdminFrm.htm") != -1)
baseUrl = "../../CCForm/";
if (currentURL.indexOf("MyBill.htm") != -1 || currentURL.indexOf("MyDict.htm") != -1)
baseUrl = "../CCForm/";
if (currentURL.indexOf("FrmGener.htm") != -1 || currentURL.indexOf("FrmDBVer.htm") != -1 || currentURL.indexOf("DtlFrm.htm") != -1)
baseUrl = "./";
//表格模式
if (frmDtl.ListShowModel == "0")
src = baseUrl + "Dtl2017.htm?1=1";
if (frmDtl.ListShowModel == "1")
src = baseUrl + "DtlCard.htm?1=1";
if (frmDtl.ListShowModel == "2") {
if (frmDtl.UrlDtl == null || frmDtl.UrlDtl == undefined || frmDtl.UrlDtl == "")
return "从表" + frmDtl.Name + "没有设置URL,请在" + frmDtl.FK_MapData + "_Self.js中解析";
src = basePath + "/" + frmDtl.UrlDtl;
if (src.indexOf("?") == -1)
src += "?1=1";
}
var refpk = this.pageData.WorkID;
if (refpk == undefined)
refpk = pageData.OID;
src += "&EnsName=" + frmDtl.No + "&RefPKVal=" + refpk + "&FK_MapData=" + frmDtl.FK_MapData + "&IsReadonly=" + (isReadonly == true ? 1 : 0) + "&" + urlParam + "&Version=1&FrmType=0";
return "";
}
/**
* 获取表单显示的列数
* @param {any} tableColType
*/
function getTableCol(tableColType) {
tableColType = tableColType || 0;
switch (parseInt(tableColType)) {
case 0:
return 4;
case 1:
return 6;
case 2:
return 3;
default:
return 4;
}
}
/**
* 获取字段占的列数
* @param {any} colSpan
* @param {any} tabCol
*/
function getColSpanClass(colSpan, tabCol) {
colSpan = colSpan || 1;
if (tabCol == 4) {
switch (parseInt(colSpan)) {
case 1:
return "layui-col-sm4 layui-col-md4 layui-col-xs8";
case 2:
return "layui-col-sm6 layui-col-md6 layui-col-xs8";
case 3:
return "layui-col-sm10 layui-col-md10 layui-col-xs8";
case 4:
return "layui-col-sm12 layui-col-md12 layui-col-xm12";
default:
return "layui-col-sm4 layui-col-md4 layui-col-xs8";
}
}
if (tabCol == 6) {
switch (parseInt(colSpan)) {
case 1:
return "layui-col-xs2";
case 2:
return "layui-col-xs4";
case 3:
return "layui-col-xs6";
case 4:
return "layui-col-xs8";
case 5:
return "layui-col-xs10";
case 6:
return "layui-col-xs12";
default:
return "layui-col-xs2";
}
}
}
/**
* 获取标签占的列数
* @param {any} LabelColSpan
* @param {any} tabCol
*/
function getLabelColSpanClass(LabelColSpan, tabCol) {
LabelColSpan = LabelColSpan || 1;
if (tabCol == 4) {
switch (parseInt(LabelColSpan)) {
case 1:
return "layui-col-sm2 layui-col-md2 layui-col-xs4";
case 2:
return "layui-col-sm6 layui-col-md6 layui-col-xs4";
case 3:
return "layui-col-sm8 layui-col-md8 layui-col-xs4";
case 4:
return "layui-col-sm12 layui-col-md12 layui-col-xs12";
default:
return "layui-col-sm2 layui-col-md2 layui-col-xs4";
}
}
if (tabCol == 6) {
switch (parseInt(LabelColSpan)) {
case 1:
return "layui-col-xs2";
case 2:
return "layui-col-xs4";
case 3:
return "layui-col-xs6";
case 4:
return "layui-col-xs8";
case 5:
return "layui-col-xs10";
case 6:
return "layui-col-xs12";
default:
return "layui-col-xs2";
}
}
}