!function(){
	var httpData=GetRequest();
	var patientImg = "";
	var userInfo = JSON.parse(window.localStorage.getItem(httpRequest.agentName));
	//设置网页打印的页眉页脚为空 
	function PageSetup_Null() {
		var HKEY_Root,HKEY_Path,HKEY_Key; 
		HKEY_Root="HKEY_CURRENT_USER"; 
		HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"; 
		try { 
			var Wsh = new ActiveXObject("WScript.Shell");
			HKEY_Key="header"; 
			Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,""); 
			HKEY_Key="footer"; 
			Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
			window.print();
		} catch(e) {
			window.print();
		}
	}
	function bindEvent() {
		$("#printBtn").click(function() {
			var bdhtml = window.document.body.innerHTML, 
		    	sprnstr = "<!--startprint-->",
		    	eprnstr = "<!--endprint-->", 
		    	prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17);   
		    prnhtml=prnhtml.substring(0, prnhtml.indexOf(eprnstr));   
		    window.document.body.innerHTML = prnhtml; 
		    PageSetup_Null();
		})
		//查看签收
		$("#seeQianShou").click(function() {
			var imgUrl = httpRequest.getImgUrl(patientImg);
			parent.layer.open({
	    		type: 1,
		      	title:false,
		      	shadeClose: true,
		      	content:'<img style="width:360px;height:500px;" src="'+imgUrl+'">'
	    	})
//	        parent.layer.open({
//	          type:1,
//	          shift: 2,
//	          shade:0.6,
//	          title:false,
//	          shadeClose:true,
//	          content:'<img style="width:360px;height:500px;" src="'+imgUrl+'">'
//	        });
		})
	}
	new Vue({
		el:"#app",
		data:{
			accountList: {},
			planStatus:""
		},
		mounted:function(){
			this.getServiceItemsAfterStop()
			bindEvent();
			this.planStatus = httpData.planStatus || "";
		},
		methods:{
			getServiceItemsAfterStop: function() {
				var vm = this,
					loadding = layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
				rehaAPI.getServiceItemsAfterStop({planId: httpData.planids}).then(function(res){
					layer.close(loadding);
					if(res.status==200){
						vm.accountList = res.data
						patientImg = res.data.patient_img;
					}else{
						layer.msg(res.msg,{icon:5});
					}
				})
			}
		},
		filters:{
		  	formatDate:function(value, format) {
		  		if(!value) return ;
		  		var fmt=format || "yyyy-MM-dd hh:mm";
				var date = new Date(value);
				if (/(y+)/.test(fmt)) {
					fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
				}
				let o = {
					'M+': date.getMonth() + 1,
					'd+': date.getDate(),
					'h+': date.getHours(),
					'm+': date.getMinutes(),
					's+': date.getSeconds()
				};
				for (let k in o) {
					if (new RegExp(`(${k})`).test(fmt)) {
						let str = o[k] + '';
						fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : ('00' + str).substr(str.length));
					}
				}
				return fmt;
			},
			getImgUrl: function(value) {
				var url = httpRequest.getImgUrl(value);
				return url;
			}
		}
	})
}();