<template>
  <div class="patient-container">
    <patient-sidebar :id="patient_id" defaultActive="1-9"></patient-sidebar>
    <div v-loading="loading">
      <div class="patient-app-container advice-container app-container">

        <div>
                    <span style="margin-left: 10px;float:right;">
                        <el-button type="primary" icon="el-icon-circle-plus-outline" size="small"
                                   @click="show_dialog = true">新增</el-button>

                        <el-button type="primary" icon="el-icon-edit-outline" size="small"
                                   @click="showEdit">修改</el-button>
                      <el-button type="primary" icon="el-icon-printer" size="small"
                                 @click="print">打印</el-button>
                      <el-button size="small"  type="danger" @click="deleteAction">删除</el-button>
                    </span>
        </div>
        <!--<div></div>-->
        <div class="cell clearfix">
          <label class="title"><span class="name">日期查询</span> : </label>
          <el-date-picker v-model="start_time" prefix-icon="el-icon-date" :editable="false" style="width: 196px;"
                          type="date" placeholder="选择日期时间" align="right" format="yyyy-MM-dd"
                          value-format="yyyy-MM-dd" @change="startTimeChange"></el-date-picker>
          <span class="">-</span>
          <el-date-picker v-model="end_time" prefix-icon="el-icon-date" :editable="false" style="width: 196px;"
                          type="date" placeholder="选择日期时间" align="right" format="yyyy-MM-dd"
                          value-format="yyyy-MM-dd" @change="endTimeChange"></el-date-picker>
        </div>
        <div class="record">
          <el-row :gutter="15">
            <el-col :span="10">
              <el-table :header-cell-style="{
                  backgroundColor: 'rgb(245, 247, 250)',
                  color: '#606266'
                }"
                :row-style="{ color: '#303133' }" ref="inspection_table" :data="inspectionList"
                        border highlight-current-row @current-change="changeCurrentRecordTwo"
                        @selection-change="selectSummary"
                        :row-class-name="tableRow"
              >
                <el-table-column type="selection" width="60" align="center"></el-table-column>
                <el-table-column label="阶段小结名称" align="center">
                  <template slot-scope="scope">
                     {{scope.row.title}}
                  </template>
                </el-table-column>
                <el-table-column label="记录时间" align="center">
                  <template slot-scope="scope">
                     {{getTime(scope.row.record_time)}}
                  </template>
                </el-table-column>
                <el-table-column label="记录医生" align="center">
                  <template slot-scope="scope">
                     {{getDoctor(scope.row.admin_user_id)}}
                  </template>
                </el-table-column>
              </el-table>
            </el-col>
            <el-col :span="14">
              <div class="record_content_panel">
                <div style="background-color:rgb(245, 247, 250)" class="title">阶段小结内容</div>
                <div style="padding:10px;border-bottom:1px solid #DCDFE6;"><span v-if="editObj.record_time!=''">阶段小结时间:{{getTime(editObj.record_time)}}</span></div>  
                <!-- <div style="padding: 10px 10px 0;">阶段小结概要:</div>  
                <div style="padding:10px;border-bottom:1px solid #DCDFE6;">
                  <span style="margin-right:10px;line-height:30px;">干体重(kg):{{editObj.dry_weight}}</span>
                  <span style="margin-right:10px;line-height:30px;">共透析:{{editObj.dialysis_count}}次</span>
                  <span style="margin-right:10px;line-height:30px;">HD:{{editObj.hd_count}}次</span>
                  <br>
                  <span style="margin-right:10px;line-height:30px;">HDF:{{editObj.hdf_count}}次</span>
                  <span style="margin-right:10px;line-height:30px;">HP:{{editObj.hp_count}}次</span>
                  <span style="margin-right:10px;line-height:30px;">其他:{{editObj.other_count}}次</span>
                   <br>
                  <span style="margin-right:10px;line-height:30px;">透析器:{{editObj.dialzer_apparatus}}</span>
                  <span style="margin-right:10px;line-height:30px;">灌流器:{{editObj.perfusion_apparatus}}</span>
                  <span style="margin-right:10px;line-height:30px;">抗凝剂:
                    <span> {{getAnticoagulant(editObj.anticoagulant)}}</span>
                  </span>
                  <span style="margin-right:10px;line-height:30px;">透析液:(钾:{{editObj.kalium}} 钙:{{editObj.autunite}} Na:{{editObj.natrium}})</span>
                  <br>
                  <span style="margin-right:10px;line-height:30px;">每次透析:<span v-if="editObj.hour!=''"> {{editObj.hour}}小时</span>
                   <span v-if="editObj.minute!=0">{{editObj.minute}}分</span></span>
                  <span style="margin-right:10px;line-height:30px;">透前体重（kg）:{{editObj.befor_weight}}</span>
                  <span style="margin-right:10px;line-height:30px;">透后体重（kg）:{{editObj.after_weight}}</span>
                  <br>
                  <span style="margin-right:10px;line-height:30px;">透前血压（mmHg):{{editObj.befor_pressure}}</span>
                  <span style="margin-right:10px;line-height:30px;">透后血压（mmHg):{{editObj.after_pressure}}</span>
                </div> -->
                 <div style="padding:10px;border-bottom:1px solid #DCDFE6;line-height:20px;">阶段小结总结:
                   {{editObj.template_summary_content}}
                 </div>
                <div style="padding:10px;border-bottom:1px solid #DCDFE6;line-height:20px;">阶段小结化验结果:
                  <div>
                    <div v-for="item in editObj.template_inspection_content">
                    <p style="font-weight: bold;margin: 10px 0;">{{ item.project_name }} 检查日期:{{getTime(item.arr[0].inspect_date)}}</p>
                    <div style="display:flex;flex-wrap: wrap;">
                      <div v-for="it in item.arr" style="width:33%;margin-bottom:5px;">
                        {{ it.item_name }} <span v-if="it.unit!=''">[{{it.unit}}]</span>:
                         {{it.inspect_value}}
                        <span v-if="parseInt(it.inspect_value) < parseInt(it.range_min)">
                           ↓
                          </span> 
                          <span v-if="parseInt(it.inspect_value) > parseInt(it.range_max)">
                           ↑
                        </span> 
                      </div>
                    </div>
                  </div>
                  </div>
                </div>  
               
                <div style="padding:10px;line-height:20px;">阶段小结个体化透析方案:{{editObj.template_plan_content}}</div>
              </div>
            </el-col>
          </el-row>
        </div>
      </div>
     
      <el-dialog title="新增阶段小结" width="80%" top="5vh" :visible.sync="show_dialog">
        <div>
          <div class="new_record_form">
            <div class="cell clearfix">
              <el-form  :model="form" ref="form">
                <el-row :gutter="24">
                  <el-col :span="20">
                    <el-form-item label="阶段小结名称:">
                      <el-input v-model="form.title"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                 <!-- <el-row :gutter="24">
                  <el-col :span="8">
                    <el-form-item label="阶段小结时间:">
                        <el-date-picker
                            @change="changeStartYear"
                            v-model="form.start_year"
                            type="year"
                            value-format="yyyy"
                            placeholder="选择年">
                        </el-date-picker>
                    </el-form-item> 
                  </el-col>
                  <el-col :span="8">
                    <el-form-item>
                      <el-radio-group v-model="form.radio">
                        <el-radio :label="1" >月份</el-radio>
                        <el-radio :label="2" >季度</el-radio>
                     </el-radio-group>
                    </el-form-item> 
                  </el-col>
                  
                  <el-col :span="8" v-if="form.radio == 1">
                    <el-form-item>
                      <el-date-picker
                        @change="changeStartMonth"
                        value-format="MM"
                        v-model="form.start_month"
                        type="month"
                        placeholder="选择月">
                      </el-date-picker>
                    </el-form-item> 
                  </el-col>
                  <el-col :span="8" v-if="form.radio == 2">
                    <el-form-item>
                       <el-select v-model="form.quarter" placeholder="请选择" @change="changeQuarter">
                        <el-option
                          v-for="item in timeType"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id">
                        </el-option>
                      </el-select>
                    </el-form-item> 
                  </el-col> 
                 </el-row>   -->
                
              </el-form>
            </div>

            <div class="cell clearfix" style="margin-top: 10px">
              <!-- <label class="title"><span class="name">阶段小结摘要</span> : </label> -->
              <el-form>
                  <!-- <el-row :gutter="24">
                    <el-col :span="8">
                     <el-form-item label="干体重">
                      <el-input v-model="form.dry_weight"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="共透析(次)">
                      <el-input v-model="form.dialysis_count"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="HD(次)">
                      <el-input v-model="form.hd_count"></el-input>
                     </el-form-item>  
                    </el-col>
                  </el-row>
                  <el-row :gutter="24">
                    <el-col :span="8">
                     <el-form-item label="HDF(次)">
                      <el-input v-model="form.hdf_count"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="HP(次)">
                      <el-input v-model="form.hp_count"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="其他(次)">
                      <el-input v-model="form.other_count"></el-input>
                     </el-form-item>  
                    </el-col>
                  </el-row>
                   <el-row :gutter="24">
                    <el-col :span="8">
                     <el-form-item label="透析器">
                       <el-input v-model="form.dialzer_apparatus" @focus="showInnerDialog('7')"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="灌流器">
                        <el-input v-model="form.perfusion_apparatus" @focus="showInnerDialog('8')"></el-input>
                      </el-form-item>  
                    </el-col>

                    <el-col :span="8">
                     <el-form-item label="抗凝剂">
                    
                       <el-select v-model="form.anticoagulant" placeholder="请选择" style="width:100%;">
                          <el-option :key="0" label="请选择" :value="0"></el-option>
                          <el-option v-for="(item, index) in anticoagulantList" :label="item.name" :key="index + 'e'"
                           :value="item.id"></el-option>
                       </el-select>
                     </el-form-item>  
                    </el-col>
                  </el-row>
                   <div>透析液</div>
                   <el-row :gutter="24">
                    <el-col :span="8">
                     <el-form-item label="钾">
                      <el-input v-model="form.kalium"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="钙">
                      <el-input v-model="form.autunite"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="钠">
                      <el-input v-model="form.natrium"></el-input>
                     </el-form-item>  
                    </el-col>
                  </el-row>
                   <div>透析时长</div>
                   <el-row :gutter="24">
                    <el-col :span="8">
                     <el-form-item label="时">
                      <el-input v-model="form.hour"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="分">
                      <el-input v-model="form.minute"></el-input>
                     </el-form-item>  
                    </el-col>
                  </el-row>
                  <el-row :gutter="24">
                    <el-col :span="8">
                     <el-form-item label="透前体重(kg)">
                      <el-input v-model="form.befor_weight"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="透后体重(kg)">
                      <el-input v-model="form.after_weight"></el-input>
                     </el-form-item>  
                    </el-col>
                  </el-row>
                   <el-row :gutter="24">
                    <el-col :span="8">
                     <el-form-item label="透前血压(mmHg)">
                      <el-input v-model="form.befor_pressure"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="透后血压(mmHg)">
                      <el-input v-model="form.after_pressure"></el-input>
                     </el-form-item>  
                    </el-col>
                  </el-row> -->
                 
                  <el-row>
                    <label class="title"><span class="name">阶段小结总结</span> : </label>
                     <el-select v-model="form.template_summary_id" placeholder="请选择" @change="changeSummary">
                        <el-option
                        v-for="item in summaryList"
                        :key="item.value"
                        :label="item.content"
                        :value="item.value">
                        </el-option>
                     </el-select>
                     <el-input style="margin:10px 0;" type="textarea" autosize v-model="form.template_summary_content"></el-input>
                  </el-row>
                  <el-row>
                    <label class="title"><span class="name">阶段小结个体化透析方案</span> : </label>
                     <el-select v-model="form.template_plan_id" placeholder="请选择" @change="changeTempalte">
                        <el-option
                        v-for="item in planList"
                        :key="item.value"
                        :label="item.content"
                        :value="item.value">
                        </el-option>
                     </el-select>
                     <el-input style="margin:10px 0;" type="textarea"  autosize v-model="form.template_plan_content"></el-input>
                  </el-row>
                  <el-row>
                    <label class="title"><span class="name">阶段小结化验结果</span> : </label>
                    <el-button type="primary" @click="toInspection">选择检验检查</el-button>
                
                     <div class="borderBox">
                       <div v-for="item in form.template_inspection_content">
                        <p>{{ item.project_name }}</p>
                        <div style="display:flex;flex-wrap: wrap;">
                          <div v-for="it in item.arr" style="width:33%;">
                           {{ it.item_name }} <span v-if="it.unit!=''"> [{{it.unit}}] </span>:
                            {{it.inspect_value}}
                             <span v-if="parseInt(it.inspect_value) < parseInt(it.range_min)">
                             ↓
                           </span> 
                           <span v-if="parseInt(it.inspect_value) > parseInt(it.range_max)">
                            ↑
                          </span> 
                          </div>
                        </div>
                      </div>
                     </div>
                  </el-row>
                  <el-row style="margin:10px 0 0;">
                    <el-col :span="8">
                      <el-form-item label="记录医生">
                        <el-select v-model="form.admin_user_id" placeholder="请选择">
                            <el-option
                            v-for="item in docList"
                            :key="item.admin_user_id"
                            :label="item.user_name"
                            :value="item.admin_user_id">
                            </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="记录时间">
                         <el-date-picker
                            v-model="form.record_time"
                             type="datetime"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            placeholder="选择日期时间">
                        </el-date-picker>
                      </el-form-item>
                    </el-col>
                  </el-row>
              </el-form>
            </div>
            <div style="text-align: right; padding-right: 0px; padding-top: 10px; padding-bottom: 10px;">
              <el-button @click="show_dialog = false">取消</el-button>
              <el-button type="primary" @click="saveCreation()">保存
              </el-button>
            </div>
          </div>
        </div>
      </el-dialog>

      
      <!-- 编辑阶段小结 -->
       <el-dialog title="编辑阶段小结" width="80%" top="5vh" :visible.sync="edit_show_dialog">
        <div>
          <div class="new_record_form">
            <div class="cell clearfix">
              <el-form  :model="form" ref="form">
                <el-row :gutter="24">
                  <el-col :span="20">
                    <el-form-item label="阶段小结名称:">
                      <el-input v-model="form.title"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                 <!-- <el-row :gutter="24">
                  <el-col :span="8">
                    <el-form-item label="阶段小结时间:">
                        <el-date-picker
                            v-model="form.start_year"
                            type="year"
                            value-format="yyyy-MM-dd"
                            placeholder="选择年">
                        </el-date-picker>
                    </el-form-item> 
                  </el-col>
                  <el-col :span="8">
                    <el-form-item>
                      <el-radio-group v-model="form.radio">
                        <el-radio :label="1" >月份</el-radio>
                        <el-radio :label="2" >季度</el-radio>
                     </el-radio-group>
                    </el-form-item> 
                  </el-col>
                  
                  <el-col :span="8" v-if="form.radio == 1">
                    <el-form-item>
                      <el-date-picker
                        @change="changeStartMonth"
                        value-format="MM"
                        v-model="form.start_month"
                        type="month"
                        placeholder="选择月">
                      </el-date-picker>
                    </el-form-item> 
                  </el-col>
                  <el-col :span="8" v-if="form.radio == 2">
                    <el-form-item>
                       <el-select v-model="form.quarter" placeholder="请选择" @change="changeQuarter">
                        <el-option
                          v-for="item in timeType"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id">
                        </el-option>
                      </el-select>
                    </el-form-item> 
                  </el-col> 
                 </el-row>   -->
                
              </el-form>
            </div>

            <div class="cell clearfix" style="margin-top: 10px">
              <!-- <label class="title"><span class="name">阶段小结摘要</span> : </label> -->
              <el-form>
                  <!-- <el-row :gutter="24">
                    <el-col :span="8">
                     <el-form-item label="干体重">
                      <el-input v-model="form.dry_weight"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="共透析(次)">
                      <el-input v-model="form.dialysis_count"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="HD(次)">
                      <el-input v-model="form.hd_count"></el-input>
                     </el-form-item>  
                    </el-col>
                  </el-row> -->
                  <!-- <el-row :gutter="24">
                    <el-col :span="8">
                     <el-form-item label="HDF(次)">
                      <el-input v-model="form.hdf_count"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="HP(次)">
                      <el-input v-model="form.hp_count"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="其他(次)">
                      <el-input v-model="form.other_count"></el-input>
                     </el-form-item>  
                    </el-col>
                  </el-row> -->
                   <!-- <el-row :gutter="24">
                    <el-col :span="8">
                     <el-form-item label="透析器">
                       <el-input v-model="form.dialzer_apparatus" @focus="showInnerDialog('7')"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="灌流器">
                        <el-input v-model="form.perfusion_apparatus" @focus="showInnerDialog('8')"></el-input>
                      </el-form-item>  
                    </el-col>

                    <el-col :span="8">
                     <el-form-item label="抗凝剂">
                       <el-select v-model="form.anticoagulant" placeholder="请选择" style="width:100%;">
                          <el-option :key="0" label="请选择" :value="0"></el-option>
                          <el-option v-for="(item, index) in anticoagulantList" :label="item.name" :key="index + 'e'"
                           :value="item.id"></el-option>
                       </el-select>
                     </el-form-item>  
                    </el-col>
                  </el-row> -->
                   <!-- <div>透析液</div>
                   <el-row :gutter="24">
                    <el-col :span="8">
                     <el-form-item label="钾">
                      <el-input v-model="form.kalium"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="钙">
                      <el-input v-model="form.autunite"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="钠">
                      <el-input v-model="form.natrium"></el-input>
                     </el-form-item>  
                    </el-col>
                  </el-row> -->
                   <!-- <div>透析时长</div>
                   <el-row :gutter="24">
                    <el-col :span="8">
                     <el-form-item label="时">
                      <el-input v-model="form.hour"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="分">
                      <el-input v-model="form.minute"></el-input>
                     </el-form-item>  
                    </el-col>
                  </el-row> -->
                  <!-- <el-row :gutter="24">
                    <el-col :span="8">
                     <el-form-item label="透前体重(kg)">
                      <el-input v-model="form.befor_weight"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="透后体重(kg)">
                      <el-input v-model="form.after_weight"></el-input>
                     </el-form-item>  
                    </el-col>
                  </el-row> -->
                   <!-- <el-row :gutter="24">
                    <el-col :span="8">
                     <el-form-item label="透前血压(mmHg)">
                      <el-input v-model="form.befor_pressure"></el-input>
                     </el-form-item>  
                    </el-col>
                    <el-col :span="8">
                     <el-form-item label="透后血压(mmHg)">
                      <el-input v-model="form.after_pressure"></el-input>
                     </el-form-item>  
                    </el-col>
                  </el-row> -->
                 
                  <el-row>
                    <label class="title"><span class="name">阶段小结总结</span> : </label>
                     <el-select v-model="form.template_summary_id" placeholder="请选择" @change="changeSummaryOne">
                        <el-option
                        v-for="item in summaryList"
                        :key="item.value"
                        :label="item.content"
                        :value="item.value">
                        </el-option>
                     </el-select>
                     <el-input style="margin:10px 0;" type="textarea" autosize v-model="form.template_summary_content"></el-input>
                  </el-row>
                  <el-row>
                    <label class="title"><span class="name">阶段小结个体化透析方案</span> : </label>
                     <el-select v-model="form.template_plan_id" placeholder="请选择" @change="changeTempalte">
                        <el-option
                        v-for="item in planList"
                        :key="item.value"
                        :label="item.content"
                        :value="item.value">
                        </el-option>
                     </el-select>
                     <el-input style="margin:10px 0;" type="textarea" autosize v-model="form.template_plan_content"></el-input>
                  </el-row>
                  <el-row>
                    <label class="title"><span class="name">阶段小结化验结果</span> : </label>
                    <el-button type="primary" @click="toInspection">选择检验检查</el-button>
                   
                     <div class="borderBox">
                       <div v-for="item in form.template_inspection_content">
                        <p>{{ item.project_name }}</p>
                        <div style="display:flex;flex-wrap: wrap;">
                          <div v-for="it in item.arr" style="width:33%;">
                            {{ it.item_name }} <span v-if="it.unit!=''"> [{{it.unit}}] </span>:
                             {{it.inspect_value}}
                             <span v-if="parseInt(it.inspect_value) < parseInt(it.range_min)">
                            ↓
                           </span> 
                           <span v-if="parseInt(it.inspect_value) > parseInt(it.range_max)">
                             ↑
                          </span> 
                          </div>
                        </div>
                      </div>
                     </div>
                  </el-row>
                  <el-row style="margin-top:10px;">
                    <el-col :span="8">
                      <el-form-item label="记录医生">
                        <el-select v-model="form.admin_user_id" placeholder="请选择">
                            <el-option
                            v-for="item in docList"
                            :key="item.admin_user_id"
                            :label="item.user_name"
                            :value="item.admin_user_id">
                            </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="记录时间">
                         <el-date-picker
                            v-model="form.record_time"
                             type="datetime"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            placeholder="选择日期时间">
                        </el-date-picker>
                      </el-form-item>
                    </el-col>
                  </el-row>
              </el-form>
            </div>
            <div style="text-align: right; padding-right: 0px; padding-top: 10px; padding-bottom: 10px;">
              <el-button @click="edit_show_dialog = false">取消</el-button>
              <el-button type="primary" @click="editCreation()">保存
              </el-button>
            </div>
          </div>
        </div>
      </el-dialog>

       <el-dialog
        title="提示"
        :visible.sync="dialogVisibleInspection"
        width="80%"
        >
        <span>
          <el-form>
            <el-row>
              <el-form-item>
                <span>选择检验检查时间:</span>
                <div>
                  <el-form-item
                   label="时间:"
                   prop="startYear"
                   style="width:100%;"
                 >
                 <el-date-picker 
                    @change="changeYear"
                    v-model="startYear" 
                    class="timePicker" 
                    type="month" 
                    placeholder=""
                    format="yyyy-MM" 
                    value-format="yyyy-MM">
	               </el-date-picker>
                 </el-form-item>
                 <!-- <el-form-item  label="月份:"
                   prop="startYear"
                   style="width:100%;">     
                  <el-date-picker
                    v-model="startMonth"
                    type="month"
                    format="MM"
                    value-format="MM"
                    placeholder="请选择">
                  </el-date-picker>  
                 </el-form-item> -->
                </div>
              </el-form-item>
            </el-row>
            <el-row>
               <span>选择检验检查项目:</span>
                 <div class="record">
                  <el-row :gutter="15">
                    <el-col :span="10">
                      <el-table :header-cell-style="{
                          backgroundColor: 'rgb(245, 247, 250)',
                          color: '#606266'
                        }"
                        :row-style="{ color: '#303133' }"
                        ref="single_table"
                        :data="tableList"
                        border highlight-current-row 
                        @current-change="changeCurrentRecord"
                        @selection-change="selectionChangeOne"
                        :row-class-name="tableRow"
                        @row-click="onRowClick"
                      
                      >
                        <el-table-column type="selection" width="60" align="center"></el-table-column>
                        <el-table-column label="检验项目" align="center">
                          <template slot-scope="scope">
                            {{scope.row.project_name}}
                          </template>
                        </el-table-column>
                      </el-table>
                    </el-col>
                    <el-col :span="14">
                      <div class="record_content_panel">
                        <el-table :header-cell-style="{
                          backgroundColor: 'rgb(245, 247, 250)',
                          color: '#606266'
                        }"
                        :row-style="{ color: '#303133' }" :data="tableData"
                                border highlight-current-row @current-change="didChangeCurrentRecord"
                                @selection-change="selectionChange"
                                :row-class-name="tableRow"
                                
                      >
                        <el-table-column label="检验项目" align="center">
                          <template slot-scope="scope">
                            {{scope.row.item_name}}
                          </template>
                        </el-table-column>
                        <el-table-column label="结果" align="center">
                          <template slot-scope="scope">
                            {{scope.row.inspect_value}}
                           <span v-if="parseInt(scope.row.inspect_value) < parseInt(scope.row.range_min)">
                            ↓
                          </span> 
                           <span v-if="parseInt(scope.row.inspect_value) > parseInt(scope.row.range_max)">
                             ↑
                          </span> 
                          </template>
                        </el-table-column>
                        <el-table-column label="参考值" align="center">
                          <template slot-scope="scope">
                           {{scope.row.range_min}} ~  {{scope.row.range_max}}
                          </template>
                        </el-table-column>
                        <el-table-column label="单位" align="center">
                          <template slot-scope="scope">
                            {{scope.row.unit}}
                          </template>
                        </el-table-column>
                      </el-table>
                      </div>
                    </el-col>
                  </el-row>
                </div>
            </el-row>
          </el-form>

        </span>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisibleInspection = false">取 消</el-button>
          <el-button type="primary" @click="toContent">确 定</el-button>
        </span>
      </el-dialog>
      
       
  

      <multi-select-box
        :propsForm="InnerDialogProps"
        v-on:dialog-comfirm="innerDialogComfirm"
        v-on:dialog-cancle="innerDialogCancle"
      ></multi-select-box>

    </div>
  </div>

  <!-- </div> -->
</template>

<script>
  import PatientSidebar from './components/PatientSidebar'
  import Editor from '@/components/Editor'
 
  import { getInitDataList,getInspectionMajorItem,getInspectionDetail,getInspectionItemList,saveCreation,getTemplateSummaryList,getTemplateSummaryDetail,UpdateTemplateSummary,deleteSummary } from '@/api/patient'
  import { parseTime } from '@/utils'
  import BreadCrumb from '@/xt_pages/components/bread-crumb'
  import { uParseTime } from '@/utils/tools'
  import { getDataConfig } from '@/utils/data'
  import multiSelectBox from '../dialysis/details/dialog/MultiSelectBox'
 import MsgTip from '../dialysis/details/dialog/MsgTip'
 
  const moment = require('moment')
  export default {
    name: 'templateSummary',
    components: {
      PatientSidebar,
      BreadCrumb,
      Editor,
      MsgTip,
      multiSelectBox,
    },
    data() {
      return {
        InnerDialogProps: {
          values: [],
          visibility: false,
          isShowTextArea: true,
          customContent: '',
          titles: '',
          type: '' // 不同弹框类型，用来匹配数据
        },
        loading: false,
        title: '',
        patient_id: 0,
        date: [],
        start_time: '',
        end_time: '',
        course_of_disease_time: '',
        records: [],
        doctors: [],
        current_select_record: null,
        show_dialog: false,
        show_edit_dialog: false,
        uploading_new_record: false,
        templates: this.$store.getters.configlist.course_disease,
        select_template: '',
        new_content: '',
        edit_new_content: '',
        edit_course_of_disease_time: '',
        selectingRows: [],
        table_current_index: -1,
        edit_current_id: 0,
        edit_title: '',
        value:'',
        form:{
          id:0,
          title:"",
          start_year:new Date(),
          start_month:new Date(),
          radio:1,
          quarter:1,
          dry_weight:"",
          dialysis_count:"",
          hd_count:"",
          hdf_count:"",
          hp_count:"",
          other_count:"",
          dialzer_apparatus:"",
          perfusion_apparatus:"",
          anticoagulant:"",
          kalium:"",
          autunite:"",
          natrium:"",
          hour:"",
          minute:"",
          befor_weight:"",
          after_weight:"",
          befor_pressure:"",
          after_pressure:"",
          template_summary_id:"",
          template_summary_content:"",
          template_plan_id:"",
          template_summary_content:"",
          template_inspection_id:0,
          template_inspection_content:"",
          admin_user_id:this.$store.getters.xt_user.user.id,
          record_time: moment().locale('zh-cn').format('YYYY-MM-DD HH:mm:ss'),
          patient_id:"",
          start_time:"",
          end_time:"",
          template_plan_content:"",
        },
        timeType:[
          {id:1,name:"第一季度"},
          {id:2,name:"第二季度"},
          {id:3,name:"第三季度"},
          {id:4,name:"第四季度"},
        ],
        monthType:[
          {id:1,name:"一月"},
          {id:2,name:"二月"},
          {id:3,name:"三月"},
          {id:4,name:"四月"},
          {id:5,name:"五月"},
          {id:6,name:"六月"},
          {id:7,name:"七月"},
          {id:8,name:"八月"},
          {id:9,name:"九月"},
          {id:10,name:"十月"},
          {id:11,name:"十一月"},
          {id:12,name:"十二月"},
        ],
        options:[],
        dialogVisibleInspection:false,
        editDialogVisible:false,
        edit_show_dialog:false,
        InspectionMajor:[],
        other_start_time:"",
        startYear:moment(new Date()).endOf('month').subtract('month', +1).endOf('month').format("YYYY-MM-DD") ,
        // startMonth:(new Date().getMonth - 1).toString(),
        tableList:[],
        tableData:[],
        inspectDataList:[],
        projectList:[],
        docList:[],
        inspectionList:[],
        editObj:{},
        anticoagulantList:[],
        dialyzerPerfusionApparatus:[],
        irrigations:[],
        dialyzerList:[],
        irrigationList:[],
        stockType:[],
        summaryList:[],
        planList:[],
        projectStr:"",
        projectIndate:"",
        start_year:"2021",
        start_month:"",
        start_date: moment(new Date()).startOf("month").format("YYYY-MM-DD"),
        end_date: moment(new Date()).endOf('month').format("YYYY-MM-DD"),
        ids:"",
        lastYear:new moment().subtract(1,'months').date(1).format("YYYY-MM-DD"),
      }
    },
    created() {
      console.log("this.$store.getters.xt_user.user.id",this.$store.getters.xt_user.user.id)
      this.patient_id = this.$route.params && this.$route.params.id
      var now = new Date()
      this.date = [now.getTime() - (7 * 24 * 60 * 60 * 1000), now.getTime()]

      var nowDate = new Date()
      var nowYear = nowDate.getFullYear()
      var nowMonth = nowDate.getMonth() + 1
      
      var nowDay = nowDate.getDate()
      this.end_time =
        nowYear +
        '-' +
        (nowMonth < 10 ? '0' + nowMonth : nowMonth) +
        '-' +
        (nowDay < 10 ? '0' + nowDay : nowDay)
      nowDate.setMonth(nowDate.getMonth() - 1)
      nowYear = nowDate.getFullYear()
      nowMonth = nowDate.getMonth() + 1
      nowDay = nowDate.getDate()
      this.start_time =
        nowYear +
        '-' +
        (nowMonth < 10 ? '0' + nowMonth : nowMonth) +
        '-' +
        (nowDay < 10 ? '0' + nowDay : nowDay)
      this.other_start_time = nowYear +'-' +(nowMonth < 10 ? '0' + nowMonth : nowMonth) +'-' + (nowDay < 10 ? '0' + nowDay : nowDay)
      var anticoagulantsConfitOne = this.$store.getters.anticoagulants_confit
       const arrFour = []
        Object.keys(anticoagulantsConfitOne).map((item, index) => {
          if (index != 2) {
            arrFour.push(anticoagulantsConfitOne[item])
          }
        })

      this.anticoagulantList = arrFour
      console.log("抗凝剂量",this.anticoagulantList)
      var endtime= moment(new Date()).endOf('month').subtract('month', +1).endOf('month').format("YYYY-MM-DD") 
      console.log("endtime",endtime)
      this.getlist()
      this.getInspectionMajor()
      this.getTemplateSummaryList()
     
    },
    methods: {
      getTime(val) {
         if(val == ""){
          return ""
         }else {
          return uParseTime(val, '{y}-{m}-{d}')
         }
      },
      getTimeTwo(val) {
         if(val == ""){
          return ""
         }else {
          return uParseTime(val, '{y}-{m}-{d} {h}:{i}:{s}')
         }
      },
      getTimeOne(val) {
         if(val < 0){
           return ""
         }
         if(val == ""){
          return ""
         }else {
          return uParseTime(val, '{m}')
         }
      },
      showEdit(){
       
        this.getCurrentRecordDetailOne()
      },
      onRowClick(){

      },
      didChangeCurrentRecord(){

      },
      changeCurrentRecord(val){
       
        this.getInspectionDetai(val)
      },
      selectionChangeOne(val){
        // console.log("hhhhhhhhh",val)
        this.getInspectionItemList(val)
      },
      startTimeChange(val){
       console.log("val",val)
       this.start_time = val
       this.getTemplateSummaryList()
      },
      endTimeChange(val){
       this.end_time = val
       this.getTemplateSummaryList()
      },
      print(){
        this.$router.push({path:"/patient/patient/templateSummary/print?id="+this.form.id})
      },
      tableRow(){

      },
      getQuarter(year,quarter){
        var start_time = ""
        if(quarter == 1){
           
        }
      },
      didSelectionChange(){

      },
      changeCurrentRecordTwo(val){
        console.log("val232232",val.id)
        this.form.id = val.id
        this.getCurrentRecordDetail(val.id)
      },
      changeCurrentRecordOne(){

      },
      getlist(){
        var params={
          start_year:this.getTime(this.form.start_year),
          start_month:this.getTime(this.form.start_month),
          quarter:this.form.quarter,
          patient_id:this.patient_id,
          start_time:this.start_date,
          end_time:this.end_date,
        }
        console.log("世纪时间",params)
        console.log(moment(moment(2020 + '-01-01').toDate()).quarter(2).format("YYYY-MM-DD"))
        getInitDataList(params).then(response=>{
          if(response.data.state == 1){
             var prescription_list =  response.data.data.prescription_list
             this.form.dialzer_apparatus = prescription_list.dialysis_dialyszers
             this.form.perfusion_apparatus = prescription_list.dialysis_irrigation
             this.form.anticoagulant = prescription_list.anticoagulant
             this.form.hour = prescription_list.dialysis_duration_hour
             this.form.minute = prescription_list.dialysis_duration_minute
             this.form.kalium = prescription_list.kalium
             this.form.natrium = prescription_list.sodium
             this.form.autunite = prescription_list.calcium
             var beforlist = response.data.data.beforlist
             console.log("透前数据565665565656",beforlist)
             this.form.befor_weight = beforlist.weight_before
             this.form.dry_weight = beforlist.dry_weight
             var afterlist =  response.data.data.after_list
             console.log("透后数据232332323232",afterlist)
             this.form.after_weight = afterlist.weight_after
             this.form.after_pressure = afterlist.systolic_blood_pressure + "/"+afterlist.diastolic_blood_pressure
             this.form.befor_pressure = beforlist.systolic_blood_pressure +"/"+beforlist.diastolic_blood_pressure
             var modelist = response.data.data.modelist
             console.log("modelist",modelist)
             var docList = response.data.data.docList
            //  console.log("doctlist",docList)
             this.docList = docList
             var stockType = response.data.data.stockType
             var arr = []
            var arrTwo = []
            for(let i=0;i<stockType.length;i++){
              if(stockType[i].stock_attribute == 2){
                  arr.push(stockType[i])
              }
              if(stockType[i].stock_attribute == 3){
                  arrTwo.push(stockType[i])
              }
            }
            var dialyzator = []
            var irrigation = []
            for(let i=0;i<arr.length;i++){
              for(let j=0;j<arr[i].GoodInfo.length;j++){
                  dialyzator.push(arr[i].GoodInfo[j])
              }
            }
            this.dialyzerList = dialyzator
            // console.log("arrtt2323232332232323",arrTwo)
            for(let i=0;i<arrTwo.length;i++){
              for(let j=0;j<arrTwo[i].GoodInfo.length;j++){
                  irrigation.push(arrTwo[i].GoodInfo[j])
              }
            }
            this.irrigationList = irrigation
            // console.log("透析器233223",this.dialyzerList)
            // console.log("灌流器323323223",this.irrigationList)
             var count = ""
             var total_count = 0
             for(let i=0;i<modelist.length;i++){
               total_count += modelist[i].count
              if(modelist[i].mode_id == 1){
                 this.form.hd_count = modelist[i].count
              }
              if(modelist[i].mode_id == 2){
                this.form.hdf_count =  modelist[i].count
              }
              if(modelist[i].mode_id == 4){
                this.form.hp_count = modelist[i].count
              }

              if(modelist[i].mode_id!=1&&modelist[i].mode_id!=2 && modelist[i].mode_id!=4){
                  count += modelist[i].count
              }

             }
             this.form.other_count = count
             
             this.form.dialysis_count = total_count
            //  console.log("modelist",modelist)
             var summaryList = response.data.data.summaryList
            //  console.log("summaryList",summaryList)
             this.summaryList = summaryList
             var planList = response.data.data.planList
            //  console.log("planlist",planList)
             this.planList = planList
          }
       })
      },
      toInspection(){
        
        this.dialogVisibleInspection = true
      },

      //获取大项数据来源
      getInspectionMajor(){
          console.log("start_year",this.startYear)
          var params = {
            other_start_time:this.startYear,
            patient_id:this.patient_id,
            last_time:this.lastYear,
          }
         console.log("开始数据",params)
        getInspectionMajorItem(params).then(response=>{
          if(response.data.state == 1){
            var list = response.data.data.list
            console.log("列表23232232323",list)
            // this.$refs.single_table.setCurrentRow(list[0])
            this.tableList = list
           
          }
        })
      },
      //获取小项的值
      getInspectionDetai(val){
        var params = {
          project_id:val.project_id,
          patient_id:val.patient_id,
          inspect_date:val.inspect_date,
        }
        // console.log("param2233233223",params)
       getInspectionDetail(params).then(response=>{
          if(response.data.state ==1){
            var list = response.data.data.list
            // console.log("详情222",list)
           
            this.tableData = list
          }
       })
      },
      selectionChange(val){
        // console.log("val233223",val)
        selectionChange().then(response=>{

        })
      },
      getInspectionItemList(val){
        this.projectList = []
        this.inspectDataList = []
       for(let i=0;i<val.length;i++){
        this.projectList.push(val[i].project_id)
        this.inspectDataList.push(val[i].inspect_date)
      }
    
      },
      toContent(){
      
         var str = this.projectList.join(",")
         this.projectStr = str
         var inspe_date = this.inspectDataList.join(",")
         this.projectIndate = inspe_date
         var params = {
           ids:str,
           inspect_date:inspe_date,
           patient_id:this.patient_id,
         }
        //  console.log("params",params)
        getInspectionItemList(params).then(response=>{
           if(response.data.state == 1){
             var list = response.data.data.list
            let arr = this.unique(list,'project_name')
            // console.log("选择检验检查",arr)
           
            this.form.template_inspection_content = arr
            this.dialogVisibleInspection = false
           
           }
        })  
      },
      saveCreation(){
   
        if (this.form.dry_weight == ""){
          this.form.dry_weight = 0
        }
        if (this.form.dialysis_count == ""){
          this.form.dialysis_count = 0
        }
        if (this.form.hd_count == ""){
          this.form.hd_count = 0
        }
        if (this.form.hdf_count == ""){
          this.form.hdf_count = 0
        }
       if (this.form.hp_count == ""){
          this.form.hp_count = 0
        }
        if (this.form.other_count == ""){
          this.form.other_count = 0
        }
        if (this.form.kalium == ""){
          this.form.kalium = 0
        }
        if (this.form.autunite == ""){
          this.form.autunite = 0
        }
       if (this.form.natrium == ""){
          this.form.natrium = 0
        }
        if (this.form.hour == ""){
          this.form.hour = 0
        }
        if (this.form.minute == ""){
          this.form.minute = 0
        }
        if(this.form.befor_weight == ""){
          this.form.befor_weight = 0
        }
        if(this.form.after_weight == ""){
          this.form.after_weight = 0
        }
        if(this.form.befor_pressure == ""){
          this.form.befor_pressure = 0
        }
        var year = this.form.start_year+"-"+"01"+"-"+"01"
        console.log("年",year)
        var month = this.form.start_year+"-"+this.form.start_month+"-"+"01"
        console.log("月",month)
         var params = {
            title:this.form.title,
            dry_weight:this.form.dry_weight.toString(),
            dialysis_count:parseInt(this.form.dialysis_count),
            hd_count:parseInt(this.form.hd_count),
            hdf_count:parseInt(this.form.hdf_count),
            hp_count:parseInt(this.form.hp_count),
            other_count:parseInt(this.form.other_count),
            dialzer_apparatus:this.form.dialzer_apparatus,
            perfusion_apparatus:this.form.perfusion_apparatus,
            anticoagulant:this.form.anticoagulant,
            kalium:this.form.kalium.toString(),
            autunite:this.form.autunite.toString(),
            natrium:this.form.natrium.toString(),
            hour:parseInt(this.form.hour),
            minute:parseInt(this.form.minute),
            befor_weight:this.form.befor_weight.toString(),
            after_weight:this.form.after_weight.toString(),
            befor_pressure:this.form.befor_pressure,
            template_summary_content:this.form.template_summary_content,
            template_plan_content:this.form.template_plan_content,
            // template_inspection_content:JSON.stringify(this.form.template_inspection_content),
            admin_user_id:this.form.admin_user_id,
            record_time:this.form.record_time,
            after_pressure:this.form.after_pressure,
            template_summary_id:this.form.template_summary_id,
            template_summary_content:this.form.template_summary_content,
            template_plan_id:this.form.template_plan_id,
            template_inspection_id:this.form.template_inspection_id,
            patient_id:parseInt(this.patient_id),
            project_id:this.projectStr,
            inspect_date:this.projectIndate,
            start_year:year,
            start_month:month,
            radio:this.form.radio,
         }
          console.log("parawm232323223",params)
    
        saveCreation(params).then(response=>{
           if(response.data.state ==1){
             var summary =  response.data.data.summary
            //  console.log("summary",summary)
             this.getTemplateSummaryList()
             this.$message.success("保存成功!");
             this.show_dialog = false
             this.form.title = ""
             this.form.dry_weight = ""
             this.form.dialysis_count =""
             this.form.hd_count= ""
             this.form.hdf_count = ""
             this.form.hp_count = ""
             this.form.other_count =""
             this.form.dialzer_apparatus = ""
             this.form.perfusion_apparatus = ""
             this.form.anticoagulant  = ""
             this.form.kalium = ""
             this.form.autunite = ""
             this.form.natrium = ""
             this.form.hour =""
             this.form.minute = ""
             this.form.befor_weight = ""
             this.form.after_weight = ""
             this.form.befor_pressure = ""
             this.form.template_summary_content = ""
             this.form.template_plan_content = ""
             this.form.template_inspection_content = ""
             this.from.after_pressure = ""
             this.form.template_summary_id = ""
             this.form.template_plan_id = ""
             this.form.template_inspection_id = ""
           }
        })
      },
      getTemplateSummaryList(){
          var params = {
            patient_id:this.patient_id,
            start_time:this.start_time,
            end_time:this.end_time,
          }
        console.log("param2222",params)
        getTemplateSummaryList(params).then(response=>{
           if(response.data.state ==1){
              var list = response.data.data.list
              this.inspectionList = list
              this.$refs.inspection_table.setCurrentRow(this.inspectionList[0])
              this.getCurrentRecordDetail(this.inspectionList[0].id)
           }
        })
      },
      getCurrentRecordDetail(id){
          var params = {
            id:id
          }
         getTemplateSummaryDetail(params).then(response=>{
           if(response.data.state == 1){
              var list = response.data.data.list
              var inspectlist = response.data.data.inspectlist
              console.log("inspectlist2322332",list)
              let arr = this.unique(inspectlist,'project_name')
              console.log("hhh23h2323223223232323",arr)
              list.template_inspection_content = arr
              this.editObj = list

           }
        })
      },
      getTime(val) {
         if(val < 0){
           return ""
         }
         if(val == ""){
          return ""
         }else {
          return uParseTime(val, '{y}-{m}-{d}')
         }
      },
      showInnerDialog: function(val) {
        this.InnerDialogProps.visibility = true
        switch (val) {
           case '7': // 透析器

            for(let i=0;i<this.dialyzerList.length;i++){
               this.dialyzerList[i].name = this.dialyzerList[i].specification_name
            }
            this.InnerDialogProps.values = this.dialyzerList
            this.InnerDialogProps.titles = '透析器'
            this.InnerDialogProps.type = 'dialyzers'
            this.InnerDialogProps.selected = this.form.dialzer_apparatus
            this.InnerDialogProps.isShowTextArea = false
            break
           case '8':
           for(let i=0;i<this.irrigationList.length;i++){
             this.irrigationList[i].name = this.irrigationList[i].specification_name
           }
            this.InnerDialogProps.values = this.irrigationList
            this.InnerDialogProps.titles = '灌流器'
            this.InnerDialogProps.type = 'irrigations'
            this.InnerDialogProps.selected = this.form.perfusion_apparatus
            this.InnerDialogProps.isShowTextArea = false
            break
        }
      },
      innerDialogComfirm: function(val) {
        this.InnerDialogProps.visibility = false
        switch (val.type) {
          case 'dialyzers':
           this.form.dialzer_apparatus = val.value.join(',')
          break
          case 'irrigations':
           this.form.perfusion_apparatus = val.value.join(',')
          break
        }
      },
      innerDialogCancle: function() {
        this.InnerDialogProps.visibility = false
      },
      getCurrentRecordDetailOne(){
         var params = {
            id:this.form.id
          }
         getTemplateSummaryDetail(params).then(response=>{
           if(response.data.state == 1){
              var list = response.data.data.list
              var inspectlist =  response.data.data.inspectlist
              console.log("详情232332233223232323",list)
              let arr = this.unique(inspectlist,'project_name')
              this.form.template_inspection_content = arr
              this.edit_show_dialog = true
              this.form.title = list.title
              this.form.id = list.id
              this.form.admin_user_id = list.admin_user_id
              this.form.after_pressure = list.after_pressure
              this.form.after_weight = list.after_weight
              this.form.anticoagulant = list.anticoagulant
              this.form.autunite = list.autunite
              this.form.befor_pressure = list.befor_pressure
              if( list.befor_weight == 0){
                 this.form.befor_weight = ""
              }else{
                this.form.befor_weight = list.befor_weight
              }
              if(list.dialysis_count == 0){
                 this.form.dialysis_count = ""
              }else{
                this.form.dialysis_count = list.dialysis_count
              }
             
              this.form.dialzer_apparatus = list.dialzer_apparatus
              this.form.dry_weight = list.dry_weight
               this.form.hd_count= list.hd_count
               this.form.hdf_count= list.hdf_count
               this.form.hour = list.hour
               this.form.hp_count = list.hp_count
               this.form.kalium= list.kalium
               this.form.minute = list.minute
               this.form.natrium =list.natrium
               this.form.perfusion_apparatus= list.perfusion_apparatus
               this.form.record_time = this.getTimeTwo(list.record_time)
               console.log("时间232233232",list.record_time)
               if(list.template_inspection_id == 0){
                  list.template_inspection_id = ""
               }else{
                 this.form.template_inspection_id = list.template_inspection_id
               }
              
               this.form.template_plan_content = list.template_plan_content
               if(list.template_plan_id == 0){
                 this.form.template_plan_id  = ""
               }else{
                 this.form.template_plan_id = list.template_plan_id
               }
             
               console.log("hhhhhhhhh",list.template_plan_id)
               this.form.template_summary_content =list.template_summary_content
               if(list.template_summary_id == 0){
                 this.form.template_summary_id = ""
               }else{
                 this.form.template_summary_id = list.template_summary_id
               }
              
               this.projectIndate = list.inspect_date
               this.projectStr = list.project_id
           }
        })  
      },
      changeSummary(){
       for(let i=0;i<this.summaryList.length;i++){
         if(this.form.template_summary_id == this.summaryList[i].value){
            this.form.template_summary_content = this.summaryList[i].content
         }
       }
      },
      changeSummaryOne(){
       for(let i=0;i<this.summaryList.length;i++){
         if(this.form.template_summary_id == this.summaryList[i].value){
            this.form.template_summary_content = this.summaryList[i].content
         }
       }
      },
      changeTempalte(){
       for(let i=0;i<this.planList.length;i++){
         if(this.form.template_plan_id == this.planList[i].value){
           this.form.template_plan_content = this.planList[i].content
         }
       }
      },
      editCreation(){
        var params = {
            id:this.form.id,
            title:this.form.title,
            dry_weight:this.form.dry_weight.toString(),
            dialysis_count:parseInt(this.form.dialysis_count),
            hd_count:parseInt(this.form.hd_count),
            hdf_count:parseInt(this.form.hdf_count),
            hp_count:parseInt(this.form.hp_count),
            other_count:parseInt(this.form.other_count),
            dialzer_apparatus:this.form.dialzer_apparatus,
            perfusion_apparatus:this.form.perfusion_apparatus,
            anticoagulant:this.form.anticoagulant,
            kalium:this.form.kalium.toString(),
            autunite:this.form.autunite.toString(),
            natrium:this.form.natrium.toString(),
            hour:parseInt(this.form.hour),
            minute:parseInt(this.form.minute),
            befor_weight:this.form.befor_weight.toString(),
            after_weight:this.form.after_weight.toString(),
            befor_pressure:this.form.befor_pressure,
            template_summary_content:this.form.template_summary_content,
            template_plan_content:this.form.template_plan_content,
            admin_user_id:this.form.admin_user_id,
            record_time:this.form.record_time,
            after_pressure:this.form.after_pressure,
            template_summary_id:this.form.template_summary_id,
            template_plan_id:this.form.template_plan_id,
            template_inspection_id:this.form.template_inspection_id,
            patient_id:parseInt(this.patient_id),
            project_id:this.projectStr,
            inspect_date:this.projectIndate,
         }
         console.log("parawm232323223",params)
        
        UpdateTemplateSummary(params).then(response=>{
          if(response.data.state == 1){
            var list = response.data.data.list
            this.$message.success("保存成功")
            this.edit_show_dialog = false
            this.getTemplateSummaryList()
          }
        })
      },
      unique(data, key) {
        let lastData = [];
        data.forEach(item => {
          let status = lastData.some(project_name => project_name[key] == item[key]);
          if (!status) {
            let obj = {
              project_name:'',
              arr:[]
            }
            obj.project_name = item.project_name
            obj.arr.push(item);
            lastData.push(obj);
          } else {
            lastData.forEach((project_name, index) => {
              if (project_name[key] === item[key]) {
                project_name.arr.push(item);
              }
            });
          }
        });
        return lastData;
      },
      getDoctor(id){
        var user_name = ""
        for(let i=0;i<this.docList.length;i++){
          if(id == this.docList[i].admin_user_id){
             user_name = this.docList[i].user_name
          }
        }
        return user_name
      },
      changeStartYear(){
        this.form.title = ""
        this.form.dry_weight = ""
        this.form.dialysis_count =""
        this.form.hd_count= ""
        this.form.hdf_count = ""
        this.form.hp_count = ""
        this.form.other_count =""
        this.form.dialzer_apparatus = ""
        this.form.perfusion_apparatus = ""
        this.form.anticoagulant  = ""
        this.form.kalium = ""
        this.form.autunite = ""
        this.form.natrium = ""
        this.form.hour =""
        this.form.minute = ""
        this.form.befor_weight = ""
        this.form.after_weight = ""
        this.form.befor_pressure = ""
        this.form.template_summary_content = ""
        this.form.template_plan_content = ""
        this.form.template_inspection_content = ""
        this.from.after_pressure = ""
        this.form.template_summary_id = ""
        this.form.template_plan_id = ""
        this.form.template_inspection_id = ""
        this.start_year = this.form.start_year
        console.log("年份",this.form.start_year)
        console.log("月份",this.getTimeOne(this.form.start_month))
        var start = this.form.start_year + "-" + this.getTimeOne(this.form.start_month) + "-"+"01"
        var end = this.form.start_year + "-" + this.getTimeOne(this.form.start_month) + "-"+"30"
        this.start_date = start
        this.end_date = end
        this.getlist()
      },
      changeStartMonth(){
        this.form.title = ""
        this.form.dry_weight = ""
        this.form.dialysis_count =""
        this.form.hd_count= ""
        this.form.hdf_count = ""
        this.form.hp_count = ""
        this.form.other_count =""
        this.form.dialzer_apparatus = ""
        this.form.perfusion_apparatus = ""
        this.form.anticoagulant  = ""
        this.form.kalium = ""
        this.form.autunite = ""
        this.form.natrium = ""
        this.form.hour =""
        this.form.minute = ""
        this.form.befor_weight = ""
        this.form.after_weight = ""
        this.form.befor_pressure = ""
        this.form.template_summary_content = ""
        this.form.template_plan_content = ""
        this.form.template_inspection_content = ""
        this.form.after_pressure = ""
        this.form.template_summary_id = ""
        this.form.template_plan_id = ""
        this.form.template_inspection_id = ""
        console.log("sart",this.form.start_month)
        var end = ""
        if(this.form.start_month == "02"){
          end = this.start_year +"-"+ this.form.start_month + "-"+"28"
        }else{
          end = this.start_year +"-"+ this.form.start_month + "-"+"30"
        }
        var start = this.start_year +"-"+ this.form.start_month+"-"+"01"
       
        this.start_date  = start
        this.end_date = end 
        console.log("开始时间",this.start_date)
        console.log("结束时间",this.end_date)
        this.getlist()
       
      },
      changeQuarter(val){
        this.form.title = ""
        this.form.dry_weight = ""
        this.form.dialysis_count =""
        this.form.hd_count= ""
        this.form.hdf_count = ""
        this.form.hp_count = ""
        this.form.other_count =""
        this.form.dialzer_apparatus = ""
        this.form.perfusion_apparatus = ""
        this.form.anticoagulant  = ""
        this.form.kalium = ""
        this.form.autunite = ""
        this.form.natrium = ""
        this.form.hour =""
        this.form.minute = ""
        this.form.befor_weight = ""
        this.form.after_weight = ""
        this.form.befor_pressure = ""
        this.form.template_summary_content = ""
        this.form.template_plan_content = ""
        this.form.template_inspection_content = ""
       
        this.form.after_pressure = ""
        this.form.template_summary_id = ""
        this.form.template_plan_id = ""
        this.form.template_inspection_id = ""
        if(val == 1){
          this.start_date = this.start_year+"-"+"01"+"-"+"01"
          this.end_date = this.start_year +"-"+"03"+"-"+"31"
        }
        if(val == 2){
          this.start_date = this.start_year +"-"+ "04"+"-"+"01"
          this.end_date = this.start_year +"-"+ "06"+"-"+"30"
        }
        if(val == 3){
          this.start_date = this.start_year +"-"+ "07"+"-"+"01"
          this.end_date = this.start_year +"-"+ "09"+"-"+"30"
        }
        if(val == 4){
          this.start_date = this.start_year +"-"+ "09"+"-"+"01"
          this.end_date = this.start_year +"-"+ "12"+"-"+"31"
        }
        this.getlist()
      },
      getAnticoagulant(id){
        
        var name = ""
        for(let i=0;i<this.anticoagulantList.length;i++){
          if(id == this.anticoagulantList[i].id){
              name = this.anticoagulantList[i].name
          }
        }
        return name
      },
      changeYear(val){
        console.log("val2323323223",val)
        if(val == "2021-02"){
          this.startYear = val+"-" + "28"
        }else{
          this.startYear = val+"-" + "30"
        }
       
        this.lastYear = val+"-"+"01"
        this.getInspectionMajor()
      },
      selectSummary(val){
        console.log("val23232",val)
        var arr = []
        for( let i=0;i<val.length;i++){
           arr.push(val[i].id)
        }
     
        var str = arr.join(",")
       console.log("str",str)
       this.ids = str
      },
     deleteAction(){
       if(this.ids == ""){
         this.$message.error("请勾选需要删除的数据")
         return
       } 
       this.$confirm('确认删除这条记录?', '删除记录', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
           let params = {
              ids: this.ids,
            }
            console.log("params2323",params)
            
            deleteSummary(params).then(response => {
              if (response.data.state == 0) {
                this.$message.error(response.data.msg)
                return false
              } else {
                var msg =response.data.data.msg
                this.getTemplateSummaryList()
                
              }
            })
          })
          .catch(() => {
          })
     }

    },
  //  watch: {
  //   inspectionList: function() {
  //     this.$nextTick(function() {
  //       this.$refs.inspection_table.setCurrentRow(this.inspectionList[0])
  //     })
  //   },
   
  //  },
  }
</script>

<style rel="stylesheet/css" lang="scss" scoped>
  .borderBox{
    border: 1px solid #DCDFE6;
    padding: 10px;
    margin-top: 10px;
    border-radius: 4px;
    p{
      font-weight: bold;
      font-size: 20px;
      margin: 10px 0;
    }
  }
  .container {
    margin-left: 180px;
    padding: 20px;
    background: #fff;
    min-height: calc(100vh - 173px);
    margin-bottom: 15px;

  .record {
    padding-top: 20px;
  }

  }
  .record_content_panel {
    border-width: 1px;
    border-style: solid;
    border-color: #ebeef5;
    min-height: 200px;

  .title {
    font-size: 14px;
    font-weight: 500;
    color: #909399;
    line-height: 44px;
    height: 44px;
    text-align: center;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #ebeef5;
  }

  .content {
    padding: 12px 15px;
    font-size: 15px;
    color: gray;
    line-height: 22px;
  }

  }

  .new_record_form {

  /*/ / padding: 10 px, 25 px;*/

  .textarea_panel {
    margin-top: 10px;
  }

  }
</style>
<style>
.el-table td,
.el-table th.is-leaf,
.el-table--border,
.el-table--group {
  border-color: #d0d3da;
}
.el-table--border::after,
.el-table--group::after,
.el-table::before {
  background-color: #d0d3da;
}
.el-select-dropdown {
  max-width: 1000px !important;
}
</style>
