//逻辑类型 var FieldTypeS = { Normal: '0', Enum: '1', FK: '2', WinOpen: '3' }; //数据类型 var FormDataType = { AppString: '1', AppInt: '2', AppFloat: '3', AppBoolean: '4', AppDouble: '5', AppDate: '6', AppDateTime: '7', AppMoney: '8', AppRate: '9' }; //控件类型 var UIContralType = { TB: '0', DDL: '1', CheckBok: '2', RadioBtn: '3', MapPin: '4', MicHot: '5' }; //表单扩展函数 var Form_Ext_Function = ""; //表单整体是否只读 var Form_ReadOnly = false; //审核组件是否启用 var WorkCheck_Enable = false; //当前表单 var curFK_MapData = null; //加载节点表单控件 function GenerFormElement() { var args = new RequestArgs(); var nodeId = args.FK_Node; if (nodeId) { while (nodeId.substring(0, 1) == '0') { nodeId = nodeId.substring(1); } nodeId = nodeId.replace('#', ''); } curFK_MapData = "ND" + nodeId; //只读 if (args.IsReadonly && args.IsReadonly == "1") { Form_ReadOnly = true; } //只读 if (args.IsEdit && args.IsEdit == "0") { Form_ReadOnly = true; } AjaxMobileService({ action: "nodeformelements", FK_Flow: args.FK_Flow, FK_Node: args.FK_Node, WorkID: args.WorkID, FID: args.FID, CWorkID: args.CWorkID, PWorkID: args.PWorkID }, function (scope) { var pushData = cceval('(' + scope + ')'); //有错误消息 if (pushData.error) { MsgHidenLoader(); var _Html = ""; //清空面板 $("#Controls_view").empty(); //隐藏按钮 $("#Btn_Send").hide(); $("#Btn_Save").hide(); $("#Btn_Return").hide(); $("#Btn_Other").hide(); $(_Html).appendTo('#Controls_view'); //刷新 $("#Controls_view").trigger("create"); $("#Controls_view").listview('refresh'); return; } //装载控件 var transControl = new TransControlFromJson(pushData); var _html = transControl.To_Html(); //添加审核组件 if (pushData.WorkCheck) { //_html += "
  • " + pushData.WorkCheck.WCText + "
  • "; _html += WorkCheck_InitHtml(); //_html += "
  • 点击查看审批详细信息

  • "; } //公文文件 if (pushData.OfficeFile) { _html += "
  • 公文
  • "; if (pushData.OfficeFile.FileExit == "false") { _html += "
  • 文件不存在
  • "; } else { _html += "
  • 下载公文

  • "; } } //展显 $(_html).appendTo('#Controls_view'); //刷新 $("#Controls_view").trigger("create"); $("#Controls_view").listview('refresh'); //日期控件 $('input:jqmData(role="datebox")').mobiscroll(optDate); $('input:jqmData(role="datetimebox")').mobiscroll(optDateTime); //加载自定义脚本 LoadFormSelfJavaScript(curFK_MapData); //执行扩展函数 if (Form_Ext_Function.length > 0) { cceval(Form_Ext_Function); } //存在扩展设置 if (pushData.MapExts) { CCForm_DealMapExt(pushData.MapExts); } MsgHidenLoader(); }, this); } //独立表单初始化控件 function Frm_InitControls(FK_MapData) { MessageShow("正在加载...", false); $("#Controls_view").empty(); var args = new RequestArgs(); curFK_MapData = args.FK_MapData; var curFormIsEdit = "1"; Form_ReadOnly = false; if (FK_MapData && FK_MapData != "") { curFK_MapData = FK_MapData; } //只读 if (args.IsReadonly && args.IsReadonly == "1") { Form_ReadOnly = true; curFormIsEdit = "0"; } //只读 if (args.IsEdit && args.IsEdit == "0") { Form_ReadOnly = true; curFormIsEdit = "0"; } AjaxMobileService({ action: "ccformelements", FK_Flow: args.FK_Flow, FK_Node: args.FK_Node, FK_MapData: curFK_MapData, WorkID: args.WorkID, FID: args.FID, CWorkID: args.CWorkID, PWorkID: args.PWorkID, IsTest: args.IsTest, IsEdit: curFormIsEdit }, function (scope) { var pushData = cceval('(' + scope + ')'); //只读 if (pushData.IsReadOnly == "1") { Form_ReadOnly = true; curFormIsEdit = "0"; } var transControl = new TransControlFromJson(pushData); var _html = transControl.To_Html(); //展显 $(_html).appendTo('#Controls_view'); //刷新 $("#Controls_view").trigger("create"); $("#Controls_view").listview('refresh'); //日期控件 $('input:jqmData(role="datebox")').mobiscroll(optDate); $('input:jqmData(role="datetimebox")').mobiscroll(optDateTime); //加载自定义脚本 LoadFormSelfJavaScript(curFK_MapData); //执行扩展函数 if (Form_Ext_Function.length > 0) { cceval(Form_Ext_Function); } //存在扩展设置 if (pushData.MapExts) { CCForm_DealMapExt(pushData.MapExts); } MsgHidenLoader(); }, this); } //根据控件原型返回相应控件编码 function TransControlFromJson(controls) { this.Form_Controls = controls; this.control = null; this.Ctrl_Class = ""; //控件是否可用 this.Enable = true; } //控件属性 TransControlFromJson.prototype = { To_Html: function () { var _html = ""; var groupFields = this.Form_Controls.GroupField; //数据分组字段 for (var i = 0, j = groupFields.length; i < j; i++) { var groupField = groupFields[i]; _html += "
  • " + groupField.Lab + "
  • "; //数据普通字段 var fields = groupField.Fields; for (var k = 0, m = fields.length; k < m; k++) { this.Ctrl_Class = ""; this.control = fields[k]; this.Enable = true; //判断控件是否可用 if (this.control.UIIsEnable == "0" || Form_ReadOnly == true) { this.Enable = false; //this.Ctrl_Class = "readonly = \"readonly\" "; this.Ctrl_Class = "disabled=\"disabled\" "; } //图片签名 if (this.control.IsSigan == "1") { _html += "
  • "; _html += this.CreateSignPicture(); _html += "
  • "; continue; } _html += "
  • "; //加载其他数据控件 switch (this.control.LGType) { case FieldTypeS.Normal: //输出普通类型字段 if (this.control.UIContralType == UIContralType.DDL) { //判断外部数据或WS类型. if (this.Enable == false) { this.Ctrl_Class = "disabled=\"disabled\" "; } _html += this.CreateDDLPK(); break; } switch (this.control.MyDataType) { case FormDataType.AppString: _html += this.CreateTBString(); break; case FormDataType.AppInt: _html += this.CreateTBInt(); break; case FormDataType.AppFloat: case FormDataType.AppDouble: case FormDataType.AppMoney: _html += this.CreateTBFloat(); break; case FormDataType.AppDate: //日期\boolen型的不允许获取焦点,所以只能禁用 if (this.Enable == false) { this.Ctrl_Class = "disabled=\"disabled\" "; } _html += this.CreateTBDate(); break; case FormDataType.AppDateTime: //日期\boolen型的不允许获取焦点,所以只能禁用 if (this.Enable == false) { this.Ctrl_Class = "disabled=\"disabled\" "; } _html += this.CreateTBDateTime(); break; case FormDataType.AppBoolean: //日期\boolen型的不允许获取焦点,所以只能禁用 if (this.Enable == false) { this.Ctrl_Class = "disabled=\"disabled\" "; } _html += this.CreateCBBoolean(); break; } break; case FieldTypeS.Enum: //枚举值下拉框 //日期\boolen型的不允许获取焦点,所以只能禁用 if (this.Enable == false) { this.Ctrl_Class = "disabled=\"disabled\" "; } _html += this.CreateDDLEnum(); break; case FieldTypeS.FK: //外键表下拉框 //日期\boolen型的不允许获取焦点,所以只能禁用 if (this.Enable == false) { this.Ctrl_Class = "disabled=\"disabled\" "; } _html += this.CreateDDLPK(); break; case FieldTypeS.WinOpen: //打开系统页面 switch (this.control.UIContralType) { case UIContralType.MapPin: //地图定位 _html += this.CreateMapPin(); break; case UIContralType.MicHot: //语音控件 _html += this.CreateMicHot(); break; } break; } _html += "
  • "; } //按钮 if (groupField.FrmBtns && groupField.FrmBtns.length > 0) { var btn_css = "style=\"color:#096BC1;font-size: 0.8em;\""; for (var iFrmBtn = 0; iFrmBtn < groupField.FrmBtns.length; iFrmBtn++) { var frmBtnID = groupField.FrmBtns[iFrmBtn].MyPK; var frmBtnText = groupField.FrmBtns[iFrmBtn].Text; var frmBtnEventType = groupField.FrmBtns[iFrmBtn].EventType; var frmBtnEventContext = groupField.FrmBtns[iFrmBtn].EventContext; var frmBtnIsEnable = groupField.FrmBtns[iFrmBtn].IsEnable; var disabled = "disabled"; if (frmBtnIsEnable == 1) { } //js事件 Form_Ext_Function += "$('#Btn_" + frmBtnID + "').on('tap', function () { FrmBtnEventFactory('" + frmBtnID + "','" + frmBtnEventType + "','" + frmBtnEventContext + "'); });" //生成页面 _html += "
  • "; _html += " "; _html += "
  • "; } } //多附件 if (groupField.MapAths && groupField.MapAths.length > 0) { //_html += "
  • 附件
  • "; for (var iAth = 0; iAth < groupField.MapAths.length; iAth++) { _html += "
  • "; _html += " "; _html += "

    " + groupField.MapAths[iAth].Name; _html += " (" + groupField.MapAths[iAth].AthMentDBs + ")个"; _html += "

    "; _html += "

    点击查看详细

    "; _html += "
    "; _html += "
  • "; } } //明细表 if (groupField.MapDtls && groupField.MapDtls.length > 0) { //_html += "
  • 表格
  • "; for (var iDtl = 0; iDtl < groupField.MapDtls.length; iDtl++) { _html += "
  • "; _html += " "; _html += "

    " + groupField.MapDtls[iDtl].Name; _html += " (" + groupField.MapDtls[iDtl].Dtl_DBCount + ")条记录"; _html += "

    "; _html += "

    点击查看详细

    "; _html += "
    "; _html += "
  • "; } } } return _html; }, CreateSignPicture: function () { //图片签名 var html_Sign = ""; html_Sign += "
    "; html_Sign += ""; html_Sign += "
    "; return html_Sign; }, CreateTBString: function () { var html_string = ""; var strPlaceholder = ""; //启用二维码 if (this.control.IsEnableQrCode && this.control.IsEnableQrCode == "1") { strPlaceholder = "通过扫一扫添加"; Form_Ext_Function += "$('#Btn_" + this.control.KeyOfEn + "').on('tap', function () { QrCodeToInput('TB_" + this.control.KeyOfEn + "'); });" 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 (this.control.UIHeight > 40) { html_string = ""; html_string += ""; return html_string; } //单行文本 html_string = ""; html_string += ""; return html_string; }, CreateTBInt: function () { var inputHtml = ""; inputHtml += ""; return inputHtml; }, CreateTBFloat: function () { return ""; }, CreateTBDate: function () { var inputHtml = ""; inputHtml += ""; return inputHtml; }, CreateTBDateTime: function () { //Form_Ext_Function += "$('#TB_" + this.control.KeyOfEn + "').datetimepicker({lang:'ch'});"; var inputHtml = ""; inputHtml += ""; return inputHtml; }, CreateCBBoolean: function () { var checkBoxVal = ""; var keyOfEn = this.control.KeyOfEn; var CB_Html = "
    "; if (this.control.FieldRelValue == "1") checkBoxVal = "checked='checked'"; CB_Html += " " + this.control.Name + ""; CB_Html += " "; CB_Html += " "; CB_Html += " "; CB_Html += "
    "; return CB_Html; }, CreateDDLEnum: function () { var selectedVal = this.control.FieldRelValue; //下拉框和单选都使用下拉框实现 var ctrl_ID = "RB_" + this.control.KeyOfEn; if (this.control.UIContralType == UIContralType.DDL) { ctrl_ID = "DDL_" + this.control.KeyOfEn; } var html_Select = ""; html_Select += ""; return html_Select; }, CreateDDLPK: function () { var args = new RequestArgs(); var selectedVal = this.control.FieldRelValue; var html_Select = ""; html_Select += ""; return html_Select; }, CreateMapPin: function () { var html_MapPin = ""; //展示内容 html_MapPin += "
    "; if (this.Enable == false) { html_MapPin += ""; } else { html_MapPin += ""; } html_MapPin += "" + this.control.FieldRelValue + ""; html_MapPin += "
    "; //数据控件 html_MapPin += ""; //地图定位 return html_MapPin; }, CreateMicHot: function () { 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 = this.control.KeyOfEn; $.ajax({ url: "common/DingDingWebApi.ashx", type: 'GET', async: false, cache: false, data: { action: "GenerMedias", FK_MapData: curFK_MapData, FK_Flow: args.FK_Flow, FK_Node: args.FK_Node, WorkID: args.WorkID, FID: args.FID, CWorkID: args.CWorkID, PWorkID: args.PWorkID, KeyOfEn: keyOfEn }, success: function (data) { var pushData = cceval("(" + data + ")"); for (var i = 0; i < pushData.length; i++) { var mediaId = pushData[i].RefPKVal; var duration = pushData[i].Tag2; html_MicHot += "
    "; html_MicHot += "
    "; html_MicHot += "
    " + duration + "\"
    "; html_MicHot += "
    "; if (bDelete == true) { html_MicHot += "
    "; } html_MicHot += "
    "; } }, error: function (xhr, errorType, error) { alert(errorType + ', ' + error); } }); // html_MicHot += "
    "; // html_MicHot += "
    "; // html_MicHot += "
    12\"
    "; // html_MicHot += "
    "; // html_MicHot += "
    "; // html_MicHot += "
    "; html_MicHot += "
    "; //语音 return html_MicHot; } } //初始化审核组件,主意:async 必须要同步 function WorkCheck_InitHtml() { var args = new RequestArgs(); var _Html = ""; //获取审核数据 $.ajax({ type: "POST", url: "common/action.ashx", dataType: "text", //返回json格式的数据 async: false, cache: false, data: { action: "formworkchecktracks", FK_Flow: args.FK_Flow, FK_Node: args.FK_Node, WorkID: args.WorkID, FID: args.FID }, success: function (scorp) { var pushData = cceval('(' + scorp + ')'); if (pushData.Msg) { _Html = "
  • " + pushData.Msg + "
  • "; } else { //历史审核信息 var sigantureEnabel = pushData.WorkCheck.SigantureEnabel; for (var i = 0; i < pushData.WorkCheck.tracks.length; i++) { var nodeID = pushData.WorkCheck.tracks[i].NodeID; var nodeName = pushData.WorkCheck.tracks[i].NodeName; var msgHtml = pushData.WorkCheck.tracks[i].MsgHtml; var signHtml = pushData.WorkCheck.tracks[i].SigantureHtml; var rdt = pushData.WorkCheck.tracks[i].RDT; _Html += "
  • " + nodeName + "
  • "; _Html += "
  • "; _Html += "

    " + msgHtml + "

    "; if (sigantureEnabel == "true" && signHtml.indexOf("DataUser") > -1) { signHtml = ""; } _Html += "

    签名:" + signHtml + "

    "; _Html += "

    日期:" + rdt + "

    "; _Html += "
  • "; } //是否添加审核意见框 if (pushData.WorkCheck.WCState == "Enable") { WorkCheck_Enable = true; _Html += "
  • " + pushData.CurrNode.Name + "
  • "; _Html += "
  • "; _Html += ""; _Html += ""; _Html += "
  • "; } } //如果没有信息则提示无信息 if (_Html == "") { _Html = "
  • "; } return _Html; } }); return _Html; } //提交审核意见 function WorkCheck_Submit() { //如果启用审核意见则执行保存 if (WorkCheck_Enable == true) { var rsVal = $("#WorkCheck_Remark").val(); if (rsVal == undefined || rsVal == "") { MessageShow("请填写审核意见。", true); return false; } //执行发送 var args = new RequestArgs(); AjaxMobileService({ action: "saveworkcheck", FK_Flow: args.FK_Flow, FK_Node: args.FK_Node, WorkID: args.WorkID, FID: args.FID, WorkCheckMsg: rsVal }, function (scorp) { if (scorp != "true") { MessageShow("审核意见保存失败" + scorp, true); return false; } }, this); } return true; } //多附件 function SelectedAthMents(MyPK, name, OID) { //中文名 $("#Header_Ath").html(name); //编号 $("#HD_Ath_MyPK").val(MyPK); if (OID) { $("#HD_Ath_OID").val(OID); } else { $("#HD_Ath_OID").val("0"); } $.mobile.changePage($("#page_athment")); } //打开明细表 function SelectedDtlNo(dtlNo, name) { //明细表中文名 $("#Header_Dtl").html(name); //明细表编号 $("#HD_CurDtl_No").val(dtlNo); $.mobile.changePage($("#page_dtl")); } //打开定位地图 function GetMapLocationAddress(keyOfen) { if (typeof GetMapLocationCoords != "undefined") { //获取当前定位坐标 GetMapLocationCoords(function (result) { if (result.latitude) { //定位,打开微调地图,范围放大到2000 OpenMapSearch(result.latitude, result.longitude, 2000, function (poi) { if (poi.city) { var address = poi.city + poi.adName + poi.snippet; var args = new RequestArgs(); $.ajax({ type: "GET", url: "common/DingDingWebApi.ashx", dataType: "text", //返回json格式的数据 async: false, cache: false, data: { action: "SaveMapCoords", FK_MapData: curFK_MapData, FK_Flow: args.FK_Flow, FK_Node: args.FK_Node, WorkID: args.WorkID, FID: args.FID, CWorkID: args.CWorkID, PWorkID: args.PWorkID, KeyOfEn: keyOfen, latitude: poi.latitude, longitude: poi.longitude, address: address }, success: function (scope) { if (scope == "true") { $("#LBL_" + keyOfen).html(address); $("#TB_" + keyOfen).val(address); } else { MessageShow("保存失败" + scope, true); } } }); } else { MessageShow(JSON.stringify(poi), true); } }); } else { MessageShow("获取定位失败" + JSON.stringify(result), true); } }); } else { MessageShow("调用高德地图控件失败,请在钉钉打开。", true); } } //地图显示 function OpenMapView(keyOfen) { //打开高德地图 if (typeof OpenDDBizMapView != "undefined") { var args = new RequestArgs(); $.ajax({ type: "GET", url: "common/DingDingWebApi.ashx", dataType: "text", //返回json格式的数据 async: false, cache: false, data: { action: "openmapbycoords", FK_MapData: curFK_MapData, FK_Flow: args.FK_Flow, FK_Node: args.FK_Node, WorkID: args.WorkID, FID: args.FID, CWorkID: args.CWorkID, PWorkID: args.PWorkID, KeyOfEn: keyOfen }, success: function (scope) { var pushData = cceval('(' + scope + ')'); if (pushData.address) { OpenDDBizMapView(pushData.latitude, pushData.longitude, pushData.address); } } }); } //打开其他地图 } //开始录音 function StartOpenRecord(keyOfEn) { //配置进度条 var progressManage = null; progressManage = new ProgressManage({ contentId: 'Recorde_' + keyOfEn, totalCount: 60, proModel: ProgressModel.sencond, timing: 1000, clickFun: function () { if (ProgressGlo.TimeOut != null) { clearTimeout(ProgressGlo.TimeOut); ProgressGlo.TimeOut = null; if (typeof DingDing_StopRecorder != "undefined") { DingDing_StopRecorder(); } //progressManage.ReStartProgress(); } }, ComplateFun: function () { //progressManage.DoProgress(); } }); //录音开始 var StartRecordFun = function () { progressManage.DoProgress(); } //录音成功 var RecordSucessFun = function (downLoadRes, recordRes) { //recordRes.mediaId; // 停止播放音频MediaID //recordRes.duration; // 返回音频的时长,单位:秒 //downLoadRes.localAudioId //创建语音图标 if (downLoadRes) { var duration = 0; if (recordRes.duration) { duration = Math.ceil(recordRes.duration); } var html_MicHot = "
    "; html_MicHot += "
    "; html_MicHot += "
    " + duration + "\"
    "; html_MicHot += "
    "; html_MicHot += "
    "; html_MicHot += "
    "; $(html_MicHot).appendTo("#PanelRecords_" + keyOfEn); } //移除暂停录音 progressManage.RemoveLoading(); if (ProgressGlo.TimeOut != null) { clearTimeout(ProgressGlo.TimeOut); ProgressGlo.TimeOut = null; } } //录音失败 var RecordFaildFun = function (err) { progressManage.RemoveLoading(); } //启动录音 if (typeof DingDing_StartRecorder != "undefined") { var args = new RequestArgs(); DingDing_StartRecorder(keyOfEn, StartRecordFun, RecordSucessFun, RecordFaildFun); } } //开始播放录音 function StartPlayRecord(localAudioId, mediaId) { //var src = $("#imgSrc_" + mediaId).attr("src") //if (src.indexOf("wx_startplay.gif") > 0) { // if (typeof DingDingStopPaly != undefined) { // $("#imgSrc_" + mediaId).attr("src", "image/Field/wx_stopplay.png"); // } // return; //} //$("#imgSrc_" + mediaId).attr("src", "image/Field/wx_startplay.gif"); //return; //开始播放 var onPlayStart = function () { $("#imgSrc_" + mediaId.replace("@", "")).attr("src", "image/Field/wx_startplay.gif"); } //播放停止 var onPlayEnd = function () { $("#imgSrc_" + mediaId.replace("@", "")).attr("src", "image/Field/wx_stopplay.png"); } //播放出现错误 var onPlayFaild = function (err) { $("#imgSrc_" + mediaId.replace("@", "")).attr("src", "image/Field/wx_stopplay.png"); } if (typeof DingDing_PlayAudio != "undefined") { DingDing_PlayAudio(localAudioId, mediaId, onPlayStart, onPlayEnd, onPlayFaild); } } //删除语音 function DeleteRecord(mediaId) { if (confirm("确定要删除所选语音吗?")) { var args = new RequestArgs(); $.ajax({ type: "GET", url: "common/DingDingWebApi.ashx", dataType: "text", //返回json格式的数据 async: false, cache: false, data: { action: "deleterecordes", FK_MapData: curFK_MapData, FK_Flow: args.FK_Flow, FK_Node: args.FK_Node, WorkID: args.WorkID, FID: args.FID, CWorkID: args.CWorkID, PWorkID: args.PWorkID, mediaId: mediaId }, success: function (scope) { $("#Content_" + mediaId.replace("@", "")).remove(); } }); } } //扫描二维码 function QrCodeToInput(ctrlId) { DingDing_OpenBarCode(function (scope) { $("#" + ctrlId).val(scope.text); }); }