<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>完成项目服务</title>
		<link rel="stylesheet" href="../../../css/bootstrap.min.css" />
	    <link rel="stylesheet" type="text/css" href="../../../css/style.min.css"/>
	    <link rel="stylesheet" type="text/css" href="../../../css/cross.css"/>
		<style type="text/css">
			[v-cloak]{display: none;}
			.flex-box{display: -webkit-box;      /* OLD - iOS 6-, Safari 3.1-6 */         /* OLD - Firefox 19- (buggy but mostly works) */
				  display: -ms-flexbox;      /* TWEENER - IE 10 */     /* NEW - Chrome */
				  display: flex;             /* NEW, Spec - Opera 12.1, Firefox 20+ */
				  -webkit-box-pack: center;
				  -ms-flex-pack: center;
				  justify-content: center;
				  -webkit-box-align: center;
				  -ms-flex-align: center;
				  align-items: center;
				  -ms-flex-wrap: wrap;
				      flex-wrap: wrap;
				  }
			.flex-box-item{-webkit-box-flex: 1;      /* OLD - iOS 6-, Safari 3.1-6 */
				  -moz-box-flex: 1;         /* OLD - Firefox 19- */
				  -webkit-flex: 1;          /* Chrome */
				  -ms-flex: 1;              /* IE 10 */
				  width: 50%;               /* For old syntax, otherwise collapses. */
				  flex: 1;                  /* NEW, Spec - Opera 12.1, Firefox 20+ */
				 position: relative;}
			.icon{width: 12px;height: 12px;vertical-align: middle;background-size: 100% auto;background-repeat: no-repeat;display: inline-block;background-position: center center;}
			.icon-arrow-down{background-image: url(../images/icon/tiaozhuan_xia_icon.png);}
			.icon-gouxuan{background-image: url(../images/icon/gouxuan_lanse_icon.png);}
			.icon-check{background-image: url(../images/icon/zhankai_btn.png);}
			.icon-arrow-right{background-image: url(../images/icon/tiaozhuan_icon.png);background-size: auto 100%;}
			.icon-check,.icon-arrow-down{transition: all .3s ease-in-out;}
			.active .icon-check,.collapsed .icon-arrow-down{transform: rotateZ(180deg);}
			.icon-16{width: 16px;height: 16px;}
			.icon-18{width: 18px;height: 18px;}
			.service-top{font-size: 0;line-height: 1;font-weight: 500;}
			.service-name span{vertical-align: middle;font-size: 16px;}
			.service-name span+span{margin-left: 10px;}
			.service-name{line-height: 1.5;margin-bottom: 0;}
			.service-index{border: 1px solid #12b7f5;width: 16px;line-height: 1;height: 16px;font-size: 14px;display: inline-block;text-align: center;color: #12b7f5;}
			.label-group{padding-left: 26px;}
			.label-group span{color: #12b7f5;font-size: 14px;line-height: 1;margin-top: 10px;}
			.label-blue{border-radius: 5px;border: solid 1px #12b7f5;padding: 4px 15px;display: inline-block;margin-right: 27px;}
			.panel-body{padding: 20px 20px 0;font-size: 14px;color: #999;}
			.service-content{line-height: 30px;padding-bottom: 15px;border-bottom: 1px solid #d7dce6;}
			.service-address{border-bottom: 1px solid #d7dce6;}
			.btn-yuyue{background-color: #02cfb9;color: #fff;}
			.btn-yuyue:hover,.btn-yuyue:link{color: #fff;background-color: #01c1ad;}
			.btn-fuwuma{background-color: #2dbe55;color: #fff;}
			.btn-fuwuma:hover,.btn-fuwuma:link{color: #fff;background-color: #209440;}
			.btn-zhidao{background-color: #12b7f5;color: #fff;}
			.btn-zhidao:hover,.btn-zhidao:link{color: #fff;background-color: #10a0d6;}
			.service-operation .btn{width: 90px;}
			.view-detail{color: #12b7f5;cursor: pointer;}
			.record-list{max-height: 0;overflow: hidden;transition: all .3s linear;}
			.record-list.active{max-height: 999px;}
			.record-item{background-color: #f5f5fa;margin-bottom: 10px;padding: 10px;}
			.complete-title{font-size: 14px;color: #333;padding: 10px 0;border-bottom: 1px solid #D7DCE6;}
			.guanlian-list{border: 1px solid #d7dce6;padding: 3px 5px;}
			.upload-box{padding: 10px 0 10px 10px;overflow: hidden;border: 1px solid #d7dce6;}
			.upload-box li{width: 60px;height: 60px;position: relative;display: block;float: left;margin-right: 10px;}
			.upload-box li img{width: 100%;display: block;}
			.upload-img-box{width: 100%;height: 100%;overflow: hidden;}
			.delete-img{position: absolute;right: -5px;top: -5px;color: #fff;background-color: #ccc;border-radius: 100%;text-align: center;line-height: 15px;width: 15px;height: 15px;}
			.upload-img{position: absolute;left: 0;right: 0;top: 0;bottom: 0;opacity: 0;z-index: 3;font-size: 0;width: 100%;height: 100%;}
			.add-img{font-size: 40px;line-height: 60px;font-weight: 500;width: 60px;height: 60px;display: block;text-align: center;border: 1px dashed #d7dce6;color: #bec8d2;}
			.yslb>span:after{content: '、';}
			.yslb>span:last-child:after{display: none;}
		</style>
	</head>
	<body>
		<div id="app" v-cloak role="tablist" aria-multiselectable="true">
		  <div class="panelcurPage">
		    <div class="panel-heading" role="tab" @click="changeCollapseIndex(index)">
		      <h4 class="panel-title">
		        <a role="button" class="flex-box">
		          <div class="flex-box-item service-top">
		          	<p class="service-name"><span class="service-index">1</span><span>{{service.title}}</span></p>
		         	<div class="label-group">
		         		<span class="pull-right mt5"><i v-if="service.statusName=='已完成'" class="icon icon-gouxuan icon-18 mr5"></i>{{service.statusName}}</span>
		         		<span class="label-blue">{{service.shortExecuteTime}}</span>
		         		<span class="label-blue" v-for="doctor in service.executeDoctorList">{{doctor}}</span>
		         	</div>
		          </div>
		          <!--<span class="icon icon-arrow-down ml50"></span>-->
		        </a>
		      </h4>
		    </div>
		    <div class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
		      	<div class="panel-body">
		      		<div class="service-content">{{service.content}}</div>
		      		<div class="service-address ptb20">
		      			<div class="flex-box">
		      				<div class="flex-box-item">
		      					<p class="m0">地点：{{service.hospitalName}}</p>
		      					<p class="m0">时间：{{service.executeTime | formatDate}}</p>
		      				</div>
		      				<div class="flex-box-item">
		      					<p class="m0 yslb">执行：<span v-for="(doctor,index) in service.executeDoctorList">{{doctor}}</span></p>
		      					<p class="m0">收费：{{service.expense}}元</p>
		      				</div>
		      			</div>
		      		</div>
		   		</div>
	       </div>
		  </div>
	   		<div class="panel-body">
	      		<div class="service-operation pt10">
	      			<p><span class="pull-right view-detail" :class="{active:isCollapse}" @click="chakan"><i class="icon icon-check mr5 icon-16"></i>{{isCollapse?'收起详情':'查看详情'}}</span>指导与汇报记录</p>
	      			<div class="record-list" :class="{active:isCollapse}">
	      				<div class="record-item" v-for="item in service.messageList">
	      					<div class="flex-box c-999 f14">
		      					<div class="flex-box-item">
		      						{{item.adminTeamName}}
		      					</div>
		      					<div class="flex-box-item">
		      						{{item.createTime}}
		      					</div>
		      				</div>
		      				<div class="f14 c-333">{{item.content}}</div>
	      				</div>
	      			</div>
	      		</div>
	      		<div class="complete-info pt10">
	      			<div class="complete-title">完成情况</div>
	      			<div class="ptb10">
	      				<p class="f14 mb5"><span class="c-999">完成情况：</span>{{service.completeTime}}</p>
	      				<p class="f14 mb5"><span class="c-999">执行医生：</span>{{service.operatorDoctorName}}</p>
	      			</div>
	      		</div>
	      		<div class="note-info pt10">
	      			<p class="f14 c-333">服务完成笔记</p>
	      			<textarea v-if="service.status!=1" class="form-control" style="resize: none;" rows="4" placeholder="可备注您的服务记录" v-model="service.node"></textarea>
	      			<div v-if="service.status==1">{{service.node}}</div>
	      		</div>
	      		<div class="note-info pt10" style="display: none;">
	      			<p class="f14 c-333">关联记录</p>
	      			<p class="guanlian-list text-center">
	      				<span class="pull-right"><i class="icon icon-arrow-right"></i></span>随访记录sfs
	      			</p>
	      		</div>
	      		<div class="note-info pt10">
	      			<p class="f14 c-333">相关记录</p>
	      			<ul class="upload-box"  v-if="service.status!=1">
	      				<li class="flex-box" v-for="(img,index) in upImgs">
	      					<div class="upload-img-box">      						
		      					<img :src="img.baseUrl" />
	      					</div>
	      					<a class="delete-img" @click="deleteImg(index)">&times;</a>
	      				</li>
	      				<li class="flex-box" v-if="upImgs.length<5">
	      					<span class="add-img">＋</span>
	      					<input type="file" @change="upLoadImgToBase64" class="upload-img" />
	      				</li>
	      			</ul>
	      			<ul class="upload-box"  v-if="service.status==1">
	      				<li class="flex-box" v-for="img in service.relationRecordImg">
	      					<div class="upload-img-box">      						
		      					<img :src="img | getImgUrl" />
	      					</div>
	      				</li>
	      			</ul>
	      		</div>
	      		<div class="text-center ptb50" v-if="service.status!=1">
	      			<button class="btn btn-zhidao" @click="qrwc">确认完成</button>
	      		</div>
	      	</div>
		</div>
		<script type="text/javascript" src="../../../js/vue.js"></script>
		<script type="text/javascript" src="../../../js/jquery-2.2.4.js" ></script>
		<script type="text/javascript" src="../../../api/http-request.js"></script>
		<script type="text/javascript" src="../../../api/rehabilitation-api.js"></script>
		<script src="../../../js/util.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			!function(){
				var httpData=GetRequest();
				new Vue({
					el:"#app",
					data:{
						imgData: {
				            accept: 'image/gif, image/jpeg, image/png, image/jpg',
				        },
				        isCollapse:false,
				        upImgs:[],
				        upImgArr:[],
				        planid:httpData['planid'],
				        service:[]
					},
					mounted:function(){
						this.getServiceItem();
					},
					methods:{
						getServiceItem:function(){
							var vm=this;
							var loadding = top.layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
							rehaAPI.serviceItem({planDetailId:vm.planid}).then(function(res){
								top.layer.close(loadding);
								if(res.status==200){
									vm.service=res.data;
								}else{
									top.layer.msg(res.msg,{icon:5});
								}
							})
						},
						deleteImg:function(idx){
							console.log(idx)
							this.upImgs.splice(idx,1)
						},
						chakan:function(){
							this.isCollapse=!this.isCollapse;
						},
						upLoadImgToBase64:function(){
							var vm=this;
				            var img1=event.target.files[0];  
				            console.log(img1)
				            var reader =new FileReader();  
				            var type=img1.type;//文件的类型，判断是否是图片  
				            var size=img1.size;//文件的大小，判断图片的大小  
				            if(this.imgData.accept.indexOf(type) == -1){  
				                alert('请选择我们支持的图片格式！');  
				                return false;  
				            }  
				            if(size>3145728){  
				                alert('请选择3M以内的图片！');  
				                return false;  
				            }
				            reader.readAsDataURL(img1);
			             	reader.onload = function (e) {
			             		vm.upImgs.push({baseUrl:e.target.result});
			             		vm.upImgArr.push(img1);
//			             		vm.uploadImg(vm.upImgArr);
			             	}
						},
						qrwc:function(){
							var vm=this;
							vm.uploadImg(vm.upImgArr,vm.updateNoteAndImageRehabilitationOperate);
						},
						 //上传图片
				        uploadImg:function(data,cb){
				        	var vm=this;
				        	var len = data.length;
						    if (!len){
						        cb && cb();
						    }else{
						    	var file=data[len-1];
						    	var formData = new FormData();
								formData.append('file', file);
						    	rehaAPI.upload(formData).then(function(res){
						    		console.log(res)
						    		if(res.status==200){
						    			console.log(vm.upImgs[len-1])
						    			vm.upImgs[len-1].img=res.data;
						    			data.pop();
						    			vm.uploadImg(data,cb);
						    		}
								})
						    }
						},
						updateNoteAndImageRehabilitationOperate:function(){
							var vm=this;
							var _image=[];
							for(var i in vm.upImgs){
								_image.push(vm.upImgs[i].img);
							}
							var params={
								planDetailId:vm.planid,
								node:vm.service.node,
								image:JSON.stringify(_image)
							}
							var loadding = top.layer.load(0, {shade: false}); //0代表加载的风格，支持0-2
							rehaAPI.updateNoteAndImageRehabilitationOperate(params).then(function(res){
					    		top.layer.close(loadding);
					    		console.log(res)
					    		if(res.status==200){
					    			vm.getServiceItem();
					    			parent.serviceItem.getServiceItemList();
					    		}
							})
						},
			       	},
					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;
						}
					}
				})
			}()
		</script>
	</body>
</html>
