var Request = GetRequest();
new Vue({
  	el: '#app',
	data:{
		  queryData:{},
		  status:false,//2计划中，可编辑
//	  	options: [],
	  	// options_type:[{way_key:'1',value_type:'门诊'},{way_key:'22',value_type:'家庭(全科)'},{way_key:'3',value_type:'电话'}],
	  	options_class:[{class:'1',name:'高血压'},{class:'2',name:'糖尿病'},{class:'1,2',name:'高血压、糖尿病'}],
	  	options_statue:[]
	},
  	methods:{
  		saveButton:function(){
  			
  		}
  	},
	mounted: function(){
		var vm = this
		  var Request = GetRequest();
		  this.initData()
	  	//随访状态
	  	recordAPI.getFollowUpStatue({ name: 'FOLLOWUP_MANAGER_STATUS' }).then(function(res) {
	  		if(res.status == 200) {
	  			vm.options_statue = res.list
	  		} else {
	  			toastr.error(res.msg)
	  		}
	  	})
	},
	methods:{
		initData:function(){
			var vm=this
			recordAPI.getFollowup({id:Request["id"]}).then(function(res){
				if(res.status==200){
					var data = res.data
					console.log(data)
					data.followupDate = data.followupDate?data.followupDate.substr(0,16):''
					vm.queryData = data
					console.log(vm.queryData.followupDate)
					window.localStorage.setItem('serveFollowupDate',JSON.stringify(data));//储存数据，后续页面需要调用
					if(data.status=='2'){
						vm.status=false
					  }else{
						  vm.status=true
					  }		
	//			  	recordAPI.getFollowUpDoc({
	//			  		patient: data.patientCode
	//			  	}).then(function(res) {
	//			  		if(res.status == 200) {
	//			  			var data = res.data
	//			  			vm.options = data.list
	//			  		} else {
	//			  			//				toastr.error(res.msg)
	//			  		}
	//			  	})
				}else{
					toastr.error(res.msg)
				}	
			})
	
		},
		saveButton: function () {
			var vm=this
			var params={
				id:Request["id"],
				date:this.queryData.followupDate+':00',
				followupClass:this.queryData.followupClass,
				followupManagerStatus:this.queryData.followupManagerStatus,
				plandate:'',
				followupType:this.queryData.followupType			
			}
			recordAPI.startFollowup(params).then(function (res) {
				if (res.status == 200) {
					toastr.info('保存成功')
					vm.initData()
				} else {
					toastr.error(res.msg)
				}
			})

		}
	}
})

