new Vue({
  el: '#app',
  data: {
   	guidances:[
   		{name:'日吸烟量',type:1,value:"",unit:'支',key:"DAILY_SMOKING"},
   		{name:'日吸烟量期望',type:1,value:"",unit:'支',key:"SOMKING_EXP"},
   		{name:'心理调整',type:2,value:"",unit:'',key:"PSY_ADJUST_RESULT_CODE",
   			options:[{key: "1",value:"理想"},{key: "2",value: "良好"},{key: "3",value: "一般"},{key: "4",value: "差"}]
   		},
   		{name:'日饮酒量',type:1,value:"",unit:'两',key:"DAILY_DRINKING"},
   		{name:'日饮酒量期望',type:1,value:"",unit:'两',key:"DRINK_EXP"},
   		{name:'医德行为',type:2,value:"",unit:'',key:"COMPLIANCE_RESULT_CODE",
   			options:[{key: "1",value:"理想"},{key: "2",value: "良好"},{key: "3",value: "一般"},{key: "4",value: "差"}]
   		},
   		{name:'摄盐情况',type:2,value:"",unit:'',key:"SALT_TAKEN_LEVEL_CODE",
   			options:[{key: "1",value:"轻"},{key: "2",value: "中"},{key: "3",value: "重"}]
   		},
   		{name:'摄盐情况期望',type:2,value:"",unit:'',key:"SALT_TAKEN_LEVEL_EXP",
   			options:[{key: "1",value:"轻"},{key: "2",value: "中"},{key: "3",value: "重"}]
   		},
   		{name:'主食',type:1,value:"",unit:'克/天',key:"DAILY_STAPLE"},
   		{name:'运动频率',type:2,value:"",unit:'',key:"EXERCISE_FREQ_CODE",
   			options:[{key: "1",value:"每周 <= 三次"},{key: "2",value: "每周 > 三次"},{key: "3",value: "极少运动"},{key: "4",value: "残疾、关节等原因不能运动"},{key: "99",value: "不详"}]
   		},
   		{name:'运动时长',type:1,value:"",unit:'分钟/次',key:"EXERCISE_DURATION_MINS"},
   		{name:'运动频率期望',type:2,value:"",unit:'',key:"EXERCISE_FREQ_CODE_EXP",
   			options:[{key: "1",value:"每周 <= 三次"},{key: "2",value: "每周 > 三次"},{key: "3",value: "极少运动"},{key: "4",value: "残疾、关节等原因不能运动"},{key: "99",value: "不详"}]
   		},
   		{name:'运动时长期望',type:1,value:"",unit:'分钟/次',key:"EXERCISE_DURATION_MINS_EXP"},
   	],
   	objData:''
  },
  mounted: function() {
  	var vm = this
  	var Request = GetRequest();
  	recordAPI.getFollowupProjectData({id:Request["id"],followupProject:4}).then(function(res){
			if(res.status==200){
				var data = res.data;
				vm.objData = res.data
//				delete data["create_time"];delete data["followup_id"];delete data["followup_project"];delete data["id"];
				var allData = vm.guidances;
				for(var key in data){
					for(var j=0;j<allData.length;j++){
						if(allData[j].key == key){
							allData[j].value = data[key]
							break;
						}
					}
				}
			}
		})
  },
  methods:{
  	saveButton:function(){
  				var vm = this;
	      params = {id: vm.objData.followup_id, followupProject:vm.objData.followup_project}
	      var checkID = {}
	      $(".inline-container input").each(function(i,v){//把所有被选中的复选框的值存入数组
	           checkID[$(this).attr('name')] = $(this).val()
	        });
	         $(".inline-container select").each(function(i,v){//把所有被选中的复选框的值存入数组
	           checkID[$(this).attr('name')] = $(this).val()
	        });
	        console.log(checkID)
	        params.followupProjectData = JSON.stringify(checkID);
					recordAPI.ModifyFollowupResult(params).then(function(res){
					if(res.status==200){
						toastr.error("保存成功")
					}else{
						toastr.error(res.msg)
					}
				})
  	}
  }
})