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.

258 lines
13 KiB
Plaintext

function InitMapAttrOfCtrl(mapAttr, frmData) {
var defValue = mapAttr.DefVal;
var eleHtml = '';
//外部数据源类型.
if (mapAttr.LGType == "0" && mapAttr.MyDataType == "1" && mapAttr.UIContralType == "1") {
//枚举类型.
if (mapAttr.UIIsEnable == 1)
enableAttr = "";
else
enableAttr = "disabled='disabled'";
return "<select id='DDL_" + mapAttr.KeyOfEn + "' name='DDL_" + mapAttr.KeyOfEn + "' " + (mapAttr.UIIsEnable == 1 ? '' : 'disabled="disabled"') + " class='layui-input'>" + InitDDLOperation(frmData, mapAttr, defValue) + "</select>";
}
//外键类型.
if (mapAttr.LGType == "2" && mapAttr.MyDataType == "1") {
//枚举类型.
if (mapAttr.UIIsEnable == 1)
enableAttr = "";
else
enableAttr = "disabled='disabled'";
//判断外键是否为树形结构
var uiBindKey = mapAttr.UIBindKey;
if (uiBindKey != null && uiBindKey != undefined && uiBindKey != "") {
var sfTable = new Entity("BP.Sys.SFTable");
sfTable.SetPKVal(uiBindKey);
var count = sfTable.RetrieveFromDBSources();
if (count != 0 && sfTable.CodeStruct == "1") {
return "<select id='DDL_" + mapAttr.KeyOfEn + "' class='easyui-combotree' style='width:" + parseInt(mapAttr.UIWidth) * 2 + "px;height:28px' class='layui-input'></select>";
}
}
return "<select id='DDL_" + mapAttr.KeyOfEn + "' name='DDL_" + mapAttr.KeyOfEn + "' " + (mapAttr.UIIsEnable == 1 ? '' : 'disabled="disabled"') + " class='layui-input'>" + InitDDLOperation(frmData, mapAttr, defValue) + "</select>";
}
//外部数据类型.
if (mapAttr.LGType == "0" && mapAttr.MyDataType == "1" && mapAttr.UIContralType == 1) {
//枚举类型.
if (mapAttr.UIIsEnable == 1)
enableAttr = "";
else
enableAttr = "disabled='disabled'";
if (mapAttr.UIContralType == 1)
return "<select id='DDL_" + mapAttr.KeyOfEn + "' name='DDL_" + mapAttr.KeyOfEn + "' " + (mapAttr.UIIsEnable == 1 ? '' : 'disabled="disabled"') + " class='layui-input'>" + InitDDLOperation(frmData, mapAttr, defValue) + "</select>";
if (mapAttr.UIContralType == 3) {
//横向排列
var RBShowModel = 3;
if (mapAttr.AtPara.indexOf("@RBShowModel=3") == -1)
RBShowModel = 0;
return InitRBShowContent(frmData, mapAttr, defValue, RBShowModel, enableAttr);
}
}
//添加文本框 ,日期控件等
//AppString
if (mapAttr.MyDataType == "1" && mapAttr.UIContralType == 0) { //不是外键
if (mapAttr.UIHeight <= 40) //普通的文本框.
{
//如果是图片签名,并且可以编辑
if (mapAttr.IsSigan == "1" && mapAttr.UIIsEnable == 1) {
var html = "<input maxlength=" + mapAttr.MaxLen + " id='TB_" + mapAttr.KeyOfEn + "' value='" + defValue + "' type=hidden />";
//是否签过
var sealData = new Entities("BP.Tools.WFSealDatas");
sealData.Retrieve("OID", GetQueryString("WorkID"), "FK_Node", GetQueryString("FK_Node"), "SealData", GetQueryString("UserNo"));
if (sealData.length > 0) {
eleHtml += "<img src='../../DataUser/Siganture/" + defValue + ".jpg' alt='" + defValue+"' style='border:0px;width:100px;height:30px;' id='Img" + mapAttr.KeyOfEn + "' />" + html;
isSigantureChecked = true;
}
else {
eleHtml += "<img src='../../DataUser/Siganture/siganture.jpg' onerror=\"this.src='../../DataUser/Siganture/UnName.jpg'\" ondblclick='figure_Template_Siganture(\"" + mapAttr.KeyOfEn + "\",\"" + defValue + "\")' style='border:0px;width:100px;height:30px;' id='Img" + mapAttr.KeyOfEn + "' />" + html;
}
return eleHtml;
}
//如果不可编辑,并且是图片名称
if (mapAttr.IsSigan == "1") {
var val = ConvertDefVal(frmData, mapAttr.DefVal, mapAttr.KeyOfEn);
var html = "<input maxlength=" + mapAttr.MaxLen + " id='TB_" + mapAttr.KeyOfEn + "' value='" + val + "' type=hidden />";
eleHtml += "<img src='../../DataUser/Siganture/" + val + ".jpg' onerror=\"this.src='../../DataUser/Siganture/siganture.jpg'\" style='border:0px;width:100px;height:30px;' id='Img" + mapAttr.KeyOfEn + "' />" + html;
return eleHtml;
}
var enableAttr = '';
if (mapAttr.UIIsEnable == 0)
enableAttr = "disabled='disabled'";
return "<input id='TB_" + mapAttr.KeyOfEn + "' maxlength=" + mapAttr.MaxLen + " name='TB_" + mapAttr.KeyOfEn + "' style='width:100%;height:28px;' type='text' " + enableAttr + "' placeholder='" + (mapAttr.Tip || '') + "' class='layui-input'/>";
}
if (mapAttr.AtPara && mapAttr.AtPara.indexOf("@IsRichText=1") >= 0) {
var eleHtml = "";
//如果是富文本就使用百度 UEditor
if (mapAttr.UIIsEnable == "0") {
//只读状态直接 div 展示富文本内容
//eleHtml += "<script id='" + editorPara.id + "' name='TB_" + mapAttr.KeyOfEn + "' type='text/plain' style='" + styleText + "'>" + defValue + "</script>";
//eleHtml += "<div class='richText' style='width:" + mapAttr.UIWidth + "px'>" + defValue + "</div>";
eleHtml += "<div class='richText'>" + defValue + "</div>";
} else {
document.BindEditorMapAttr = mapAttr; //存到全局备用.
//设置编辑器的默认样式
var styleText = "text-align:left;font-size:12px;";
styleText += "width:100%;";
styleText += "height:" + mapAttr.UIHeight + "px;";
//注意这里 name 属性是可以用来绑定表单提交时的字段名字的
eleHtml += "<script id='editor' name='TB_" + mapAttr.KeyOfEn + "' type='text/plain' style='" + styleText + "'>" + defValue + "</script>";
}
eleHtml = "<div style='white-space:normal;'>" + eleHtml + "</div>";
return eleHtml
}
//普通的大块文本.
return "<textarea maxlength=" + mapAttr.MaxLen + " style='height:" + mapAttr.UIHeight + "px;width:100%;' name='TB_" + mapAttr.KeyOfEn + "' id='TB_" + mapAttr.KeyOfEn + "' type='text' " + (mapAttr.UIIsEnable == 1 ? '' : ' disabled="disabled"') + " class='layui-input'/>"
}
if (mapAttr.MyDataType == "1" && mapAttr.UIContralType == 8) {
//如果是图片签名,并且可以编辑
var ondblclick = ""
if (mapAttr.UIIsEnable == 1) {
ondblclick = " ondblclick='figure_Template_HandWrite(\"" + mapAttr.KeyOfEn + "\",\"" + defValue + "\")'";
}
var html = "<input maxlength=" + mapAttr.MaxLen + " id='TB_" + mapAttr.KeyOfEn + "' value='" + defValue + "' type=hidden />";
eleHtml += "<img src='" + defValue + "' " + ondblclick + " onerror=\"this.src='../../DataUser/Siganture/UnName.jpg'\" style='border:0px;width:" + mapAttr.UIWidth + "px;height:" + mapAttr.UIHeight + "px;' id='Img" + mapAttr.KeyOfEn + "' />" + html;
return eleHtml;
}
//日期类型.
if (mapAttr.MyDataType == 6) {
var enableAttr = '';
if (mapAttr.UIIsEnable == 1)
enableAttr = 'onfocus="WdatePicker({dateFmt:' + "'yyyy-MM-dd'})" + '";';
else
enableAttr = "disabled='disabled'";
return "<input " + enableAttr + " style='width:120px;' name='TB_" + mapAttr.KeyOfEn + "' id='TB_" + mapAttr.KeyOfEn + "' type='text' class='Wdate' placeholder='" + (mapAttr.Tip || '') + "' class='layui-input'/>";
}
//时期时间类型.
if (mapAttr.MyDataType == 7) {
var enableAttr = '';
if (mapAttr.UIIsEnable == 1)
enableAttr = 'onfocus="WdatePicker({dateFmt:' + "'yyyy-MM-dd HH:mm'})" + '";';
else
enableAttr = "disabled='disabled'";
return "<input id='TB_" + mapAttr.KeyOfEn + "' class='Wdate' type='text' style='width:160px;' " + enableAttr + " name='TB_" + mapAttr.KeyOfEn + "' placeholder='" + (mapAttr.Tip || '') + "' class='layui-input'/>";
}
// boolen 类型.
if (mapAttr.MyDataType == 4) { // AppBoolean = 7
if (mapAttr.UIIsEnable == 1)
enableAttr = "";
else
enableAttr = "disabled='disabled'";
//CHECKBOX 默认值
var checkedStr = '';
if (checkedStr != "true" && checkedStr != '1') {
checkedStr = ' checked="checked" ';
}
checkedStr = ConvertDefVal(frmData, '', mapAttr.KeyOfEn);
return "<input " + enableAttr + " " + (defValue == 1 ? "checked='checked'" : "") + " type='checkbox' id='CB_" + mapAttr.KeyOfEn + "' name='CB_" + mapAttr.KeyOfEn + "' " + checkedStr + " /><label for='CB_" + mapAttr.KeyOfEn + "' >" + mapAttr.Name + "</label>";
}
//枚举类型.
if (mapAttr.MyDataType == 2 && mapAttr.LGType == 1) { //AppInt Enum
//枚举类型.
if (mapAttr.UIIsEnable == 1)
enableAttr = "";
else
enableAttr = "disabled='disabled'";
if (mapAttr.UIContralType == 1)
return "<select id='DDL_" + mapAttr.KeyOfEn + "' name='DDL_" + mapAttr.KeyOfEn + "' " + (mapAttr.UIIsEnable == 1 ? '' : 'disabled="disabled"') + " class='layui-input'>" + InitDDLOperation(frmData, mapAttr, defValue) + "</select>";
if (mapAttr.UIContralType == 3) {
//横向排列
var RBShowModel = 3;
if (mapAttr.AtPara.indexOf("@RBShowModel=3") == -1)
RBShowModel = 0;
return InitRBShowContent(frmData, mapAttr, defValue, RBShowModel, enableAttr);
}
/*if (mapAttr.UIIsEnable == 1)
enableAttr = "";
else
enableAttr = "disabled='disabled'";
return "<select name='DDL_" + mapAttr.KeyOfEn + "' " + (mapAttr.UIIsEnable == 1 ? '' : 'disabled="disabled"') + ">" + InitDDLOperation(frmData, mapAttr, defValue) + "</select>";
*/
}
// AppDouble AppFloat
if (mapAttr.MyDataType == 5 || mapAttr.MyDataType == 3) {
var enableAttr = '';
if (mapAttr.UIIsEnable != 1)
enableAttr = "disabled='disabled'";
//获取DefVal,根据默认的小数点位数来限制能输入的最多小数位数
var defVal = mapAttr.DefVal;
var bit;
if (defVal != null && defVal !== "" && defVal.indexOf(".") >= 0)
bit = defVal.substring(defVal.indexOf(".") + 1).length;
// alert(mapAttr.KeyOfEn);
return "<input style='text-align:right;width:125px;' onkeyup=" + '"' + "if(!(value.indexOf('-')==0&&value.length==1)&&isNaN(value)) execCommand('undo');limitLength(this," + bit + ");" + '"' + " onafterpaste=" + '"' + "if(isNaN(value))execCommand('undo')" + '"' + " maxlength=" + mapAttr.MaxLen / 2 + " type='text'" + enableAttr + " name='TB_" + mapAttr.KeyOfEn + "' id='TB_" + mapAttr.KeyOfEn + "' placeholder='" + (mapAttr.Tip || '') + "' class='layui-input'/>";
}
if ((mapAttr.MyDataType == 2)) { //AppInt
var enableAttr = '';
if (mapAttr.UIIsEnable != 1) {
enableAttr = "disabled='disabled'";
}
return "<input style='text-align:right;width:125px;' onkeyup=" + '"' + "if(!(value.indexOf('-')==0&&value.length==1)&&isNaN(value)) || (value%1 !== 0))execCommand('undo')" + '"' + " onafterpaste=" + '"' + "if(isNaN(value) || (value%1 !== 0))execCommand('undo')" + '"' + " maxlength=" + mapAttr.MaxLen / 2 + " type='text'" + enableAttr + " name='TB_" + mapAttr.KeyOfEn + "' id='TB_" + mapAttr.KeyOfEn + "' placeholder='" + (mapAttr.Tip || '') + "' class='layui-input'/>";
}
//AppMoney AppRate
if (mapAttr.MyDataType == 8) {
var enableAttr = '';
if (mapAttr.UIIsEnable == 1) {
} else {
enableAttr = "disabled='disabled'";
}
//获取DefVal,根据默认的小数点位数来限制能输入的最多小数位数
var defVal = mapAttr.DefVal;
var bit;
if (defVal != null && defVal !== "" && defVal.indexOf(".") >= 0)
bit = defVal.substring(defVal.indexOf(".") + 1).length;
else
bit = 2;
return "<input style='text-align:right;' onkeyup=" + '"' + "if(isNaN(value))execCommand('undo');limitLength(this," + bit + ");" + '"' + " onafterpaste=" + '"' + "if(isNaN(value))execCommand('undo')" + '"' + " maxlength=" + mapAttr.MaxLen / 2 + " type='text'" + enableAttr + " name='TB_" + mapAttr.KeyOfEn + "' id='TB_" + mapAttr.KeyOfEn + "' value='0.00' placeholder='" + (mapAttr.Tip || '') + "' class='layui-input'/>";
}
alert(mapAttr.Name + "的类型没有判断.");
return;
}