Browse Source

Merge branch 'master' of linehang/PC-prescription into master

linehang 7 years ago
parent
commit
9035985ee7
2 changed files with 140 additions and 60 deletions
  1. 16 5
      body-record.html
  2. 124 55
      js/buz/body-record.js

+ 16 - 5
body-record.html

@ -20,14 +20,16 @@
    	.fs14 {font-size: 14px;}
    	.f-hover {background-color: #12b7f5; color: #fff;}
    	.h-lh-14 {height: 14px; line-height: 14px;}
    	h2, h3 {margin: 0;}
    	h2, h3, h4 {margin: 0;}
    	span, em {float: left;margin: 0; padding: 0;color: #12b7f5; text-align: center; cursor: pointer;}
    	.tab-record {overflow: hidden; width: 260px; height: 40px; border-radius: 5px; border: 1px solid #12b7f5; margin: 0 auto 20px;}
    	.tab-record  span {width: 129px; height: 38px;border: 0;line-height: 38px;}
    	.lit-wrap { padding-top: 30px;margin: 0 auto;}
    	.bg-con { background-color: #F5F5FA;}
    	.con-record { width: 520px; padding: 20px 0; margin: 0 auto;}
    	.day-record span {width: 88px; height: 28px;margin: 0 20px;border: 1px solid #12b7f5; border-radius: 15px;line-height: 28px;}
    	h3 span, h4 span { height: 28px;border: 1px solid #12b7f5; border-radius: 15px;line-height: 28px;}
    	.day-record span {width: 88px; margin: 0 20px;}
    	.status-record span {width: 58px; height: 18px; margin: 30px 0 0 12.5px; border-radius: 10px;line-height: 20px;}
    	.times-record {margin: 30px 0 24px;}
    	.is-ok {width: 100px; color: #12B7F5}
    	.is-height {width: 100px; margin: 0 110px; color: #fe5f59;}
@ -51,10 +53,19 @@
					<span>90天</span>
					<span>半年</span>
				</h3>
				<h4 class="status-record fs14 clearfix">
					<span class="f-hover">早餐前</span>
					<span>早餐后</span>
					<span>午餐前</span>
					<span>午餐后</span>
					<span>晚餐前</span>
					<span>晚餐后</span>
					<span>睡前</span>
				</h4>
				<p class="h-lh-14 times-record fs14 clearfix">
					<em class="is-ok"></em>
					<em class="is-height"></em>
					<em class="is-low"></em>
					<em class="is-ok">正常:0次</em>
					<em class="is-height">偏高:0次</em>
					<em class="is-low">偏低:0次</em>
				</p>
				<div class="canvas-record fs14"><strong class="danwei" style="color: #12B7F5">单位(mmol/L)</strong>
					<canvas id="canvas" width="520" height="230"></canvas>

+ 124 - 55
js/buz/body-record.js

@ -3,28 +3,88 @@
	var request = getRequest(),
		patient = request.patiCode || '';
	var tabIndex = 0,
		dayIndex = 0;
		dayIndex = 0,
		statusIndex = 1;
	// 绘制折线图初始定义
	var ctx = document.getElementById('canvas').getContext("2d");
	var dataCanvas = {
		labels : [],
		datasets : [
				{
					fillColor : "rgba(220,220,220,0.5)",
					strokeColor : "rgba(220,220,220,1)",
					pointColor : "rgba(220,220,220,1)",
					pointStrokeColor : "#fff",
					data : []
				},
				{
					fillColor : "rgba(151,187,205,0.5)",
					strokeColor : "rgba(151,187,205,1)",
					pointColor : "rgba(151,187,205,1)",
					pointStrokeColor : "rgba(151,187,205,1)",
					data : []
				}
			]
		},
		defaults = {
			scaleStartValue : 0,
			scaleShowLabels : true,
	    	datasetFill : false,         // 是否填充数据集 
	    	animation : true,            // 是否执行动画  
	    	animationSteps : 60,          // 动画的时间   
	    	animationEasing : "easeOutQuart",    // 动画的特效   
	    	onAnimationComplete : null    // 动画完成时的执行函数
		};
	var myLineChart = null;
//	new Chart(ctx).Line(dataCanvas, defaults);
	$('.tab-record span').click(function() {
		tabIndex = $(this).index();
		dataCanvas.labels = [];
		dataCanvas.datasets[0].data = [];
		dataCanvas.datasets[1].data = [];
		// 初始化数据
		if(tabIndex == 1) {
			statusIndex = 0;
			$('.status-record').hide();
		} else {
			var ele = $('.status-record span').get(0);
			indexHover(ele);
			statusIndex = 1;
			$('.status-record').show();
		}
		indexHover(this);
		dayIndex = 0;
		var ele = $('.day-record span').get(0)
		var ele = $('.day-record span').get(0);
		indexHover(ele);
		// 切换数据
		getBodyRecord(tabIndex, dayIndex);
		canvasDataDefault();
	});
	$('.day-record span').click(function() {
		dayIndex = $(this).index();
		if(tabIndex == 0) {
			var ele = $('.status-record span').get(0);
			indexHover(ele);
			statusIndex = 1;
		}
		indexHover(this);
		// 切换数据
		getBodyRecord(tabIndex, dayIndex);
		canvasDataDefault();
		
	});
	$('.status-record span').click(function() {
		statusIndex = $(this).index() + 1;
		indexHover(this);
		canvasDataDefault();
	});
	// 点击指示特效
	function indexHover(ele) {
		$(ele).siblings().removeClass('f-hover');
		$(ele).addClass('f-hover');
	};
	// 绘图数据格式化
	function canvasDataDefault() {
		dataCanvas.labels = [];
		dataCanvas.datasets[0].data = [];
		dataCanvas.datasets[1].data = [];
		// 切换数据
		getBodyRecord(tabIndex, dayIndex, statusIndex);
	}
	// 时间推算
	function getDateFromCurrentDate(fromDate, dayInterval) {
@ -35,6 +95,19 @@
		var day = curDate.getDate() < 10 ? "0" + curDate.getDate() : curDate.getDate();
		return year + "-" + month + "-" + day + " 00:00:00";
	};
	// 血糖标准
	function getNormalLevel(index) {
		return [
			[],
			[6.1, 3.9],
			[7.8, 4.4],
			[6.1, 3.9],
			[7.8, 4.4],
			[6.1, 3.9],
			[7.8, 4.4],
			[6.1, 3.9]
		][index];
	};
	// 获取最后一条数据
	var dataLast = {patient: patient};
	var lastXT = '',
@ -48,50 +121,24 @@
        	lastXT = res.data.xt.recordDate;
        	lastXY = res.data.xy.recordDate;
        	// 初始化执行
			getBodyRecord(tabIndex, dayIndex);
			getBodyRecord(tabIndex, dayIndex, statusIndex);
    	}else{
        	showWarningMsg(res.msg)
    	}
	})
	// 绘制折线图初始定义
	var ctx = document.getElementById('canvas').getContext("2d");
	var dataCanvas = {
		labels : [],
		datasets : [
			{
				fillColor : "rgba(220,220,220,0.5)",
				strokeColor : "rgba(220,220,220,1)",
				pointColor : "rgba(220,220,220,1)",
				pointStrokeColor : "#fff",
				data : []
			},
			{
				fillColor : "rgba(151,187,205,0.5)",
				strokeColor : "rgba(151,187,205,1)",
				pointColor : "rgba(151,187,205,1)",
				pointStrokeColor : "rgba(151,187,205,1)",
				data : []
			}
		]
	};
	var defaults = {
		scaleStartValue : 0,
		scaleShowLabels : true,
    	datasetFill : false,         // 是否填充数据集 
    	animation : true,            // 是否执行动画  
    	animationSteps : 60,          // 动画的时间   
    	animationEasing : "easeOutQuart",    // 动画的特效   
    	onAnimationComplete : null    // 动画完成时的执行函数
	}
	var myLineChart = null;
//	new Chart(ctx).Line(dataCanvas, defaults);
	// 获取数据
	function getBodyRecord(tab, day) {
	function getBodyRecord(tab, day, statu) {
		if(!lastXT || !lastXY) {
			showWarningMsg("该居民无体征记录");
			return;
		}
		};
		var xtMax = getNormalLevel(statusIndex)[0],
			xtMin = getNormalLevel(statusIndex)[1],
			xyMax = [139, 89],
			xymin = [90, 60],
			toNormal = 0,
			toHigh = 0,
			toLow = 0;
		$('.danwei').html(tab == 0 ? '单位(mmol/L)' : '单位(mmHg)');
		var	dayNum = 0;
		switch(day) {
@ -106,21 +153,28 @@
		}
		var type = (tab == 0 ? 1 : 2),
			startdate = (tab == 0 ? lastXT : lastXY),
			enddate = getDateFromCurrentDate(startdate, -dayNum),
			gi_type = (tab == 0 ? 1 : 0);// 字段不清楚暂时不处理
		$('.data-record').html(enddate.substr(0, 11) + '至' + startdate.substr(0,11));
			enddate = getDateFromCurrentDate(startdate, -dayNum);
		$('.data-record').html('<' + enddate.substr(0, 10) + '至' + startdate.substr(0,10) + '>');
		var recordData = {
			type: type,
			begin: enddate,
			end: startdate,
			gi_type: gi_type,
			gi_type: statu,
			patient: patient
		}
		};
		// 获取体征记录
		bodyRecordApis.getBodyRecordData({data: recordData}).then(function(res){
			if(myLineChart) {// 如果构造过,解析
        		myLineChart.destroy();
        	}
			if(res.status == 200){
	        	var list = res.list,
	        		len = 0;
	        	if(list) {
	        		len = list.length;
	        	} else {
	        		showWarningMsg("当前状态下无居民体征记录");return;
	        	};
	        	list.reverse();
	        	for(var i = 0; i < len; i++) {
	        		if(len == 1) {
@ -132,18 +186,33 @@
	        		}
	        		if(tabIndex == 1) {
	        			if(len == 1) {
	        				dataCanvas.datasets[1].data = [null, list[i].value2];	
	        				dataCanvas.datasets[1].data = [null, list[i].value2];
	        			} else {
	        				dataCanvas.datasets[1].data[i] = list[i].value2;
	        			}
	        			// 血压判断
	        			if(list[i].value1 > xyMax[0] || list[i].value2 > xyMax[1]) {
	        				++toHigh;
	        			} else if(list[i].value1 < xyMin[0] || list[i].value2 < xyMin[1]) {
	        				++toLow;
	        			} else {
	        				++toNormal;
	        			}
	        		} else {
	        			dataCanvas.datasets[1].data[i] = []
	        			// 血糖判断
	        			if(list[i].value1 > xtMax) {
	        				++toHigh;
	        			} else if(list[i].value1 < xtMin) {
	        				++toLow;
	        			} else {
	        				++toNormal;
	        			};
	        		}
	        	}
	        	$('.is-ok').html("正常:" + toNormal + "次");
	        	$('.is-height').html("偏高:" + toHigh + "次");
	        	$('.is-low').html("偏低:" + toLow + "次");
	        	// 绘制图
	        	if(myLineChart) {// 如果构造过,解析
	        		myLineChart.destroy();
	        	}
	        	myLineChart = new Chart(ctx).Line(dataCanvas, defaults);
	    	}else{
	        	showWarningMsg(res.msg)