/**************************提示：只允许修改开发区域，其他区域会被覆盖！********************************/
mod.definePage("workflow/metas/js/approve", function (waf, wfCommonUtil) {
	var _public = {}, _private = {}, me = _self;
	var okPolicy = new Array();
	var noPolicy = new Array();
	var assign = {};
	var selnextPersons = {};
	var transId = null;
	var locationurl = waf.getUrlParams(document.location.href);
	var approvetype = locationurl.type;
	var passId = locationurl.passid;
	var sourceIDs = locationurl.sourceIDs;
	var msgId = locationurl.msgId;
	var showerror = "";
	var nextActIndex = "#nextAct";
	var approveOpinions = {};
	var isFirst = true;
	var approvePolicy = {};
	var riskInsight = false;
	var billInsightOption = {};
	/**
	 *  初始化CA认证配置
	*/
	var caConfig = {
		caConfigInfo: null,
		rootDiv: null,
		CA_plainText: null,
		CA_signature: null,
		plainTextMap: null,
		plainSignatureMap: null
	};
	//@beginPublic
	waf.extend(_public, {
		//控件事件描述:
		submit: function (event, value) {
			return _private.submit(event, value);
		}
		,
		//控件事件描述:
		save: function (event, value) {
			return _private.save(event, value);
		}
		,
		//控件事件描述:
		deliver: function (event, value) {
			return _private.deliver(event, value);
		}
		,
		//控件事件描述:
		passAssignment: function (event, value) {
			return _private.passAssignment(event, value);
		}
		,
		//控件事件描述:
		kickback: function (event, value) {
			return _private.kickback(event, value);
		}
		,
		//控件事件描述:
		appendActivity: function (event, value) {
			return _private.appendActivity(event, value);
		}
		,
		//控件事件描述:
		dynamicSign: function (event, value) {
			return _private.dynamicSign(event, value);
		}
		,
		//控件事件描述:
		jumpto: function (event, value) {
			return _private.jumpto(event, value);
		}
		,
		//控件事件描述:
		viewProcessDiagram: function (event, value) {
			return _private.viewProcessDiagram(event, value);
		}
		,
		//控件事件描述:
		billImage: function (event, value) {
			return _private.billImage(event, value);
		}
		,
		//控件事件描述:
		bill: function (event, value) {
			return _private.bill(event, value);
		}
		,
		//控件事件描述:
		showoperate: function (event, value) {
			return _private.showoperate(event, value);
		}
		,
		//控件事件描述:
		nextActs: function (event, ui) {
			return _private.nextActs(event, ui);
		}
		,
		//控件事件描述:
		modifynextActs: function (event, value) {
			return _private.modifynextActs(event, value);
		}
		,
		//控件事件描述:
		changePolicy: function (event, ui) {
			return _private.changePolicy(event, ui);
		}
		,
		//控件事件描述:
		changeselPolicy: function (event, ui) {
			return _private.changeselPolicy(event, ui);
		}
		,
		//控件事件描述:
		myPhrase: function (event, value) {
			return _private.myPhrase(event, value);
		}
		,
		//控件事件描述:
		openPerson: function (event, value) {
			return _private.openPerson(event, value);
		}
		,
		//控件事件描述:
		esignatureOnClick: function (event, ui) {
			return _private.esignatureOnClick(event, ui);
		}
		,
		//控件事件描述:
		nextAct: function (event, ui) {
			return _private.nextAct(event, ui);
		}
		,
		//控件事件描述:
		modifynextAct: function (event, value) {
			return _private.modifynextAct(event, value);
		}
		,
		//页面事件描述:
		pageOnload: function (e) {
			return _private.pageOnload(e);
		}
		,
		//页面事件描述:
		pageOnRenderBefore: function (e) {
			return _private.pageOnRenderBefore(e);
		}
		,
		//页面事件描述:
		phrasedel: function (e) {
			return _private.phrasedel(e);
		}
		,
		//页面事件描述:
		phrasesure: function (e) {
			return _private.phrasesure(e);
		}
		,
		addphrase: function (e) {
			return _private.addphrase(e);
		}
		,
		//页面事件描述:
		phraseback: function (e) {
			return _private.phraseback(e);
		}
		,
		//页面事件描述:
		phraseadd: function (e) {
			return _private.phraseadd(e);
		}
		,
		//页面函数描述:$event.get("desc")
		reloadTranId: function () {
			return _private.reloadTranId();
		}
		,
		//页面函数描述:$event.get("desc")
		getnextacts: function () {
			return _private.getnextacts();
		}
		,
		//页面函数描述:$event.get("desc")
		showtab: function () {
			return _private.showtab();
		}
		,
		//页面函数描述:$event.get("desc")
		setmanualdecision: function () {
			return _private.setmanualdecision();
		}
		,
		//页面函数描述:$event.get("desc")
		setmodifynextAct: function () {
			return _private.setmodifynextAct();
		}
		,
		//页面函数描述:批量审批内嵌列表界面
		getbatchlist: function () {
			return _private.getbatchlist();
		}
		,
		//页面函数描述:显示内嵌单据
		displayBillInfo: function (url) {
			return _private.displayBillInfo(url);
		}
		,
		//页面函数描述:$event.get("desc")
		getPolicy: function (approveValueStr) {
			return _private.getPolicy(approveValueStr);
		}
		,
		//页面函数描述:$event.get("desc")
		setPolicy: function (val) {
			return _private.setPolicy(val);
		}
		,
		//页面函数描述:$event.get("desc")
		isNeedDefaultOption: function (vals) {
			return _private.isNeedDefaultOption(vals);
		}
		,
		//页面函数描述:$event.get("desc")
		setsendmailormsg: function (isOpenMessageSendOnUI, notifyNextBySMS, notifyNextByMail) {
			return _private.setsendmailormsg(isOpenMessageSendOnUI, notifyNextBySMS, notifyNextByMail);
		}
		,
		//页面函数描述:$event.get("desc")
		resizePage: function () {
			return _private.resizePage();
		}
		,
		//页面函数描述:$event.get("desc")
		showapprovehis: function (procInstId) {
			return _private.showapprovehis(procInstId);
		}
		,
		//页面函数描述:$event.get("desc")
		showbtn: function () {
			return _private.showbtn();
		}
		,
		//页面函数描述:$event.get("desc")
		setselnextperson: function (actId, name, id) {
			return _private.setselnextperson(actId, name, id);
		}
		,
		//页面函数描述:$event.get("desc")
		loadNextActs: function () {
			return _private.loadNextActs();
		}
		,
		//页面函数描述:$event.get("desc")
		getOpinion: function (actInstId, assignId, billId) {
			return _private.getOpinion(actInstId, assignId, billId);
		}
		,
		//页面函数描述:$event.get("desc")
		getphrase: function () {
			return _private.getphrase();
		}
		,
		//页面函数描述:$event.get("desc")
		setselnextactperson: function (resultStr) {
			return _private.setselnextactperson(resultStr);
		}
		,
		//页面函数描述:$event.get("desc")
		shownextActs: function (nextactname, ui) {
			return _private.shownextActs(nextactname, ui);
		}
		,
		//页面函数描述:传阅反馈提交
		passComentsubmit: function () {
			return _private.passComentsubmit();
		}
		,
		//页面函数描述:初始化加载CA
		initCAConfig: function (tCAConfig) {
			return _private.initCAConfig(tCAConfig);
		}
		,
		//页面函数描述:批量提交的处理CA
		batchSubmitForCA: function () {
			return _private.batchSubmitForCA();
		}
		,
		//页面函数描述:CA认证调用第三方js，弹出密码校验处理,isBatch 是否批量
		checkCAPassword: function (isBatch) {
			return _private.checkCAPassword(isBatch);
		}
		,
		//页面函数描述:批量审批提交
		batchSubmit: function () {
			return _private.batchSubmit();
		}
		,
		//页面函数描述:获取批量审批所选信息
		getbatchid: function () {
			return _private.getbatchid();
		}
		,
		//页面函数描述:批量审批提交
		_batchsubmit: function (info) {
			return _private._batchsubmit(info);
		}
		,
		//页面函数描述:获取提交审批信息
		getApprove: function () {
			return _private.getApprove();
		}
		,
		//页面函数描述:批量审批，CA获取业务单据签名的明码，与加密后的密文
		beforeBatchSubmitSigature: function (selectBillIds) {
			return _private.beforeBatchSubmitSigature(selectBillIds);
		}
		,
		//页面函数描述:提交时获取下一步参与人信息
		getNextPersons: function (isSave) {
			return _private.getNextPersons(isSave);
		}
		,
		//页面函数描述:决策提交
		manualdecisionsubmit: function () {
			return _private.manualdecisionsubmit();
		}
		,
		//页面函数描述:审批提交的处理CA
		beforeInnerSubmit: function () {
			return _private.beforeInnerSubmit();
		}
		,
		//页面函数描述:审批提交单据校验
		innerSubmit: function () {
			return _private.innerSubmit();
		}
		,
		//页面函数描述:审批提交
		_submit: function (isReadOnly) {
			return _private._submit(isReadOnly);
		}
		,
		//页面函数描述:审批提交前对加签数据进行处理，获取加签的数据
		beforeSubmitSigature: function () {
			return _private.beforeSubmitSigature();
		}
		,
		//页面函数描述:对数字类型进行处理
		toDecimal: function (src, pos) {
			return _private.toDecimal(src, pos);
		}
		,
		//页面函数描述:检查是否保存
		checkIsSave: function (callback, type) {
			return _private.checkIsSave(callback, type);
		}
		,
		//页面函数描述:审批保存
		_save: function (isReadOnly) {
			return _private._save(isReadOnly);
		}
		,
		//页面函数描述:关闭当前页面
		backto: function () {
			return _private.backto();
		}
		,
		//页面函数描述:流程附件html片段
		addUploadHtml: function () {
			return _private.addUploadHtml();
		}
		,
		//页面函数描述:获取附件数量及详情
		getAttchmentcount: function () {
			return _private.getAttchmentcount();
		}
		,
		//页面函数描述:选择附件事件
		selattachment: function (item, attcreater, beizhu) {
			return _private.selattachment(item, attcreater, beizhu);
		}
		,
		//页面函数描述:附件删除
		attachmentDelete: function (item, id) {
			return _private.attachmentDelete(item, id);
		}
		,
		//页面函数描述:附件预览
		attachmentView: function (id, type) {
			return _private.attachmentView(id, type);
		}
		,
		//页面函数描述:判断是否是waf1的单据
		isWaf1Bill: function (url) {
			return _private.isWaf1Bill(url);
		}
		,
		//页面函数描述:显示单据摘要
		messageDigest: function () {
			return _private.messageDigest();
		},
		jMessageAlert: function (message) {
			return _private.jMessageAlert(message);
		},
		//控件事件描述:
		onselect: function (event, ui) {
			return _private.onselect(event, ui);
		},
		//页面函数描述:保存常用审批意见
		addphrase: function () {
			return _private.addphrase();
		}
		,
		//控件事件描述:
		openAttachmentPage: function (event, value) {
			return _private.openAttachmentPage(event, value);
		}
		,
		//页面函数描述:
		getAssignInfo: function () {
			return _private.getAssignInfo();
		}
	});
	_self.subscribeEvent("pageOnLoadEvent", _public.pageOnload, "after");

	_self.subscribeEvent("pageOnRenderEvent", _public.pageOnRenderBefore, "before");

	_self.subscribeEvent("phrasedelActionEvent", _public.phrasedel, "overwrite");

	_self.subscribeEvent("phrasesureActionEvent", _public.phrasesure, "overwrite");

	_self.subscribeEvent("phrasebackActionEvent", _public.phraseback, "overwrite");

	_self.subscribeEvent("phraseaddActionEvent", _public.phraseadd, "overwrite");

	//@endPublic
	//@beginTemplateFunctions

	//@endTemplateFunctions

	/**************************开发区域开始**********************************************/
	//@beginPrivate
	waf.extend(_private, {
		modifyNextAct: "#modifynextAct",
		charFrameId: "predictionChartIframe",
		curTab: "",
		leftPanelWidth: "",
		rightPanelWidth: "",
		isPredict: true,
		displayBillInfo: function (url) {
			if (assign.attachmentMode) {
				if (!url.endsWith("nobill.html")) {
					url += "&hasAttachment=false";
				}
			}
			waf("#billFrame").wafIframe('option', 'src', url);
		},
		getPolicy: function (approveValueStr) {
			if (approveValueStr == null || approveValueStr == "") {
				approveValueStr = "0;" + _self._localeStr.WEB_AGREE + ";" + _self._localeStr.WEB_AGREE + ";:1;" + _self._localeStr.WEB_DISAGREE + ";" + _self._localeStr.WEB_DISAGREE + ";";
			}
			var strs = approveValueStr.split(":"); //字符分割   
			for (var i = 0; i < strs.length; i++) {
				var strTemp = strs[i].split(";");
				var key = strTemp[0];
				var text = strTemp[1];
				var type = strTemp.length == 2 ? _self._localeStr.WEB_ALL : strTemp[2];
				var line = strTemp.length < 4 ? "" : strTemp[3];
				var o = {};
				o.alias = text;
				o.value = key;
				if ("agree" == type || type == _self._localeStr.WEB_AGREE || "同意" == type) {
					okPolicy.push(o);
				} else if ("disagree" == type || type == _self._localeStr.WEB_DISAGREE || "不同意" == type) {
					noPolicy.push(o);
				} else if ("all" == type || type == _self._localeStr.WEB_ALL || "全部" == type) {
					okPolicy.push(o);
					noPolicy.push(o);
				}
			}
		},
		setPolicy: function (val) {
			if (val == "true") {
				if (isFirst) {
					isFirst = false;
				} else {
					approveOpinions.disagree = $("#approveOpinion").val();
					approvePolicy.disagree = waf("#policy").wafSelect("getValue");
				}
				if (approvePolicy.agree) {
					waf("#policy").wafSelect("setValue", approvePolicy.agree);
				}
				$("#approveOpinion").val(approveOpinions.agree);
				waf("#policy").wafSelect("option", "enumSource", okPolicy);
			} else {
				if (isFirst) {
					isFirst = false;
				} else {
					approveOpinions.agree = $("#approveOpinion").val();
					approvePolicy.agree = waf("#policy").wafSelect("getValue");
				}
				if (approvePolicy.disagree) {
					waf("#policy").wafSelect("setValue", approvePolicy.disagree);
				}
				$("#approveOpinion").val(approveOpinions.disagree);
				waf("#policy").wafSelect("option", "enumSource", noPolicy);
			}
			_private.reloadTranId();
			if (waf(nextActIndex).wafCheckbox("isChecked")) {
				_private.loadNextActs();
			}
		},
		isNeedDefaultOption: function (vals) {
			if (assign.isNeedDefaultOption) {
				waf("#approveOpinion").val(vals);
			}
			if (assign.defaultOpinion != null && assign.defaultOpinion != "") {
				waf("#approveOpinion").val(assign.defaultOpinion);
			}
		},
		getDefaultOption: function (vals) {
			if (assign.isNeedDefaultOption) {
				approveOpinions = { agree: _self._localeStr.WEB_AGREE, disagree: _self._localeStr.WEB_DISAGREE };
			}
			if (assign.defaultOpinion != null && assign.defaultOpinion != "") {
				approveOpinions = { agree: assign.defaultOpinion, disagree: assign.defaultOpinion };
			}
		},
		setsendmailormsg: function (isOpenMessageSendOnUI, notifyNextBySMS, notifyNextByMail) {
			waf("#issendmsgormail").wafPanel("option", "hidden", !isOpenMessageSendOnUI);
			waf("#sendmsg").wafCheckbox("option", "hidden", !isOpenMessageSendOnUI);
			waf("#sendmail").wafCheckbox("option", "hidden", !isOpenMessageSendOnUI);
			waf("#sendmsg").wafCheckbox("setChecked", notifyNextBySMS);
			waf("#sendmail").wafCheckbox("setChecked", notifyNextByMail);
		},
		resizePage: function () {
			var rightwidth = Math.ceil((300 / window.innerWidth) * 100);
			if (window.screen.width <= 1366) {
				rightwidth = 21;
			}
			var leftwidth = 100 - rightwidth;
			waf("#splitPanel").wafSplitPanel("option", { split: false, leftWidth: leftwidth, rightWidth: rightwidth });
			var billHeightOffset = 220;
			var tabOffset = 100;
			if (assign.newPage && approvetype == "approve") {
				billHeightOffset = 160;
				tabOffset = 155;
			}
			if (approvetype != "approve") {
				billHeightOffset -= 120;
			}
			$("#tabs .ui-waftabs-panel").eq(0).height(window.innerHeight - tabOffset);
			if (approvetype == "batchapprove") {
				if (assign.batchApproveUrl) {
					var times = 0;
					waf("#billFrame").wafIframe("option", "height", window.innerHeight - 100);
					var interval = setInterval(function () {
						try {
							window.frames['billFrame'].$("#gview_queryGrid .ui-jqgrid-bdiv").eq(0).css("height", window.innerHeight - 220);
							if (times > 4) {
								clearInterval(interval);
							}
							times++;
						} catch (e) { }
					}, 500);
					waf("#billFrame").wafIframe("option", "scrolling", "auto");
				} else {
					$("#gview_queryGrid .ui-jqgrid-bdiv").height($("#tabs").height() - 100);
					$("#gview_queryGrid .ui-jqgrid-bdiv").css("overflow-y", "auto");
					$("#panel5 .ui-jqgrid").height($("#tabs").height());
				}
			} else {
				if (assign.messageDigest) {
					$("#panel5").css({ "height": window.innerHeight - billHeightOffset, "overflow-y": "auto", "overflow-x": "hidden" });
					$("#bill_content").css({ "height": window.innerHeight - billHeightOffset, "overflow": "auto" });
				} else {
					waf("#billFrame").wafIframe("option", "height", window.innerHeight - billHeightOffset);
					waf("#billFrame").wafIframe("option", "scrolling", "auto");
				}
			}
			if (assign.absStr || assign.decisionDesc) {
				_private.changeBillHeight(90, false);
			}
			if (approvetype == "batchapprove" || approvetype == "approve") {
				$("#myPhraseList .scrollhid").height($("#approveTask").height() - 100);
			}
		},
		changeBillHeight: function (height, isClose) {
			var billHeight = 0;
			if (assign.messageDigest) {
				billHeight = $("#panel5").height();
			} else {
				billHeight = waf("#billFrame").wafIframe("option", "height");
			}
			if (isClose) {
				billHeight += height;
			} else {
				billHeight -= height;
			}
			if (assign.messageDigest) {
				$("#panel5").css({ "height": billHeight, "overflow-y": "auto" });
			} else {
				waf("#billFrame").wafIframe("option", "height", billHeight);
				waf("#billFrame").wafIframe("option", "scrolling", "auto");
			}
		},
		showapprovehis: function (procInstId) {
			var params = {};
			params.embed = "true";
			params.proInstId = procInstId;
			waf.doPost({
				url: waf.getContextPath() + '/flowRelated.do?method=getFlowRealted',
				data: params,
				success: function (data) {
					var _html = '';
					for (var i = 0; i < data.length; i++) {
						var action = data[i].action;
						var node = data[i].node;
						if (node == null) {
							node = "";
						}
						var operatorResult = data[i].operatorResult;
						if (operatorResult == "" || operatorResult == null) {
							operatorResult = action;
						}
						var op = '';
						var operatorOpinion = data[i].operatorOpinion;
						if (operatorOpinion == "" || operatorOpinion == null) {
							operatorOpinion = "";
						}
						var classname = 'agree';
						/*
						*  0:打回;1:跳转 ;2:加签;3:转交; 4:终止;5:重新指定执行人;6:添加执行人;7:挂起;8:撤销挂起;9:审批;10;审批撤回
						*/
						var type = data[i].type;
						var titlename = "";
						if (type == 9 || type == 10) {
							var operatorResults = operatorResult.split(",");
							if (operatorResults.length == 2) {
								op += "<span title=" + _self._localeStr.WEB_APPROVALRESULTS + ">" + _self._localeStr.WEB_APPROVALRESULTS + "：</span><span title='" + operatorResults[0] + "'>" + operatorResults[0] + "</span><br/>";
								op += "<span title=" + _self._localeStr.WEB_HANDLEROPINIONS + ">" + _self._localeStr.WEB_HANDLEROPINIONS + "：</span><span title='" + operatorResults[1] + "'>" + operatorResults[1] + "</span><br/>";
								if (operatorResults[0] == _self._localeStr.WEB_DISAGREE || operatorResults[0] == "Disagree") {
									classname = 'disagree';
								}
							} else {
								op += "<span title='" + operatorResult + "'>" + operatorResult + "</span><br/>";
							}
							titlename = _self._localeStr.WEB_APPROVALCOMMENTS;
						} else {
							op += "<span title='" + operatorResult + "'>" + operatorResult + "</span><br/>";
							if (type == 1) {
								classname = 'jump';
								titlename = _self._localeStr.WEB_JUMPCOMMENTS;
							} else if (type == 2) {
								classname = 'append';
								titlename = _self._localeStr.WEB_COUNTERSIGNCOMMENTS;
							} else if (type == 4) {
								classname = 'stop';
								titlename = _self._localeStr.WEB_ENDCOMMENTS;
							} else if (type == 3) {
								classname = 'deliver';
								titlename = _self._localeStr.WEB_TRANSFERRCOMMENTS;
							} else if (type == 0) {
								classname = 'jump';
								titlename = _self._localeStr.WEB_REJECTCOMMENTS;
							}
						}
						if (titlename != "") {
							op += "<span title='" + titlename + "'>" + titlename + "：</span><span title='" + operatorOpinion + "'>" + operatorOpinion + "</span><br/>";
						}
						if (i > 0) {
							if (data[i].node == data[i - 1].node) {
								_html += '<div class="infos">' +
									'	<div class="content">' +
									'		<div class="title">' +
									'			<i></i>' +
									'			<span style="float:left;">' + data[i].operatorTime + '</span>' +
									'			<span style="float:right;">' + data[i].operator + '</span>' +
									'		</div>' +
									'		<div class="op">' + op + '</div>' +
									'	</div>' +
									'</div>';
								if (i != data.length - 1) {
									if (data[i].node != data[i + 1].node) {
										_html += '</div></li>';
									}
								}
								continue;
							}
						}
						_html += '<li>' +
							'<div class="node">' +
							'	<i class="' + classname + '"></i>' +
							'	<span>' + node + '</span>' +
							'</div>';
						if (i != data.length - 1) {
							if (data[i].node == data[i + 1].node) {
								_html += '<div class="info"><div class="infos">';
							} else {
								_html += '<div class="info">';
							}
						} else {
							_html += '<div class="info">';
						}
						_html += '	<div class="content">' +
							'		<div class="title">';
						if (i != data.length - 1) {
							if (data[i].node == data[i + 1].node) {
								_html += '<i></i>';
							}
						}
						_html += '			<span style="float:left;">' + data[i].operatorTime + '</span>' +
							'			<span style="float:right;">' + data[i].operator + '</span>' +
							'		</div>' +
							'		<div class="op">' + op + '</div>' +
							'	</div>' +
							'</div>';
						if (i != data.length - 1) {
							if (data[i].node != data[i + 1].node) {
								_html += '</li>';
							}
						}
					}
					if (!_html) {
						_html = _self._localeStr.WEB_NOAPPROVALRECORDS;
					}
					$("#approveHisInfo ul")[0].innerHTML = _html;
				}
			});
		},
		showbtn: function () {
			waf('#dynamicSign').wafLinkButton("option", "hidden", !assign.dynamicSign);
			waf('#appendActivity').wafLinkButton("option", "hidden", !assign.allowAppendActivity || approvetype == "manualdecision");
			waf('#jumpto').wafLinkButton("option", "hidden", !assign.allowJumpTo);
			waf('#kickback').wafLinkButton("option", "hidden", !assign.allowKickBack);
			waf('#deliver').wafLinkButton("option", "hidden", !assign.allowDeliver);
			waf('#YZJShare').wafLinkButton("option", "hidden", true);
			if (assign.allowJumpTo || assign.allowKickBack) {
				var assignId = assign.assignId;
				waf.doPost({
					url: waf.getContextPath() + '/common/tree.do?method=getJumpAndKickBackModel',
					async: false,
					data: { "assignId": assignId },
					success: function (data) {
						if (assign.allowJumpTo) {
							waf('#jumpto').wafLinkButton("option", "hidden", !data.jumpTo);
						}
						if (assign.allowKickBack) {
							waf('#kickback').wafLinkButton("option", "hidden", !data.kickBack);
						}
					}
				});
			}
			if (assign.canSpecifyNextPerformer || assign.mustShowPostActivities || assign.showNextP) {
				if (assign.mustShowPostActivities || assign.showNextP) {
					waf(nextActIndex).wafCheckbox("option", "checked", true);
				}
			} else {
				waf(nextActIndex).wafCheckbox("option", "hidden", true);
			}
			if (approvetype == "batchapprove") {
				waf('#btnImage').wafLinkButton("option", "hidden", false);
				waf('#btnBill').wafLinkButton("option", "hidden", false);
			}
			if (approvetype == "approve") {
				waf("#save").wafLinkButton("option", "hidden", false);
			}
		},
		setselnextperson: function (actId, name, id) {
			var ps = {};
			if (selnextPersons[actId]) {
				ps = selnextPersons[actId];
				if (ps[id]) {
					return;
				}
			}
			ps[id] = {
				number: "",
				name: name,
				id: id
			};
			selnextPersons[actId] = ps;
		},
		loadNextActs: function () {
			_private.getnextacts();
			var nextActs = assign.nextActs;
			_private.innerloadNextActs(nextActs);
		},

		innerloadNextActs: function (nextActs, selectAct) {
			var table = $("#nextActList");
			var _innerhtml = "";
			if (nextActs) {//有后继活动
				var actTitles = {};
				if (nextActs.length == 0) {
					_innerhtml += "<div>" + _self._localeStr.WEB_NOSETACTIVITYPERSON + "</div>";
					$(_private.modifyNextAct).wafLinkButton("option", "hidden", true);
				} else {
					var hasAct = false;
					var selectActobj = {};
					if (selectAct) {
						for (var actid in selectAct) {
							selectActobj[actid] = actid;
						}
					}
					for (var i = 0; i != nextActs.length; i++) {
						var act = nextActs[i];
						var num = 0;
						var actId = act.actId;
						var candidateselected = act.candidateselected;
						if (!selectActobj[actId]) {
							for (var id in candidateselected) {
								_private.setselnextperson(actId, candidateselected[id], id);
								num++;
							}
						}
						if (_private.isPredict && !act.isPredict) continue;
						hasAct = true;
						var actKey = act.actKey;
						var actName = act.actName;
						var isAllPersonAsPerformer = act.isAllPersonAsPerformer;
						var persons = act.persons;
						var count = act.count;
						var issel = false;
						var title = "";
						if (num > 0) {
							issel = true;
						}
						_innerhtml += "<div class='actInfo' actId='" + actId + "' actKey='" + actKey + "' title='" + actName + "'>" + actName + "</div>" +
							"<div class='actInfoperson' id='" + actId + "'>";
						if (issel) {
							_innerhtml += _self._localeStr.WEB_SELECTED;
							var j = 0;
							for (var id in candidateselected) {
								if (j > 0) {
									title += "、";
								}
								title += candidateselected[id];
								if (j > 2) {
									j++;
									continue;
								}
								if (j > 0) {
									_innerhtml += "、";
								}
								_innerhtml += "<span class='persons' personid='" + id + "'>" + candidateselected[id] + "</span>";
								j++;
							}
							actTitles[actId] = title;
							if (j > 2) {
								_innerhtml += _self._localeStr.WEB_ANDSOON + j + _self._localeStr.WEB_PEOPLE;
							}
						} else if (count > 0) {
							_innerhtml += "";
							var j = 0;
							for (var id in persons) {
								if (j > 0) {
									title += "、";
								}
								title += persons[id];
								if (j > 2) {
									_innerhtml += _self._localeStr.WEB_ANDSOON + count + _self._localeStr.WEB_PEOPLE;
									break;
								}
								if (j > 0) {
									_innerhtml += "、";
								}
								_innerhtml += "<span class='persons' personid='" + id + "'>" + persons[id] + "</span>";
								j++;
							}
							actTitles[actId] = title;
						} else {
							_innerhtml += _self._localeStr.WEB_UNSELECTEDPERSON;
						}
						_innerhtml += "</div>";
					}
					if (!hasAct) {
						_innerhtml += "<div>" + _self._localeStr.WEB_POINTNEXTTIP + "</div>";
					}
					$(_private.modifyNextAct).wafLinkButton("option", "hidden", false);
				}
				table.html(_innerhtml);
				for (var actTitle in actTitles) {
					$("#" + actTitle).attr("title", actTitles[actTitle]);
				}
			}
		},
		getOpinion: function (actInstId, assignId, billId) {
			var params = {};
			params.actInstId = actInstId;
			params.assignId = assignId;
			params.billId = billId;
			params.type = approvetype;
			waf.doPost({
				url: waf.getContextPath() + '/workflow/approve.do?method=getOpinion',
				data: params,
				success: function (data) {
					if (data != null && data != "" && data.option != null && data.option != "") {
						$("#approveOpinionInfo span").text(data.option);
					} else {
						$("#approveOpinionInfo").hide();
					}
				}
			});
		}
		,
		supportMulti: function () {
			$("#approveDeliverBtn span").text(_self._localeStr.WEB_DELIVER);
			$("#approvePassBtn span").text(_self._localeStr.WEB_CIRCULATEBTN);
			$("#approveAppendBtn span").text(_self._localeStr.WEB_ADDSIGN);
			$("#approveDynamicSignBtn span").text(_self._localeStr.WEB_CONTERSIGNED);
			$("#approveSaveBtn span").text(_self._localeStr.WEB_SAVE);
			$("#approveSubmitBtn span").text(_self._localeStr.WEB_SUBMIT);
			$("#btnUpload").prepend(_self._localeStr.WEB_UPLOADATTACH);
			$("#attachmul1").prepend(_self._localeStr.WEB_ATTCHNUM);
			$("#attchmul2").prepend(_self._localeStr.WEB_VIEWDETAIL);
			$("#attachmul3").prepend(_self._localeStr.WEB_ATTCHGE);
			$("#attchment").append($(".attchmentnuminfo"));
			$("#attchment").append($("#upload"));
			$("#myPhraseInfo .edit").text(_self._localeStr.WEB_SAVE);
			$("#myPhraseInfo .backprevious").text(_self._localeStr.WEB_BACK);
			$("#myPhraseInfo .commit").text(_self._localeStr.WEB_DETERMINE);
			$("#myPhrasetext").prop("placeholder", _self._localeStr.WEB_ENTER_COMMENTS);
		}
		,
		initApprove: function () {
			if (assign.riskInsight) {
				_private.initRiskInsight();
			} else {
				waf("#riskInsight").wafTab("remove");
			}
			_private.initEsignature();
			_private.initCCPerson();
			_private.showbtn();
			_private.initBillPage();
			_private.initAttachment();
			_private.initOperateIframe();
			_private.initAbstractAndPhrase();
			_private.initApprovePolicy()
		}
		,
		initBatchapprove: function () {
			_private.initEsignature();
			_private.showbtn();
			locationurl.billIds = decodeURIComponent(parent.window.billIDs);
			locationurl.assignmentIds = parent.window.assignmentIDs;
			_private.getbatchlist();
			_private.initAbstractAndPhrase();
			_private.initApprovePolicy()
			waf("#attchment").wafSection("option", "hidden", true);
			$("#upload").remove();
			$("#operateInfo").remove();
			$(".attchmentnuminfo").remove();
		}
		,
		initManualdecision: function () {
			_private.initManualdecisionNextAct();
			_private.showbtn();
			_private.initBillPage();
			_private.initAttachment();
			_private.initOperateIframe();
			_private.initDecisionDescAndVal();

		}
		,
		initPassComent: function () {
			if (assign.passcoment != null) {
				waf('#passComentOpinion').val(assign.passcoment);
			}
			if (assign.isFeedBack) {
				waf("#sendmsgs").wafCheckbox("disable");
				waf("#sendmails").wafCheckbox("disable");
			}
			waf('#submit').wafLinkButton("option", "hidden", assign.isFeedBack);
			waf("#passAssignment").wafLinkButton("option", "hidden", (assign.againPass === "false"));
			_private.initBillPage();
			_private.initAttachment();
			_private.initOperateIframe();
		}
		,
		initManualdecisionNextAct: function () {
			nextActIndex = "#nextAct1";
			_private.modifyNextAct = "#modifynextAct1";
			if (waf(nextActIndex).wafCheckbox("isChecked")) {
				_private.loadNextActs();
			}
		}
		,
		initRiskInsight: function () {
			try {
				//动态引入风险洞察模块  与web框架解耦
				mod.use("billInsight", function () {
					//如果进入说明有风险洞察模块
					riskInsight = true;
					$("#form").append('<div id="billInsight" class="" ctrlrole="waf.billInsight" data-domcreated="true"></div>');
					$("#li_approveTask").css("width", "50%");
					$("#li_riskInsight").show();
					billInsightOption = _private.getWeakRisk();
					_private.updateBillInsightNum(billInsightOption);
					$(window).resize(function () {
						_private.resizeBillInsight(true);
					});
				});
			} catch (e) {
				console.log(_self._localeStr.WEB_CONSOLETEXT);
			}
		}
		,
		initCCPerson: function () {
			if (assign.allowCC) {
				$('#panelCC').show();
			}
			if (assign.ccPersonIds != null && assign.ccPersonName != null) {
				waf("#textCC").prop("personIds", assign.ccPersonIds);
				waf("#textCC").val(assign.ccPersonName);
			}
		}
		,
		initEsignature: function () {
			if (!assign.isEsignature || assign.esignatureAttachId == undefined || assign.esignatureAttachId == '') {
				$("#panel6").remove();
			} else {
				var _html = "<img src='/easweb/webviews/webframework/webcom/attachment/view.jsp?bosID=" + assign.esignatureAttachId + "'/>";
				$("#esigndiv")[0].innerHTML = _html;
			}
		}
		,
		initBillPage: function () {
			if (assign.messageDigest) {
				try {
					_private.messageDigest();
				} catch (e) {
					console.log(_self._localeStr.WEB_BILLINITFAILED);
				}
			} else {
				if (!assign.billEditUrl || assign.billEditUrl == "nobill.html") {
					assign.billEditUrl = '/easweb/webviews/workflow/nobill.html?';
				}
				if (approvetype == "passComent" && msgId) {
					assign.billEditUrl = assign.billEditUrl + '&msgId=' + encodeURIComponent(msgId);
				}
				_private.displayBillInfo(assign.billEditUrl);
			}
		}
		,
		initAttachment: function () {
			waf("#attachmentBtn").wafLinkButton("option", "hidden", assign.attachDisabled);
			_private.refreshAttachCountInner(assign.attachmentCount);
		}
		,
		initOperateIframe: function () {
			var url = "/easweb/dynamicPage.do?event=initialize&method=doEvent&uipk=com.kingdee.bos.workflow.metas.approveRelatedInfo&isshowapprove=true&assignmentId=" + assign.assignId;
			waf("#operateiframe").wafIframe('option', 'src', url);
		}
		,
		initApprovePolicy: function () {
			_private.getPolicy(assign.approveValue);
			_private.getDefaultOption();
			if (assign.id) {
				waf("#approveResult").wafRadioGroup("setValue", assign.approveResult);
				waf("#policy").wafSelect("setValue", assign.handlerOpinion)
			} else {
				waf("#approveResult").wafRadioGroup("setValue", "true");
			}
		}
		,
		initAbstractAndPhrase: function () {
			if (assign.absStr) {
				waf("#optionalSection").wafSection("option", "title", _self._localeStr.WEB_PROCESSSUMMARY);
				waf("#optionalSection").wafSection("option", "hidden", false);
				$("#description").text(assign.absStr);
			}
			_private.getphrase();
			$("#myPhraseList").on("click", "li", function (e) { _private.clickPhrase(e) });
			$("#myPhraseList").on("dblclick", "li", function (e) { _private.dblclickPhrase(e) });
			$("#myPhraseList").on("click", "li i", function (e) { _private.phrasedel(e) });
		}
		,
		initDecisionDescAndVal: function () {
			if (assign.decisionDesc) {
				waf("#optionalSection").wafSection("option", "title", _self._localeStr.WEB_DECISONDESC);
				waf("#optionalSection").wafSection("option", "hidden", false);
				$("#description").text(assign.decisionDesc);
				_private.changeBillHeight(85, false);
			}
			_private.setmanualdecision();
		}
		,
		initCalProcDiagram: function () {
			var url = "/easweb/webviews/workflow/calProcDiagramNew.jsp?procInstId=" + assign.procInstId + "&actinstId=" + assign.actInstId + "&newPage=" + assign.newPage;
			waf("#" + _private.charFrameId).wafIframe('option', 'src', url);
			var urlWin = "/easweb/webviews/workflow/calProcDiagram.jsp?procInstId=" + assign.procInstId + "&actinstId=" + assign.actInstId;
			waf("#chartIframe").wafIframe('option', 'src', urlWin);
			$("#chart").click(function () {
				$("#chart").hide()
			});
			$("#chartClose").click(function () {
				$("#chart").hide()
			});
			$("#openChartIframe").click(function () {
				$("#chart").show()
			});
			var times = 0;
			var interval = setInterval(function () {
				if (window.frames[_private.charFrameId]) {
					var num = window.frames[_private.charFrameId].num;
					if (num > 0) {
						var iWidth = window.innerWidth * (4 / 5);
						var rowNum = parseInt(iWidth / 176);
						var calcHeight = Math.ceil(num / rowNum) * 140;
						var winHeight = "";
						if (top == parent.parent) {
							winHeight = window.innerHeight;
						} else {
							//门户打开
							winHeight = window.screen.availHeight - 120;
						}
						var iHeight = winHeight * (4 / 5);
						if (calcHeight < iHeight) {
							iHeight = calcHeight;
						}
						var iTop = (winHeight - 70 - iHeight) / 2;
						var iLeft = (window.innerWidth - 10 - iWidth) / 2;
						$("#chartIframe").css({
							"margin-left": iLeft,
							"margin-top": iTop,
							width: iWidth,
							height: iHeight
						});
					}
				}
				times++
				if (times > 100) {
					clearInterval(interval)
				}
			}, 100);
		}
		,
		initPageLayout: function () {
			//按钮布局：按钮靠左，按钮靠右  不同布局简略图位置也显示不一样
			if (assign.newPage) {
				$("#predictionChart").remove();
				_private.charFrameId = "predictionChartIframeNew";
				_private.initBtnNew();
			} else {
				$("#predictionChartNew").remove();
			}
			if (locationurl.isOpenNewTab != undefined && locationurl.isOpenNewTab == "true") {
				$("#nextActList").css("height", "20vh");
			}
		}
		,
		initCalProcDiagramPanel: function () {
			//只有审批时才展示预估图
			if (approvetype == "approve") {
				_private.initCalProcDiagram();
			} else {
				$("#chart").remove();
				$("#predictionChart").remove();
				$("#predictionChartNew").remove();
			}
		}
		,
		initSection: function () {
			if (approvetype != "batchapprove") {
				waf("#predictionChart").wafSection("option", 'onopen', function (event) {
					_private.changeBillHeight(50, false);
				});
				waf("#predictionChart").wafSection("option", 'onclose', function (event) {
					_private.changeBillHeight(50, true);
				});
				waf("#operateInfo").wafSection("option", 'onopen', function (event) {
					_private.changeBillHeight(220, false);
				});
				waf("#operateInfo").wafSection("option", 'onclose', function (event) {
					_private.changeBillHeight(220, true);
				});
				waf("#optionalSection").wafSection("option", 'onopen', function (event) {
					_private.changeBillHeight(60, false);
				});
				waf("#optionalSection").wafSection("option", 'onclose', function (event) {
					_private.changeBillHeight(60, true);
				});
			}
		}
		,
		initZoomTool: function () {
			$("#onClose").show();
			$("#tabs_ul li").eq($("#tabs_ul li").length - 1).append($("#onClose"));
			$("#splitPanel_LeftSplitPanel").prepend($("#onOpen"));
			$("#onClose").bind("click", function () {
				$("#splitPanel").height($("#splitPanel_LeftSplitPanel").height());
				rightPanelWidth = $("#splitPanel_RightSplitPanel").width();
				leftPanelWidth = $("#splitPanel_LeftSplitPanel").width();
				$("#splitPanel_RightSplitPanel").css("width", "0%");
				$("#splitPanel_LeftSplitPanel").css("width", "100%");
				$("#onOpen").show();
				if (riskInsight && _private.curTab == "riskInsight") {
					$(".billInsight_cardPanel").css("display", "none");
				}
				if (approvetype == "batchapprove" && !assign.batchApproveUrl) {
					var newWidth = $("#queryGrid").wafGrid("getGridParentWidth");
					$("#queryGrid").jqGrid("setGridWidth", newWidth);
				}
			});
			$("#onOpen").bind("click", function () {
				$("#onOpen").hide();
				$("#splitPanel_RightSplitPanel").css("width", rightPanelWidth);
				$("#splitPanel_LeftSplitPanel").css("width", leftPanelWidth);
				if (riskInsight && _private.curTab == "riskInsight") {
					$(".billInsight_cardPanel").show();
				}
				if (approvetype == "batchapprove" && !assign.batchApproveUrl) {
					var newWidth = $("#queryGrid").wafGrid("getGridParentWidth");
					$("#queryGrid").jqGrid("setGridWidth", newWidth);
				}
			});
			$("#onOpen").bind("hover", function () {
				$("#onOpen").css("opacity", 1);
			});
		}
		,
		pageOnload: function (e) {
			$("body").ready(function () {
				_private.supportMulti();
				_private.showtab();
				var billId = assign.billId;
				if (approvetype == "approve") {
					_private.initApprove();
				} else if (approvetype == "batchapprove") {
					_private.initBatchapprove();
					// 添加首次查看记录
					if (locationurl && locationurl.assignmentIds) {
						var actionUrl = waf.getContextPath() + "/activityProperty.do?method=addAssignReadTime";
						var params = {};
						params.assignIds = locationurl.assignmentIds;
						waf.doPost({
							url: actionUrl,
							data: params,
							async: true,
							success: function (data) {
							}
						});
					}
				} else if (approvetype == "manualdecision") {
					_private.initManualdecision();
				} else if (approvetype == "passComent") {
					_private.initPassComent();
					billId = passId;
				}
				_private.initSection();
				_private.initPageLayout();
				_private.initCalProcDiagramPanel();
				_private.getOpinion(assign.actInstId, assign.assignId, billId);
				_private.setsendmailormsg(assign.isOpenMessageSendOnUI, assign.notifyNextBySMS, assign.notifyNextByMail);
				if (assign.newPage) {
					_private.initZoomTool();
				}
				_private.resizePage();
				window.scrollTo(0, 0);
				var newTab = waf.getUrlParams(document.URL).isOpenNewTab
				if (newTab) {
					$("#operateInfo").css("margin", "3px 5px 5px 0");
				}
			});
		}
		,
		initBtnNew: function () {
			var submitBtn = waf('#submit').wafLinkButton("option", "hidden");
			$("#toolBar .ui-toolbar-ul").css("float", "right");
			if (approvetype == "approve" || approvetype == "batchapprove") {
				if (approvetype == "approve") {
					var offset = $("#panelNew1").width() - ($("#approveSaveBtn").width() * 2 + 20);
					if (offset > 0) {
						$("#approveSaveBtn").css("margin-left", offset / 2);
					}
				} else {
					$("#approveSubmitBtn").css("float", "right");
				}

				$("#toolBarNew1").show();
				$("#panelNew1").show();
				$("#labelapproveResult_label").hide();
				waf('#approveSubmitBtn').wafLinkButton("option", "hidden", submitBtn);
				waf('#approveSaveBtn').wafLinkButton("option", "hidden", waf('#save').wafLinkButton("option", "hidden"));
				waf('#approveDeliverBtn').wafLinkButton("option", "hidden", waf('#deliver').wafLinkButton("option", "hidden"));
				waf('#approvePassBtn').wafLinkButton("option", "hidden", waf('#passAssignment').wafLinkButton("option", "hidden"));
				waf('#approveKickbackBtn').wafLinkButton("option", "hidden", waf('#kickback').wafLinkButton("option", "hidden"));
				waf('#approveAppendBtn').wafLinkButton("option", "hidden", waf('#appendActivity').wafLinkButton("option", "hidden"));
				waf('#approveDynamicSignBtn').wafLinkButton("option", "hidden", waf('#dynamicSign').wafLinkButton("option", "hidden"));
				waf('#approveJumpBtn').wafLinkButton("option", "hidden", waf('#jumpto').wafLinkButton("option", "hidden"));
			} else if (approvetype == "manualdecision") {
				$("#panelNew3").show();
				var b = waf('#deliver').wafLinkButton("option", "hidden");
				if (!b) {
					$("#toolBarNew3").show();
				}
				waf('#decisionDeliverBtn').wafLinkButton("option", "hidden", waf('#deliver').wafLinkButton("option", "hidden"));
				waf('#decisionSubmitBtn').wafLinkButton("option", "hidden", submitBtn);
			} else if (approvetype == "passComent") {
				$("#panelNew2").show();
				var b = waf('#passAssignment').wafLinkButton("option", "hidden");
				if (!b) {
					$("#toolBarNew2").show();
				}
				waf('#passPassBtn').wafLinkButton("option", "hidden", b);
				waf('#passSubmitBtn').wafLinkButton("option", "hidden", submitBtn);
			}
			waf('#submit').wafLinkButton("option", "hidden", true);
			waf('#save').wafLinkButton("option", "hidden", true);
			waf('#deliver').wafLinkButton("option", "hidden", true);
			waf('#passAssignment').wafLinkButton("option", "hidden", true);
			waf('#kickback').wafLinkButton("option", "hidden", true);
			waf('#appendActivity').wafLinkButton("option", "hidden", true);
			waf('#dynamicSign').wafLinkButton("option", "hidden", true);
			waf('#jumpto').wafLinkButton("option", "hidden", true);
			if (approvetype != "batchapprove") {
				$("#assignTitle").show();
				$("#assignTitle").css("width", $("#toolBar").width() - $("#toolBar .ui-toolbar-ul").width());
				$("#assignTitle").text(assign.title);
				$("#assignTitle").prop("title", assign.title);
			}
		},
		changePolicy: function (event, ui) {
			_private.setPolicy(ui.current);
			if (ui.current == "false") {
				$("#panel").hide();
			} else {
				$("#panel").show();
			}
		}

		,
		deliver: function (event, value) {
			var para = {};
			if (approvetype == "batchapprove") {
				para.sourceID = _private.getbatchid().assignIds;
			} else {
				para.sourceID = assign.assignId;
			}
			wfCommonUtil.deliverAssignment(para);
		}
		,
		passAssignment: function (event, value) {
			var para = {};
			if (approvetype == "batchapprove") {
				var info = _private.getbatchid();
				para.sourceID = info.assignIds;
				para.bizObjID = info.billIds;
			} else {
				para.sourceID = assign.assignId;
				para.bizObjID = assign.billId;
			}
			wfCommonUtil.passComment(para);
		}
		,
		kickback: function (event, value) {
			var assignid = "";
			if (approvetype == "batchapprove") {
				assignid = _private.getbatchid().assignIds;
			} else {
				assignid = assign.assignId;
			}
			var url = waf.getContextPath() + "/dynamicPage.do?event=initialize&method=doEvent&uipk=com.kingdee.bos.workflow.metas.kickBackPage&assignmentId=" + encodeURIComponent(assignid);
			wfCommonUtil.windowopen(url, _self._localeStr.WEB_REJECT, 450, 320);
		}
		,
		jumpto: function (event, value) {
			var assignid = "";
			if (approvetype == "batchapprove") {
				assignid = _private.getbatchid().assignIds;
			} else {
				assignid = assign.assignId;
			}
			var url = waf.getContextPath() + "/dynamicPage.do?event=initialize&method=doEvent&uipk=com.kingdee.bos.workflow.metas.jump&assignmentId=" + encodeURIComponent(assignid);
			wfCommonUtil.windowopen(url, _self._localeStr.WEB_JUMP, 450, 281);
		}
		,
		dynamicSign: function (event, value) {
			var assignid = "";
			if (approvetype == "batchapprove") {
				assignid = _private.getbatchid().assignIds;
			} else {
				assignid = assign.assignId;
			}
			var url = waf.getContextPath() + "/dynamicPage.do?event=initialize&method=doEvent&uipk=com.kingdee.bos.workflow.metas.dynamicSignPage&assignmentId=" + encodeURIComponent(assignid);
			wfCommonUtil.windowopen(url, _self._localeStr.WEB_COUNTERSIGNPART, 450, 281);
		}
		,
		appendActivity: function (event, value) {
			var billId = "";
			var assignId = "";
			if (approvetype == "batchapprove") {
				var info = _private.getbatchid();
				assignId = info.assignIds;
				billId = info.billIds;
			} else {
				assignId = assign.assignId;
				billId = assign.billId;
			}

			var url = waf.getContextPath() + "/dynamicPage.do?event=initialize&method=doEvent&uipk=com.kingdee.bos.workflow.metas.appendSignPage&assignmentId=" + encodeURIComponent(assignId) + "&billIds=" + encodeURIComponent(billId) + "&isAppended=" + assign.isAppended;
			if (assign.appendMode) {
				url += '&appendMode=' + assign.appendMode[0];
			}
			if (assign.routeMode) {
				url += '&routeMode=' + assign.routeMode[0];
			}
			wfCommonUtil.windowopen(url, _self._localeStr.WEB_COUNTERSIGN, 520, 746);
		}
		,
		modifynextAct: function (event, value) {
			_private.setmodifynextAct();
		},
		setselnextactperson: function (resultStr) {
			_private.innerloadNextActs(assign.nextActs, resultStr);
			for (var actid in resultStr) {
				var ps = resultStr[actid];
				var _innerhtml = _self._localeStr.WEB_SELECTED;
				var j = 0;
				if (_private.isEmptyObject(ps)) {
					delete selnextPersons[actid];
				} else {
					var title = "";
					for (var id in ps) {
						var person = ps[id];
						var name = person.name;
						_private.setselnextperson(actid, name, id);
						if (j > 0) {
							title += "、";
						}
						title += name;
						if (j > 2) {
							j++;
							continue;
						}
						if (j > 0) {
							_innerhtml += "、";
						}
						_innerhtml += "<span class='persons' personid='" + id + "'>" + name + "</span>";
						j++;
					}
					if (j > 2) {
						_innerhtml += _self._localeStr.WEB_ANDSOON + j + _self._localeStr.WEB_PEOPLE;
					}
					$("#" + actid).html(_innerhtml);
					$("#" + actid).attr("title", title);
				}
			}
		},
		isEmptyObject: function (obj) {
			for (var key in obj) {
				return false;
			}
			return true;
		}
		,
		getphrase: function () {
			waf.doPost({
				url: waf.getContextPath() + '/workflow/approve.do?method=getAppMyPhraseList',
				success: function (data) {
					var myPhraseList = $("#myPhraseList .showdel");
					myPhraseList.html("");
					for (var i = 0; i < data.length; i++) {
						//<li data-id="p4AAAABOtHGGjkdQ" onclick="setPhraseColor(this)" ondblclick="myPhraseCommit()" title="h">h<i onclick="myPhraseDelete(&quot;p4AAAABOtHGGjkdQ&quot;)"></i></li>
						var row = $("<li></li>");
						row.attr({ "data-id": data[i].id, title: data[i].phraseText });
						row.text(data[i].phraseText);
						row.append("<i></i>");
						myPhraseList.append(row);
					}
				}

			});
		},
		clickPhrase: function (e) {
			$("#myPhraseInfo li").removeClass("cur");
			var targetElem = $(e.target);
			targetElem.addClass("cur");
			$("#myPhrasetext").val(targetElem.attr("title"));
			$("#myPhrasetext").attr("data-id", targetElem.attr("data-id"));

		},
		dblclickPhrase: function (e) {
			var itemval = $(e.target).attr("title");
			$("#approveOpinion").val(itemval);
			$("#myPhraseInfo li").removeClass("cur");
			$("#myPhrasetext").attr("data-id", "");
			$("#myPhrasetext").val("");
			$("#phrasePanel").hide();

		},
		phrasesure: function (e) {
			var text = $("#myPhrasetext").val();
			if (text != null && text.length > 1000) {
				_self.showInfo(_self._localeStr.WEB_APPROVALCOMMENTS_TOOLONG);
				return null;
			}
			$("#approveOpinion").val(text);
			$("#myPhraseInfo li").removeClass("cur");
			$("#myPhrasetext").attr("data-id", "");
			$("#myPhrasetext").val("");
			$("#phrasePanel").hide();
		}
		,
		phraseback: function (e) {
			$("#myPhraseInfo li").removeClass("cur");
			$("#myPhrasetext").attr("data-id", "");
			$("#myPhrasetext").val("");
			$("#phrasePanel").hide();
		}
		,
		myPhrase: function (event, value) {
			$("#phrasePanel").show();
			$("#myPhrasesection .ui-jqgrid-bdiv").css("height", "auto");
		}

		,
		addphrase: function () {
			// 对添加新的的超长审批意见做判断
			var text = $("#myPhrasetext").val();
			if (text != null && text.length > 1000) {
				_self.showInfo(_self._localeStr.WEB_APPROVALCOMMENTS_TOOLONG);
				return null;
			}
			var param = {};
			var rowid = $("#myPhrasetext").attr("data-id");
			var value = $("#myPhrasetext").val();
			if (!value) {
				return;
			}
			if (rowid) {
				param.method = "updateOption";
				param.opId = rowid;
				param.opName = value;
			} else {
				param.phraseTxt = value;
				param.method = "saveMyPhrase";
			}
			waf.doPost({
				url: waf.getContextPath() + '/workflow/approve.do',
				data: param,
				success: function (data) {
					_private.getphrase();
					_self.showSuccess(_self._localeStr.WEB_ADDCOMMONCOMMENTS);
				}
			});
		}
		,
		phrasedel: function (e) {
			var param = {};
			param.phraseIds = $(e.target).parent().attr("data-id");
			$("#myPhrasetext").attr("data-id", "");
			$("#myPhrasetext").val("");
			waf.doPost({
				url: waf.getContextPath() + '/workflow/approve.do?method=delMyPhrase',
				data: param,
				success: function (data) {
					_private.getphrase();
					_self.showSuccess(_self._localeStr.WEB_DELETECOMMONCOMMENTS);
				}
			});
		}
		,
		pageOnRenderBefore: function (e) {
			assign = _self.getPageInitData();
			//获取CA初始化的值 
			if (approvetype != "passComent") {
				_private.initCAConfig(assign.CAConfig);
			}
			var title = '';
			if (approvetype == "batchapprove") {
				title = _self._localeStr.WEB_BATCHAPPROVAL;
			} else {
				title = assign.title;
			}
			_self.changeTitle(title);
		}
		,
		phraseadd: function (e) {
			var datarow = { phraseText: "" };
			waf("#myPhrasegrid").wafGrid('addRow', { data: datarow });
		}
		,
		viewProcessDiagram: function (event, value) {
			var para = {};
			if (approvetype == "batchapprove") {
				var assignIds = _private.getbatchid().assignIds;
				if (assignIds.split(";").length != 1) {
					_self.showInfo(_self._localeStr.WEB_SELECTARECORD);
					return false;
				}
				para.sourceID = assignIds.split(";")[0];
			} else {
				para.sourceID = assign.assignId;
			}
			wfCommonUtil.viewProcessDiagram(para);
		}
		,
		reloadTranId: function () {
			var approveResult = waf("#approveResult").wafRadioGroup("getValue");
			var policy = waf("#policy").wafSelect("getValue");
			var ispass;
			if (approveResult == "false") {
				ispass = false;
			} else if (approveResult == "true") {
				ispass = true;
			}
			if (assign) {
				var approveValueStr = assign.approveValue;
				if (approveValueStr == null || approveValueStr == "") {
					approveValueStr = "0;" + _self._localeStr.WEB_AGREE + ";" + _self._localeStr.WEB_AGREE + ";:1;" + _self._localeStr.WEB_DISAGREE + ";" + _self._localeStr.WEB_DISAGREE + ";";
				}
				var strs = approveValueStr.split(":"); //字符分割	  
				for (var i = 0; i < strs.length; i++) {
					var strTemp = strs[i].split(";");
					//如果没有4位长度说明没有配置关联决策项
					if (strTemp.length != 4)
						continue;
					if (ispass && policy == strTemp[0]) {
						transId = strTemp[3];
						return;
					}
				}
			}
		}
		,
		changeselPolicy: function (event, ui) {
			_private.reloadTranId();
			if (waf(nextActIndex).wafCheckbox("isChecked")) {
				_private.loadNextActs();
			}
		}
		,
		getnextacts: function () {
			var param = {};
			param.assignId = assign.assignId;
			param.associatedLine = transId;
			param.isPredict = _private.isPredict;
			param.isNewProcessCenter = true;
			waf.doPost({
				url: waf.getContextPath() + '/common/tree.do?method=findPostParticipants',
				data: param,
				async: false,
				success: function (data) {
					assign.nextActs = data;
				}
			});
		}
		,
		showtab: function () {
			if (approvetype == "approve" || approvetype == "batchapprove") {
				$("#tabs").wafTabs("remove", "#manualdecision");
				$("#tabs").wafTabs("remove", "#passComent");
			} else if (approvetype == "manualdecision") {
				$("#tabs").wafTabs("remove", "#approveTask");
				$("#tabs").wafTabs("remove", "#passComent");
			} else if (approvetype == "passComent") {
				$("#tabs").wafTabs("remove", "#approveTask");
				$("#tabs").wafTabs("remove", "#manualdecision");
			}
			if (approvetype != "approve") {
				waf("#riskInsight").wafTab("remove");
			}
		}
		,
		setmanualdecision: function () {
			var items = assign.decisionItems;
			var opinions = assign.decisionOpinions;
			var _html = "";
			var itemArr = items.split(";");
			var opinionArr = new Array();
			if (!opinions) {
				var opinionItem = "";
				for (var i = 0; i < itemArr.length; i++) {
					opinionItem += (i + 1);
					if (i < itemArr.length - 1) {
						opinionItem += ";";
					}
					opinionArr.push(i + 1);
				}
				assign.decisionOpinions = opinionItem;
			} else {
				opinionArr = opinions.split(";");
			}
			var json = [];
			for (var i = 0; i < itemArr.length; i++) {
				var name = itemArr[i];
				var val = opinionArr[i];
				var para = {};
				para.value = val + "_" + i;
				para.alias = name;
				json.push(para);
			}
			waf("#radioDecision").wafRadioGroup("setItems", null, json);
			waf("#radioDecision").wafRadioGroup("setValue", json[0].value);
		}
		,
		nextActs: function (event, ui) {
			_private.shownextActs("modifynextAct1", ui);
		}
		,
		nextAct: function (event, ui) {
			_private.shownextActs("modifynextAct", ui);
		}
		,
		modifynextActs: function (event, value) {
			_private.setmodifynextAct();
		}
		,
		setmodifynextAct: function () {
			var jsonval = "";
			if (selnextPersons == null || selnextPersons.length == 0) {
				jsonval = "";
			} else {
				jsonval = JSON.stringify(selnextPersons);
			}

			waf.window.open({
				url: waf.getContextPath() + "/dynamicPage.do?event=initialize&method=doEvent&uipk=com.kingdee.bos.workflow.metas.setNextAct&debug=true&assignmentId=" + encodeURIComponent(assign.assignId) + "&selnextPersons=" + encodeURIComponent(jsonval) + "&asso=" + transId + "&isPredict=" + _private.isPredict,
				openType: "iframe",
				method: 'POST',
				data: {},
				modal: true,
				title: _self._localeStr.WEB_NEXTACTIVITY,
				position: 'center',
				width: 1020,
				height: 580,
				minHeight: 560,
				minWidth: 1020,
				iconCls: "waf-ui-icon",
				draggable: true,
				resizable: true,
				close: function (event, ui) {
				},
				retValCallBack: function (resultData) {
					if (resultData && resultData.resultStr && resultData.resultStr.length > 0) {
						var resultStr = JSON.parse(resultData.resultStr);
						selnextPersons = {};
						_private.isPredict = resultData.isPredict;
						_private.setselnextactperson(resultStr);
					}
				}
			});
		}
		,
		getbatchlist: function () {
			if (assign.batchApproveUrl) {
				var url = waf.getContextPath() + assign.batchApproveUrl + '&hasToolbar=false&showCommonQuery=false';
				var billIds = locationurl.billIds.split(";");
				var temp = 'id%20in%20(';
				for (var i = 0; i < billIds.length; i++) {
					if (billIds[i]) {
						if (i == 0) {
							temp += "%27" + encodeURIComponent(billIds[i]) + "%27";
						} else {
							temp += "%2C%27" + encodeURIComponent(billIds[i]) + "%27";
						}
					}
				}
				temp += ')';
				//waf頁面片段加form表單還不行，只能出此下策
				$("<form id='framesrcbillform' method='POST' type='hidden' target='billFrame' action='" + url + "'></form>")
					.insertAfter($("#billFrame"))
					.append($("<input type='hidden' name='filterInfo' value='" + temp + "'>"))
					.append($("<input type='hidden' name='botpFilter' value='" + temp + "'>"))
				setTimeout(function () { document.getElementById("framesrcbillform").submit(); }, 500);
				var times = 0;
				var interval = setInterval(function () {
					var frame = document.getElementById("billFrame");
					$($(frame)[0].contentDocument.body).find(".ui-jqgrid").css({ "margin": "0px", "width": "100%" });
					if (times > 600) {
						clearInterval(interval);
					}
					times++;
				});
			} else {
				waf("#billFrame").remove();
				var listinfo = {};
				waf.doPost({
					url: waf.getContextPath() + '/workflow/approve.do?method=getBatchApproveBillGrid',
					data: { billIds: locationurl.billIds },
					async: false,
					success: function (data) {
						listinfo = data;
					}
				});
				var headers = listinfo.headers;
				var list = listinfo.list;
				var fields = listinfo.fields;
				if (headers.length > 0) {
					var colmodel = [];
					var paraid = {
						name: "id",
						label: "id",
						hidden: true,
						key: true
					};
					colmodel.push(paraid);
					for (var m = 0; m < headers.length; m++) {
						var para = {
							name: fields[m],
							label: headers[m]
						};
						colmodel.push(para);
					}
					var myGridoptions = {
						id: "queryGrid",
						colModel: colmodel,
						multiselect: true,
						loadInit: false,
						shrinkToFit: true
					};
					//列数太多显示的表格有问题  web框架bug 暂时这样
					if (headers.length > 15) {
						myGridoptions.shrinkToFit = false;
					}
					var dom = waf.createDOM("grid", myGridoptions);
					waf.appendDOM(waf("#panel5"), dom);
					waf.initComponent("grid", myGridoptions, dom);
					for (var i = 0; i < list.length; i++) {
						for (var j in list[i]) {
							if (list[i][j] != null && typeof list[i][j] == "object") {
								list[i][j] = list[i][j].alias;
							}
						}
						waf("#queryGrid").wafGrid('addRow', { data: list[i] });
					}
				}
			}
		}
		,
		shownextActs: function (nextactname, ui) {
			if (ui.checked) {
				$(".approve-next-persons").show();
				_private.loadNextActs();
			} else {
				$(".approve-next-persons").hide();
				waf("#" + nextactname).wafLinkButton("option", "hidden", true);
				selnextPersons = {};
			}

		}
		,
		submit: function (event, value) {
			if (approvetype == "approve") {
				_private.confirmSumit("beforeInnerSubmit");
			} else if (approvetype == "manualdecision") {
				_private.manualdecisionsubmit();
			} else if (approvetype == "batchapprove") {
				_private.confirmSumit("batchSubmitForCA");
			} else if (approvetype == "passComent") {
				_private.passComentsubmit();
			}
		}
		,
		confirmSumit: function (funcName) {
			if (assign.enableMultiapproveConfirm == "true") {
				var ok = function () {
					_private[funcName]();
				};
				var cancel = function () {
					return;
				};
				waf.msgBox.showConfirm({
					title: _self._localeStr.WEB_MESSPROMPT,
					summaryMsg: _self._localeStr.WEB_CONFIRMSUBMITAPPROVAL,
					buttonType: "ok-cancel",
					buttonCallBack: [ok, cancel]
				});
			} else {
				_private[funcName]();
			}
		}
		,
		passComentsubmit: function () {
			var params = {};
			params.parameter = sourceIDs;
			params.chksendMessage = "yes";
			if (waf("#sendmsgs").wafCheckbox("isChecked")) {
				params.chksendMobile = "yes";
			}
			if (waf("#sendmails").wafCheckbox("isChecked")) {
				params.chksendMail = "yes";
			}
			params.opinion = $("#passComentOpinion").val();
			var option = $("#passComentOpinion").val();
			if (option != null && option.length > 1000) {
				_self.showInfo(_self._localeStr.WEB_FEEDBACKCOMMENTS_TOOLONG);
				return null;
			}
			waf.doPost({
				url: waf.getContextPath() + '/passComment/get.do?method=commit',
				data: params,
				success: function (data) {
					_self.showSuccess(_self._localeStr.WEB_DEEDBACKCIRCULATESUCCESS);
					_private.backto();
				}
			});
		}
		,
		initCAConfig: function (tCAConfig) {
			caConfig.caConfigInfo = tCAConfig;
			if (caConfig.caConfigInfo.isSignatureApprove === "true" && caConfig.caConfigInfo.caType != "5") {//只有做CA认证时加载CA控件
				var initflag = initTopesa();
				if (initflag != 0) {
					waf.msgBox.showError(_self._localeStr.WEB_CAINITFAILED);
				}
			}
		}
		,
		batchSubmitForCA: function () {
			if (caConfig.caConfigInfo.checkPassword === "true" && caConfig.caConfigInfo.isSignatureApprove === "true" && caConfig.caConfigInfo.caType != "5") {//CA进行密码验证处理
				_private.checkCAPassword(true);
			} else {
				_private.batchSubmit();
			}
		}
		,
		checkCAPassword: function (isBatch) {
			var setcss = function () {
				var item = parent.$(".ui-msgbox .ui-prompt .prompt");
				if ($(item)) {
					$(item).css({ "height": "78px", "margin": "20px 0 20px 190px", "background": "url(/easweb/webviews/workflow/img/waitpic.png) no-repeat" });
				}
			};
			setTimeout(setcss, 100);
			var prmt = function (r, dialog) {
				if (r) {//验证密码
					var res = -1;
					try {
						res = checkPassword(r, caConfig.caConfigInfo.userName);
					} catch (errMsg) {
						_self.showInfo(_self._localeStr.WEB_USBKEYCHECKPASSDETAIL + errMsg.message);
						return false;
					}
					if (res != 0) {
						_self.showInfo(_self._localeStr.WEB_USBKEYCHECKPASS);
					} else {//调用提交方法
						if (isBatch) {//判断是否是批量提交
							_private.batchSubmit();
						} else {
							_private.innerSubmit();
						}
					}

				}
			};
			var cancel = function () {
				return;
			};
			waf.msgBox.showPrompt({
				title: _self._localeStr.WEB_MESSPROMPT,
				icon: "prompt",
				summaryMsg: _self._localeStr.WEB_INPUTUSBKEYPASSWORD,
				buttonCallBack: [prmt, cancel]
			});
			parent.$("#waf-messageBox-prompt-input").prop("type", "password");
		}
		,
		batchSubmit: function () {
			var info = _private.getbatchid();
			if (info == null) {
				return;
			}
			_private._batchsubmit(info);
		}
		,
		getbatchid: function () {
			var info = {};
			var assignIds = "";
			var billIds = "";
			var allbillIds = locationurl.billIds;
			var allassignmentIds = locationurl.assignmentIds;
			if (assign.batchApproveUrl) {
				var frame = document.getElementById("billFrame");
				billIds = $(frame)[0].contentWindow.waf("#queryGrid").dataGrid("getSelectedRows");
			} else {
				billIds = waf("#queryGrid").wafGrid("getSelectedRows");
			}
			if (billIds.length == 0) {
				billIds = allbillIds;
				assignIds = allassignmentIds;
			} else {
				for (var i = 0; i < allbillIds.split(";").length; i++) {
					var allbillId = allbillIds.split(";")[i];
					if (billIds.toString().indexOf(allbillId) > -1) {
						if (assignIds != "") {
							assignIds += ";";
						}
						assignIds += allassignmentIds.split(";")[i];
					}
				}
				billIds = billIds.join(";");
			}
			info.billIds = billIds;
			info.assignIds = assignIds;
			return info;
		}
		,
		_batchsubmit: function (info) {
			var approve = _private.getApprove();
			if (!approve) {
				return;
			}
			var billIds = info.billIds;
			var assignIds = info.assignIds;
			//add by liujx 添加CA批量认证的判断
			approve.isSignatureApprove = caConfig.caConfigInfo.isSignatureApprove;
			if (caConfig.caConfigInfo.isSignatureApprove === "true" && caConfig.caConfigInfo.caType != "5") {//判断是否处理CA认证签名
				//获取需要签名的明码，与签名后的密文
				if (!_private.beforeBatchSubmitSigature(billIds)) {
					return;
				}
				approve.plainTextMap = caConfig.plainTextMap;
				approve.plainSignatureMap = caConfig.plainSignatureMap;
			}
			var nextPersons = _private.getNextPersons();
			if (!nextPersons) {
				return;
			}
			var ok = function () {
				var params = {};
				approve.nextActs = nextPersons;
				params.approve = JSON.stringify(approve);
				params.assignIds = assignIds;
				params.billIds = billIds;
				waf.doPost({
					url: waf.getContextPath() + '/common/tree.do?method=batchSubmits',
					data: params,
					success: function (data) {
						if (data == "OK") {
							_self.showSuccess(_self._localeStr.WEB_BATCHAPPROVESUCCESS);
							_private.backto();
						} else {
							_self.showInfo(_self._localeStr.WEB_PLEASEREFRESH);
						}
					}
				});
			};
			var cancel = function () {
				return;
			};
			if (showerror != "") {
				waf.msgBox.showConfirm({
					title: _self._localeStr.WEB_MESSPROMPT,
					summaryMsg: showerror,
					buttonType: "ok-cancel",
					buttonCallBack: [ok, cancel]
				});
			} else {
				ok();
			}
		}
		,
		getApprove: function () {
			var opinion = waf("#approveOpinion").val();
			if (assign.needApproveOpinion && (opinion == null || opinion.trim() == "")) {//必须填写审批意见的判断
				_self.showInfo(_self._localeStr.WEB_APPROVALCOMMENTSNOBLANK);
				return null;
			}
			if (opinion != null && opinion.length > 1000) {
				_self.showInfo(_self._localeStr.WEB_APPROVALCOMMENTSTOOLONG);
				return null;
			}
			var ispass = null;
			var approveResult = waf("#approveResult").wafRadioGroup("getValue");
			if (approveResult == "false") {
				ispass = 'false';
				if (assign.mustFillOpinionWhenDisagree == "true") {
					if ((opinion == null || opinion.trim() == "") || opinion == _self._localeStr.WEB_DISAGREE) {//mustFillOpinionWhenDisagree  不同意时必须填写审批意见的判断 
						_self.showInfo(_self._localeStr.WEB_DISAGREEOPINION);
						return null;
					}
				}
			} else if (approveResult == "true") {
				ispass = 'true';
			}
			var approve = {};
			approve.assignId = assign.assignId;
			approve.id = assign.id;
			approve.opinion = opinion;
			var handlerOpinion = waf("#policy").wafSelect("getValue");
			if (handlerOpinion) {
				approve.handlerOpinion = handlerOpinion;
			} else {
				approve.handlerOpinion = "0";
			}
			approve.handlerContent = waf("#policy").wafSelect("getSelectedAlias");

			//审批结果
			approve.approveResult = ispass;
			//关联路径
			approve.transitionId = transId;

			//是否发送邮件/短信
			approve.isSendSMS = waf("#sendmsg").wafCheckbox("isChecked") ? "true" : "false";
			approve.isSendMail = waf("#sendmail").wafCheckbox("isChecked") ? "true" : "false";
			if (assign.multiapproveinfoId)
				approve.id = assign.multiapproveinfoId;
			var isesignaturecheck = false;
			if (approvetype == "approve" || approvetype == "batchapprove") {
				isesignaturecheck = waf("#esignature").wafCheckbox("isChecked");
			} else if (approvetype == "manualdecision") {
				isesignaturecheck = waf("#esignature1").wafCheckbox("isChecked");
			}
			if (assign.isEsignature && isesignaturecheck) {//电子签名
				approve.esignatureid = assign.esignatureId;
			}
			return approve;
		}
		,
		beforeBatchSubmitSigature: function (selectBillIds) {
			//组织业务id
			var modelIDs = "";
			var tbillIDs;
			if (Object.prototype.toString.call(selectBillIds) === '[object Array]') {
				tbillIDs = selectBillIds;
			} else {
				tbillIDs = selectBillIds.split(";");
			}
			for (var i = 0; i < tbillIDs.length; i++) {
				if (modelIDs != "") {
					modelIDs += ",";
				}
				modelIDs += tbillIDs[i];
			}
			if (modelIDs === undefined || modelIDs == null || modelIDs === "") {
				waf.msgBox.showError("bill id can't be null");
				return false;
			}
			//列表界面在前端无法获取bosType，webServer层根据单据ID获得bosType进而获得相关的配置信息
			var actionUrl = waf.getContextPath() + "/component/ca.do?method=getPlainTextFromDB&billIDs=" + waf.encodeURIComponent(modelIDs) + "&isFromWF=true";
			waf.doPost({
				url: actionUrl,
				async: false,
				success: function (data) {
					if (data == null || data == "" || data == undefined) {
						return false;
					} else {
						caConfig.plainTextMap = data.plainTextMap;
					}
				},
				error: function (data) {
					waf.msgBox.showError("getPlainTextFromDB failed");
					return false;
				}
			});
			//对明文字段进行签名，获取密文数据
			var arraySignature = "";
			var billids = modelIDs.split(",");
			for (var i = 0; i < billids.length; i++) {
				var key = billids[i];
				//签名接口调用
				var signResult = -1;
				try {
					signResult = signMessage(caConfig.plainTextMap[key], caConfig.caConfigInfo.userName);
				} catch (errMsg) {
					_self.showInfo(_self._localeStr.WEB_SIGANATUREFAILED + errMsg.message);
					return false;
				}
				if (signResult == 1 || signResult == 2 || signResult == 3) {
					if (signResult == 1 || signResult == 2) {
						_self.showInfo(_self._localeStr.WEB_SIGAFAILEDUSBKEY);
					}
					return false;
				}
				if (arraySignature != "") {
					arraySignature += ",";
				}
				arraySignature += signResult;

			}
			caConfig.plainSignatureMap = arraySignature;
			return true;
		}
		,
		getNextPersons: function (isSave) {
			var locale = waf.getContext().locale;
			var symbol = "。";
			if (locale == "l1") {
				symbol = ".";
			}
			//下一步参与人设置
			showerror = "";
			var nextPersons = [];
			//判断是否是审批同意 add by liujx 审批不同意的不校验下一步参与人
			var ispass = waf("#approveResult").wafRadioGroup("getValue");//1 不同意
			if (ispass == "false") {
				return nextPersons;
			}
			var isnextact = waf(nextActIndex).wafCheckbox("isChecked");
			var directActName = "";
			if (isnextact) {
				var num = 0;
				var index = 0;
				var directCount = 0;
				var directIsSel = false;
				for (var i = 0; i != assign.nextActs.length; i++) {
					if (_private.isPredict && !assign.nextActs[i].isPredict) continue;
					var act = {};
					act.actKey = assign.nextActs[i].actKey;
					act.persons = {};
					var flag = false;
					directCount++;
					for (var actId in selnextPersons) {
						if (actId == assign.nextActs[i].actId) {
							var persons = selnextPersons[actId];
							for (var id in persons) {
								act.persons[id] = 'true';
								flag = true;
							}
						}
					}
					if (directCount == 1) {
						directIsSel = flag;
					}
					if (!flag) {
						if (num < 3) {
							if (showerror != "") {
								showerror += "、";
							}
							showerror += assign.nextActs[i].actName;
						}
						num++;
						if (num == 1) {
							directActName = assign.nextActs[i].actName;
						}
					} else {
						nextPersons[index] = act;
						index++;
					}
				}
				if (num > 0) {
					if (num > 2) {
						showerror += _self._localeStr.WEB_ANDSOON + num + _self._localeStr.WEB_NODE;
					}
					if (!isSave && assign.mustSetAllNextPerson) {
						_self.showInfo(_self._localeStr.WEB_NEXTACTIVITY + ":" + showerror + symbol);
						return null;
					}
					if (!isSave && assign.mustSetAllNextPersonDirectNull && !directIsSel) {
						_self.showInfo(_self._localeStr.WEB_NEXTACTIVITY + ":" + directActName + symbol);
						return null;
					}
					showerror += _self._localeStr.WEB_NOPARTICIPANTSUBMIT;
				}
			}
			return nextPersons;
		}
		,
		manualdecisionsubmit: function () {
			var selectValue = waf("#radioDecision").wafRadioGroup("getValue");
			if (selectValue) {
				var selItems = $("#radioDecision input[value='" + selectValue + "']").next()[0].innerHTML;
				var params = {};
				var nextPersons = _private.getNextPersons();
				if (!nextPersons) {
					return;
				}
				var ok = function () {
					nextPersons = JSON.stringify(nextPersons);
					params.nextperson = nextPersons;
					params.assignId = assign.assignId;
					params.decisionTitle = assign.decisionName;
					params.decisionItems = assign.decisionItems;
					params.decisionDesc = assign.decisionDesc;
					params.decisionOpinions = assign.decisionOpinions;
					params.SelectedItems = selItems;
					params.SelectedOpinions = selectValue.substr(0, selectValue.indexOf("_"));
					waf.doPost({
						url: waf.getContextPath() + '/manualdecision/submit.do?method=submit',
						data: params,
						success: function (data) {
							_self.showSuccess(_self._localeStr.WEB_DECISIONSUBMITSUCCESS);
							_private.backto();
						}
					});
				};
				var cancel = function () {
					return;
				};
				if (showerror != "") {
					waf.msgBox.showConfirm({
						title: _self._localeStr.WEB_MESSPROMPT,
						summaryMsg: showerror,
						buttonType: "ok-cancel",
						buttonCallBack: [ok, cancel]
					});
				} else {
					ok();
				}
			}
		}
		,
		beforeInnerSubmit: function () {
			if (caConfig.caConfigInfo.checkPassword === "true" && caConfig.caConfigInfo.isSignatureApprove === "true" && caConfig.caConfigInfo.caType != "5") {
				_private.checkCAPassword(false);
			} else {
				_private.innerSubmit();
			}
		}
		,
		innerSubmit: function () {
			if (assign.mustUploadAttachment && waf("#approveResult").wafRadioGroup("getValue") == "true") {
				var isCurAssignUploadAttach = false;
				waf.doPost({
					url: waf.getContextPath() + '/iwebattachment.do?method=isCurAssignUploadAttach',
					data: { assignId: assign.assignId },
					async: false,
					success: function (data) {
						if (data == false) {
							_self.showWarning(_self._localeStr.WEB_MUSTUPLOAD);
						}
						isCurAssignUploadAttach = data;
					}
				});
				if (!isCurAssignUploadAttach) return;
			}
			assign.operation = 'approve';
			var callback = function (isSuccess) {
				if (isSuccess) {
					_private._submit(false);
				}
			}
			var issubmit = _private.checkIsSave(callback, "submit");
			if (issubmit == null) {
				//_self.showInfo(_self._localeStr.WEB_CHECKERRORSUBMITEND);
				_self.jMessageAlert(_self._localeStr.WEB_CHECKERRORSUBMITEND)
				return false;
			}
			_private._submit(issubmit);
		}
		,
		_submit: function (isReadOnly) {
			var approve = _private.getApprove();
			if (!approve) {
				return;
			}
			var nextPersons = _private.getNextPersons();
			if (!nextPersons) {
				return;
			}
			var ok = function () {
				approve.operation = assign.operation;
				var op = approve.operation;
				if (caConfig.caConfigInfo.isSignatureApprove === "true" && caConfig.caConfigInfo.caType != "5") {//判断是否处理CA认证
					if (!_private.beforeSubmitSigature()) {//工作流审批CA认证，
						return;
					}
					approve.plainText = caConfig.CA_plainText;
					approve.signature = caConfig.CA_signature;
				}
				if (isReadOnly === undefined || isReadOnly === null || isReadOnly === "") {//没有参数默认为只做提交
					isReadOnly = true;
				}
				if (!isReadOnly) {//传入保存的参数
					var frame = document.getElementById("billFrame");
					if (frame.contentDocument.getElementById("frame_tab_0") != null
						&& frame.contentDocument.getElementById("frame_tab_0") != undefined) {
						frame = frame.contentDocument.getElementById("frame_tab_0");
					}
					if (frame.contentWindow._self.getCurrentModel) {
						var modelInfo = frame.contentWindow._self.getCurrentModel();
						var editModel = JSON.stringify(modelInfo);
						approve.model = editModel;
					}
					if (approve.model == null) {
						if (frame.contentWindow._self.fireEvent) {
							var s = frame.contentWindow._self.fireEvent("save");
							if (!s) {
								return false;
							}
						}
					}
				}
				approve.isReadOnly = isReadOnly.toString();
				approve.isSignatureApprove = caConfig.caConfigInfo.isSignatureApprove;
				approve.nextActs = nextPersons;
				if ($("#textCC").prop('personIds')) {
					approve.ccPersonIds = $("#textCC").prop('personIds');
				}
				var params = {};
				params.approve = JSON.stringify(approve);
				waf.doPost({
					url: waf.getContextPath() + '/common/tree.do?method=submits',
					data: params,
					success: function (data) {
						if (data) {
							assign.id = data;
							_self.showSuccess(_self._localeStr.WEB_SUBMITSUCCESS);
							_private.backto();
						} else {
							_self.showInfo(_self._localeStr.WEB_PLEASEREFRESH);
						}
					}
				});
			};
			var cancel = function () {
				return;
			};
			if (showerror != "") {
				waf.msgBox.showConfirm({
					title: _self._localeStr.WEB_MESSPROMPT,
					summaryMsg: showerror,
					buttonType: "ok-cancel",
					buttonCallBack: [ok, cancel]
				});
			} else {
				ok();
			}
		}
		,
		beforeSubmitSigature: function () {
			//获取表单数据
			var plainText = "";
			var signatureField = caConfig.caConfigInfo.signatureFields;
			if (signatureField === null || signatureField === "") {
				return true;
			}
			var signatureFields = signatureField.split(';');
			for (var i = 0; i < signatureFields.length; i++) {
				var srcValue = "CANOTSIGNATURE";//默认不处理
				try {
					srcValue = eval("document.getElementById('billFrame').contentWindow.document.getElementsByName('" + signatureFields[i] + "')[0].value");
				} catch (e) {
					srcValue = "CANOTSIGNATURE";
				}
				if (typeof (srcValue) == "undefined") {
					srcValue = "CANOTSIGNATURE";
				}
				if (caConfig.caConfigInfo.precisionInfo && caConfig.caConfigInfo.precisionInfo[signatureFields[i]]) {
					var pos = parseInt(caConfig.caConfigInfo.precisionInfo[signatureFields[i]]);
					if (pos < 0) {
						pos = 2;
					} else if (pos > 4) {
						pos = 4;
					}
					srcValue = _private.toDecimal(srcValue, pos);
				}
				plainText = plainText + srcValue;
			}
			//签名接口调用
			var signResult = -1;
			try {
				signResult = signMessage(plainText, caConfig.caConfigInfo.userName);
			} catch (errMsg) {
				_self.showInfo(_self._localeStr.WEB_SIGANATUREFAILED + errMsg.message);
				return false;
			}
			if (signResult == 1 || signResult == 2 || signResult == 3) {
				if (signResult == 1 || signResult == 2) {
					_self.showInfo(_self._localeStr.WEB_SIGAFAILEDUSBKEY);
					return false;
				}
			} else {
				//设置签名结果到数据中
				caConfig.CA_plainText = plainText;
				caConfig.CA_signature = signResult;
			}
			return true;
		}
		,
		toDecimal: function (src, pos) {
			var f = parseFloat(src);
			if (isNaN(f)) {
				return false;
			}
			//判断是否有小数点
			var src_rs = src.indexOf('.');
			if (src_rs > 0) {
				//判断小数点末尾是否为0,是则消去
				var src_zero = src.lastIndexOf('0');
				while (src.length == src_zero + 1) {
					src = src.substring(0, src_zero);
					src_zero = src.lastIndexOf('0');
				}
				//判断小数点末尾是否为".",是则消去
				if (src.length == src_rs + 1) {
					var src_int = src.substring(0, src_rs);
					src = src_int;
				}
				//判断是否有配置签名要求的浮点数,0为没有配置
				if (pos == 0) {
					return src;
				}
			}
			//如果配置了浮点数则进行这里的逻辑
			var f = Math.round(src * Math.pow(10, pos)) / Math.pow(10, pos);
			var s = f.toString();
			var rs = s.indexOf('.');
			if (rs < 0 && pos > 0) {
				rs = s.length;
				s += '.';
			}
			while (s.length <= rs + pos) {
				s += '0';
			}
			return s;
		}
		,
		save: function (event, value) {
			var callback = function (isSuccess) {
				if (isSuccess) {
					_private._save();
				}
			}
			var issubmit = _private.checkIsSave(callback, "save");
			if (issubmit == "callBack") {
				return;
			}
			if (issubmit == null) {
				//_self.showInfo(_self._localeStr.WEB_CHECKERRORSUBMITEND);
				_self.jMessageAlert(_self._localeStr.WEB_CHECKERRORSUBMITEND);
				return false;
			}
			_private._save(issubmit);
			//单据如果有修改，更新风险洞察
			if (!issubmit && riskInsight) {
				billInsightOption = _private.getWeakRisk();
				_private.updateBillInsightNum(billInsightOption);
			}
		}
		,
		checkIsSave: function (callback, type) {
			var issubmit = null;
			if (!assign.billIsReadOnly) {//非只读
				//流程参数（不同意不校验单据必录项）
				if (type == "submit" && assign.disagreenotsave && waf("#approveResult").wafRadioGroup("getValue") == "false") {
					return true;
				}
				var frame = document.getElementById("billFrame");
				if (frame) {
					if (frame.contentWindow._self && frame.contentWindow._self.saveAndCallBack) {//回调
						frame.contentWindow._self.saveAndCallBack(callback);
						return "callBack";
					} else {//waf2
						var canSaveBill = false;
						var haveChangeBill = null;//单据是否修改过,不是所有的单据会有这个校验
						var contentWindowSelf = null;
						if (frame.contentWindow._self) {
							contentWindowSelf = frame.contentWindow._self;
						} else if (frame.contentDocument.getElementById("frame_tab_0") && frame.contentDocument.getElementById("frame_tab_0").contentWindow._self) {
							contentWindowSelf = frame.contentDocument.getElementById("frame_tab_0").contentWindow._self;
						}
						if (contentWindowSelf) {
							var WFBizSubmitCheckPriority = false;
							if (contentWindowSelf.isWFBizSubmitCheckPriority) {
								WFBizSubmitCheckPriority = contentWindowSelf.isWFBizSubmitCheckPriority();
							}
							if (WFBizSubmitCheckPriority) {
								if (contentWindowSelf.fireEvent) {
									haveChangeBill = contentWindowSelf.fireEvent("judgeDataModifyActionEvent", ["workflow"]);
								} else {
									if (contentWindowSelf.checkBillDataChanges) {//检查s-HR 单据数据是否发生变化
										haveChangeBill = contentWindowSelf.checkBillDataChanges();
									}
								}
								if (contentWindowSelf.beforeSubmit) {
									canSaveBill = contentWindowSelf.beforeSubmit();
								} else {
									if (contentWindowSelf.fireEvent) {
										canSaveBill = contentWindowSelf.fireEvent("fieldOnStoreEvent") && contentWindowSelf.fireEvent("submitBeforeActionEvent");
									}
								}
							} else {
								if (contentWindowSelf.beforeSubmit) {
									canSaveBill = contentWindowSelf.beforeSubmit();
								} else {
									if (contentWindowSelf.fireEvent) {
										canSaveBill = contentWindowSelf.fireEvent("fieldOnStoreEvent") && contentWindowSelf.fireEvent("submitBeforeActionEvent");
									}
								}
								if (contentWindowSelf.fireEvent) {
									haveChangeBill = contentWindowSelf.fireEvent("judgeDataModifyActionEvent", ["workflow"]);
								} else {
									if (contentWindowSelf.checkBillDataChanges) {//检查s-HR 单据数据是否发生变化
										haveChangeBill = contentWindowSelf.checkBillDataChanges();
									}
								}
							}
							if (canSaveBill) {//如果校验通过
								if (typeof haveChangeBill == "boolean") {
									issubmit = !haveChangeBill;
								} else {
									issubmit = false;
								}
							}
						} else {
							issubmit = true;
						}
					}
				} else {
					issubmit = true;
				}
			} else {
				issubmit = true;
			}
			return issubmit;
		}
		,
		_save: function (isReadOnly) {
			assign.operation = 'approve';
			var approve = _private.getApprove();
			if (!approve) return;
			//var nextPersons=_private.getNextPersons(true);
			//if(!nextPersons)nextPersons=[];
			if (isReadOnly === undefined || isReadOnly === null || isReadOnly === "") {//没有参数默认为只做提交
				isReadOnly = true;
			}
			if (!isReadOnly) {//传入保存的参数
				var frame = document.getElementById("billFrame");
				if (frame.contentDocument.getElementById("frame_tab_0") != null
					&& frame.contentDocument.getElementById("frame_tab_0") != undefined) {
					frame = frame.contentDocument.getElementById("frame_tab_0");
				}
				if (frame.contentWindow._self.getCurrentModel) {
					var modelInfo = frame.contentWindow._self.getCurrentModel();
					var editModel = JSON.stringify(modelInfo);
					approve.model = editModel;
				}
				if (approve.model == null) {
					if (frame.contentWindow._self.fireEvent) {
						var s = frame.contentWindow._self.fireEvent("save");
						if (!s) {
							return false;
						}
					}
				}
			}

			approve.isReadOnly = isReadOnly.toString();
			//approve.nextActs = nextPersons;
			if ($("#textCC").prop('personIds')) {
				approve.ccPersonIds = $("#textCC").prop('personIds');
				approve.personName = $("#textCC").prop('value');
			}
			var params = {};
			params.approve = JSON.stringify(approve);
			waf.doPost({
				url: waf.getContextPath() + '/common/tree.do?method=saves',
				data: params,
				success: function (data) {
					if (data) {
						assign.id = data;
						_self.showSuccess(_self._localeStr.WEB_SAVESUCCESS);
					}
				}
			});
		}
		,
		backto: function () {
			//谷歌部分低版本不能释放互斥锁,只能手动释放
			try {
				if ($("#billFrame").length > 0 && $("#billFrame")[0].contentWindow._self.fireEvent) {
					$("#billFrame")[0].contentWindow._self.fireEvent('destroyEvent');
				}
			} catch (e) {
				console.log("流程中心手动释放单据锁失败");
			}
			if (waf.isInFramePage()) {
				waf.closeCurPageTab();
			} else if (top && top.jMessager && top.jMsgcenter && top.jMsgcenter.tab_post_add) {
				//不加时间提示会被冲掉
				setTimeout(function () {
					top.jMessager.sendMsg(top.jMsgcenter.tab_close);
				}, 800);
			} else {
				setTimeout(function () {
					try {
						if (window.opener) {
							if (window.opener.refreshCurrentPage) {
								window.opener.refreshCurrentPage()
							}
							if (opener.waf && opener.waf('#queryGrid')[0] != undefined) {
								opener.waf('#queryGrid').wafGrid('reloadGrid')
							}
						}
					} catch (e) { }
					try {
						// 尝试关闭窗口
						window.close();
						// 检查窗口是否仍然存在，如果存在则表示没有权限
						//if (!window.closed) {
						console.log("没有权限关闭窗口。");
						// waf.doGet({
						// 	url: '/shr/shr/msf/service.do?method=callService&serviceName=getSsoOAUrl&ssoPath=http%3a%2f%2foa.shichuangyi.cn%3a8080%2fwui%2findex.html%3fssoToken%3d%7b0%7d%23%2fmain%2fworkflow%2flistDoing%3fmenuIds%3d1%2c13%26menuPathIds%3d1%2c13%26_key%3dybt3pm',
						// 	success: function (data) {
						// 		location.href = data
						// 	}
						// });
						location.href = 'https://m.shichuangyi.cn/m-approval/static/oaDoneTransfer.html';
						//location.href = "/shr/dynamic.do?uipk=shr.workflow.view&inFrame=true";
						//}
					} catch (error) {
						console.log("关闭窗口失败:", error.message);
						_self.showSuccess(_self._localeStr.WEB_TASKHASDONE)
					}
				}, 500);
			}
		}
		,
		addUploadHtml: function () {
			var attachmentUploadUrl = waf.getContextPath() + '/iwebattachment.do?method=upload&bosID=' + encodeURIComponent(assign.billId) + '&beizhu=' + assign.assignId;
			var options = {
				autoUpload: true,
				url: attachmentUploadUrl,
				multiSelect: true,
				onComplete: function (e, data) {
					_private.getAttchmentcount();
				},
				onAdd: function (e, data) {
				},
				onFail: function (e, data) {
					if (data.result.length > 0) {
						if (data.result[0].error) {
							_self.showInfo(data.result[0].error);
						}
					}
				}
			};
			$("#upload").wafFileUploadUI(options);
			_private.getAttchmentcount();
		}
		,
		getAttchmentcount: function () {
			var params = {};
			params.assignId = assign.assignId;
			params.billId = assign.billId;
			var pageType = _self.getUrlParam('type');
			if (pageType != null && 'passComent' === pageType) {
				params.isPassAround = true;
			}
			waf.doPost({
				url: waf.getContextPath() + '/iwebattachment.do?method=getDataList',
				data: params,
				success: function (data) {
					if (data.disabled) {
						$("#attchment,.attchmentnuminfo,#upload").remove();
						return;
					}
					if (!data.canAdd) {
						$("#upload").remove();
					}
					var len = data.list.length;
					$("#attchmentnum").html(len);
					if (len > 0) {
						waf("#attchment").wafSection("open");
					} else {
						waf("#attchment").wafSection("close");
					}

					var _html = '';
					for (var i = 0; i < len; i++) {
						var row = data.list[i];
						var simpleName = row.simpleName;
						var classname = "file";
						var picFormat = ['jpg', 'gif', 'jpeg', 'png', 'bmp'];
						if (picFormat.indexOf(simpleName) > -1) {
							classname = "pic";
						}
						_html += '<li><div><i class="' + classname + '"></i>' +
							'<span class="name" title="' + row.name + '.' + simpleName + '">' + row.name + '.' + simpleName + '</span>' +
							'<span class="size">(' + row.size + ')</span>' +
							'<a class="download" href="/easweb/webviews/workflow/download.jsp?bosID=' + row.id + '" download="' + row.name + '.' + simpleName + '" target="_blank"></a>';
						//图片和pdf支持预览
						if (classname == 'pic') {
							_html += '<i class="preview" onclick="javascript:_self.attachmentView(\'' + row.id + '\',\'pic\')"></i>';
						} else if (simpleName == 'pdf') {
							_html += '<i class="preview" onclick="javascript:_self.attachmentView(\'' + row.id + '\',\'pdf\')"></i>';
						}
						if (row.canDelete) {
							_html += '<i class="delete" onclick="javascript:_self.attachmentDelete(\'' + row['boAttchAsso.id'] + '\',\'' + row.id + '\')"></i>';
						}
						_html += '</div></li>';
					}
					$("#attachmentContent ul")[0].innerHTML = _html;
				}
			});
		}
		,
		attachmentDelete: function (bosId, attachId) {
			var ok = function () {
				waf.doPost({
					url: waf.getContextPath() + '/iwebattachment.do?method=delete',
					data: { "bosId": bosId, "attachId": attachId },
					success: function (data) {
						_self.showSuccess(_self._localeStr.WEB_ATTACHMENTDELETESUCESS);
						_self.getAttchmentcount();
					}
				});
			};
			var cancel = function () {
				return;
			};
			waf.msgBox.showConfirm({
				title: _self._localeStr.WEB_MESSPROMPT,
				summaryMsg: _self._localeStr.WEB_DeleteFile,
				buttonType: "ok-cancel",
				buttonCallBack: [ok, cancel]
			});

		}
		,
		attachmentView: function (id, type) {
			var url = "";
			if (type == "pic") {
				url = "/easweb/webviews/workflow/viewpic.jsp?bosID=" + id;
			} else if (type == "pdf") {
				url = "/easweb/webviews/webframework/webcom/attachment/view.jsp?bosID=" + id;
			}
			window.open(url, "_blank");
		}
		,
		billImage: function (event, value) {
			var params = {};
			params.billID = assign.billId;
			params.method = 'getimageurl';
			waf.doPost({
				url: waf.getContextPath() + '/workflow/approve.do',
				data: params,
				success: function (data) {
					var url = data.imgurl;
					if (url == "") {
						_self.showWarning(_self._localeStr.WEB_IMAGESTATE + data.state + _self._localeStr.WEB_SUPPORTSTATE);
					} else if (url == "noImg") {
						_self.showWarning(_self._localeStr.WEB_HASNOIMAGE);
					} else {
						window.open(url, "_blank");
					}
				}
			});
		}
		,
		bill: function (event, value) {
			var para = {};
			if (approvetype == "batchapprove") {
				var assignIds = _private.getbatchid().assignIds;
				if (assignIds.split(";").length != 1) {
					_self.showInfo(_self._localeStr.WEB_SELECTARECORD);
					return false;
				}
				para.sourceID = assignIds;
			} else {
				para.sourceID = assign.assignId;
			}
			para.msgId = msgId;
			wfCommonUtil.showBill(para);
		}
		,
		messageDigest: function () {
			var messageDigest = assign.messageDigest;
			if (messageDigest.toString().indexOf('table') > 0) {
				waf("#panel5").wafPanel("option", "hidden", true);
				waf("#bill").wafSection("option", "hidden", false);
				document.getElementById("bill_content").innerHTML = messageDigest;
			} else {
				waf("#billFrame").remove();
				waf("#billAttachment").remove();
				//单据头
				var billDigest = eval('(' + messageDigest + ')');
				var options = {
					title: _self._localeStr.WEB_BASICINFO,
					id: 'billBaseInfo',
					name: "billBaseInfo",
					openIconCls: 'ui-section-minus',
					closeIconCls: 'ui-section-plus',
					autoOpen: true,
					style: "margin-right: 0px;"
				};
				var billBaseInfo = waf.createDOM("section", options);
				waf.appendDOM(waf("#panel5"), billBaseInfo);
				waf.initComponent("section", options, billBaseInfo);
				var items = billDigest.items;
				for (var i = 0; i < items.length; i++) {
					var labeloptions = { id: "labelContainer" + i, caption: items[i][0], style: "width: 33%;float: left;" };
					var labeldom = waf.createDOM("labelContainer", labeloptions);
					waf("#billBaseInfo").wafSection("appendChildren", labeldom);
					waf.initComponent("labelContainer", labeloptions, labeldom);
					var txtoptions = {
						id: "billbase" + i,
						caption: items[i][1]
					};
					var textDom = waf.createDOM("label", txtoptions);
					labeldom.wafLabelContainer('append', textDom);
					waf.initComponent("label", txtoptions, textDom);
				}
				//分录
				var entries = billDigest.entrys;
				for (var j = 0; j < entries.length; j++) {
					var obj = entries[j];
					var billEntriesoptions = {
						title: obj.alias.l2,
						id: 'billEntriesInfo' + j,
						name: "billEntriesInfo" + j,
						openIconCls: 'ui-section-minus',
						closeIconCls: 'ui-section-plus',
						autoOpen: true,
						style: "margin-right: 0px;"
					};
					var billEntriesInfo = waf.createDOM("section", billEntriesoptions);
					waf.appendDOM(waf("#panel5"), billEntriesInfo);
					waf.initComponent("section", billEntriesoptions, billEntriesInfo);
					if (obj.values.length > 0) {
						var colmodel = [];
						var env = obj.values[0].items;
						for (var m = 0; m < env.length; m++) {
							var para = {
								name: env[m][3],
								label: env[m][0]
							};
							colmodel.push(para);
						}
						var myGridoptions = {
							id: "myGrid" + j,
							colModel: colmodel
						};
						var dom = waf.createDOM("grid", myGridoptions);
						waf("#billEntriesInfo" + j).wafSection("appendChildren", dom);
						waf.initComponent("grid", myGridoptions, dom);
						var rowData = obj.values;
						var gridData = new Array();
						for (var n = 0; n < rowData.length; n++) {
							var rr = rowData[n].items;
							var rowdata = {};
							for (var h = 0; h < rr.length; h++) {
								var colname = rr[h][3];
								rowdata[colname] = rr[h][1];
							}
							gridData.push(rowdata);
						}

						waf("#myGrid" + j).wafGrid('addRow', { data: gridData });
					}
				}
			}
		}
		,
		initMsgDigestBillAttach: function () {
			var billAttachmentList = assign.billAttachments;
			var billAttachmentOptions = {
				title: _self._localeStr.WEB_ATTACHMENT,
				id: 'billAttachment',
				name: "billAttachment",
				openIconCls: 'ui-section-minus',
				closeIconCls: 'ui-section-plus',
				autoOpen: true,
				style: "margin-right: 0px;"
			};
			var billAttachment = waf.createDOM("section", billAttachmentOptions);
			waf.appendDOM(waf("#panel5"), billAttachment);
			waf.initComponent("section", billAttachmentOptions, billAttachment);
			$("#billAttachment .title").after('<span id="billAttachTitle">' + _self._localeStr.WEB_TOTALATCHMNT + '<i></i><span>' + billAttachmentList.length + '</span>个</span>');
			var _html = "<div class='attachmentContent'><ul>";
			for (var i = 0; i < billAttachmentList.length; i++) {
				var row = billAttachmentList[i];
				var simpleName = row.simpleName;
				var classname = "file";
				var picFormat = ['jpg', 'gif', 'jpeg', 'png', 'bmp'];
				if (picFormat.indexOf(simpleName) > -1) {
					classname = "pic";
				}
				var judgeAttachType = "";
				if (row.attachTypeEnum == 1) {
					judgeAttachType = "<span class='procAttach'>" + _self._localeStr.WEB_PROCESSATTACHMENTS + "</span>";
				}
				_html += '<li><div><i class="' + classname + '"></i>' +
					'<span class="name" title="' + row.name + '.' + simpleName + '">' + judgeAttachType + row.name + '.' + simpleName + '</span>' +
					'<span class="size">(' + row.size + ')</span>' +
					'<a class="download" href="/easweb/webviews/workflow/download.jsp?bosID=' + row.id + '" download="' + row.name + '.' + simpleName + '" target="_blank"></a>';
				//图片和pdf支持预览
				if (classname == 'pic') {
					_html += '<i class="preview" onclick="javascript:_self.attachmentView(\'' + row.id + '\',\'pic\')"></i>';
				} else if (simpleName == 'pdf') {
					_html += '<i class="preview" onclick="javascript:_self.attachmentView(\'' + row.id + '\',\'pdf\')"></i>';
				}
				_html += '</div></li>';
			}
			_html += "</ul></div>";
			return _html;
		}
		,
		selattachment: function (item, attcreater, beizhu) {
		}
		,
		showoperate: function (event, value) {
			var para = {};
			if (approvetype == "batchapprove") {
				var assignIds = _private.getbatchid().assignIds;
				if (assignIds.split(";").length != 1) {
					_self.showInfo(_self._localeStr.WEB_SELECTARECORD);
					return false;
				}
				para.assignmentId = assignIds.split(";")[0];
			} else {
				para.assignmentId = assign.assignId;
			}
			if (wfCommonUtil.getOperationRecordsPerm(para.assignmentId)) {
				wfCommonUtil.showApproveDetail(para);
			} else {
				waf.msgBox.showInfo({ title: _self._localeStr.WEB_MESSAGEALERT, summaryMsg: _self._localeStr.WEB_FORBIDVIEW });
				$(".ui-msgbox .content").width("330px");
			}
		}
		,
		esignatureOnClick: function (event, ui) {
			if (ui.checked) {
				$("#esigndiv").show();
			} else {
				$("#esigndiv").hide();
			}
		}
		,
		isWaf1Bill: function (url) {
		}
		,
		jMessageAlert: function (message) {
			_self.showInfo(message);
		}
		,
		onselect: function (event, ui) {
			//风险洞察
			if (riskInsight) {
				if (ui.panel.id == "riskInsight") {
					waf("#billInsight").billInsight("intelligentInspection", billInsightOption.list);
					//解绑框架的click事件，否则当点击其他地方风险洞察内容会消失
					waf("body").unbind("click");
					$(".billInsight_cardPanel").draggable("disable");
					_private.updateBillInsightNum(billInsightOption);
					_private.resizeBillInsight(false);
					_private.curTab = "riskInsight";
				} else {
					$(".billInsight_cardPanel").css("display", "none");
					_private.curTab = "";
				}
			}
		}
		,
		resizeBillInsight: function (windowResize) {
			var top = $("#li_approveTask").offset().top + 44;
			var left = $("#li_approveTask").offset().left;
			if (!windowResize) left += 10;
			var width = $("#tabs_ul").width();
			var t = $(".ui-cardPanel").attr("style") + "width:" + width + "px !important";
			$(".billInsight_cardPanel").css("cssText", t);
			$(".billInsight_cardPanel").css({ "top": top, "left": left });
			$(".ui-cardPanel .noRecords,.ui-cardPanel .noRecordsImage,.ui-cardPanel .noRecordsText").css({ width: "100%", margin: "0px", "min-width": "160px" });
		}
		,
		getWeakRisk: function () {
			var urlParams = waf.getUrlParam(assign.billEditUrl);
			var billId = urlParams.billId;
			var uipk = urlParams.uipk;
			var billInsightOption = {};
			waf.doPost({
				async: false,
				url: waf.getContextPath() + "/risk/ForWebController.do?method=getWeakRisk",
				data: {
					uipk: uipk,
					id: billId,
					riskIds: assign.riskInsight
				},
				success: function (data) {
					if (data != null) {
						billInsightOption = data;
					}
				}
			});
			return billInsightOption;
		}
		,
		updateBillInsightNum: function (billInsightOption) {
			if (!billInsightOption.allExecSuccess) {
				$("#li_riskInsight span").eq(0).text(_self._localeStr.WEB_RISKINSIGHT + "(" + billInsightOption.failSize + ")");
			} else {
				$("#li_riskInsight span").eq(0).text(_self._localeStr.WEB_RISKINSIGHT);
			}
		}
		,
		openPerson: function (event, value) {
			var selectedIds = waf("#textCC").prop("personIds");
			var height = 552;
			if (window.screen.height < 800) {
				height = 500;
			}
			var tempWin;
			if (parent.waf) {
				tempWin = parent.waf.window;
			} else {
				tempWin = waf.window;
			}
			var params = {};
			params.f7Type = encodeURIComponent("person");
			params.singleSelect = false;
			tempWin.open({
				url: waf.getContextPath() + "/webviews/workflow/commonSelectF7.jsp?selectedIds=" + encodeURIComponent(selectedIds),
				openType: "iframe",
				method: 'POST',
				data: params,
				style: { 'padding': '0px' },
				modal: true,
				title: _self._localeStr.WEB_CC,
				position: 'center',
				width: 1000,
				height: height,
				minHeight: height,
				minWidth: 1000,
				iconCls: "waf-ui-icon",
				draggable: true,
				resizable: true,
				close: function (event, ui) {
				},
				retValCallBack: function (resultData) {
					if (resultData && resultData.resultStr && resultData.resultStr.length > 0) {
						var val = resultData.resultStr.split("||");
						waf("#textCC").prop("personIds", val[1]);
						waf("#textCC").val(val[2]);
					}
				}
			});
		}
		,
		_pageLoadCompletedEventHandler: function () {
		}
		,
		openAttachmentPage: function (event, value) {
			var url = "/easweb/dynamicPage.do?event=initialize&method=doEvent&uipk=com.kingdee.bos.workflow.metas.AttachmentList&assignId=" + assign.assignId + "&billId=" + encodeURIComponent(assign.billId);
			var pageType = _self.getUrlParam('type');
			if (pageType != null && 'passComent' === pageType) {
				url += "&isPassAround=true";
			}
			waf.window.open({
				url: url,
				openType: "iframe",
				modal: true,
				title: _self._localeStr.WEB_ATCHMNTMANAGE,
				position: 'center',
				width: 900,
				height: 600,
				iconCls: "waf-ui-icon",
				draggable: true,
				resizable: true,
				close: function (event, ui) {
					waf.window.close();
					_private.refreshAttachCount();
				}
			});
		}
		,
		refreshAttachCount: function () {
			waf.doPost({
				url: waf.getContextPath() + '/iwebattachment.do?method=getAttachCountByBill',
				data: { billId: assign.billId },
				async: false,
				success: function (data) {
					_private.refreshAttachCountInner(data);
				}
			});
		}
		,
		refreshAttachCountInner: function (count) {
			var attachmentBtnTitle = _self._localeStr.WEB_ATCHMNTMANAGE;
			if (count > 0) {
				attachmentBtnTitle = _self._localeStr.WEB_ATCHMNTMANAGE + "(" + count + ")";
			}
			$("#attachmentBtn span").text(attachmentBtnTitle);
		}
		,
		getAssignInfo: function () {
			return assign;
		}
	});//@endPrivate
	_self.subscribeEvent("pageLoadCompletedEvent", _private._pageLoadCompletedEventHandler, "after");
	/**************************开发区域结束**********************************************/
	return _public;
});
