var FieldTypeS = { Normal: 0, Enum: 1, FK: 2, WinOpen: 3 }, FormDataType = { AppString: 1, AppInt: 2, AppFloat: 3, AppBoolean: 4, AppDouble: 5, AppDate: 6, AppDateTime: 7, AppMoney: 8, AppRate: 9 }, UIContralType = { TB: 0, DDL: 1, CheckBok: 2, RadioBtn: 3, MapPin: 4, MicHot: 5 }; //解析表单字段 MapAttr function InitDtlMapAttr(Sys_MapAttr, groupID, frmData, isReadonly, type, dtlIndx) { isReadonly = isReadonly || "0"; var _html = ""; $.grep(Sys_MapAttr, function (item) { if (type == 'dtl' || type == 'refmethod' || type == 'dtls') return item.IsEnableInAPP != 0 && item.UIVisible != 0; else return item.IsEnableInAPP != 0 && item.UIVisible != 0 && (item.GroupID == groupID || GetPara(item.AtPara, "GroupName") == groupID); }).forEach(function (attr) { //图片签名 if (attr.IsSigan == "1") { _html += "
"; _html += FormUtils.CreateSignPicture(attr); _html += "
"; return; } //加载其他数据控件 switch (attr.LGType) { case FieldTypeS.Normal: //输出普通类型字段 if (attr.UIContralType == UIContralType.DDL) { //判断外部数据或WS类型. _html += "
"; _html += DtlFormUtils.CreateDDLPK(attr, frmData, isReadonly, type, dtlIndx); break; } switch (attr.MyDataType) { case FormDataType.AppString: _html += DtlFormUtils.CreateTBString(attr, frmData, isReadonly, type, dtlIndx); break; case FormDataType.AppInt: _html += "
"; _html += DtlFormUtils.CreateTBInt(attr, frmData, isReadonly, type, dtlIndx); break; case FormDataType.AppFloat: case FormDataType.AppDouble: case FormDataType.AppMoney: _html += "
"; _html += DtlFormUtils.CreateTBFloat(attr, frmData, isReadonly, type, dtlIndx); break; case FormDataType.AppDate: //日期\boolen型的不允许获取焦点,所以只能禁用 _html += "
"; _html += DtlFormUtils.CreateTBDate(attr, frmData, isReadonly, type, dtlIndx); break; case FormDataType.AppDateTime: //日期\boolen型的不允许获取焦点,所以只能禁用 _html += "
"; _html += DtlFormUtils.CreateTBDateTime(attr, frmData, isReadonly, type, dtlIndx); break; case FormDataType.AppBoolean: //日期\boolen型的不允许获取焦点,所以只能禁用 _html += "
"; _html += DtlFormUtils.CreateCBBoolean(attr, frmData, isReadonly, type, dtlIndx); break; } break; case FieldTypeS.Enum: //枚举值下拉框 if (attr.Name.length >= 10) { // var ctrl_ID = "RB_" + attr.KeyOfEn; // if (attr.UIContralType == UIContralType.DDL) { var ctrl_ID = "DDL_" + attr.KeyOfEn; if (type == 'dtls') ctrl_ID += "_" + dtlIndex; _html += ""; _html += "
"; _html += ""; } else { _html += "
"; _html += DtlFormUtils.CreateDDLEnum(attr, frmData, isReadonly, type, dtlIndx); } break; case FieldTypeS.FK: //外键表下拉框 if (attr.Name.length >= 10) { _html += DtlFormUtils.CreateDDLPK(attr, frmData, isReadonly, type, dtlIndx); } else { _html += "
"; _html += DtlFormUtils.CreateDDLPK(attr, frmData, isReadonly, type, dtlIndx); } break; case FieldTypeS.WinOpen: //打开系统页面 _html += "
"; switch (item.UIContralType) { case UIContralType.MapPin: //地图定位 _html += DtlFormUtils.CreateMapPin(attr, frmData, isReadonly, type, dtlIndx); break; case UIContralType.MicHot: //语音控件 _html += DtlFormUtils.CreateMicHot(attr, frmData, isReadonly, type, dtlIndx); break; } break; } _html += "
"; }); return _html; } var DtlFormUtils = { CreateSignPicture: function (attr, frmData, isReadonly, type, dtlIndx) { //图片签名 var elementId = "Sign_" + attr.KeyOfEn; if (type == "dtls") elementId = "Sign_" + dtlIndx + "_" + attr.KeyOfEn; var val = ConvertDefVal(frmData, attr.DefVal, attr.KeyOfEn); var html_Sign = ""; html_Sign += "
"; html_Sign += ""; // html_Sign += defValue; html_Sign += "
"; return html_Sign; }, CreateTBString: function (attr, frmData, isReadonly, type, dtlIndx) { var html_string = ""; var strPlaceholder = "请输入"; if (attr.UIIsEnable == "0") strPlaceholder = ""; var elementId = "TB_" + attr.KeyOfEn; if (type == "dtls") elementId = "TB_" + dtlIndx + "_" + attr.KeyOfEn; var mustInput = attr.UIIsInput == 1 || (type == "en" && attr.MinLen > 0) ? '*' : ""; //启用二维码 if (attr.IsEnableQrCode && attr.IsEnableQrCode == "1") { html_string += "
"; strPlaceholder = "通过扫一扫添加"; Form_Ext_Function += "$('#Btn_" + attr.KeyOfEn + "').on('tap', function () { QrCodeToInput('" + elementId + "'); });" html_string += ""; html_string += "
"; html_string += "
"; html_string += " "; html_string += "
"; html_string += "
"; html_string += "
"; html_string += " "; html_string += "
"; html_string += "
"; html_string += "
"; return html_string; } //大文本备注信息解析 if (attr.UIContralType == 60) { html_string += "
"; var filename = basePath + "/DataUser/CCForm/BigNoteHtmlText/" + attr.FK_MapData + ".htm"; var htmlobj = $.ajax({ url: filename, async: false }); var str = htmlobj.responseText; if (htmlobj.status == 404) str == ""; html_string += str; html_string += "
"; return html_string; } //多行文本 if (attr.UIHeight > 30) { html_string += "
"; html_string += ""; //if (attr.AtPara && attr.AtPara.indexOf("@IsRichText=1") >= 0) { // //如果富文本有数据,就用 div 展示html // //html_string += "
"; // html_string += ""; //} else { //非富文本或者 如果没有数据 就用textarea if (attr.UIIsEnable == "0" || isReadonly == "1") html_string += "
"; else html_string += ""; //} return html_string; } //单行文本 if ((attr.UIIsInput == 1 || (type == "en" && attr.MinLen > 0)) && attr.UIIsEnable == 1) { html_string += "
"; html_string += ""; } else { html_string += "
"; html_string += ""; } if (attr.UIIsEnable == "0" || isReadonly == "1") { html_string += ""; } else { html_string += ""; } return html_string; }, CreateTBInt: function (attr, frmData, isReadonly, type, dtlIndx) { var elementId = "TB_" + attr.KeyOfEn; if (type == "dtls") elementId = "TB_" + dtlIndx + "_" + attr.KeyOfEn; var mustInput = attr.UIIsInput == 1 ? '*' : ""; var inputHtml = ""; if (attr.UIIsEnable == "0" || isReadonly == "1") inputHtml += ""; else { inputHtml += ""; } return inputHtml; }, CreateTBFloat: function (attr, frmData, isReadonly, type, dtlIndx) { var elementId = "TB_" + attr.KeyOfEn; if (type == "dtls") elementId = "TB_" + dtlIndx + "_" + attr.KeyOfEn; var attrdefVal = attr.DefVal; var bit; if (attrdefVal != null && attrdefVal !== "" && attrdefVal.indexOf(".") >= 0) bit = attrdefVal.substring(attrdefVal.indexOf(".") + 1).length; else bit = 2; var event = ""; if (attr.UIIsEnable == "1") { if (attr.MyDataType == 8) event = " onkeyup=\"valitationAfter(this, 'money');limitLength(this," + bit + "); FormatMoney(this, " + bit + ", ',')\""; else event = " onkeyup=\"valitationAfter(this, 'float');if(isNaN(value)) execCommand('undo');limitLength(this," + bit + ");\"" + " onafterpaste=\"valitationAfter(this, 'float');if(isNaN(value))execCommand('undo');\""; } var mustInput = attr.UIIsInput == 1 ? '*' : ""; var inputHtml = ""; if (attr.UIIsEnable == "0" || isReadonly == "1") inputHtml += ""; else inputHtml += ""; return inputHtml; }, CreateTBDate: function (attr, frmData, isReadonly, type, dtlIndx) { var elementId = "TB_" + attr.KeyOfEn; if (type == "dtls") elementId = "TB_" + dtlIndx + "_" + attr.KeyOfEn; var labID = "LAB_" + attr.KeyOfEn; if (type == "dtls") labID = "LAB_" + dtlIndx + "_" + attr.KeyOfEn; var mustInput = attr.UIIsInput == 1 ? '*' : ""; var inputHtml = ""; if (attr.UIIsEnable == "0" || isReadonly == 1) { inputHtml += ""; } else { inputHtml += ""; inputHtml += "

请选择日期

"; inputHtml += "
"; inputHtml += ""; } return inputHtml; }, CreateTBDateTime: function (attr, frmData, isReadonly, type, dtlIndx) { var elementId = "TB_" + attr.KeyOfEn; if (type == "dtls") elementId = "TB_" + dtlIndx + "_" + attr.KeyOfEn; var labID = "LAB_" + attr.KeyOfEn; if (type == "dtls") labID = "LAB_" + dtlIndx + "_" + attr.KeyOfEn; var mustInput = attr.UIIsInput == 1 ? '*' : ""; var inputHtml = ""; if (attr.UIIsEnable == "0" || isReadonly == 1) { inputHtml += ""; } else { inputHtml += ""; inputHtml += " "; inputHtml += ""; inputHtml += ""; } return inputHtml; }, CreateCBBoolean: function (attr, frmData, isReadonly, type, dtlIndx) { var elementId = "CB_" + attr.KeyOfEn; if (type == "dtls") elementId = "CB_" + dtlIndx + "_" + attr.KeyOfEn; var switchId = "SW_" + attr.KeyOfEn; if (type == "dtls") switchId = "SW_" + dtlIndx + "_" + attr.KeyOfEn; var checkBoxVal = ""; var keyOfEn = attr.KeyOfEn; var CB_Html = ""; CB_Html += " "; CB_Html += " "; if (attr.UIIsEnable == "0" || isReadonly == "1") CB_Html += "
"; else CB_Html += "
"; CB_Html += "
"; CB_Html += "
"; return CB_Html; //var checkBoxVal = ""; //var keyOfEn = attr.KeyOfEn; //var CB_Html = ""; //CB_Html += " "; //CB_Html += " "; //CB_Html += "
"; //CB_Html += "
"; //CB_Html += "
"; ////CB_Html += " "; //return CB_Html; }, CreateDDLEnum: function (attr, frmData, isReadonly, type, dtlIndx) { //下拉框和单选都使用下拉框实现 var mustInput = attr.UIIsInput == 1 ? '*' : ""; var ctrl_ID = "DDL_" + attr.KeyOfEn; if (type == "dtls") ctrl_ID = "DDL_" + dtlIndx + "_" + attr.KeyOfEn; var html_Select = ""; html_Select += ""; return html_Select; }, CreateDDLPK: function (attr, frmData, isReadonly, type, dtlIndx) { var ctrl_ID = "DDL_" + attr.KeyOfEn; if (type == "dtls") ctrl_ID = "DDL_" + dtlIndx + "_" + attr.KeyOfEn; var mustInput = attr.UIIsInput == 1 ? '*' : ""; var html_Select = ""; html_Select += "  "; return html_Select; }, CreateMapPin: function (attr, frmData, isReadonly, type, dtlIndx) { var html_MapPin = ""; //展示内容 html_MapPin += "
"; if (this.Enable == false) { html_MapPin += ""; } else { html_MapPin += ""; } html_MapPin += ""; html_MapPin += "
"; //数据控件 html_MapPin += ""; //地图定位 return html_MapPin; }, CreateMicHot: function (attr, frmData, isReadonly, type, dtlIndx) { var html_MicHot = ""; var bDelete = this.Enable; //展示内容 html_MicHot += "
"; if (this.Enable == false) { html_MicHot += ""; } else { html_MicHot += ""; } html_MicHot += ""; html_MicHot += "
"; html_MicHot += "


"; html_MicHot += "
"; //获取历史语音 var args = new RequestArgs(); var keyOfEn = attr.KeyOfEn; html_MicHot += "
"; //语音 return html_MicHot; } }; //初始化下拉列表框的OPERATION function InitDDLOperation1(frmData, mapAttr, defVal) { var operations = ''; var data = frmData[mapAttr.KeyOfEn]; if (data == undefined) data = frmData[mapAttr.UIBindKey]; if (data == undefined) { //枚举类型的. if (mapAttr.LGType == 1) { var enums = frmData.Sys_Enum; enums = $.grep(enums, function (value) { return value.EnumKey == mapAttr.UIBindKey; }); $.each(enums, function (i, obj) { operations += ""; }); } return operations; } if (data == undefined) { return operations; } $.each(data, function (i, obj) { operations += ""; }); return operations; }