//将v1版本表单元素转换为v2 杨玉慧 silverlight 自由表单转化为H5表单 function GenerFrm() { var handler = new HttpHandler("BP.WF.HttpHandler.CCMobile"); handler.AddJson(pageData); var data = handler.DoMethodReturnString("FrmView_Init"); //执行保存方法. if (data.indexOf('err@') == 0) { mui.alert(data); return; } jsonStr = data; var flow_Data; try { flow_Data = JSON.parse(data); frmData = flow_Data; } catch (err) { mui.alert("GenerFrm转换JSON失败:" + jsonStr); return; } //获得当前表单的数据,然后把该数据替换掉 frmData的数据. handler = new HttpHandler("BP.WF.HttpHandler.WF_MyView"); handler.AddJson(pageData); var data = handler.DoMethodReturnString("MyFrm_Init_Data"); //执行保存方法. if (data.indexOf('err@') == 0) { alert(data); return; } var frmDB; try { if (data != null && data != undefined && data != "") { frmDB = JSON.parse(data); //设置主表数据. flowData.MainTable[0] = frmDB; } } catch (err) { //console.log(data); alert("err@ MyFrm_Init_Data转换JSON失败,请查日志."); return; } //获取没有解析的外部数据源 var uiBindKeys = flow_Data["UIBindKey"]; if (uiBindKeys.length != 0) { //获取外部数据源 handler/JavaScript var operdata; for (var i = 0; i < uiBindKeys.length; i++) { var sfTable = new Entity("BP.Sys.SFTable", uiBindKeys[i].No); var srcType = sfTable.SrcType; if (srcType != null && srcType!="") { //Handler 获取外部数据源 if (srcType == 5) { var selectStatement = sfTable.SelectStatement; if(plant=='CCFLOW'){ selectStatement = basePath +"/DataUser/SFTableHandler.ashx" + selectStatement; }else{ selectStatement = basePath +"/DataUser/SFTableHandler" + selectStatement; } operdata = DBAccess.RunDBSrc(selectStatement, 1); } //JavaScript获取外部数据源 if (srcType == 6) { operdata = DBAccess.RunDBSrc(sfTable.FK_Val, 2); } frmData[uiBindKeys[i].No] = operdata; } } } //定义常用的变量. //节点信息. var wf_node = frmData["WF_FrmNodeComponent"][0]; //设置标题. document.getElementById("title").innerHTML = frmData.WF_Node[0].Name; //$("#titleBar").val(frmData.WF_Node[0].Name); //解析表单 var node = frmData["WF_Node"][0]; if (node.FormType == 2 || node.FormType == 3) { var url = node.FormUrl; if (url.indexOf("@basePath") != -1) url = url.replace('@basePath', basePath); if (url == "") url = basePath + "/DataUser/DefaultSelfFormUrl.htm"; else if (url.indexOf("http") == -1) url = basePath + url; if (url.indexOf('?') == -1) { url = url + "?1=2"; } url += "&WorkID=" + GetQueryString("WorkID") + "&FK_Flow=" + GetQueryString("FK_Flow") + "&FK_Node=" + GetQueryString("FK_Node"); var html = "'; eleIframe = $(""); if (pageData.IsReadOnly) { } else { if (frmDtl.DtlSaveModel == 0) { eleHtml.append(addLoadFunction(frmDtl.No, "blur", "SaveDtl")); eleIframe.attr('onload', frmDtl.No + "load()"); } } eleHtml.append(eleIframe); //added by liuxc,2017-1-10,此处前台JS中增加变量DtlsLoadedCount记录明细表的数量,用于加载完全部明细表的判断 var js = ""; if (!pageData.IsReadonly) { js = ""; eleHtml.append($(js)); } return eleHtml; } //初始化轨迹图 function figure_Template_FigureFlowChart(wf_node) { //轨迹图 var sta = wf_node.FrmTrackSta; var x = wf_node.FrmTrack_X; var y = wf_node.FrmTrack_Y; var h = wf_node.FrmTrack_H; var w = wf_node.FrmTrack_W; if (sta == 0) { return $(''); } if (sta == undefined) { return; } var src = "./WorkOpt/OneWork/OneWork.htm?CurrTab=Track"; src += '&FK_Flow=' + pageData.FK_Flow; src += '&FK_Node=' + pageData.FK_Node; src += '&WorkID=' + pageData.WorkID; src += '&FID=' + pageData.FID; var eleHtml = '
' + "" + '
'; eleHtml = $(eleHtml); eleHtml.css('position', 'absolute').css('top', y).css('left', x).css('width', w).css('height', h); return eleHtml; } //审核组件 function figure_Template_FigureFrmCheck(wf_node) { //审核组键FWCSta Sta,FWC_X X,FWC_Y Y,FWC_H H, FWC_W W from WF_Node var sta = wf_node.FWCSta; var x = wf_node.FWC_X; var y = wf_node.FWC_Y; // var h = wf_node.FWC_H; // var w = wf_node.FWC_W; if (sta == 0) return $(''); var src = "./WorkOpt/WorkCheck.htm?s=2"; var fwcOnload = ""; var paras = ''; paras += "&FID=" + pageData["FID"]; paras += "&OID=" + pageData["WorkID"]; paras += '&FK_Flow=' + pageData.FK_Flow; paras += '&FK_Node=' + pageData.FK_Node; paras += '&WorkID=' + pageData.WorkID; paras += '&IsReadonly=1'; paras += '&csc=1'+Math.random(); src += "&DoType=View"; src += "&IsMobile=1"; src += "&r1="+Math.random() + paras; //暂时修改高度为500px. var eleHtml = '
' + "
" + '
'; eleHtml = $(eleHtml); return eleHtml; } //子流程 function figure_Template_FigureSubFlowDtl(wf_node) { var sta = wf_node.SFSta; var h = wf_node.SF_H; if (sta == 0) return $(''); var src = "./WorkOpt/SubFlow.htm?s=2"; var fwcOnload = ""; var paras = ''; paras += "&FID=" + pageData["FID"]; paras += "&OID=" + pageData["WorkID"]; paras += '&FK_Flow=' + pageData.FK_Flow; paras += '&FK_Node=' + pageData.FK_Node; paras += '&WorkID=' + pageData.WorkID; if (sta == 2)//只读 { src += "&DoType=View"; } else { fwcOnload = "onload= 'WC" + wf_node.NodeID + "load();'"; $('body').append(addLoadFunction("WC" + wf_node.NodeID, "blur", "SaveDtl")); } src += "&r=q" + paras; var eleHtml = '
' + "" + '
'; eleHtml = $(eleHtml); return eleHtml; } //初始化框架 function figure_Template_IFrame(fram) { var eleHtml = ''; var src = dealWithUrl(fram.src) + "IsReadOnly=0"; eleHtml = $('
' + '
'); var iframe = $(+""); eleHtml.append(iframe); return eleHtml; } //处理URL,MainTable URL 参数 替换问题 function dealWithUrl(src) { var src = fram.URL.replace(new RegExp(/(:)/g), ':'); var params = '&FID=' + pageData.FID; params += '&WorkID=' + pageData.WorkID; if (src.indexOf("?") > 0) { var params = getQueryStringFromUrl(src); if (params != null && params.length > 0) { $.each(params, function (i, param) { if (param.indexOf('@') == 0) {//是需要替换的参数 paramArr = param.split('='); if (paramArr.length == 2 && paramArr[1].indexOf('@') == 0) { if (paramArr[1].indexOf('@WebUser.') == 0) { params[i] = paramArr[0].substring(1) + "=" + frmData.MainTable[0][paramArr[1].substr('@WebUser.'.length)]; } if (frmData.MainTable[0][paramArr[1].substr(1)] != undefined) { params[i] = paramArr[0].substring(1) + "=" + frmData.MainTable[0][paramArr[1].substr(1)]; } //使用URL中的参数 var pageParams = getQueryString(); var pageParamObj = {}; $.each(pageParams, function (i, pageParam) { if (pageParam.indexOf('@') == 0) { var pageParamArr = pageParam.split('='); pageParamObj[pageParamArr[0].substring(1, pageParamArr[0].length)] = pageParamArr[1]; } }); var result = ""; //通过MAINTABLE返回的参数 for (var ele in frmData.MainTable[0]) { if (paramArr[0].substring(1) == ele) { result = frmData.MainTable[0][ele]; break; } } //通过URL参数传过来的参数 for (var pageParam in pageParamObj) { if (pageParam == paramArr[0].substring(1)) { result = pageParamObj[pageParam]; break; } } if (result != '') { params[i] = paramArr[0].substring(1) + "=" + unescape(result); } } } }); src = src.substr(0, src.indexOf('?')) + "?" + params.join('&'); } } else { src += "?q=1"; } return src; } var colVisibleJsonStr = '' var jsonStr = ''; var frmData = {}; if ("undefined" == typeof Hide_IsShowTrack) { var Hide_IsShowTrack = true; }; $(function () { initPageParam(); //初始化参数 //InitToolBar("MyView"); //工具栏.ajax GenerFrm(); //表单数据.ajax }); function BackToHome() { SetHref('../CCMobilePortal/Home.htm?UserNo=' + GetQueryString('UserNo') + "&Token=" + GetQueryString("Token")); } function BackToTodolist() { SetHref('Todolist.htm?UserNo=' + GetQueryString('UserNo') + "&Token=" + GetQueryString("Token")); } function BackToStart() { SetHref('Start.htm?UserNo=' + GetQueryString('UserNo') + "&Token=" + GetQueryString("Token")); } function TimeBase() { var url = "./WorkOpt/OneWork/TimeBase.htm?FK_Flow=" + GetQueryString("FK_Flow") + "&WorkID=" + GetQueryString("WorkID") + "&t=" + Math.random(); SetHref(url); }