<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>SBIF评分系统</title>
		<link rel="stylesheet" href="./static/common/layui/css/layui.css" />
		<style>
			body {
            background: #23282B;
            color: #FFF;
            font-size: 14px;
        }

        .content {
            overflow: hidden;
        }

        .content-title {
            height: 40px;
            line-height: 40px;
            padding: 0 15px;
            display: flex;
            justify-content: space-between;
        }


        .content-body {
            background: #283637;
        }

        .content-body .data-item-group {
            display: flex;
        }

        .content-body .data-item-group .data-item-l, .content-body .data-item-group .data-item-r {
            border: 1px solid #21292B;
            padding: 0 10px;
            height: 40px;
            line-height: 40px;
            flex: 1;
            padding: 0 15px;
            display: flex;
            text-align: left;
            white-space: nowrap;
            text-overflow: ellipsis;
            overflow: hidden;
        }

        .content-body .data-item {
            padding: 0 10px;
            height: 40px;
            line-height: 40px;
        }

        .red {
            color: red;
        }

        .orangered {
            color: orangered;
        }

        .yellow {
            color: yellow;
        }

        .olive {
            color: olive;
        }

        .green {
            color: green;
        }


        .color-block {
            position: absolute;
            right: 0;
            top: 0;
        }

        .color-block ul, .color-block li {
            margin: 0;
            padding: 0;
        }

        .color-block li {
            padding: 5px 10px;
            color: #111;
        }

        .color-block li.red-block {
            background-color: red;
        }

        .color-block li.orangered-block {
            background-color: orangered;
        }

        .color-block li.yellow-block {
            background-color: yellow;
        }

        .color-block li.olive-block {
            background-color: olive;
        }

        .color-block li.green-block {
            background-color: green;
        }

        #page-content {
            display: none;
        }

        .dialog {
            position: fixed;
            z-index: 9999;
            top: 15%;
            background: #FFF;
            width: 90%;
            margin: 0 2.5%;
            color: #333;
            border-radius: 2px;
            padding: 2.5%;
        }

        .dialog-title {
            height: 30px;
            line-height: 30px;
            display: flex;
            justify-content: space-between;
            border-bottom: 1px solid #eee;
        }

        .dialog-title .layui-icon {
            color: #333;
            font-weight: bold;
        }

        .static-data .data-item-l {
            display: flex;
        }

        .layui-item {
            flex: 1;
            background: none;
            border: none;
            color: #FFF;
        }


        .radio-label {
            margin: 0 5px;
            padding: 5px 20px;
        }

        .radio-label input, .radio-label select {
            margin-right: 10px;
            position: relative;
            top: 1px;
        }

        .layui-item {
            background: #283637;
        }

        .toast {
            position: fixed;
            top: 20%;
            z-index: 999;
            text-align: center;
            width: 100%;
        }

        .toast-info {
            background: #FFF;
            color: #333;
            display: inline-block;
            padding: 10px 20px;
            border-radius: 3px;
            font-size: 14px;
        }


    </style>
	</head>

	<body>
		<div class="container" id="app">

			<div id="page-content">
				<div class="color-block">
					<ul>
						<li class="red-block">五级</li>
						<li class="orangered-block">四级</li>
						<li class="yellow-block">三级</li>
						<li class="olive-block">二级</li>
						<li class="green-block">一级</li>
					</ul>
				</div>

				<div class="content">
					<div class="content-title">
						<div>
							人工SBIF累计评分
						</div>
					</div>
					<div class="content-body">
						<div class="data-item-group">
							<div class="data-item-l">
								{{jifaScore ? jifaScore : ''}}
							</div>
						</div>
					</div>
				</div>

				<div class="content">
					<div class="content-title">
						<div>
							SBIF即时评分
						</div>
						<div>
							<button type="button" class="layui-btn" style="margin-right: 40px" @click="openImmediateScore('ISBIF即时评分')">
								<i class="layui-icon layui-icon-chart-screen"></i>
							</button>
						</div>
					</div>
					<div class="content-body">
						<div class="data-item-group">
							<div class="data-item-l">
								{{jiangeScore ? jiangeScore : ''}}
							</div>
						</div>
					</div>
				</div>

				<div class="content">
					<div class="content-title">
						<div>
							自动SBIF累计评分
						</div>
						<button type="button" class="layui-btn" @click="openAutoScore('自动ISBIF累计评分')">
							<i class="layui-icon layui-icon-chart-screen"></i>
						</button>
					</div>
					<div class="content-body">
						<div class="data-item-group">
							<div class="data-item-l">
								{{dingsdianScore ? dingsdianScore : ''}}
							</div>
						</div>
					</div>
				</div>

				<div class="content">
					<div class="content-title">
						<div>
							静态指标
						</div>
						<div>
							<button type="button" class="layui-btn" @click="saveStaticData">
								保存静态数据
							</button>
						</div>
					</div>
					<div class="content-body static-data">
						<div class="data-item-group">
							<div class="data-item-l">
								<div>
									<span :class="$options.filters._indexMovement(staticIndex)">运动</span>：
								</div>
								<!--                        <input type="text" v-model="staticIndex.indexMovement" class="layui-item">-->
								<select v-model="staticIndex.indexMovement" class="layui-item">
									<option value="遵嘱活动">遵嘱活动</option>
									<option value="刺痛定位">刺痛定位</option>
									<option value="刺痛躲避">刺痛躲避</option>
									<option value="刺痛屈曲">刺痛屈曲</option>
									<option value="无反应">无反应</option>
								</select>
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l">
								<div @click="showAbnormalInfo(2,$options.filters._tongReflect(staticIndex))">
									<span :class="$options.filters._tongReflect(staticIndex)">瞳孔对光反射</span>：
								</div>
								<!--                        <input type="text" v-model="staticIndex.tongReflect" class="layui-item">-->
								<select v-model="staticIndex.tongReflect" class="layui-item">
									<option value="双瞳反应">双瞳反应</option>
									<option value="单瞳反应">单瞳反应</option>
									<option value="双瞳无反应">双瞳无反应</option>
								</select>
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l">
								<div @click="showAbnormalInfo(2,$options.filters._tongChange(staticIndex))">
									<span :class="$options.filters._tongChange(staticIndex)">瞳孔变化</span>：
								</div>
								<!--                        <input type="text" v-model="staticIndex.tongChange" class="layui-item">-->
								<select v-model="staticIndex.tongChange" class="layui-item">
									<option value="等大等圆">等大等圆</option>
									<option value="单瞳增大">单瞳增大</option>
									<option value="双瞳增大">双瞳增大</option>
								</select>
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l">
								<div @click="showAbnormalInfo(2,$options.filters._indexXz(staticIndex))"> 
									<span :class="$options.filters._indexXz(staticIndex)">血肿体积（ml）</span>：
								</div>
								<input type="nubmer" v-model="staticIndex.indexXz" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l">
								<div>
									<span :class="$options.filters._indexZwm(staticIndex)">蛛网膜下腔出血</span>：
								</div>
								<!--                        <input type="text" v-model="staticIndex.indexZwm" class="layui-item">-->
								<select v-model="staticIndex.indexZwm" class="layui-item">
									<option value="无">无</option>
									<option value="有">有</option>
								</select>
							</div>
						</div>
						<!--                <div class="data-item-group">-->
						<!--                    <div class="data-item-l">-->
						<!--                        血糖（mmol/l）：<input type="text" v-model="staticIndex.indexXt" class="layui-item">-->
						<!--                    </div>-->
						<!--                </div>-->
						<div class="data-item-group">
							<div class="data-item-l">
								<div @click="showAbnormalInfo(2,$options.filters._indexNzx(staticIndex))">
									<span :class="$options.filters._indexNzx(staticIndex)">脑中线偏移距离（cm）</span>：
								</div>
								<input type="nubmer" v-model="staticIndex.indexNzx" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l">
								<div @click="showAbnormalInfo(2,staticIndex.indexHckd<1)">
									环池平均宽度（mm）：
								</div>
								<input type="nubmer" v-model="staticIndex.indexHckd" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l">
								<div>
									年龄：
								</div>
								<input type="text" v-model="staticIndex.age" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l">
								<div>
									<span :class="$options.filters._surgery(staticIndex)">是否手术</span>：
								</div>
								<label class="radio-label" for="is_surgery_code1"><input id="is_surgery_code1" v-model="staticIndex.surgery"
									 type="radio" name="isSurgery" value="1" title="否" checked />否</label>
								<label class="radio-label" for="is_surgery_code2"><input id="is_surgery_code2" type="radio" v-model="staticIndex.surgery"
									 name="isSurgery" value="2" title="是" />是</label>
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l">
								<div>
									<span :class="$options.filters._medicalHistory(staticIndex)">既往慢性病史</span>：
								</div>
								<!--                    <input type="text" v-model="staticIndex.medicalHistory" class="layui-item">-->
								<select v-model="staticIndex.medicalHistory" class="layui-item">
									<option value="无">无</option>
									<option value="有一个">有一个</option>
									<option value="有两个">有两个</option>
									<option value="有三个">有三个</option>
								</select>
							</div>
						</div>
					</div>

					<div id="myChart" style="height: 400px;width: 100%;"></div>
				</div>

				<div class="content">
					<div class="content-title">
						动态指标
					</div>
					<div class="content-body">
						<div class="data-item-group">
							<div class="data-item-l" @click="showAbnormalInfo(3,$options.filters._systValue(systValue))">
								<span :class="$options.filters._systValue(systValue)">收缩压</span>：{{systValue ?
                        systValue.systValue : ''}}
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l">
								舒张压：{{systValue ? systValue.diasValue : ''}}
							</div>
						</div>
						<div class="data-item-group">
							<!--<div class="data-item-l">-->
							<!--平均压：{{systValue ? systValue.mapValue : ''}}-->
							<!--</div>-->
							<div class="data-item-l">
								<span :class="$options.filters._avgValue(systValue)">平均动脉压</span>（mmHg）：{{systValue ?
                        systValue.avgValue : ''}}
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l" @click="showAbnormalInfo(1,$options.filters._icpValue(systValue))">
								<span :class="$options.filters._icpValue(systValue)">颅内压</span>（mmHg）：{{systValue ?
                        systValue.icpValue
                        : ''}}
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l" @click="showAbnormalInfo(4,$options.filters._ngzyValue(systValue))">
								<span :class="$options.filters._ngzyValue(systValue)">脑灌注压</span>（mmHg）：{{systValue ?
                        systValue.ngzyValue : ''}}
							</div>
						</div>
					</div>
				</div>

				<div class="content">
					<div class="content-title">
						&nbsp;
					</div>
					<div class="content-body">
						<div class="data-item-group"> 
							<div class="data-item-l" @click="showAbnormalInfo(5,$options.filters._spo2Grade(spo2Value))">
								<span :class="$options.filters._spo2Grade(spo2Value)">血氧饱和度</span>（%）：{{ spo2Value ?
                        spo2Value.spo2Value : ""}}
							</div>
						</div>
						<!--                <div class="data-item-group">-->
						<!--                    <div class="data-item-l">-->
						<!--                        血氧脉搏值：{{ spo2Value ? spo2Value.rateValue : ""}}-->
						<!--                    </div>-->
						<!--                </div>-->
						<div class="data-item-group">
							<div class="data-item-l">
								血流灌注指数：{{ spo2Value ? spo2Value.perfValue : ""}}
							</div>
						</div>
					</div>
				</div>

				<div class="content">
					<div class="content-title">
						&nbsp;
					</div>
					<div class="content-body">
						<div class="data-item-group">
							<div class="data-item-l" @click="showAbnormalInfo(7,$options.filters._heartValue(heartValue))">
								<span :class="$options.filters._heartValue(heartValue)">心跳</span>（bpm）：{{ heartValue ?
                        heartValue.heartValue : ""}}
							</div>
						</div>
						<!--                <div class="data-item-group">-->
						<!--                    <div class="data-item-l">-->
						<!--                        心室收缩次数：{{ heartValue ? heartValue.vpcValue : ""}}-->
						<!--                    </div>-->
						<!--                </div>-->
						<!--                <div class="data-item-group">-->
						<!--                    <div class="data-item-l">-->
						<!--                        心脏停搏：{{ heartValue ? heartValue.pauseValue : ""}}-->
						<!--                    </div>-->
						<!--                </div>-->
						<!--                <div class="data-item-group">-->
						<!--                    <div class="data-item-l">-->
						<!--                        成对早搏：{{ heartValue ? heartValue.coupletsValue : ""}}-->
						<!--                    </div>-->
						<!--                </div>-->
						<!--                <div class="data-item-group">-->
						<!--                    <div class="data-item-l">-->
						<!--                        漏搏：{{ heartValue ? heartValue.beatsValue : ""}}-->
						<!--                    </div>-->
						<!--                </div>-->
						<!--                <div class="data-item-group">-->
						<!--                    <div class="data-item-l">-->
						<!--                        RonTs融合：{{ heartValue ? heartValue.rontsValue : ""}}-->
						<!--                    </div>-->
						<!--                </div>-->
						<!--                <div class="data-item-group">-->
						<!--                    <div class="data-item-l">-->
						<!--                        室性过早搏动：{{ heartValue ? heartValue.vpbValue : ""}}-->
						<!--                    </div>-->
						<!--                </div>-->
						<div class="data-item-group">
							<div class="data-item-l">
								<span :class="$options.filters._respValue(heartValue)">呼吸率</span>（bpm）: {{ heartValue ?
                        heartValue.respValue : ""}}
							</div>
						</div>
					</div>
				</div>

				<div class="content">
					<div class="content-title">
						&nbsp;
					</div>
					<div class="content-body">
						<div class="data-item-group">
							<div class="data-item-l" @click="showAbnormalInfo(6,$options.filters._tempValue(tempValue))">
								<span :class="$options.filters._tempValue(tempValue)">体温</span>（℃）：{{ tempValue ?
                        tempValue.tempValue : ""}}
							</div>
						</div>
					</div>
				</div>

				<div class="content">
					<div class="content-title">
						<div>

						</div>
						<div>
							<button type="button" class="layui-btn" @click="saveBloodGasData">
								保存血气数据
							</button>
						</div>
					</div>
					<div class="content-body">
						<div class="data-item-group">
							<div class="data-item-l" >
								<span :class="$options.filters._K(nA)" @click="showAbnormalInfo(9,$options.filters._K(nA))">钾离子(K)</span>：
								<!--                        {{ nA ? nA.K : ""}}-->
								<input type="nubmer" v-model="nA.K" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l" >
								<div >
									<span :class="nA.NA>145?'red':(nA.NA<135?'green':'')" @click="showAbnormalInfo(nA.NA>145?14:(nA.NA<135&&nA.NA>=130?15:(nA.NA<130?16:'')),nA.NA>145||nA.NA<135)">钠离子(NA)：</span>
								</div>
								<!--                        {{ nA ? nA.NA : ""}}-->
								<input type="nubmer" v-model="nA.NA" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l">
								<div>
									<span :class="$options.filters._ICA(nA)">钙离子(ICA)</span>：
								</div>
								<!--                        {{ nA ? nA.LAC : ""}}-->
								<input type="nubmer" v-model="nA.ICA" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l">
								<span :class="$options.filters._CL(nA)">氯离子(CL)</span>：
								<!--                        {{ nA ? nA.CL : ""}}-->
								<input type="nubmer" v-model="nA.CL" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l" >
								<span :class="$options.filters._ph(nA)" @click="showAbnormalInfo(10,$options.filters._ph(nA))">酸碱度(PH)</span>:
								<!--                        {{ nA ? nA.PH : ""}}-->
								<input type="nubmer" v-model="nA.PH" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l">
								<span :class="$options.filters._GLU(nA)" @click="showAbnormalInfo(12,$options.filters._GLU(nA))">血糖(GLU)</span>：
								<!--                        {{ nA ? nA.GLU : ""}}-->
								<input type="nubmer" v-model="nA.GLU" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l">
								<span :class="$options.filters._LAC(nA)">血乳酸(LAC)</span>：
								<!--                        {{ nA ? nA.LAC : ""}}-->
								<input type="nubmer" v-model="nA.LAC" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l"  >
								<span :class="$options.filters._HB(nA)" >血红蛋白(HB)</span>：
								<!--                        {{ nA ? nA.HB : ""}}-->
								<input type="nubmer" v-model="nA.HB" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l">
								<!-- @click="showAbnormalInfo(17,$options.filters._HCO3(nA))" -->
								<div><span :class="$options.filters._HCO3(nA)"  >碳酸氢根(HCO3)</span>：</div>
								<!--                        {{ nA ? nA.HCO3 : ""}}-->
								<input type="nubmer" v-model="nA.HCO3" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l" >
								<span :class="$options.filters._BE(nA)">碱剩余(BE)</span>：
								<!--                        {{ nA ? nA.BE : ""}}-->
								<input type="nubmer" v-model="nA.BE" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l" >
								<span :class="$options.filters._TCO2(nA)">总二氧化碳(TCO2)</span>：
								<!--                        {{ nA ? nA.TCO2 : ""}}-->
								<input type="nubmer" v-model="nA.TCO2" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l">
								<span :class="$options.filters._PO2(nA)"  @click="showAbnormalInfo(5,$options.filters._PO2(nA))">氧分压(PO2)</span>：
								<!--                        {{ nA ? nA.PO2 : ""}}-->
								<input type="nubmer" v-model="nA.PO2" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l" >
								<span :class="$options.filters._PCO2(nA)" @click="showAbnormalInfo(18,$options.filters._PCO2(nA))">二氧化碳分压(PCO2)</span>：
								<!--                        {{ nA ? nA.PCO2 : ""}}-->
								<input type="nubmer" v-model="nA.PCO2" class="layui-item">
							</div>
						</div>
						<div class="data-item-group">
							<div class="data-item-l" >
								<!-- @click="showAbnormalInfo(11,$options.filters._BUN(nA))" -->
								<span :class="$options.filters._BUN(nA)">尿素氮(BUN)</span>：
								<!--                        {{ nA ? nA.BUN : ""}}-->
								<input type="nubmer" v-model="nA.BUN" class="layui-item">
							</div>
						</div>

						<div class="data-item-group">
							<div class="data-item-l">
								<span :class="$options.filters._CREA(nA)" @click="showAbnormalInfo(11,$options.filters._CREA(nA))">血清肌酐(CREA)</span>：
								<!--                        {{ nA ? nA.CREA : ""}}-->
								<input type="nubmer" v-model="nA.CREA" class="layui-item">
							</div>
						</div>
						<!--                <div class="data-item-group">-->
						<!--                    <div class="data-item-l">-->
						<!--                        尿素：{{ nA ? nA.UREA : ""}}-->
						<!--                    </div>-->
						<!--                </div>-->
						<!--                <div class="data-item-group">-->
						<!--                    <div class="data-item-l">-->
						<!--                        <span :class="$options.filters._ANGAP(nA)">阴离子间隙</span>：{{ nA ? nA.ANGAP : ""}}-->
						<!--                    </div>-->
						<!--                </div>-->


						<!--                <div class="data-item-group">-->
						<!--                    <div class="data-item-l">-->
						<!--                        <span :class="$options.filters._SO2(nA)">氧饱和度</span>：{{ nA ? nA.SO2 : ""}}-->
						<!--                    </div>-->
						<!--                </div>-->
					</div>
				</div>

				<div class="dialog" v-if="autoScoreDialog">
					<div class="dialog-title">
						<p>{{autoScoreTile}}</p>
						<p @click="autoScoreDialog = false"><i class="layui-icon layui-icon-close"></i></p>
					</div>
					<div class="dialog-content">
						<div id="auto_score" style="width: 100%;height: 300px"></div>
					</div>
				</div>

				<div class="dialog" v-if="immediateScoreDialog">
					<div class="dialog-title">
						<p>{{immediateScoreTile}}</p>
						<p @click="immediateScoreDialog = false"><i class="layui-icon layui-icon-close"></i></p>
					</div>
					<div class="dialog-content">
						<div id="immediate_score" style="width: 100%;height: 300px"></div>
					</div>
				</div>


				<div class="toast" v-if="toastFlag">
					<div class="toast-info">
						{{toastText}}
					</div>
				</div>
			</div>


		</div>


	</body>

	<script type="text/javascript" src="./static/common/plugins/jquery/jquery-3.2.1.min.js"></script>
	<script type="text/javascript" src="./static/common/plugins/ECharts/echarts.js"></script>
	<script type="text/javascript" src="./static/common/vuejs/vue.js"></script>
	<script src="./static/common/js/abnormalInfo.js"></script>
	<!-- <script type="text/javascript" src="./static/common/layui/lay/modules/layer.js"></script> -->
	<script type="text/javascript" src="./static/common/layui/layui.js"></script>
	<script>
		console.log({abnormalInfo})
		var getUrlParam = function(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
			var r = window.location.search.substr(1).match(reg);
			if (r != null) {
				return decodeURI(r[2]);
			} else {
				return null;
			}
		};

		var myChart;
		var heartCheck, websocket;
		var staticData = [];


		function setMessageInnerHTML(datas) {
			console.log(datas);

		}

		var randomData = function(val) {
			now = new Date(+now + oneDay);
			value = val ? val : 128;
			return {
				name: now.toString(),
				value: [
					[now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'),
					// time,
					// Math.round(value)
					value
				]
			}
		}


		var chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
			'v', 'w', 'x', 'y', 'z',
			'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
			'X', 'Y', 'Z'
		];

		function generateMixed(n) {
			var res = "";
			for (var i = 0; i < n; i++) {
				var id = Math.ceil(Math.random() * 51);
				res += chars[id];
			}

			return res;
		}


		var data = [];
		var now = +new Date(1997, 9, 3);
		var oneDay = 24 * 3600 * 1000;
		var value = Math.random() * 1000;
		for (var i = 0; i < 1000; i++) {
			data.push(randomData());
		}


		var baseUrl = 'http://180.76.164.148:8898/';
		// var baseUrl = 'http://192.168.3.171:8898/';
		var wsUrl = 'ws://180.76.164.148:9002?userId=ZDYY'
		// var wsUrl = 'ws://192.168.3.171:9002?userId=ZDYY'

		var app = new Vue({
			el: "#app",
			data: function() {
				return {
					userId: '',
					token: "",
					staticIndex: {
						indexMovement: null,
						tongReflect: null,
						tongChange: null,
						indexXz: null,
						indexZwm: null,
						indexXt: null,
						indexNzx: null,
						indexHckd: null,
						age: null,
						surgery: null,
						medicalHistory: null,
					}, // 静态指标
					nA: {
						K: null,
						NA: null,
						LAC: null,
						CL: null,
						PH: null,
						GLU: null,
						ICA: null,
						HB: null,
						HCO3: null,
						BE: null,
						TCO2: null,
						PO2: null,
						PCO2: null,
						BUN: null,
						CREA: null,
					}, // '血糖'
					heartValue: null, // '心电指标'
					spo2Value: null, // '指脉氧饱和度指标
					systValue: null, // '无创血压'
					score: null, // '脑损害评分'
					potlI: null, // '心电图形参数'
					tempValue: null, // 体温
					jifaScore: null,
					dingsdianScore: null,
					jiangeScore: null,
					// 自动评分
					autoScoreDialog: false,
					autoScoreStatistics: [],
					autoScoreTile: '', // 统计标题
					staticData: [],
					// 即时评分
					immediateScoreDialog: false,
					immediateScoreTile: '',
					immediateScoreStatistics: [],
					websocket: null,
					toastFlag: false,
					toastText: '',
				}
			},
			filters: {
				_indexMovement(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					var indexMovement = data.indexMovement;
					if (indexMovement != null && indexMovement !== '') { //运动
						var value = indexMovement;
						if ("无反应" === value) {
							result = "orangered";
						} else if ("刺痛屈曲" === value) {
							result = "yellow";
						} else if ("刺痛躲避" === value) {
							result = "olive";
						} else if ("刺痛定位" === value) {
							result = "green";
						}
					}
					return result;
				},
				_tongChange(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					var tongChange = data.tongChange;
					if (tongChange != null && tongChange !== '') { //瞳孔变化
						var value = tongChange;
						if ("双瞳增大" === value) {
							result = "orangered";
						} else if ("单瞳增大" === value) {
							result = "olive";
						}
					}
					return result;
				},
				_tongReflect(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					var tongReflect = data.tongReflect;
					if (tongReflect != null && tongReflect !== '') { //瞳孔反射
						var value = tongReflect;
						if ("双瞳无反应" === value) {
							result = "yellow";
						} else if ("单瞳反应" === value) {
							result = "green";
						}
					}
					return result;
				},
				_indexXz(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					var indexXz = data.indexXz;
					if (indexXz != null && indexXz !== '') { //
						var value = indexXz;
						if (parseFloat(value) > 120) {
							result = "orangered";
						} else if (parseFloat(value) > 90) {
							result = "yellow";
						} else if (parseFloat(value) > 60) {
							result = "olive";
						} else if (parseFloat(value) > 30) {
							result = "green";
						}
					}
					return result;
				},
				_indexXz(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					var indexXz = data.indexXz;
					if (indexXz != null && indexXz !== '') { //
						var value = indexXz;
						if (parseFloat(value) > 120) {
							result = "orangered";
						} else if (parseFloat(value) > 90) {
							result = "yellow";
						} else if (parseFloat(value) > 60) {
							result = "olive";
						} else if (parseFloat(value) > 30) {
							result = "green";
						}
					}
					return result;
				},
				_indexNzx(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					var indexNzx = data.indexNzx;
					if (indexNzx != null && indexNzx !== '') { //
						var value = indexNzx;
						if (parseFloat(value) > 2) {
							result = "orangered";
						} else if (parseFloat(value) > 1.5) {
							result = "yellow";
						} else if (parseFloat(value) > 1) {
							result = "olive";
						} else if (parseFloat(value) > 0.5) {
							result = "green";
						}
					}
					return result;
				},
				_indexZwm(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					var indexZwm = data.indexZwm;
					if (indexZwm != null && indexZwm !== '') { //
						var value = indexZwm;
						if ("有" == indexZwm) {
							result = "green";
						}
					}
					return result;
				},
				_surgery(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					var surgery = data.surgery;
					if (surgery != null && surgery !== '') { //
						var value = surgery;
						if ("2" == surgery) {
							result = "olive";
						}
					}
					return result;
				},
				_medicalHistory(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					var medicalHistory = data.medicalHistory;
					if (medicalHistory != null && medicalHistory !== '') { //
						var value = medicalHistory;
						if ("有两个" === medicalHistory || "有三个" === medicalHistory) {
							result = "olive";
						}
					}
					return result;
				},
				_tempValue(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.tempValue !== undefined && data.tempValue !== null) {
						var value = data.tempValue;
						if (value >= 40.5) {
							result = "red";
						} else if (value >= 40) {
							result = "orangered";
						} else if (value >= 39.5) {
							result = "yellow";
						} else if (value >= 38.5) {
							result = "olive";
						} else if (value >= 37.5) {
							result = "green";
						}
					}
					return result;
				},
				_ph(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.PH !== undefined && data.PH !== null) {
						var value = data.PH;
						if (value >= 7.7 || value <= 7.1) {
							result = "red";
						} else if (value >= 7.65 || value <= 7.15) {
							result = "orangered";
						} else if (value >= 7.6 || value <= 7.2) {
							result = "yellow";
						} else if (value >= 7.55 || value <= 7.25) {
							result = "olive";
						} else if (value >= 7.5 || value <= 7.3) {
							result = "green";
						}
					}
					return result;
				},
				_K(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.K !== undefined && data.K !== null) {
						var value = data.K;
						if (value >= 6.1 || value <= 2.5) {
							result = "red";
						} else if (value >= 5.8 || value <= 2.6) {
							result = "orangered";
						} else if (value >= 5.6 || value <= 2.8) {
							result = "yellow";
						} else if (value >= 5.3 || value <= 3) {
							result = "olive";
						} else if (value >= 5 || value <= 3.2) {
							result = "green";
						}
					}
					return result;
				},
				_GLU(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.GLU !== undefined && data.GLU !== null) {
						var value = data.GLU;
						if (value >= 25 || value <= 1) {
							result = "red";
						} else if (value >= 13 || value <= 1.5) {
							result = "orangered";
						} else if (value >= 9 || value <= 2) {
							result = "yellow";
						} else if (value >= 7 || value <= 2.2) {
							result = "olive";
						} else if (value >= 6 || value <= 3) {
							result = "green";
						}
					}
					return result;
				},
				_LAC(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.LAC !== undefined && data.LAC !== null) {
						var value = data.LAC;
						if (value >= 5.5 || value <= 0.05) {
							result = "red";
						} else if (value >= 5 || value <= 0.1) {
							result = "orangered";
						} else if (value >= 4.5 || value <= 0.2) {
							result = "yellow";
						} else if (value >= 4 || value <= 0.3) {
							result = "olive";
						} else if (value >= 3.5 || value <= 0.4) {
							result = "green";
						}
					}
					return result;
				},
				_CL(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.CL !== undefined && data.CL !== null) {
						var value = data.CL;
						if (value >= 130 || value <= 73) {
							result = "red";
						} else if (value >= 125 || value <= 78) {
							result = "orangered";
						} else if (value >= 120 || value <= 83) {
							result = "yellow";
						} else if (value >= 115 || value <= 88) {
							result = "olive";
						} else if (value >= 110 || value <= 93) {
							result = "green";
						}
					}
					return result;
				},
				_HCO3(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.HCO3 !== undefined && data.HCO3 !== null) {
						var value = data.HCO3;
						if (value >= 50 || value <= 6) {
							result = "red";
						} else if (value >= 48 || value <= 8) {
							result = "orangered";
						} else if (value >= 43 || value <= 10) {
							result = "yellow";
						} else if (value >= 38 || value <= 12) {
							result = "olive";
						} else if (value >= 33 || value <= 17) {
							result = "green";
						}
					}
					return result;
				},
				_HB(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.HB !== undefined && data.HB !== null) {
						var value = data.HB;
						if (value >= 25 || value <= 3) {
							result = "red";
						} else if (value >= 20 || value <= 5) {
							result = "orangered";
						} else if (value >= 19 || value <= 7) {
							result = "yellow";
						} else if (value >= 18.5 || value <= 9) {
							result = "olive";
						} else if (value >= 18 || value <= 11) {
							result = "green";
						}
					}
					return result;
				},
				_SO2(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.SO2 !== undefined && data.SO2 !== null) {
						var value = data.SO2;
						if (value >= 105 || value <= 60) {
							result = "red";
						} else if (value >= 104 || value <= 70) {
							result = "orangered";
						} else if (value >= 103 || value <= 80) {
							result = "yellow";
						} else if (value >= 102 || value <= 85) {
							result = "olive";
						} else if (value >= 101 || value <= 90) {
							result = "green";
						}
					}
					return result;
				},
				_BE(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.BE !== undefined && data.BE !== null) {
						var value = data.BE;
						if (value >= 8 || value <= -8) {
							result = "red";
						} else if (value >= 7 || value <= -7) {
							result = "orangered";
						} else if (value >= 6 || value <= -6) {
							result = "yellow";
						} else if (value >= 5 || value <= -5) {
							result = "olive";
						} else if (value >= 4 || value <= -4) {
							result = "green";
						}
					}
					return result;
				},
				_TCO2(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.TCO2 !== undefined && data.TCO2 !== null) {
						var value = data.TCO2;
						if (value >= 53 || value <= 8) {
							result = "red";
						} else if (value >= 48 || value <= 10) {
							result = "orangered";
						} else if (value >= 43 || value <= 13) {
							result = "yellow";
						} else if (value >= 38 || value <= 16) {
							result = "olive";
						} else if (value >= 33 || value <= 19) {
							result = "green";
						}
					}
					return result;
				},
				_PO2(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.PO2 !== undefined && data.PO2 !== null) {
						var value = data.PO2;
						if (value <= 40) {
							result = "red";
						} else if (value <= 50) {
							result = "orangered";
						} else if (value <= 60) {
							result = "yellow";
						} else if (value <= 70) {
							result = "olive";
						} else if (value <= 80) {
							result = "green";
						}
					}
					return result;
				},
				_ANGAP(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.ANGAP !== undefined && data.ANGAP !== null) {
						var value = data.ANGAP;
						if (value >= 28 || value <= 3) {
							result = "red";
						} else if (value >= 26 || value <= 3.5) {
							result = "orangered";
						} else if (value >= 24 || value <= 4) {
							result = "yellow";
						} else if (value >= 22 || value <= 5) {
							result = "olive";
						} else if (value >= 20 || value <= 6) {
							result = "green";
						}
					}
					return result;
				},
				_avgValue(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.avgValue !== undefined && data.avgValue !== null) {
						var value = data.avgValue;
						if (value >= 200 || value <= 25) {
							result = "red";
						} else if (value >= 190 || value <= 40) {
							result = "yellow"
						} else if (value >= 180 || value <= 55) {
							result = "olive";
						} else if (value >= 160 || value <= 70) {
							result = "green";
						}
					}
					return result;
				},
				_systValue(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.systValue !== undefined && data.systValue !== null) {
						var value = data.systValue;
						if (value >= 200 || value <= 50) {
							result = "red";
						} else if (value >= 180 || value <= 60) {
							result = "orangered"
						} else if (value >= 160 || value <= 70) {
							result = "yellow";
						} else if (value >= 150 || value <= 80) {
							result = "olive";
						} else if (value >= 140 || value <= 90) {
							result = "green";
						}
					}
					return result;
				},
				_icpValue(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.icpValue !== undefined && data.icpValue !== null) {
						var value = data.icpValue;
						if (value >= 35) {
							result = "red";
						} else if (value >= 30) {
							result = "orangered";
						} else if (value >= 25) {
							result = "yellow";
						} else if (value >= 22) {
							result = "olive";
						} else if (value >= 18) {
							result = "green";
						}
					}
					return result;
				},
				_ngzyValue(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.ngzyValue !== undefined && data.ngzyValue !== null) {
						var value = data.ngzyValue;
						if (value <= 20) {
							result = "red";
						} else if (value <= 25) {
							result = "orangered";
						} else if (value <= 30) {
							result = "yellow";
						} else if (value <= 40) {
							result = "olive";
						} else if (value <= 60) {
							result = "green";
						}
					}
					return result;
				},
				_heartValue(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.heartValue !== undefined && data.heartValue !== null) {
						var value = data.heartValue;
						if (value >= 180 || value <= 40) {
							result = "red";
						} else if (value >= 160 || value <= 45) {
							result = "orangered";
						} else if (value >= 150 || value <= 50) {
							result = "yellow";
						} else if (value >= 140 || value <= 60) {
							result = "olive";
						} else if (value >= 110 || value <= 70) {
							result = "green";
						}
					}
					return result;
				},
				_respValue(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.respValue !== undefined && data.respValue !== null) {
						var value = data.respValue;
						if (value >= 45 || value <= 2) {
							result = "red";
						} else if (value >= 40 || value <= 4) {
							result = "orangered";
						} else if (value >= 30 || value <= 6) {
							result = "yellow";
						} else if (value >= 25 || value <= 8) {
							result = "olive";
						} else if (value >= 20 || value <= 11) {
							result = "green";
						}
					}
					return result;
				},
				_spo2Grade(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.spo2Value !== undefined && data.spo2Value !== null) {
						var value = data.spo2Value;
						if (value <= 65) {
							result = "red";
						} else if (value <= 70) {
							result = "orangered";
						} else if (value <= 75) {
							result = "yellow";
						} else if (value <= 80) {
							result = "olive";
						} else if (value <= 85) {
							result = "green";
						}
					}
					return result;
				},
				_CREA(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.CREA !== undefined && data.CREA !== null && data.CREA !== ''){
						var value = data.CREA;
						if (value >= 400 || value <= 40){
							result = "red";
						}else if(value >= 300 || value <= 50){
							result = "orangered";
						}else if(value >= 250 || value <= 60){
							result = "yellow";
						}else if(value >= 200 || value <= 70){
							result = "olive";
						}else if(value >= 180 || value <= 80){
							result = "green";
						}
					}
					return result;
				},
				_BUN(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.BUN !== undefined && data.BUN !== null && data.BUN !== ''){
						var value = data.BUN;
						if (value >= 20 || value <= 1){
							result = "red";
						}else if(value >= 15 || value <= 2){
							result = "orangered";
						}else if(value >= 12 || value <= 2.5){
							result = "yellow";
						}else if(value >= 9 || value <= 2.7){
							result = "olive";
						}else if(value >= 8 || value <= 3){
							result = "green";
						}
					}
					return result;
				},
				_ICA(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.ICA !== undefined && data.ICA !== null && data.ICA !== ''){
						var value = data.ICA;
						if (value >= 1.61 || value <= 0.96){
							result = "red";
						}else if(value >= 1.58 || value <= 0.98){
							result = "orangered";
						}else if(value >= 1.5 || value <= 1){
							result = "yellow";
						}else if(value >= 1.45 || value <= 1.05){
							result = "olive";
						}else if(value >= 1.4 || value <= 1.1){
							result = "green";
						}
					}
					return result;
				},
				_PCO2(data) {
					var result = "";
					if (data == null) {
						return result;
					}
					if (data.PCO2 !== undefined && data.PCO2 !== null && data.PCO2 !== ''){
						var value = data.PCO2;
						if (value >= 65 || value <= 20){
							result = "red";
						}else if(value >= 60 || value <= 22){
							result = "orangered";
						}else if(value >= 55 || value <= 26){
							result = "yellow";
						}else if(value >= 50 || value <= 30){
							result = "olive";
						}else if(value >= 47 || value <= 33){
							result = "green";
						}
					}
					return result;
				},

			},
			created() {
				$('#page-content').show();
				setTimeout(function() {
					location.reload()
				}, 60 * 11 * 1000)
			},
			mounted() {
				this.token = getUrlParam("token");
				this.userId = getUrlParam("userId");
				// this.token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxMTYyMzEzMDM0MTc0ODEyMTYyIiwiZXhwIjoxNTk0NjMwODE0LCJpYXQiOjE1OTQwMjYwMTR9.QWo0WHf6inZKCQM3QgOysmOgloIfoSSV5ORyE2PprMpXSfn7b7JW2lQ_Pyxi3OipUgi3Wl_-4werjsVx_Ufr3A";
				// this.userId = "1161282290756624386";
				// this.userId = "1283971705852772353";
				// this.userId = "1284048364360626177";    // 测试病人3
				// this.userId = "1284050925901770753";    // 测试病人4
				// this.userId = "1284115834836541442";    // 测试病人11
				// this.userId = "1285135004961292289";    // 测试病人1
				// this.userId = "1285477346842959873";    // 测试病人2
				// this.userId = "1286153076564209666";    // 林全茂
				// this.userId = "1288016557307490306"; // 李宁

				// this.userId = "1284108001442324481";    // 本地测试地址
				// this.userId = "1300952143651549186";    // 本地测试地址
				myChart = echarts.init(document.getElementById('myChart'));
				if (this.userId) {
					this.getStaticData();
					this.initSocket();
					this.getDefaultData();
				}
				// this.getAutoScoreStatistics();

			},
			methods: {
				// 保存血气数据
				saveBloodGasData() {
					var _this = this;
					var reg = /^(-?\d+)(\.\d+)?$/;
					if (this.nA.K && !reg.test(this.nA.K)) {
						_this.toastFlag = true;
						_this.toastText = "钾离子只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.nA.NA && !reg.test(this.nA.NA)) {
						_this.toastFlag = true;
						_this.toastText = "钠离子只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.nA.ICA && !reg.test(this.nA.ICA)) {
						_this.toastFlag = true;
						_this.toastText = "钙离子只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.nA.CL && !reg.test(this.nA.CL)) {
						_this.toastFlag = true;
						_this.toastText = "氯离子只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.nA.PH && !reg.test(this.nA.PH)) {
						_this.toastFlag = true;
						_this.toastText = "酸碱度只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.nA.GLU && !reg.test(this.nA.GLU)) {
						_this.toastFlag = true;
						_this.toastText = "血糖只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.nA.LAC && !reg.test(this.nA.LAC)) {
						_this.toastFlag = true;
						_this.toastText = "血乳酸只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.nA.HB && !reg.test(this.nA.HB)) {
						_this.toastFlag = true;
						_this.toastText = "血红蛋白只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.nA.HCO3 && !reg.test(this.nA.HCO3)) {
						_this.toastFlag = true;
						_this.toastText = "碳酸氢根只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.nA.BE && !reg.test(this.nA.BE)) {
						_this.toastFlag = true;
						_this.toastText = "碱剩余只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.nA.TCO2 && !reg.test(this.nA.TCO2)) {
						_this.toastFlag = true;
						_this.toastText = "总二氧化碳只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.nA.PO2 && !reg.test(this.nA.PO2)) {
						_this.toastFlag = true;
						_this.toastText = "氧分压只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.nA.PCO2 && !reg.test(this.nA.PCO2)) {
						_this.toastFlag = true;
						_this.toastText = "二氧化碳分压只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.nA.BUN && !reg.test(this.nA.BUN)) {
						_this.toastFlag = true;
						_this.toastText = "尿素氮分压只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.nA.CREA && !reg.test(this.nA.CREA)) {
						_this.toastFlag = true;
						_this.toastText = "血清肌酐只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}

					$.ajax({
						type: "POST",
						url: baseUrl + "gunsApi/addStat",
						data: {
							userId: _this.userId,
							K: this.nA.K,
							NA: this.nA.NA,
							LAC: this.nA.LAC,
							CL: this.nA.CL,
							PH: this.nA.PH,
							GLU: this.nA.GLU,
							ICA: this.nA.ICA,
							HB: this.nA.HB,
							HCO3: this.nA.HCO3,
							BE: this.nA.BE,
							TCO2: this.nA.TCO2,
							PO2: this.nA.PO2,
							PCO2: this.nA.PCO2,
							BUN: this.nA.BUN,
							CREA: this.nA.CREA,
						},
						headers: {
							"Authorization": this.token
						},
						success: function(resp) {
							console.log(resp)
							var {
								code,
								data,
								message
							} = resp;
							// if (code === 0) {
							//     _this.autoScoreStatistics = data;
							// }
							_this.toastFlag = true;
							_this.toastText = message;
							setTimeout(function() {
								_this.toastFlag = false;
								_this.toastText = "";
							}, 3000)
						}
					});
				},
				// 保存静态数据
				saveStaticData() {
					var _this = this;
					// var reg = /^[0-9]*$/;
					var reg = /^(-?\d+)(\.\d+)?$/;
					if (this.staticIndex.indexNzx && !reg.test(this.staticIndex.indexNzx)) {
						_this.toastFlag = true;
						_this.toastText = "脑中线偏移距离只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.staticIndex.indexNzx && !reg.test(this.staticIndex.indexNzx)) {
						_this.toastFlag = true;
						_this.toastText = "脑中线偏移距离只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}
					if (this.staticIndex.indexNzx && !reg.test(this.staticIndex.indexNzx)) {
						_this.toastFlag = true;
						_this.toastText = "脑中线偏移距离只能是数字";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 3000)
						return false;
					}

					$.ajax({
						type: "POST",
						url: baseUrl + "gunsApi/addIndex",
						data: {
							hisId: _this.userId,
							indexMovement: _this.staticIndex.indexMovement,
							tongReflect: _this.staticIndex.tongReflect,
							tongChange: _this.staticIndex.tongChange,
							indexXz: _this.staticIndex.indexXz,
							indexZwm: _this.staticIndex.indexZwm,
							indexXt: _this.staticIndex.indexXt,
							indexNzx: _this.staticIndex.indexNzx,
							indexHckd: _this.staticIndex.indexHckd,
							age: _this.staticIndex.age,
							surgery: _this.staticIndex.surgery,
							medicalHistory: _this.staticIndex.medicalHistory,
						},
						headers: {
							"Authorization": this.token
						},
						success: function(resp) {
							console.log(resp)
							var {
								code,
								data,
								message
							} = resp;
							// if (code === 0) {
							//     _this.autoScoreStatistics = data;
							// }
							_this.toastFlag = true;
							_this.toastText = message;
							setTimeout(function() {
								_this.toastFlag = false;
								_this.toastText = "";
							}, 3000)
						}
					});
				},
				// 获取静态数据
				getAutoScoreStatistics() {
					var _this = this;
					$.ajax({
						type: "GET",
						url: baseUrl + "gunsApi/getRatio",
						data: {
							id: this.userId
						},
						headers: {
							"Authorization": this.token
						},
						success: function(resp) {
							console.log(resp)
							var {
								code,
								data
							} = resp;
							if (code === 0) {
								_this.autoScoreStatistics = data;
							}
						}
					});
				},
				// 即时评分
				openImmediateScore(title) {
					this.immediateScoreDialog = true;
					this.immediateScoreTile = title;
					this.$nextTick(function() {
						var immediateScore = echarts.init(document.getElementById("immediate_score"));

						var keys = [],
							values = [];
						// console.log(this.scoreStatistics.keys())
						if (this.immediateScoreStatistics && this.immediateScoreStatistics.length <= 0) {
							return false;
						}
						for (var i = 1; i < 7; i++) {
							for (var key in this.immediateScoreStatistics[i]) {
								keys.push(key);
								if (this.jiangeScore) {
									values.push(((this.immediateScoreStatistics[i][key] / this.jiangeScore) * 100).toFixed(2));
								} else {
									values.push(this.immediateScoreStatistics[i][key]);
								}
							}
						}

						option = {
							color: ['#3398DB'],
							tooltip: {
								trigger: 'axis',
								formatter: '{b}: <br/> {c}%',
								axisPointer: {
									type: 'shadow'
								}
							},
							grid: {
								left: '3%',
								right: '4%',
								bottom: '3%',
								containLabel: true
							},
							xAxis: [{
								type: 'category',
								data: keys,
								axisLabel: {
									show: true,
									rotate: 60
								},
							}],
							yAxis: [{
								type: 'value'
							}],
							series: [{
								type: 'bar',
								label: {
									show: true,
									formatter: '{c}%',
								},
								data: values,
							}]
						};

						immediateScore.setOption(option);
					})
				},
				// 自动评分（人工和自动一样）
				openAutoScore(title) {
					this.autoScoreDialog = true;
					this.autoScoreTile = title;
					this.$nextTick(function() {
						var autuScore = echarts.init(document.getElementById("auto_score"));

						var keys = [],
							values = [];
						// console.log(this.scoreStatistics.keys())
						if (this.autoScoreStatistics && this.autoScoreStatistics.length <= 0) {
							return false;
						}
						for (var i = 1; i < 7; i++) {
							for (var key in this.autoScoreStatistics[i]) {
								keys.push(key);
								if (this.dingsdianScore) {
									values.push(((this.autoScoreStatistics[i][key] / this.dingsdianScore) * 100).toFixed(2));
								} else {
									values.push(this.autoScoreStatistics[i][key]);
								}
							}
						}

						option = {
							color: ['#3398DB'],
							tooltip: {
								trigger: 'axis',
								formatter: '{b}: <br/> {c}%',
								axisPointer: {
									type: 'shadow'
								}
							},
							grid: {
								left: '3%',
								right: '4%',
								bottom: '3%',
								containLabel: true
							},
							xAxis: [{
								type: 'category',
								data: keys,
								axisLabel: {
									show: true,
									rotate: 60
								},
							}],
							yAxis: [{
								type: 'value'
							}],
							series: [{
								type: 'bar',
								// barWidth: '60%',
								label: {
									show: true,
									formatter: '{c}%',
								},
								data: values
							}]
						};

						autuScore.setOption(option);
					})
				},
				initSocket() {
					let _this = this;
					websocket = null;
					heartCheck = {
						timeout: 1000,
						timeoutObj: null,
						timing: 0, // 计时
						maxTiming: 5,
						count: 0,
						reset: function() {
							clearInterval(heartCheck.timeoutObj);
							heartCheck.start();
							heartCheck.timing = 0;
						},
						start: function() {
							heartCheck.timeoutObj = setInterval(function() {
								websocket.send('hbreqmsg');
								heartCheck.timing++;
								if (heartCheck.timing > heartCheck.maxTiming) {
									heartCheck.count++;
									if(heartCheck.count < 5){
										heartCheck.error();
									}else{
										_this.toastFlag = true;
										_this.toastText = "网络错误，请退出重新登录";
										setTimeout(function() {
											_this.toastFlag = false;
											_this.toastText = "";
										}, 5000)
										clearInterval(heartCheck.timeoutObj);
										return false;
									}
								}
								// console.log("心跳发送：hbreqmsg")
								// console.log("无响应时间:",heartCheck.timing)
							}, this.timeout);
						},
						error: function() {
							websocket.close();
							heartCheck.reset();
							clearInterval(heartCheck.timeoutObj);
							_this.loadWS();
							// websocket = new WebSocket("ws://192.168.3.171:9002?userId=ZDYY"  + _this.userId);
							console.log("服务器无应答进行重新连接")
						}
					};

					this.loadWS();

					option = {
						title: {
							text: '心电图数据',
							textStyle: {
								color: "#fff",
							},
							left: '38%'
						},
						tooltip: {
							trigger: 'axis',
							formatter: function(params) {
								params = params[0];
								var date = new Date(params.name);
								return date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear() + ' : ' + params.value[1];
							},
							axisPointer: {
								animation: false
							}
						},
						xAxis: {
							type: 'time',
							splitLine: {
								show: false,
							},
							axisLine: {
								lineStyle: {
									color: "#FFF"
								}
							},
							axisLabel: {
								show: false,
								lineStyle: {
									color: "#FFF"
								}
							},
						},
						yAxis: {
							type: 'value',
							boundaryGap: [0, '100%'],
							splitLine: {
								show: false
							},
							// max: 12000,
							// max: 7000,
							axisLine: {
								lineStyle: {
									color: "#FFF"
								}
							},
							axisLabel: {
								lineStyle: {
									color: "#FFF"
								}
							}
						},
						series: [{
							name: '模拟数据',
							type: 'line',
							showSymbol: false,
							hoverAnimation: false,
							data: data
						}]
					};
					var timedS = 1000;
					var time = setTimeout(opa, timedS);

					function opa() {

						if (staticData.length > 0) {
							for (var i = 0; i < staticData.length; i++) {
								data.shift();
								data.push(randomData(staticData[i]));
								staticData.shift()
								// for(var j=0;j<1;j++){
								//     staticData.shift()
								// }
							}
						}
						// console.log(staticData)
						// myChart.dispose()
						// myChart = echarts.init(document.getElementById('myChart'))
						// myChart.setOption({
						//     // series: [{
						//     //     data: data
						//     // }]
						//     title: {
						//         text: '心电图数据',
						//         textStyle: {
						//             color: "#fff",
						//         },
						//         left: '38%'
						//     },
						//     tooltip: {
						//         trigger: 'axis',
						//         formatter: function (params) {
						//             params = params[0];
						//             var date = new Date(params.name);
						//             return date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear() + ' : ' + params.value[1];
						//         },
						//         axisPointer: {
						//             animation: false
						//         }
						//     },
						//     xAxis: {
						//         type: 'time',
						//         splitLine: {
						//             show: false,
						//         },
						//         axisLine: {
						//             lineStyle: {
						//                 color: "#FFF"
						//             }
						//         },
						//         axisLabel: {
						//             show: false,
						//             lineStyle: {
						//                 color: "#FFF"
						//             }
						//         }
						//     },
						//     yAxis: {
						//         type: 'value',
						//         boundaryGap: [0, '100%'],
						//         splitLine: {
						//             show: false
						//         },
						//         // max: 2000,
						//         axisLine: {
						//             lineStyle: {
						//                 color: "#FFF"
						//             }
						//         },
						//         axisLabel: {
						//             lineStyle: {
						//                 color: "#FFF"
						//             }
						//         }
						//     },
						//     series: [{
						//         name: '模拟数据',
						//         type: 'line',
						//         showSymbol: false,
						//         hoverAnimation: false,
						//         data: data
						//     }]
						// }, true, true);
						myChart.setOption({
							series: [{
								data: data
							}]
						});

						clearTimeout(time); //清除上一次的定时器，否则会无限开多个
						setTimeout(opa, timedS); //方法中调用定时器实现循环
					}

					// 使用刚指定的配置项和数据显示图表。
					myChart.setOption(option);
				},
				loadWS() {
					var _this = this;
					//判断当前浏览器是否支持WebSocket
					if ('WebSocket' in window) {
						websocket = new WebSocket(wsUrl + _this.userId + "_" + generateMixed(7));
						// websocket = new WebSocket("ws://192.168.3.171:9002?userId=ZDYY" + _this.userId);
						//websocket = new WebSocket("ws://127.0.0.1:9002?userId=" + result.id);
						//websocket = new WebSocket("wss://zcpg.xazhcx.com/getStaticDatawss/?userId="+result.id);
						//websocket默认是传输字符串的，需要改为arraybuffer二进制传输类型
						//webOrTcpsocket.binaryType = "arraybuffer";
					} else {
						alert('当前浏览器 Not support websocket')
					}


					//连接发生错误的回调方法
					websocket.onerror = function() {
						setMessageInnerHTML("WebSocket连接发生错误");
						websocket.close();
						_this.toastFlag = true;
						_this.toastText = "网络错误，请退出重新登录";
						setTimeout(function() {
							_this.toastFlag = false;
							_this.toastText = "";
						}, 5000)
						// websocket = new WebSocket(wsUrl + _this.userId + "_" + generateMixed(7));
					};

					//连接成功建立的回调方法
					websocket.onopen = function() {
						setMessageInnerHTML("连接成功");
						heartCheck.start();
					};

					_this.staticData = [];

					//接收到消息的回调方法
					websocket.onmessage = function(event) {
						// console.log(event.data)
						if (event.data === 'hbreqmsg') {
							heartCheck.reset();
							return false;
						}
						// console.log(event)
						if (event && event.data !== '连接成功') {
							// if (event.data.indexOf("_d") !== -1) {
							//     var df = event.data.substring(0, event.data.indexOf("_"));
							//     // $('#df').html(df);
							//     //$('#jf').html(df);
							//     console.log(df)
							// } else if (event.data.indexOf("=") !== -1) {
							//     var df = event.data.substring(0, event.data.indexOf("="));
							//     console.log(df)
							//
							// } else if (event.data.indexOf("_z") !== -1) {
							//     var data = event.data;
							//     console.log(data)
							// }

							if (event.data.indexOf("_s") !== -1) { // 手动
								_this.jifaScore = event.data.split("_")[0];
							} else if (event.data.indexOf("_d") !== -1) { // 自动
								_this.dingsdianScore = event.data.split("_")[0];
								// _this.getAutoScoreStatistics();
							} else if (event.data.indexOf("_m") !== -1) { // 自动
								var tempStr = event.data.split("_")[0];
								var data = JSON.parse(tempStr);
								_this.autoScoreStatistics = data;
							} else if (event.data.indexOf("_j") !== -1) { // 即时
								_this.jiangeScore = event.data.split("_")[0];
							} else if (event.data.indexOf("_z") !== -1) { // 即时柱状图数据
								var tempStr = event.data.split("_")[0];
								var data = JSON.parse(tempStr);
								_this.immediateScoreStatistics = data;
								// console.log(_this.immediateScoreStatistics)
							} else if (event.data.indexOf("_x") !== -1) { // 血糖
								var tempStr = event.data.split("_")[0];
								var data = JSON.parse(tempStr);
								_this.nA = data;
							} else {
								var data = JSON.parse(event.data);
								// console.log(data)
								//console.log(data.spo2Value);
								// 血糖
								// if (data.NA !== null && data.NA !== undefined) {
								//     _this.nA = data;
								// }

								if (data.tempValue) { // 体温
									_this.tempValue = data;
									// console.log(_this.tempValue)
								}

								if (data.icpValue) { // 颅内压
									if (!_this.systValue) {
										_this.systValue = {};
									}
									_this.systValue.icpValue = data.icpValue;
									// console.log(_this.systValue)
								}

								if (data.ecg !== null || data.press !== null || data.spo2 !== null || data.stat !== null || data.gradeValue !==
									null) {
									// console.log(data);
									if (data.stat) { // 血糖
										_this.nA = data.stat;
									}

									if (data.spo2) { // 指脉氧饱和度指标
										_this.spo2Value = data.spo2;

									}

									if (data.press) {
										var press = data.press;
										var dias = press.diasValue;
										var syst = press.systValue;
										var icp = press.icpValue;
										// var avgValue = Math.round((dias - syst) / 3 + dias);
										// var ngzyValue = avgValue - icp;

										press.avgValue = press.mapValue;
										press.ngzyValue = press.ngzValue;
										_this.systValue = press;
									}


									if (data.ecg) { // 心电指标
										_this.heartValue = data.ecg;
									}

									if (data.gradeValue) { // 评分
										_this.jifaScore = data.gradeValue;
										_this.dingsdianScore = data.gradeValue;
										// _this.getAutoScoreStatistics();
									}
								}


								if (data.systValue !== null && data.systValue !== undefined) {
									// var dias = data.diasValue;
									// var syst = data.systValue;
									// var icp = data.icpValue;
									// var avgValue = Math.round((dias - syst) / 3 + dias);
									// var ngzyValue = avgValue - icp;
									data.avgValue = data.mapValue;
									data.ngzyValue = data.ngzValue;
									_this.systValue = data;
								}


								// if(!_this.systValue){
								//     _this.systValue = {};
								// }
								//
								if (data.icpValue) { // 颅内压
									_this.systValue.icpValue = data.icpValue;
								}

								if (data.mapValue) { // 平均动脉压
									_this.systValue.avgValue = data.mapValue;
								}

								if (data.ngzValue) { // 脑灌注压
									_this.systValue.ngzyValue = data.ngzValue;
								}


								if (data.diasValue) { // 舒张压
									_this.systValue.diasValue = data.diasValue;
								}

								if (data.systValue) { // 收缩压
									_this.systValue.systValue = data.systValue;
								}

								// 静态指标
								if (data.tongReflect !== null && data.tongReflect !== undefined) {
									_this.staticIndex = data;
								}
								// 心电指标
								if (data.heartValue !== null && data.heartValue !== undefined) {
									_this.heartValue = data;
								}
								// 指脉氧饱和度指标
								if (data.spo2Value !== null && data.spo2Value !== undefined) {
									_this.spo2Value = data;
								}
								// 心电图形数据
								// if (data.potlI !== null && data.potlI !== undefined) {
								//     var potlIs = data.potlI.split('^');
								//     for (var i = 0; i < potlIs.length; i++) {
								//         staticData.push(~potlIs[i]);
								//     }
								//     var potlIis = data.potlIi.split('^');
								//     for (var i = 0; i < potlIis.length; i++) {
								//         staticData.push(~potlIis[i]);
								//     }
								//     var potlIiis = data.potlIii.split('^');
								//     for (var i = 0; i < potlIiis.length; i++) {
								//         staticData.push(~potlIiis[i]);
								//     }
								//     var potlAvrs = data.potlAvr.split('^');
								//     for (var i = 0; i < potlAvrs.length; i++) {
								//         staticData.push(~potlAvrs[i]);
								//     }
								//     var potlAvls = data.potlAvl.split('^');
								//     for (var i = 0; i < potlAvls.length; i++) {
								//         staticData.push(~potlAvls[i]);
								//     }
								//     var potlAvfs = data.potlAvf.split('^');
								//     for (var i = 0; i < potlAvfs.length; i++) {
								//         staticData.push(~potlAvfs[i]);
								//     }
								//     var potlVs = data.potlV.split('^');
								//     for (var i = 0; i < potlVs.length; i++) {
								//         staticData.push(~potlVs[i]);
								//     }
								// }
								if (data.potlI !== null && data.potlI !== undefined) {
									var potlIs = data.potlI.split('^');
									for (var i = 0; i < potlIs.length; i++) {
										staticData.push(potlIs[i]);
									}
								}
								if (data.potlIi !== null && data.potlIi !== undefined) {
									var potlIis = data.potlIi.split('^');
									for (var i = 0; i < potlIis.length; i++) {
										staticData.push(potlIis[i]);
									}
								}
								if (data.potlIii !== null && data.potlIii !== undefined) {
									var potlIiis = data.potlIii.split('^');
									for (var i = 0; i < potlIiis.length; i++) {
										staticData.push(potlIiis[i]);
									}
								}
								if (data.potlAvr !== null && data.potlAvr !== undefined) {
									var potlAvrs = data.potlAvr.split('^');
									for (var i = 0; i < potlAvrs.length; i++) {
										staticData.push(potlAvrs[i]);
									}
								}
								if (data.potlAvl !== null && data.potlAvl !== undefined) {
									var potlAvls = data.potlAvl.split('^');
									for (var i = 0; i < potlAvls.length; i++) {
										staticData.push(potlAvls[i]);
									}
								}
								if (data.potlAvf !== null && data.potlAvf !== undefined) {
									var potlAvfs = data.potlAvf.split('^');
									for (var i = 0; i < potlAvfs.length; i++) {
										staticData.push(potlAvfs[i]);
									}
								}
								if (data.potlV !== null && data.potlV !== undefined) {
									var potlVs = data.potlV.split('^');
									for (var i = 0; i < potlVs.length; i++) {
										staticData.push(potlVs[i]);
									}
								}
							}
						}

					};


					//连接关闭的回调方法
					websocket.onclose = function() {
						websocket.close();
						heartCheck.reset();
						clearInterval(heartCheck.timeoutObj);
						if(heartCheck.count < 5) {
							_this.loadWS();
						}
						setMessageInnerHTML("WebSocket连接关闭");
					};

					//监听窗口关闭事件，当窗口关闭时，主动去关闭websocket连接，防止连接还没断开就关闭窗口，server端会抛异常。
					window.onbeforeunload = function() {
						websocket.close();
					};
				},
				// 获取默认数据
				getDefaultData() {
					var _this = this;
					$.ajax({
						type: "POST",
						url: baseUrl + "gunsApi/getDataOne",
						data: {
							userId: this.userId
						},
						headers: {
							"Authorization": this.token
						},
						success: function(resp) {
							console.log(resp)
							var {code,data} = resp;
							if (code === 200) {
							// 	// console.log(resp.data)
							// 	// _this.staticIndex = resp.data;
								if (data.ecg !== null || data.press !== null || data.spo2 !== null || data.stat !== null || data.gradeValue !==
										null) {
									// console.log(data);
									if (data.stat) { // 血糖
										_this.nA = data.stat;
									}

									if (data.spo2) { // 指脉氧饱和度指标
										_this.spo2Value = data.spo2;

									}

									if (data.press) {
										var press = data.press;
										var dias = press.diasValue;
										var syst = press.systValue;
										var icp = press.icpValue;
										// var avgValue = Math.round((dias - syst) / 3 + dias);
										// var ngzyValue = avgValue - icp;

										press.avgValue = press.mapValue;
										press.ngzyValue = press.ngzValue;
										_this.systValue = press;
									}


									if (data.ecg) { // 心电指标
										_this.heartValue = data.ecg;
									}

									if (data.gradeValue) { // 评分
										_this.jifaScore = data.gradeValue;
										_this.dingsdianScore = data.gradeValue;
										// _this.getAutoScoreStatistics();
									}
								}
							}
						}
					});
				},
				// 获取静态数据
				getStaticData() {
					var _this = this;
					$.ajax({
						type: "GET",
						url: baseUrl + "gunsApi/getStaticData",
						data: {
							id: this.userId
						},
						headers: {
							"Authorization": this.token
						},
						success: function(resp) {
							if (resp.data != '' && resp.data != null) {
								// console.log(resp.data)
								_this.staticIndex = resp.data;
							}
						}
					});
				},
				showAbnormalInfo(code,type){
					if(!type) return
					var  content=abnormalInfo[code].content;
					var title=abnormalInfo[code].typeName;
					layui.use('layer', function(){
						var layer = layui.layer;
							layer.open({
								title,
								type: 1,
								skin: 'layui-layer-rim', //加上边框
								area:["90%",'90%'],
								offset: '20px',
								// anim: 4 ,
								content
							});	
					}); 					
				}
			}
		});
	</script>
</html>
<style>
	.layui-layer-content{
		padding:0 20px;
		box-sizing: border-box;
		color: #333;
		font-family: 'Calibri','宋体';
	}
	.layui-layer-content h3,.layui-layer-content b{
		font-weight: 600;
		padding: 10px 0;
		font-size: 16px;
	}
	.layui-layer-title h3{
		font-weight: 600;
		font-size: 16px;
		max-width: 120%;
		overflow: hidden;	
		text-overflow: ellipsis;
		display: inline-block;	
	}
	.layui-layer-content p{
		padding-left: 35px;
		line-height: 1.8;
		font-size: 12px;
		position: relative;
		text-align: justify;
	}
	.layui-layer-content p::after{
		width: 6px;
		height: 6px;
		border-radius: 50%;
		background-color: #000;
		display: block;
		content: '';
		position: absolute;
		left: 20px;
		top: 7px;
	}	
</style>
