<template>
  <!-- <div class="main-contain">
      <div class="position">
         <bread-crumb></bread-crumb>
      </div> -->
  <div class="patient-container">
    <PatientSidebar :id="patient_id" defaultActive="3-5"></PatientSidebar>
    <div v-loading="loading">
      <div class="patient-app-container advice-container app-container" style="">
        <div style="display: flex;">
          <div style="width: 34%;">
            <div style="display: flex;">
              <div style="flex: 1.1;">
                <span style="display: inline-block;border-left: 5px solid #3891f1f5;padding-left: 5px;">病史列表</span>
              </div>
              <div style="flex: 0.9;text-align: right;">
                <el-button type="primary" size="small" @click="add_click">添加</el-button>
              </div>
            </div>
            <div>
              <el-table class="table"
                ref="phy_table"
                :data="tableData"
                :highlight-current-row="true"
                @current-change="getCurrentChangeOne"
                style="width: 100%">

                <el-table-column prop="index" label="序号" width="50">
                  <template slot-scope="scope">
                     {{ scope.$index + 1 }}
                  </template>
                </el-table-column>
                <el-table-column prop="date" label="时间" width="">
                  <template slot-scope="scope">
                      {{ getTimeThree(scope.row.record_time) }}
                    </template>
                </el-table-column>
                <el-table-column prop="doctor" label="医生">
                  <template slot-scope="scope">
                    {{ getDocName(scope.row.recorder) }}
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </div>
          <div style="width: 65%;margin-left: 10px;">
            <div style="display: flex;">
              <div style="flex: 1;">
                <span style="display: inline-block;border-left: 5px solid #3891f1f5;padding-left: 5px;">详情</span>
              </div>
              <div style="flex: 1;text-align: right;">
                <div v-if='add_index == 0'>
                  <el-button type="primary" size="small" @click="showEdit">修改</el-button>
                  <el-button size="small" type="danger" @click="deleteAction">删除</el-button>
                  <el-button type="primary" size="small" @click="prints">打印</el-button>
                </div>
                <div v-if="add_index == 1">
                  <el-button type="primary" size="small" @click="showSave">保存</el-button>
                  <el-button size="small" @click="showCancel">取消</el-button>
                </div>
              </div>
            </div>
            <div style="display: flex;margin: 10px 0;">
              <div style="flex: 1;">
                记录时间:
                <el-date-picker v-model="record_date" prefix-icon="el-icon-date" :editable="false"
                              style="width: 200px;"
                              format="yyyy-MM-dd HH:mm:ss"
                               value-format="yyyy-MM-dd HH:mm:ss"
                              type="datetime" placeholder="选择日期时间" align="right" 
                              ></el-date-picker>
              </div>
              <div style="flex: 1;">
                病程医生:
                <el-select v-model="admin_user_id" placeholder="请选择" :disabled="disabled">
                  <el-option
                    v-for="item in doctorOptions"
                    :key="item.admin_user_id"
                    :label="item.user_name"
                    :value="item.admin_user_id">
                  </el-option>
                </el-select>
              </div>
              <div style="flex: 1;">
                病程标题:
                <el-input style="width: 150px;" v-model="title"></el-input>
              </div>
            </div>
            <div>
              <span style="display: inline-block;border-left: 5px solid #3891f1f5;padding-left: 5px;margin-bottom: 5px;">
                病程内容
              </span>
              <div style="margin: 10px 0;">
                <el-button type="primary" size="small" @click="template_click">
                  {{ add_index ==0 ? '设置模板' : '模板库' }}
                </el-button>
                <el-button type="primary" size="small" @click="auto_click" style="padding-bottom: 10px;">
                  自动生成
                </el-button>
                <el-button type="primary" size="small" @click="Inspect_click" style="padding-bottom: 10px;">
                  科室检查
                </el-button>
                <el-button type="primary" size="small" @click="blood_click" style="padding-bottom: 10px;">
                  血压
                </el-button>
                <el-button type="primary" size="small" @click="summary_click" style="margin-bottom: 10px;">
                  透析小结汇总
                </el-button>
                <el-button type="primary" size="small" @click="weight_click" style="margin-bottom: 10px;">
                  干体重
                </el-button>
                <el-button type="primary" size="small" @click="option_click" style="margin-bottom: 10px;">
                  透析方案
                </el-button>
                <el-button type="primary" size="small" @click="advice_click" style="margin-bottom: 10px;">
                  医嘱
                </el-button>
                <el-button type="primary" size="small" @click="diagnosis_click" style="margin-bottom: 10px;">
                  诊断
                </el-button>
                <el-button type="primary" size="small" @click="hospital_click" style="margin-bottom: 10px;">
                  出入院记录
                </el-button>
              </div>
              <ueditor ref="editor" id="editors" :content="new_content"></ueditor>
            </div>
          </div>
        </div>
      </div>

      <el-dialog
        title="设置模板"
        :visible.sync="template_dialog"
        width="20%"
        center>
        <div>
          模板名称:
          <el-input v-model="title" placeholder="请输入内容" style="width: 160px;"></el-input>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="template_dialog = false">取 消</el-button>
          <el-button type="primary" @click="saveTemplate">确 定</el-button>
        </span>
      </el-dialog>

      <el-dialog
        title="模板库"
        :visible.sync="library_dialog"
        width="70%"
        class="lirary"
        >
        <div>
          <div style="display: flex;">
            <div style="width: 27%;">
              <el-table
                :data="templateList"
                :highlight-current-row="true"
                @row-click="rowclick"
                 ref="record_table_one"
                 @current-change="getCurrentChangeTwo"
                style="width: 100%">
                <el-table-column prop="index" label="序号"  width="">
                  <template slot-scope="scope">
                       {{ scope.$index + 1 }}
                   </template>
                </el-table-column>
                <el-table-column prop="name" label="模板名称" width="">
                  <template slot-scope="scope">
                       {{ scope.row.title }}
                   </template>
                </el-table-column>
              </el-table>
            </div>
            <div style="width: 72%;margin-left: 10px;">
              <div class="Second_title">模板内容</div>
              <div style="">
                <keep-alive>
                  <ueditor ref="editorOne" id="editors" :content="new_content"></ueditor>
                </keep-alive>
              </div>
            </div>
          </div>
        </div>
        <span slot="footer" class="dialog-footer" style="text-align: center;">
          <el-button type="danger" @click="template_dele">删除模板</el-button>
          <el-button type="primary" @click="template_save">保存模板</el-button>
          <el-button type="primary" @click="toContentPint(1)">应用</el-button>
          <el-button @click="library_dialog = false">取消</el-button>
        </span>
      </el-dialog>

      <el-dialog
        title="提示"
        :visible.sync="auto_dialog"
        width="70%"
        top="0"
        >
        <div>
          <div style="display:flex;position: absolute;left: 20%;top: 20px;">
            <div>
              取值时间:
              <el-select v-model="quzhi_date" @change="datachange" placeholder="请选择" style="width: 120px;">
                <el-option
                  v-for="item in quzhi_options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </div>
            <div style="margin:0 10px">
              <el-date-picker
               @change="changStartDate"
                v-model="start_date"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                style="width: 150px;">
              </el-date-picker>
              <span>-</span>
              <el-date-picker
               @change="changEndDate"
                v-model="end_date"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                style="width: 150px;">
              </el-date-picker>
            </div>
            <div style="text-align: right;margin-bottom: 10px;">
              <el-button type="primary" size="small" @click="autotext_click">
                生成
              </el-button>
              <el-button type="primary" size="small" @click="auto_dialog=false">
                取消
              </el-button>
            </div>
          </div>
          <div v-show="AuToShow">
            <div v-html="textcontent" id="editer"></div>
            <!-- <text_content @new_content="newcontent" :patient="patient" :prescription="prescription" :berforList="berforList"
            :monitorList="monitorList" :dryweightList="dryweightList" :inpectionList="inpectionList" :dialysisOrderList="dialysisOrderList"
            :start_date="start_date" :end_date="end_date" :patient_id="patient_id" :num="num" :longAdvice="longAdvice" :groupPrescriptionList="groupPrescriptionList" :afterList="afterList" :max_blood_flow_volume="max_blood_flow_volume"
            :max_befor_systolic_blood_pressure="max_befor_systolic_blood_pressure" :min_befor_systolic_blood_pressure="min_befor_systolic_blood_pressure" :max_befor_diastolic_blood_pressure="max_befor_diastolic_blood_pressure"  :min_befor_diastolic_blood_pressure="min_befor_diastolic_blood_pressure"
            :max_after_systolic_blood_pressure="max_after_systolic_blood_pressure" :min_after_systolic_blood_pressure="min_after_systolic_blood_pressure" :max_after_diastolic_blood_pressure="max_after_diastolic_blood_pressure" :min_after_diastolic_blood_pressure="min_after_diastolic_blood_pressure"
            :max_monitor_systolic_blood_pressure="max_monitor_systolic_blood_pressure" :min_monitor_systolic_blood_pressure="min_monitor_systolic_blood_pressure" :max_monitor_diastolic_blood_pressure="max_monitor_diastolic_blood_pressure" :min_monitor_diastolic_blood_pressure="min_monitor_diastolic_blood_pressure"
            :lastDryWeight="lastDryWeight" :patientVascularAccess="patientVascularAccess" :lastBefor="lastBefor"></text_content> -->
          </div>
        </div>

      </el-dialog>
      <!-- 血压 -->
      <el-dialog
        title="血压"
        :visible.sync="blood_dialog"
        width="70%"
        class="lirary"
        >
        <div>
          <div style="display:flex;">
            <div>
              日期:
              <el-select v-model="blood_date" @change="blood_chang" placeholder="请选择" style="width: 120px;">
                <el-option
                  v-for="item in date_options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </div>
            <div style="margin:0 10px">
              <el-date-picker
               @change="changStartDate"
                v-model="start_date1"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                style="width: 150px;">
              </el-date-picker>
              <span>-</span>
              <el-date-picker
               @change="changEndDate"
                v-model="end_date1"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                style="width: 150px;">
              </el-date-picker>
            </div>
            <div style="text-align: right;margin-bottom: 10px;">
              <el-button type="primary" size="small" @click="getMonitorSearchList">
                查询
              </el-button>
            </div>
          </div>
          <div style="display: flex;">
            <div style="width: 27%;">
              <div class="Second_title">血压列表</div>
              <el-table
                :data="monitorListOne"
                :highlight-current-row="true"
                 ref="blood_table"
                 @current-change="handleMonitorChange"
                style="width: 100%">

                <el-table-column prop="date" label="透析日期"  width="" align="center">
                   <template slot-scope="scope" a>
                      {{ getTime(scope.row.schedule_date) }}
                   </template>
                </el-table-column>
                <el-table-column prop="mode" label="透析方式" width="" align="center">
                    <template slot-scope="scope">
                      {{ getModeId(scope.row.mode_id) }}
                    </template>

                </el-table-column>
              </el-table>
            </div>
            <div style="width: 72%;margin-left: 10px;">
              <div class="Second_title">内容</div>
              <div class="blood_text" style="" >
                <div v-html="monitor_blood_context"></div>
              </div>
            </div>
          </div>
        </div>
        <span slot="footer" class="dialog-footer" style="text-align: center;">
          <el-button type="primary" @click="toMonitorPint">应用</el-button>
          <!-- <el-button type="danger" @click="template_dele">删除模板</el-button>
          <el-button type="primary" @click="template_save">保存模板</el-button> -->
          <!-- <el-button type="primary" @click="toContentPint(2)">应用</el-button> -->
          <el-button @click="blood_dialog = false">取消</el-button>
        </span>
      </el-dialog>

      <!-- 透析小结汇总 -->
      <el-dialog
        title="透析小结"
        :visible.sync="summary_dialog"
        width="70%"
        class="lirary"
        >
        <div>
          <div style="display:flex;">
            <div>
              日期:
              <el-select v-model="blood_date" @change="blood_chang" placeholder="请选择" style="width: 120px;">
                <el-option
                  v-for="item in date_options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </div>
            <div style="margin:0 10px">
              <el-date-picker
               @change="changStartDate"
                v-model="start_date1"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                style="width: 150px;">
              </el-date-picker>
              <span>-</span>
              <el-date-picker
               @change="changEndDate"
                v-model="end_date1"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                style="width: 150px;">
              </el-date-picker>
            </div>
            <div style="text-align: right;margin-bottom: 10px;">
              <el-button type="primary" size="small" @click="getSummarySearchList">
                查询
              </el-button>
            </div>
          </div>
          <div style="display: flex;">
            <div style="width: 27%;">
              <div class="Second_title">透析小结汇总列表</div>
              <el-table
                :data="summaryList"
                :highlight-current-row="true"
                 ref="blood_table"
                 @current-change="summaryChange"
                 @selection-change="selectionchange2"
                style="width: 100%">
                <el-table-column type="selection"width="55">
                </el-table-column>
                <el-table-column prop="date" label="透析日期"  width="" align="center">
                  <template slot-scope="scope" a>
                      {{ getTime(scope.row.schedule_date) }}
                   </template>
                </el-table-column>
                <el-table-column prop="mode" label="透析方式" width="" align="center">
                  <template slot-scope="scope">
                      {{ getModeId(scope.row.mode_id) }}
                    </template>
                </el-table-column>
              </el-table>
            </div>
            <div style="width: 72%;margin-left: 10px;">
              <div class="Second_title">内容</div>
              <div class="blood_text" style="" >
                <div v-html="summary_context"></div>
              </div>
            </div>
          </div>
        </div>
        <span slot="footer" class="dialog-footer" style="text-align: center;">
          <!-- <el-button type="danger" @click="template_dele">删除模板</el-button>
          <el-button type="primary" @click="template_save">保存模板</el-button> -->
          <el-button type="primary" @click="toSummaryPint">应用</el-button>
          <el-button @click="summary_dialog = false">取消</el-button>
        </span>
      </el-dialog>

      <!-- 干体重 -->
      <el-dialog
        title="干体重"
        :visible.sync="weight_dialog"
        width="70%"
        class="lirary"
        >
        <div>
          <div style="display:flex;">
            <div>
              日期:
              <el-select v-model="blood_date" @change="blood_chang" placeholder="请选择" style="width: 120px;">
                <el-option
                  v-for="item in date_options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </div>
            <div style="margin:0 10px">
              <el-date-picker
               @change="changStartDate"
                v-model="start_date1"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                style="width: 150px;">
              </el-date-picker>
              <span>-</span>
              <el-date-picker
               @change="changEndDate"
                v-model="end_date1"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                style="width: 150px;">
              </el-date-picker>
            </div>
            <div style="text-align: right;margin-bottom: 10px;">
              <el-button type="primary" size="small" @click="getPatientDryWeightList">
                查询
              </el-button>
            </div>
          </div>
          <div style="display: flex;">
            <div style="width: 27%;">
              <div class="Second_title">干体重调整列表</div>
              <el-table
                :data="dryWeightList"
                :highlight-current-row="true"
                 ref="weight_table"
                 @current-change="weightChange"
                 @selection-change="selectionchange3"
                style="width: 100%">
                <el-table-column prop="date" label="时间"  width="" align="center">
                  <template slot-scope="scope">
                    {{ getTimeTwo(scope.row.ctime) }}
                   </template>
                </el-table-column>
              </el-table>
            </div>
            <div style="width: 72%;margin-left: 10px;">
              <div class="Second_title">内容</div>
              <div class="blood_text" style="" >
                <div v-html="weight_context"></div>
              </div>
            </div>
          </div>
        </div>
        <span slot="footer" class="dialog-footer" style="text-align: center;">
          <!-- <el-button type="danger" @click="template_dele">删除模板</el-button>
          <el-button type="primary" @click="template_save">保存模板</el-button> -->
          <el-button type="primary" @click="toDryWeightPint">应用</el-button>
          <el-button @click="weight_dialog = false">取消</el-button>
        </span>
      </el-dialog>

      <!-- 透析方案 -->
      <el-dialog
        title="透析方案"
        :visible.sync="option_dialog"
        width="70%"
        class="lirary"
        >
        <div>
          <div style="display: flex;">
            <div style="width: 27%;">
              <div class="Second_title">透析方案列表</div>
              <el-table
                 ref="option_table"
                :data="optionlist"
                :highlight-current-row="true"
                @selection-change="selectionchange4"
                style="width: 100%">
                <el-table-column type="selection"width="55">
                </el-table-column>
                <el-table-column prop="start" label="状态"  width=""></el-table-column>
                <el-table-column prop="mode" label="透析模式"  width=""></el-table-column>
              </el-table>
            </div>
            <div style="width: 72%;margin-left: 10px;">
              <div class="Second_title">方案详情</div>
              <div style="">
                <keep-alive>
                  <ueditor ref="editorOne" id="editors" :content="option_context"></ueditor>
                </keep-alive>
              </div>
            </div>
          </div>
        </div>
        <span slot="footer" class="dialog-footer" style="text-align: center;">
          <el-button type="primary" @click="toSystemContentPint">应用</el-button>
          <el-button @click="option_dialog = false">取消</el-button>
        </span>
      </el-dialog>

      <!-- 医嘱 -->
      <el-dialog
        title="医嘱"
        :visible.sync="advice_dialog"
        width="80%"
        class="lirary"
        >
        <div>
          <div style="display:flex;">
            <div>
              医嘱类型:
              <el-select v-model="advice_type" @change="type_chang" placeholder="请选择" style="width: 120px;">
                <el-option

                  v-for="item in type_option"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </div>
            <div style="margin-left: 10px;">
              医嘱状态:
              <el-select v-model="advice_status" @change="status_chang" placeholder="请选择" style="width: 120px;">
                <el-option
                  v-for="item in status_option"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </div>
          </div>
          <div style="">
            <el-table
              :data="adviceList"
              :highlight-current-row="true"
                ref="weight_table"
              @selection-change="selectionchange5"
              style="width: 100%">
              <el-table-column type="selection"width="55">
              </el-table-column>
              <el-table-column prop="date" label="开始时间"  width="" align="center">
                <template slot-scope="scope">
                    {{ getTimeThree(scope.row.start_time) }}
                 </template>
              </el-table-column>
              <el-table-column prop="name" label="医嘱名称"  width="" align="center">
                <template slot-scope="scope">
                    {{scope.row.advice_name }}
                 </template>
              </el-table-column>
              <el-table-column prop="guige" label="规格"  width="" align="center">
                <template slot-scope="scope">
                    {{scope.row.advice_desc}}
                 </template>
              </el-table-column>
              <el-table-column prop="danci" label="单次用量"  width="" align="center">
                <template slot-scope="scope">
                  <span v-if="scope.row.single_dose>0">{{ scope.row.single_dose }}</span>
                 </template>
              </el-table-column>
              <el-table-column prop="geiyao" label="给药途径"  width="" align="center">
                <template slot-scope="scope">
                    {{scope.row.delivery_way}}
                 </template>
              </el-table-column>
              <el-table-column prop="pinlv" label="执行频率"  width="" align="center">
                <template slot-scope="scope">
                    {{scope.row.execution_frequency }}
                 </template>
              </el-table-column>
              <el-table-column prop="beizhu" label="备注"  width="" align="center">
                <template slot-scope="scope">
                    {{scope.row.remark}}
                 </template>
              </el-table-column>
              <el-table-column prop="tingzhi" label="停止时间/执行时间"  width="" align="center">
                <template slot-scope="scope">
                  <span v-if="scope.row.advice_type == 1">
                    {{ getTimeThree(scope.row.stop_time) }}
                  </span>
                  <span v-if="scope.row.advice_type != 1">
                    {{ getTimeThree(scope.row.execution_time) }}
                  </span>

                 </template>
              </el-table-column>
              <el-table-column prop="yuanyin" label="停止原因"  width="" align="center">
                <template slot-scope="scope">
                   <span v-if="scope.row.advice_type == 1">
                    {{scope.row.remark }}
                   </span>

                 </template>
              </el-table-column>
              <el-table-column prop="yisheng" label="停止医生"  width="" align="center">
                <template slot-scope="scope">
                  <span v-if="scope.row.advice_type == 1">
                    {{ getDocName(scope.row.advice_doctor) }}
                   </span>
                </template>

              </el-table-column>
            </el-table>
          </div>
        </div>
        <span slot="footer" class="dialog-footer" style="text-align: center;" align="center">
          <el-button type="primary" @click="toAdviceContentPint">应用</el-button>
          <el-button @click="advice_dialog = false">取消</el-button>
        </span>
      </el-dialog>

      <!-- 科室检查 -->
      <el-dialog
        title="科室检查"
        :visible.sync="Inspect_dialog"
        width="70%"
        class="lirary"
        >
        <div>
          <div style="display:flex;">
            <div>
              日期:
              <el-select v-model="blood_date" @change="blood_chang" placeholder="请选择" style="width: 120px;">
                <el-option
                  v-for="item in date_options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </div>
            <div style="margin:0 10px">
              <el-date-picker
               @change="changStartDate"
                v-model="start_date1"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                style="width: 150px;">
              </el-date-picker>
              <span>-</span>
              <el-date-picker
               @change="changEndDate"
                v-model="end_date1"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择日期"
                style="width: 150px;">
              </el-date-picker>
            </div>
            <div style="text-align: right;margin-bottom: 10px;">
              <el-button type="primary" size="small" @click="toInspection">
                查询
              </el-button>
            </div>
          </div>
          <div style="display: flex;">
            <div style="width: 27%;">
              <div style="display: flex;">
                <div style="flex: 1;">
                  <div class="Second_title">检验项目</div>
                </div>
                <div style="flex: 1;text-align: right;">
                  全选<el-checkbox v-model="checked" @change="changeInspetion"></el-checkbox>
                </div>
              </div>
              <div>
                <el-collapse v-model="activeNames" @change="handleChange" v-for="(item,index) in newInspectionList" :key="item.id">
                  <el-collapse-item :title="item.project_name" :name="item.project_id">
                    <ul>
                      <li v-for="i in item.child" class="inspect" @click="childclick(i)">{{getTime(i.inspect_date)}}</li>
                    </ul>
                  </el-collapse-item>
                </el-collapse>
              </div>
            </div>
            <div style="width: 72%;margin-left: 10px;">
              <div class="Second_title">内容</div>
              <div class="blood_text" style="" >
                <div v-html="inspect_context"></div>
                <!-- {{ blood_context }} -->
              </div>
            </div>
          </div>
        </div>
        <span slot="footer" class="dialog-footer" style="text-align: center;">
          <!-- <el-button type="danger" @click="template_dele">删除模板</el-button>
          <el-button type="primary" @click="template_save">保存模板</el-button> -->
          <el-button type="primary" @click="toInpectionContentPint">应用</el-button>
          <el-button @click="Inspect_dialog = false">取消</el-button>
        </span>
      </el-dialog>
    </div>

    <!-- <table border="1" style="border-collapse: collapse;width: 100%;">
      <tr><td colspan="4">HD，每周3次，启用</td></tr>
      <tr>
        <td>透析时长（h）：4</td>
        <td>置换方式：</td>
        <td>血流量（ml/min）：250</td>
        <td></td>
      </tr>
      <tr>
        <td>血透器：空心纤维血液透析器B-18BHF(B-18BHF)</td>
        <td>血滤器：</td>
        <td>灌流器：</td>
        <td>透析液流量（ml/min）：500</td>
      </tr>
      <tr>
        <td>钾（mmol/L）：2.0</td>
        <td>钠（mmol/L）：138</td>
        <td>钙（mmol/L）：1.5</td>
        <td>碳酸氢根（mmol/L）：32</td>
      </tr>
      <tr>
        <td>抗凝剂：低分子肝素</td>
        <td>首剂（iu）：4500</td>
        <td>维持（iu）： 0</td>
        <td>总量（iu）：4500</td>
      </tr>
      <tr><td colspan="4">抗凝剂公式：自定义维持时长（H）</td></tr>
    </table> -->
  </div>
</template>

<script>
  import PatientSidebar from './components/PatientSidebar'
  import PatientSidebar_new from './components/PatientSidebar_new'
  import Editor from '@/components/Editor'
  import ueditor from '@/components/Uedtior'
  import text_content from './text_content'
  const moment = require('moment')
  import { getDataConfig } from "@/utils/data";
  import {
    createNewCourseOfDiseaseRecord,
    deleteNewCouseOfDisease,
    modifyCourseOfDiseaseRecord,
    getPatientCourseOfDiseaseList,
    saveCoureseTemplateTitle,
    getPatientCoureOfTempalate,
    saveCourseOfNewTemplate,
    deleteCourseTempalte,
    getAutoPatientContent,
    getMonitorSearchList,
    getSummarySearchList,
    getPatientDryWeightList,
    getDilaysisSystemList,
    getPatientAdviceList,
    getPatientInspectionList,
    getInspectionByProjectId,

  } from '@/api/patient'
  import { fetchMoibleAllDoctorAndNurse } from "@/api/doctor";
  import { parseTime } from '@/utils'
  import BreadCrumb from '@/xt_pages/components/bread-crumb'
  import { uParseTime } from '@/utils/tools'
  export default {
    name: 'CourseOfDisease',
    components: {
      PatientSidebar,
      BreadCrumb,
      Editor,
      PatientSidebar_new,
      ueditor,
      text_content,
    },
    data() {
      return {
        loading: false,
        title: '',
        patient_id: 0,
        date: [],
        start_time: '',
        end_time: '',

        course_of_disease_time: moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
        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: '',
        ids:"",
        idArr:[],
        org_id:0,
        add_index:0,
        disabled:true,
        template_dialog:false,
        library_dialog:false,
        auto_dialog:false,
        blood_dialog:false,
        summary_dialog:false,
        weight_dialog:false,
        option_dialog:false,
        advice_dialog:false,
        Inspect_dialog:false,
        checked:false,
        quzhi_date:1,
        start_date:'',
        end_date:'',
        start_date1:'',
        end_date1:'',
        quzhi_options:[{value:1,label:'本周'},{value:2,label:'上周'},{value:3,label:'本月'},{value:4,label:'上月'},],
        tableData:[],
        admin_user_id:"",
        record_date:moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
        template_name:"",
        id:0,
        doctorOptions:[],
        template_content:"",
        template_id:0,
        title:"",
        templateList:[],
        prescription:[],
        berforList:[],
        monitorList:[],
        dryweightList:[],
        inpectionList:[],
        dialysisOrderList:[],
        patient:{},
        AuToShow:false,
        num:"",
        longAdvice:[],
        groupPrescriptionList:[],
        afterList:[],
        max_blood_flow_volume:"",
        max_befor_systolic_blood_pressure:"",
        min_befor_systolic_blood_pressure:"",
        max_befor_diastolic_blood_pressure:"",
        min_befor_diastolic_blood_pressure:"",
        max_after_systolic_blood_pressure:"",
        min_after_systolic_blood_pressure:"",
        max_after_diastolic_blood_pressure:"",
        min_after_diastolic_blood_pressure:"",
        max_monitor_systolic_blood_pressure:"",
        min_monitor_systolic_blood_pressure:"",
        max_monitor_diastolic_blood_pressure:"",
        min_monitor_diastolic_blood_pressure:"",
        lastDryWeight:{},
        patientVascularAccess:{},
        lastBefor:{},
        Inspect:[],
        textcontent:'',
        bloodList:[
          {date:'2024-12-14',mode:'HD',
            content:'2024-12-14（HD） 透前血压：150/66mmHg；监测记录：150/66mmHg，拒测/拒测mmHg，142/69mmHg，拒测/拒测mmHg，145/69mmHg；透后血压：145/69mmHg。'
          },
          {date:'2024-12-12',mode:'HD',
            content:'2024-12-12（HD） 透前血压：150/66mmHg；监测记录：150/66mmHg，拒测/拒测mmHg，142/69mmHg，拒测/拒测mmHg，145/69mmHg；透后血压：145/69mmHg。'}
        ],
        weightlist:[],
        optionlist:[{start:'启',mode:'HD',content:''},{start:'启',mode:'HDF',content:''}],
        advicelist:[{date:'2024-12-17 07:13',name:'非布司他片',guige:'40mg*16T',danci:'25 mg',geiyao:'口服',pinlv:'qn',beizhu:'40mg*16T',tingzhi:'',yuanyin:'口服',yisheng:'qn',},
        {date:'2024-12-17 07:13',name:'非布司他片',guige:'40mg*16T',danci:'25 mg',geiyao:'口服',pinlv:'qn',beizhu:'40mg*16T',tingzhi:'',yuanyin:'口服',yisheng:'qn',}
        ],
        Inspectlist:[{id:'0001',name:'传染病四项',child:[{c_id:1,pater_id:"0001",date:'2024-12-17 07:13',text:'传染病四项 - 检验日期：2024-06-12；HbsAg阴性；抗-HCV阴性；抗-HIV阴性； 梅毒TP阴性；'},
          {c_id:2,pater_id:"0001",date:'2024-12-14 07:13',text:'传染病四项 - 检验日期：2024-06-12；HbsAg阴性；抗-HCV阴性；抗-HIV阴性； 梅毒TP阴性；'},{c_id:3,pater_id:"0001",date:'2024-12-17 07:13',text:''},{c_id:4,pater_id:"0001",date:'2024-12-14 07:13',text:''}]},
            {id:'0002',name:'铁五项',child:[{c_id:1,pater_id:"0002",date:'2024-12-15 07:13',text:''},{c_id:2,pater_id:"0002",date:'2024-12-16 07:13',text:''}]}
        ],
        bloodRows:[],
        summaryRows:[],
        weightRows:[],
        optionRows:[],
        adviceRows:[],
        activeNames:[],
        InspectRows:[],
        blood_context:'',
        summary_context:'',
        weight_context:'',
        option_context:'',
        advice_context:'',
        Inspect_context:'',
        blood_date:2,
        advice_type:2,
        advice_status:1,
        date_options:[{value:1,label:'当天'},{value:2,label:'最近七天'},{value:3,label:'最近30天'},{value:4,label:'本周'},
          {value:5,label:'上周'},{value:6,label:'本月'},{value:7,label:'上月'},{value:8,label:'今年一季度'},
          {value:9,label:'今年二季度'},{value:10,label:'今年三季度'},{value:11,label:'今年四季度'},{value:12,label:'今年上半年'},
          {value:13,label:'今年下半年'},{value:14,label:'今年'},{value:15,label:'上一年'},{value:16,label:'自定义'},
        ],
        type_option:[{value:1,label:'不限'},{value:2,label:'长期医嘱'},{value:3,label:'临时医嘱'}],
        status_option:[{value:1,label:'不限'},{value:2,label:'未停止'},{value:3,label:'已停止'}],
        monitorListOne:[],
        monitor_blood_context:"",
        summaryList:[],
        dryWeightList:[],
        adviceList:[],
        newInspectionList:[],
        newInspectionListOne:[],
        inspect_context:"",
        inspectionList:[],
        newIds:[],
        adviceNewList:[],
        all_select:0,
        systemPrescritpionList:[]
      }
    },
    created() {
      this.admin_user_id = this.$store.getters.xt_user.user.id
      if(this.admin_user_id == 0){
         this.admin_user_id = ""
      }

      this.patient_id = parseInt(this.$route.query.id)
      this.org_id = this.$store.getters.xt_user.template_info.org_id;
      if (isNaN(this.patient_id) || this.patient_id <= 0) {
        this.$notify.error({
          title: '错误',
          message: '无效的id'
        })
        this.$router.push('/patients/patients')
        return
      }
      //   const ceshi = ``

      // // const ceshi=`hellow word`
      // this.new_content = ceshi
      // this.$refs.editor.contents=ceshi
      // this.start_date = this.getFirstDayOfWeek(new Date())
      // this.end_date = this.getTime(new Date())
      this.fetchAllDoctorAndNurse()
      this.getlist()
    },
    methods: {
      getModeId(mode_id){
        var mode_name = ""
        if(mode_id == 1){
          mode_name ="HD"
        }
        if(mode_id == 2){
          mode_name ="HDF"
        }
        if(mode_id == 3){
          mode_name ="HD+HP"
        }
        if(mode_id == 4){
          mode_name ="HP"
        }
        if(mode_id == 5){
          mode_name ="HF"
        }
        if(mode_id == 6){
          mode_name ="SCUF"
        }
        if(mode_id == 7){
          mode_name ="IUF"
        }
        if(mode_id == 8){
          mode_name ="HFHD"
        }
        if(mode_id == 9){
          mode_name ="HFHD+HP"
        }
        if(mode_id == 10){
          mode_name ="PHF"
        }
        if(mode_id == 11){
          mode_name ="HFR"
        }
        if(mode_id == 12){
          mode_name ="HDF+HP"
        }
        if(mode_id == 13){
          mode_name ="CRRT"
        }
        if(mode_id == 14){
          mode_name ="腹水回输"
        }
        if(mode_id == 19){
          mode_name ="IUF+HD"
        }
        if(mode_id == 20){
          mode_name ="UF"
        }
        if(mode_id == 21){
          mode_name ="HD+"
        }
        if(mode_id == 22){
          mode_name ="血浆胆红素吸附+HDF"
        }
        if(mode_id == 23){
          mode_name ="血浆胆红素吸附"
        }
        if(mode_id == 24){
          mode_name ="I-HDF"
        }
        if(mode_id == 25){
          mode_name ="HD高通"
        }
        if(mode_id == 26){
          mode_name ="CVVH"
        }
        if(mode_id == 27){
          mode_name ="CVVHD"
        }
        if(mode_id == 28){
          mode_name ="CVVHDF"
        }
        if(mode_id == 29){
          mode_name ="PE"
        }
        if(mode_id == 30){
          mode_name ="血浆胆红素吸附+HP"
        }
        if(mode_id == 31){
          mode_name ="HPD"
        }
        if(mode_id == 32){
          mode_name ="HDP"
        }

        if(mode_id == 33){
          mode_name = "HFD"
        }
        if(mode_id == 34){
          mode_name = "HDF100"
        }
        if(mode_id == 35){
          mode_name = "HDF600"
        }
        if(mode_id == 36){
          mode_name = "HDF800"
        }
        if(mode_id == 37){
          mode_name = "HDF1000"
        }
        if(mode_id == 38){
          mode_name = "HDF80"
        }
        if(mode_id == 39){
          mode_name = "HF16"
        }
        if(mode_id == 40){
          mode_name = "HD(无肝素)"
        }
        if(mode_id == 41){
          mode_name = "HDF17H"
        }
        if(mode_id == 42){
          mode_name = "HD."
        }
        if(mode_id == 43){
          mode_name = "HD(2)"
        }
        if(mode_id == 44){
          mode_name = "导管溶栓"
        }
        return mode_name
      },
      getAnticoagulantName(val){
       var anticoagulant_name = ""
       if(val == 1){
          anticoagulant_name = "无肝素"
       }
       if(val == 2){
          anticoagulant_name = "普通肝素"
       }
       if(val == 3){
          anticoagulant_name = "低分子肝素"
       }
       if(val == 4){
          anticoagulant_name = "阿加曲班"
       }
       if(val == 5){
          anticoagulant_name = "枸橼酸钠"
       }
       if(val == 6){
          anticoagulant_name = "低分子肝素钙"
       }
       if(val == 7){
          anticoagulant_name = "低分子肝素钠"
       }
       if(val == 8){
          anticoagulant_name = "依诺肝素"
       }
       if(val == 9){
          anticoagulant_name = "达肝素"
       }
       if(val == 10){
          anticoagulant_name = "体外抗凝"
       }
       if(val == 11){
          anticoagulant_name = "那屈肝素"
       }
       if(val == 12){
          anticoagulant_name = "无抗凝剂"
       }
       if(val == 13){
          anticoagulant_name = "那屈肝素钙"
       }
       if(val == 14){
          anticoagulant_name = "肝素钙注射液"
       }
       if(val == 15){
          anticoagulant_name = "甲磺酸萘莫司他"
       }
       if(val == 16){
          anticoagulant_name = "低分子量肝素钙"
       }
       if(val == 17){
          anticoagulant_name = "肝素钠"
       }
       if(val == 18){
          anticoagulant_name = "贝米肝素钠注射液"
       }
       if(val == 19){
          anticoagulant_name = "低分子量肝素钠"
       }
       return anticoagulant_name
     },
     getAnticoagulantUnit(val){
      var anticoagulant_name = ""
       if(val == 1){
          anticoagulant_name = "mg"
       }
       if(val == 2){
          anticoagulant_name = "IU"
       }
       if(val == 3){
          anticoagulant_name = "IU"
       }
       if(val == 4){
          anticoagulant_name = "mg"
       }
       if(val == 5){
          anticoagulant_name = "ml/h"
       }
       if(val == 6){
          anticoagulant_name = "IU"
       }
       if(val == 7){
          anticoagulant_name = "IU"
       }
       if(val == 8){
          anticoagulant_name = "IU"
       }
       if(val == 9){
          anticoagulant_name = "IU/h"
       }
       if(val == 10){
          anticoagulant_name = "mg/h"
       }
       if(val == 11){
          anticoagulant_name = "mg/h"
       }
       if(val == 12){
          anticoagulant_name = "mg/h"
       }
       if(val == 13){
          anticoagulant_name = "mg/h"
       }
       if(val == 14){
          anticoagulant_name = "iu/h"
       }
       if(val == 15){
          anticoagulant_name = "mg/h"
       }
       if(val == 16){
          anticoagulant_name = "iu/h"
       }
       if(val == 17){
          anticoagulant_name = "mg/h"
       }
       if(val == 18){
          anticoagulant_name = "iu/h"
       }
       if(val == 19){
          anticoagulant_name = "iu/h"
       }
       return anticoagulant_name
     },
      changStartDate(val){
        this.start_date = val
      },
      changEndDate(val){
        this.end_date = val
      },
      datachange(val){
        if(val ==1){
          this.start_date = this.getFirstDayOfWeek(new Date())
          this.end_date = this.getTime(new Date())
        }else if(val ==2){
          this.getlastweek(new Date())
        }else if(val ==3){
          this.start_date = this.getFirstDayOfMonth(new Date())
          this.end_date = this.getTime(new Date())
        }else if(val ==4){
          this.start_date = this.getLastMonthFirstDay()
          this.end_date = this.getLastMonthLastDay()

        }
      },
      toAdviceContentPint(val){

        console.log('blood_context',this.blood_context,this.template_content);
        this.template_content = this.template_content +'<br/>'+ this.blood_context+'<br/>'+this.summary_context +'<br/>' +this.advice_context+'<br/>'+this.option_context
        this.$refs.editor.contents = this.template_content
        const iframe = document.getElementsByClassName('edui-editor-iframeholder')[0].getElementsByTagName('iframe')[0].contentDocument.getElementsByTagName('body')[0]

            this.$nextTick(()=>{
                const new_list=document.createElement('table')
                new_list.style.cssText='border:1px solid black;border-collapse:collapse;width:100%';
                let newListItem1 = document.createElement('tr');
                let new_td1 = document.createElement('td');
                let new_td2 = document.createElement('td');
                let new_td3 = document.createElement('td');
                let new_td4 = document.createElement('td');
                let new_td5 = document.createElement('td');
                let new_td6 = document.createElement('td');
                let new_td7 = document.createElement('td');
                let new_td8 = document.createElement('td');
                let new_td9 = document.createElement('td');
                let new_td10 = document.createElement('td');
                new_td1.textContent ='开始时间'
                new_td2.textContent ='医嘱名称'
                new_td3.textContent ='规格'
                new_td4.textContent ='单次用量'
                new_td5.textContent ='给药途径'
                new_td6.textContent ='执行频率'
                new_td7.textContent ='备注'
                new_td8.textContent ='停止时间/执行时间'
                new_td9.textContent ='停止原因'
                new_td10.textContent ='停嘱医生'
                newListItem1.appendChild(new_td1);
                newListItem1.appendChild(new_td2);
                newListItem1.appendChild(new_td3);
                newListItem1.appendChild(new_td4);
                newListItem1.appendChild(new_td5);
                newListItem1.appendChild(new_td6);
                newListItem1.appendChild(new_td7);
                newListItem1.appendChild(new_td8);
                newListItem1.appendChild(new_td9);
                newListItem1.appendChild(new_td10);
                new_list.appendChild(newListItem1)

               if(this.adviceList!=null && this.adviceList.length>0 && this.all_select == 0){
                for(let i in this.adviceList){
                    let newListItem2 = document.createElement('tr');
                    let new_td1 = document.createElement('td');
                    let new_td2 = document.createElement('td');
                    let new_td3 = document.createElement('td');
                    let new_td4 = document.createElement('td');
                    let new_td5 = document.createElement('td');
                    let new_td6 = document.createElement('td');
                    let new_td7 = document.createElement('td');
                    let new_td8 = document.createElement('td');
                    let new_td9 = document.createElement('td');
                    let new_td10 = document.createElement('td');
                    new_td1.textContent =this.getTimeThree(this.adviceList[i].start_time)
                    new_td2.textContent =this.adviceList[i].advice_name
                    new_td3.textContent =this.adviceList[i].advice_desc
                    new_td4.textContent =this.adviceList[i].single_dose
                    new_td5.textContent =this.adviceList[i].delivery_way
                    new_td6.textContent =this.adviceList[i].execution_frequency
                    new_td7.textContent =this.adviceList[i].remark
                    if(this.adviceList[i].advice_type == 1){
                      new_td8.textContent =this.getTimeThree(this.adviceList[i].stop_time)
                    }else{
                      new_td8.textContent =this.getTimeThree(this.adviceList[i].execution_time)
                    }
                    new_td9.textContent =this.adviceList[i].stop_reason
                    new_td10.textContent =this.getDocName(this.adviceList[i].advice_doctor)
                    newListItem2.appendChild(new_td1);
                    newListItem2.appendChild(new_td2);
                    newListItem2.appendChild(new_td3);
                    newListItem2.appendChild(new_td4);
                    newListItem2.appendChild(new_td5);
                    newListItem2.appendChild(new_td6);
                    newListItem2.appendChild(new_td7);
                    newListItem2.appendChild(new_td8);
                    newListItem2.appendChild(new_td9);
                    newListItem2.appendChild(new_td10);
                    new_list.appendChild(newListItem2)
                 }
               }

               if(this.adviceNewList!=null && this.adviceNewList.length>0 && this.all_select == 1){
                for(let i in this.adviceNewList){
                    let newListItem2 = document.createElement('tr');
                    let new_td1 = document.createElement('td');
                    let new_td2 = document.createElement('td');
                    let new_td3 = document.createElement('td');
                    let new_td4 = document.createElement('td');
                    let new_td5 = document.createElement('td');
                    let new_td6 = document.createElement('td');
                    let new_td7 = document.createElement('td');
                    let new_td8 = document.createElement('td');
                    let new_td9 = document.createElement('td');
                    let new_td10 = document.createElement('td');
                    new_td1.textContent =this.getTimeThree(this.adviceNewList[i].start_time)
                    new_td2.textContent =this.adviceNewList[i].advice_name
                    new_td3.textContent =this.adviceNewList[i].advice_desc
                    new_td4.textContent =this.adviceNewList[i].single_dose
                    new_td5.textContent =this.adviceNewList[i].delivery_way
                    new_td6.textContent =this.adviceNewList[i].execution_frequency
                    new_td7.textContent =this.adviceNewList[i].remark
                    if(this.adviceNewList[i].advice_type == 1){
                      new_td8.textContent =this.getTimeThree(this.adviceNewList[i].stop_time)
                    }else{
                      new_td8.textContent =this.getTimeThree(this.adviceNewList[i].execution_time)
                    }
                    new_td9.textContent =this.adviceNewList[i].stop_reason
                    new_td10.textContent =this.getDocName(this.adviceNewList[i].advice_doctor)
                    newListItem2.appendChild(new_td1);
                    newListItem2.appendChild(new_td2);
                    newListItem2.appendChild(new_td3);
                    newListItem2.appendChild(new_td4);
                    newListItem2.appendChild(new_td5);
                    newListItem2.appendChild(new_td6);
                    newListItem2.appendChild(new_td7);
                    newListItem2.appendChild(new_td8);
                    newListItem2.appendChild(new_td9);
                    newListItem2.appendChild(new_td10);
                    new_list.appendChild(newListItem2)
                 }
               }

              const cont = iframe.getElementsByClassName('advice_table')[0]
              cont.appendChild(new_list)
              console.log('iframe.appendChild(new_list)',cont);
              console.log('this.advice_context',this.advice_context);
            })

        this.advice_dialog = false
      },
      getCurrentChangeOne(val){
        console.log('bbbbbb1111',val);
        
        this.$refs.editor.contents = val.content
        this.record_date = ""
        if(val.id > 0){
          this.record_date = this.getTimeThree(val.record_time)
        }else{
          this.record_date  = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
        }
        // console.log("record_date----------------",this.record_date)
        this.admin_user_id = val.recorder
        if(this.admin_user_id == 0){
           this.admin_user_id = ""
        }
        this.id = val.id
        this.ids = val.id
        this.title = val.title
      },
      getCurrentChangeTwo(val){

        this.$refs.editorOne.contents = val.content
        this.template_content = ""
        this.template_content = val.content
        this.template_id = val.id
     },
     template_dele(){
       deleteCourseTempalte(this.template_id).then(response=>{
        if(response.data.state == 1){
          var msg =  response.data.data.msg
          this.$message.success("删除成功!")
          this.library_dialog = false
          this.getPatientCoureOfTempalateOne()
        }
      })
     },
     getPatientCoureOfTempalateOne(){

     },
     rowclick(){

      },

      saveTemplate(){

        var params = {
          title:this.title,
          content: this.$refs.editor.contents,
        }
      saveCoureseTemplateTitle(params).then(response=>{
        if(response.data.state == 1){
          var courseTemplate =  response.data.data.courseTemplate
          this.$message.success("保存成功!")
          this.template_dialog = false
        }
        })
      },
      template_save(){
        var params = {
         template_id:this.template_id,
         content:this.$refs.editorOne.contents
        }

        saveCourseOfNewTemplate(params).then(response=>{
           if(response.data.state == 1){
              var msg = response.data.data.msg
              this.$message.success("保存成功")
              this.library_dialog = false
           }
        })
      },
      getDocName(admin_user_id){
        var user_name = ""
        for(let i=0;i<this.doctorOptions.length;i++){
          if(admin_user_id == this.doctorOptions[i].admin_user_id){
              user_name = this.doctorOptions[i].user_name
          }
        }
       return user_name
     },
      getlist(){
          var params = {
            patient_id:this.patient_id
          }
        getPatientCourseOfDiseaseList(params).then(response=>{
            if(response.data.state == 1){
               var list = response.data.data.list
              this.tableData = []
              this.tableData = list

            }
        })
     },
     fetchAllDoctorAndNurse() {
      fetchMoibleAllDoctorAndNurse().then(response => {
        if (response.data.state == 1) {
          this.doctorOptions= []
          this.doctorOptions = response.data.data.doctors;
        }
       });
      },
      add_click(){
        this.record_date = ""
        this.record_date = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
        this.admin_user_id = ""
        this.admin_user_id = this.$store.getters.xt_user.user.id
        this.fetchAllDoctorAndNurse()
        this.$refs.editor.contents = ""
        this.id = 0
        this.disabled = false
        this.add_index = 1
      },
      showCancel(){
        this.add_index = 0
        this.disabled = true
      },
      showSave(){
        this.add_index = 0
        this.disabled = true
        console.log("haaaaaaaaaaaaaaa",this.record_date)
        this.getlist()
        if(this.record_date.length == 0) {
          this.$message.error('请选择时间')
          return
        }
        this.new_content = this.$refs.editor.contents
        if (this.new_content.length == 0) {
          this.$message.error('请填写病程内容')
          return
        }

        if(this.admin_user_id == ""){
           this.admin_user_id = 0
        }

        var params = {
          id:this.id,
          patient_id:this.patient_id,
          record_date:this.record_date,
          content:this.new_content,
          admin_user_id:this.admin_user_id,
          title:this.title
        }
       
        console.log("params",params)

        createNewCourseOfDiseaseRecord(params).then(response => {
         if(response.data.state == 1){
           var msg = response.data.data.msg
           this.$message.success("保存成功!")
           this.getlist()
         }

        }).catch(error => {

        })
        
      },
      template_click(){
        console.log('this.add_index',this.add_index);

        if(this.add_index ==0){
          this.template_dialog = true
        }else{
         getPatientCoureOfTempalate().then(response=>{
          if(response.data.state == 1){
            this.library_dialog = true
            this.templateList = response.data.data.templateList
            console.log("hahhahahaha",this.$refs)
            if(this.templateList!=null && this.templateList.length>0){
              this.$refs.record_table_one.setCurrentRow(this.templateList[0])
            }
            console.log("haaaaaaaaaaaaa",this.templateList)

          }
        })

       }
      },
      auto_click(){
        this.start_date = this.getFirstDayOfWeek(new Date())
        this.end_date = this.getTime(new Date())
        this.getAutoPatientContent()
        // this.auto_dialog = true
      },
      // 季度第一天
      getquarterstart(index,number){
        const currentYear = new Date().getFullYear();
        const Start = this.timeFormat(new Date(currentYear, index, number));
        return Start
      },
      // 季度最后一天
      getquarterend(index,number){
        const currentYear = new Date().getFullYear();
        const End = this.timeFormat(new Date(currentYear, index, number));
        return End
      },

      // 日期格式化
      timeFormat(date) {
          if (!date || typeof(date) === "string") {
            this.error("参数异常，请检查...");
          }
          var y = date.getFullYear(); //年
          if(date.getMonth() + 1<10){
            var m ='0'+(date.getMonth() + 1); //月
          }else{
            var m =date.getMonth() + 1; //月
          }
          if(date.getDate()<10){
            var d ='0'+date.getDate(); //日
          }else{
            var d = date.getDate(); //日
          }
          // var d = date.getDate(); //日

          return y + "-" + m + "-" + d;
      },

      requestCourseRecords: function() {
        this.loading = true
        getCourseOfDiseaseRecords(this.patient_id, this.start_time, this.end_time).then(rs => {
          this.loading = false
          var resp = rs.data
          if (resp.state == 1) {
            this.current_select_record = null
            this.records = resp.data.records
            console.log("records232322332323232323223",this.records)
            this.doctors = resp.data.doctors

          } else {
            this.$message.error(resp.msg)
          }
        }).catch(error => {
          this.loading = false
          this.$message.error(error)
        })
      },

      didChangeCurrentRecord: function(record) {
        this.current_select_record = record
      },
      recordTime: function(timestamp) {
        var time = new Date(timestamp * 1000)
        return parseTime(time, '{y}-{m}-{d} {h}:{i}:{s}')
      },
      doctorName: function(doctor_id) {
        for (let index = 0; index < this.doctors.length; index++) {
          const doctor = this.doctors[index]
          if (doctor.id == doctor_id) {
            return doctor.name
          }
        }
        return ''
      },
      modifyAction: function() {

        this.edit_new_content = this.$refs.edit_neditor.content
        if (this.edit_new_content.length == 0) {
          this.$message.error('请填写病程内容')
          return
        }
        this.uploading_new_record = true
        modifyCourseOfDiseaseRecord(this.patient_id, this.edit_new_content, this.edit_course_of_disease_time, this.edit_current_id, this.edit_title).then(rs => {
          this.uploading_new_record = false
          var resp = rs.data
          if (resp.state == 1) {
            this.records[this.table_current_index].content = resp.data.record.content
            this.records[this.table_current_index].record_time = resp.data.record.record_time
            this.records[this.table_current_index].recorder = resp.data.record.recorder
            this.records[this.table_current_index].title = resp.data.record.title

            this.show_edit_dialog = false
            this.edit_new_content = ''
            this.table_current_index = -1

          } else {
            this.table_current_index = -1
            this.$message.error(resp.msg)
          }

        }).catch(error => {
          this.table_current_index = -1
          this.uploading_new_record = false
          this.$message.error(error)
        })

      },

      autotext_click(){
        if(this.start_date == ""){
          this.$message.error("请选择开始时间")
        }
        if(this.end_date == ""){
          this.$message.error("请选择结束时间")
        }
        var params = {
          start_time:this.start_date,
          end_time:this.end_date,
          patient_id:this.patient_id,
        }
        console.log("start_time==============",params)
       getAutoPatientContent(params).then(response=>{
          if(response.data.state == 1){
            var prescription =  response.data.data.prescription
            this.prescription=[]
            this.prescription = prescription

            var berfor = response.data.data.berfor
            this.berforList = []
            this.berforList = berfor

            var monitorList  = response.data.data.monitorList
            this.monitorList = []
            this.monitorList = monitorList

            var dryweightList = response.data.data.dryweightList

            this.dryweightList = []
            this.dryweightList = dryweightList

            var inpectionList = response.data.data.inpectionList

            this.inpectionList = []

            this.inpectionList = inpectionList


            var patient = response.data.data.patient

            if(patient.gender == 1){
               patient.gender_name = "男"
            }
            if(patient.gender == 2){
               patient.gender_name = "女"
            }

           this.patient = patient
           var dialysisOrderList =response.data.data.dialysisOrder

           this.dialysisOrderList = []
           this.dialysisOrderList = dialysisOrderList

           var longAdvice = response.data.data.longAdvice

           this.longAdvice = []
           this.longAdvice = longAdvice

           this.groupPrescriptionList = []
           this.groupPrescriptionList = response.data.data.groupPrescriptionList

           this.afterList = response.data.data.after

           this.max_blood_flow_volume = response.data.data.max_blood_flow_volume

           this.max_befor_systolic_blood_pressure = response.data.data.max_befor_systolic_blood_pressure

         this.min_befor_systolic_blood_pressure = response.data.data.min_befor_systolic_blood_pressure

         this.max_befor_diastolic_blood_pressure  = response.data.data.max_befor_diastolic_blood_pressure

         this.min_befor_diastolic_blood_pressure = response.data.data.min_befor_diastolic_blood_pressure


         this.max_after_systolic_blood_pressure = response.data.data.max_after_systolic_blood_pressure

         this.min_after_systolic_blood_pressure = response.data.data.min_after_systolic_blood_pressure

         this.max_after_diastolic_blood_pressure = response.data.data.max_after_diastolic_blood_pressure


         this.min_after_diastolic_blood_pressure = response.data.data.min_after_diastolic_blood_pressure

         this.max_monitor_systolic_blood_pressure = response.data.data.max_monitor_systolic_blood_pressure


         this.min_monitor_systolic_blood_pressure = response.data.data.min_monitor_systolic_blood_pressure


         this.max_monitor_diastolic_blood_pressure = response.data.data.max_monitor_diastolic_blood_pressure


         this.min_monitor_diastolic_blood_pressure = response.data.data.min_monitor_diastolic_blood_pressure


         this.lastDryWeight = response.data.data.lastDryWeight

         this.patientVascularAccess = response.data.data.patientVascularAccess

         this.lastBefor = response.data.data.lastBefor


         var hd_total =0
      var hdArr =[]
      var hdf_total =0
      var hdfArr=[]
      var hdhp_total = 0
      var hdhpArr = []
      var hp_total = 0
      var hpArr= []
      var hf_total = 0
      var hfArr = []
      var scuf_total =0
      var scufArr = []
      var iuf_total =0
      var iufArr = []
      var hfhd_total =0
      var hfhdArr = []

      var hfhdhp_total =0
      var hfhdhpArr = []

      var phf_total =0
      var phfArr = []


      var hdfhp_total =0
      var hdfhpArr = []
      var crrt_total =0
      var crrtArr = []
      var iufhd_total =0
      var iufhdArr = []
      var uf_total =0
      var ufArr = []
      var hdjia_total =0
      var hdjiaArr = []
      var ihdf_total =0
      var ihdfArr = []
      var hdgaotong_total =0
      var hdgaotongArr = []
      var cvvh_total =0
      var cvvhArr = []

      var cvvhd_total =0
      var cvvhdArr = []

      var cvvhdf_total =0
      var cvvhdfArr = []
      var petotal =0
      var peArr=[]
      var hpdtotal =0
      var hpdArr=[]

      var hdptotal=0
      var hdpArr =[]

      var hfdtotal=0
      var hfdArr =[]

      var hdf100total=0
      var hdf100Arr =[]

      var hdf600total=0
      var hdf600Arr =[]

      var hdf100total=0
      var hdf100Arr =[]

      var hdf800total=0
      var hdf800Arr =[]

      var hdf1000total=0
      var hdf1000Arr =[]

      var hdf80total=0
      var hdf80Arr =[]

      var hf16total=0
      var hf16Arr =[]

      var hdwugantotal=0
      var hdwuganArr =[]

      var hdf17total=0
      var hdf17Arr =[]

      var hddiantotal=0
      var hddianArr =[]


      var hd2total=0
      var hd2Arr =[]

      var total_count = 0

      var total_min = 0
      var total_hour = 0
      var total_hour_str =""

      var dialyzerPerfusionApparatus = []
      var dialyzerArr = []
      var dialysisStrainerArr = []
      var dialysisIrrigationArr = []

      var kaliumArr= []
      var sodiumArr= []
      var calciumArr= []
      var bicarbonateArr = []
      var prescriptionSodiumArr = []

      if(this.dialysisOrderList!=null&&this.dialysisOrderList.length>0){
          total_count = this.dialysisOrderList.length
      }
      total_count = this.dialysisOrderList.length

     if(this.prescription!=null && this.prescription.length>0){
         for(let i=0;i< this.prescription.length;i++){
          if( this.prescription[i].dialyzer_perfusion_apparatus!=""){
              dialyzerPerfusionApparatus.push( this.prescription[i].dialyzer_perfusion_apparatus)
            }
              if(this.prescription[i].dialysis_dialyszers!=""){
              dialyzerArr.push( this.prescription[i].dialysis_dialyszers)
              }
              if(this.prescription[i].dialysis_strainer!=""){
              dialysisStrainerArr.push( this.prescription[i].dialysis_strainer)
              }
              if(this.prescription[i].dialysis_irrigation!=""){
              dialysisIrrigationArr.push( this.prescription[i].dialysis_irrigation)
              }
              if( this.prescription[i].kalium!=""){
                kaliumArr.push(this.prescription[i].kalium)
              }
              if( this.prescription[i].sodium!=""){
                sodiumArr.push(this.prescription[i].kalium)
              }
              if( this.prescription[i].calcium!=""){
              calciumArr.push(this.prescription[i].calcium)
              }
              if( this.prescription[i].bicarbonate!=""){
                bicarbonateArr.push(this.prescription[i].bicarbonate)
              }
              if( this.prescription[i].prescription_sodium!=""){
              prescriptionSodiumArr.push(this.prescription[i].prescription_sodium)
              }

              total_min +=  parseInt(this.prescription[i].dialysis_duration_hour *60)+ parseInt(this.prescription[i].dialysis_duration_minute)

              if(this.prescription[i].mode_id == 1){
                  hdArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 2){
                hdfArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 3){
                hdhpArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 4){
                  hpArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 5){
                  hfArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 6){
                  scufArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 7){
                  iufArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 8){
                  hfhdArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 9){
                  hfhdhpArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 10){
                  phfArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 11){
                  hfArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 12){
                hdfhpArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 13){
                crrtArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 19){
                iufhdArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 20){
                ufArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 21){
                hdjiaArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 24){
                ihdfArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 25){
                hdgaotongArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 26){
                cvvhArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 27){
                cvvhdArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 28){
                cvvhdfArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 29){
                peArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 31){
                hpdArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 32){
                hdpArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 33){
                hfdArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 34){
                hdf100Arr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 35){
                hdf600Arr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 36){
                hdf800Arr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 37){
                hdf1000Arr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 38){
                hdf80Arr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 39){
                hf16Arr.push(this.prescription[i])
              }
              console.log("hf16Arr--------------------",hf16Arr)
              if(this.prescription[i].mode_id == 40){
                hdwuganArr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 41){
                hdf17Arr.push(this.prescription[i])
              }
              if(this.prescription[i].mode_id == 42){
                hddianArr.push(this.prescription[i])
              }
              if( this.prescription[i].mode_id == 43){
                hd2Arr.push(thisprescription[i])
              }

            }
       }

        total_hour = ((total_min/60)/total_count).toFixed(2)
        total_hour_str = total_hour +"小时/次"

        hd_total = hdArr.length

        var hd_str = ""
        if(hd_total>0){
            hd_str = "HD"+ "("+hd_total+")" +"次"
        }

        hdf_total = hdfArr.length

        var hdf_str =""
        if(hdf_total>0){
          hdf_str = "HDF"+ "（"+hd_total+")" +"次"
        }

        hdhp_total = hdhpArr.length
        var hdhp_str =""
        if(hdhp_total>0){
          hdhp_str = "HD+HP"+"("+ hdhp_total+")"+"次"
        }
        hp_total = hpArr.length
        var  hp_str= ""
        if(hp_total>0){
          hp_str = "HP"+"("+hdptotal+")"+"次"
        }

        hf_total = hfArr.length
        var hf_str = ""
        if(hf_total>0){
          hf_str = "HF "+"("+hf_total+")"+"次"
        }
        var scuf_str = ""
        scuf_total = scufArr.length
        if(scuf_total>0){
          scuf_str = "SCUF"+"("+scuf_total+")"+"次"
        }
        iuf_total = iufArr.length
        var iuf_str= ""
        if(iuf_total>0){
          iuf_str = "IUF"+"("+iuf_total+")"+"次"
        }
        hfhd_total = hfhdArr.length
        var hfhd_str= ""
        if(hfhd_total>0){
          hfhd_str = "HFHD"+"("+hfhd_total+")"+"次"
        }

        hfhdhp_total = hfhdhpArr.length
        var hfhdhp_str =""
        if(hfhdhp_total>0){
          hfhdhp_str = "HFHD+HP"+"("+hfhdhp_total+")"+"次"
        }
        phf_total = phfArr.length
        var phf_str= ""
        if(phf_total>0){
          phf_str = "PHF"+ "(" +phf_total+")" + "次"
        }
        hdfhp_total = hdfhpArr.length
        var hdfhp_str =""
        if(hdfhp_total>0){
          hdfhp_str = "HDFHP"+ "("+ hdfhp_total+")"+"次"
        }
        crrt_total = crrtArr.length
        var crrt_str =""
        if(crrt_total>0){
          crrt_str = "CRRT"+"("+crrt_total+")"+"次"
        }
        iuf_total = iufhdArr.length
        var iuf_str = ""
        if(iuf_total>0){
            iuf_str = "IUF"+"("+iuf_total+")"+"次"
        }
        uf_total = ufArr.length
        var uf_str= ""
        if(uf_total>0){
            uf_str = "UF"+"("+uf_total+")" +"次"
        }

        hdjia_total = hdjiaArr.length
        var hdjia_str =""
        if(hdjia_total>0){
            hdjia_str = "HD+"+"("+hdjia_total+")"+"次"
        }

        ihdf_total = ihdfArr.length
        var ihdf_str = ""
        if(ihdf_total>0){
          ihdf_str = "IHDF"+"("+ihdf_total+")" +"次"
        }
        hdgaotong_total = hdgaotongArr
        var hdgaotong_str = ""
        if(hdgaotong_total>0){
          hdgaotong_str = "HD高通"+"("+hdgaotong_total+")"+"次"
        }
        cvvh_total = cvvhArr.length
        var cvvh_str =""
        if(cvvh_total>0){
          cvvh_str = "CVVH"+"("+cvvh_total+")" + "次"
        }
        cvvhd_total = cvvhdArr.length
        var cvvhd_str = ""
        if(cvvhd_total>0){
          cvvhd_str = "CVVHD"+"("+cvvhd_total+")"+"次"
        }
        cvvhdf_total =cvvhdfArr.length
        var cvvhdf_str = ""
        if(cvvhdf_total>0){
          cvvhdf_str="CVVHDF"+"("+cvvhdf_total+")"+"次"
        }
        petotal = peArr.length
        var pe_str =""
        if(petotal>0){
          pe_str = "PE"+"("+petotal+")"+"次"
        }
        hpdtotal = hpdArr.length
        var hpd_str =""
        if(hpdtotal>0){
            hpd_str = "HDP"+"("+hpdtotal+")"+"次"
        }
        hfdtotal = hfdArr.length
        var hfd_str =""
        if(hfdtotal>0){
            hfd_str ="HFD"+"("+hfdtotal+")" +"次"
        }
        hdf100total = hdf1000Arr.length
        var hdf100str = ""
        if(hdf100total>0){
          hdf100str = "HDF100"+"("+hdf100total+")"+"次"
        }
        hdf600total = hdf600Arr.length
        var hdf600str = ""
        if(hdf600total>0){
            hdf600str = "HDF600"+"("+hdf600tota+")"+"次"
        }
        hdf100total = hdf1000Arr.length
        var hdf1000str = ""
        if(hdf100total>0){
          hdf1000str = "HDF1000"+"("+hdf100total+")"+"次"
        }
        hdf80total = hdf80Arr.length
        var hdf80str = ""
        if(hdf80total>0){
          hdf80str ="HDF80"+"("+hdf80str+")" +"次"
        }
        hf16total = hf16Arr.length
        var hf16str = ""
        if(hf16total>0){
          hf16str = "HF16"+"("+ hf16total +")"+"次"
        }
        hdwugantotal = hdwuganArr.length
        var hdwuganstr = ""
        if(hdwugantotal>0){
          hdwuganstr = "HD无肝素"+"("+hdwugantotal+")"+"次"
        }
        hdf17total = hdf17Arr.length
        var hdf17str = ""
        if(hdf17total>0){
          hdf17str = "HDF17"+"("+hdf17total+")" + "次"
        }
        hddiantotal = hddianArr.length
        var hddianstr = ""
        if(hddiantotal>0){
          hddianstr = "HD."+"("+hddiantotal+")" + "次"
        }
        var hd2str = ""
        hd2total = hd2Arr.length
        if(hd2total>0){
          hd2str = "HD2"+"("+hd2total+")"+"次"
        }

        let dialyzerPerfusionApparatusObj={}
        let dialyzerPerfusionApparatusStr = ""

        let dialyzerArrObj = {}
        let dialyzer_str = ""

        let dialysisStrainerObj = {}
        let dialysisStrainerStr = ""

        let dialysisIrrigationObj = {}
        let dialysisIrrigationStr = ""

        let kaliumObj = {}
        let kaliumStr =""
        let kalium =""

        if(kaliumArr!=null && kaliumArr.length>0){
            kaliumArr.forEach(item => {
            kaliumObj[item] = (kaliumObj[item] + 1) || 1
          })
        }

        if(kaliumObj!=""){
          kaliumStr = JSON.stringify(kaliumObj).replace(/^{|}$/g, '')
        }

        if(kaliumStr!=""){
          var str = kaliumStr.split(":")[0]
          kalium = "钾:" + str.replace(/^"(.*)"$/, '$1')+"."+"0"+"mmol/L" + "(" +kaliumStr.split(":")[1]+")"
        }

          let sodiumObj = {}
          let sodiumStr =""

          let sodium = ""


          if(sodiumArr!=null && sodiumArr.length>0){
            sodiumArr.forEach(item => {
              sodiumObj[item] = (sodiumObj[item] + 1) || 1
            })
          }

          if(sodiumObj!=""){
            sodiumStr = JSON.stringify(sodiumObj).replace(/^{|}$/g, '')
          }

          if(sodiumStr!=""){
            var str = sodiumStr.split(":")[0]
            sodium = "钠:" + str.replace(/^"(.*)"$/, '$1')+"mmol/L" + "(" +sodiumStr.split(":")[1]+")"
          }

          let calciumObj = {}
          let calciumStr =""
          let calcium  =""

          if(calciumArr!=null && calciumArr.length>0){
            calciumArr.forEach(item => {
              calciumObj[item] = (calciumObj[item] + 1) || 1
            })
          }

          if(calciumObj!=""){
            calciumStr = JSON.stringify(calciumObj).replace(/^{|}$/g, '')
          }

          if(calciumStr!=""){
              var str = calciumStr.split(":")[0]
              calcium = "钙:" + str.replace(/^"(.*)"$/, '$1')+"mmol/L" + "(" +calciumStr.split(":")[1]+")"
          }

          let bicarbonateObj = {}
          let bicarbonateStr =""
          let bicarbonate = ""

          if(bicarbonateArr!=null && bicarbonateArr.length>0){
            bicarbonateArr.forEach(item => {
              bicarbonateObj[item] = (bicarbonateObj[item] + 1) || 1
            })
          }

          if(bicarbonateObj!=""){

            bicarbonateStr = JSON.stringify(bicarbonateObj).replace(/^{|}$/g, '')
          }

          if(bicarbonateStr!=""){
              var str = bicarbonateStr.split(":")[0]
              bicarbonate = "碳酸氢根:" + str.replace(/^"(.*)"$/, '$1')+"mmol/L" + "(" +bicarbonateStr.split(":")[1]+")"

          }

          if(dialyzerPerfusionApparatus!=null && dialyzerPerfusionApparatus.length>0){
            dialyzerPerfusionApparatus.forEach(item => {
              dialyzerPerfusionApparatusObj[item] = (dialyzerPerfusionApparatusObj[item] + 1) || 1
            })
          }

          if(dialyzerPerfusionApparatus!=null && dialyzerPerfusionApparatus.length>0){
            dialyzerPerfusionApparatus.forEach(item => {
              dialyzerPerfusionApparatusObj[item] = (dialyzerPerfusionApparatusObj[item] + 1) || 1
            })
          }

          if(dialyzerPerfusionApparatusObj!=""){
            dialyzerPerfusionApparatusStr = JSON.stringify(dialyzerPerfusionApparatusObj).replace(/^{|}$/g, '')
          }

          if(dialyzerArr!=null && dialyzerArr.length>0){
            dialyzerArr.forEach(item => {
              dialyzerArrObj[item] = (dialyzerArrObj[item] + 1) || 1
            })
          }

          dialyzer_str = JSON.stringify(dialyzerArrObj).replace(/^{|}$/g, '')


          if(dialysisStrainerArr!=null && dialysisStrainerArr.length>0){
              dialysisStrainerArr.forEach(item => {
              dialysisStrainerObj[item] = (dialysisStrainerObj[item] + 1) || 1
            })
          }

          dialysisStrainerStr =  JSON.stringify(dialysisStrainerObj).replace(/^{|}$/g, '')


          if(dialysisIrrigationArr!=null && dialysisIrrigationArr.length>0){
            dialysisIrrigationArr.forEach(item => {
              dialysisIrrigationObj[item] = (dialysisIrrigationObj[item] + 1) || 1
            })
          }

          dialysisIrrigationStr =  JSON.stringify(dialysisIrrigationObj).replace(/^{|}$/g, '')

        //  医嘱
        if(this.longAdvice!=null && this.longAdvice.length>0){
            for(let i=0;i<this.longAdvice.length;i++){
                this.longAdvice[i].advice_type_name = ""
                if(this.longAdvice[i].advice_type == 1){
                  this.longAdvice[i].advice_type_name = "长期医嘱"
                }
                if(this.longAdvice[i].advice_type == 2){
                  this.longAdvice[i].advice_type_name = "长期医嘱"
                }
                if(this.longAdvice[i].stop_state == 1){
                  this.longAdvice[i].stop_state_name = "停用"
                }
                if(this.longAdvice[i].stop_state == 2){
                  this.longAdvice[i].stop_state_name = "未停用"
                }
            }
        }

        //抗凝剂

        var anticoagulant_str =""
        if(this.groupPrescriptionList!=null && this.groupPrescriptionList.length>0){

            for(let i=0;i<this.groupPrescriptionList.length;i++){
               anticoagulant_str += this.getAnticoagulantName(this.groupPrescriptionList[i].anticoagulant) +"," + "剂量:" +this.groupPrescriptionList[i].MinZongLiang +this.getAnticoagulantUnit(this.groupPrescriptionList[i].anticoagulant)+ "~" +this.groupPrescriptionList[i].MaxZongLiang + this.getAnticoagulantUnit(this.groupPrescriptionList[i].anticoagulant)
            }
        }


          //透前
          var befor_total =0
        var cha_weight = 0
        var befor_weight =0
        var after_weight =0
        var pingjun_weight = 0
        if(this.berforList!=null){
          befor_total = this.berforList.length
          for(let i=0;i<this.berforList.length;i++){
            //  cha_weight += this.berforList[i].weight_before - this.berforList[i].WeightAfter
            befor_weight +=this.berforList[i].weight_before
            after_weight += this.berforList[i].WeightAfter
          }
        }
        console.log("befor-weight",befor_weight)
        console.log("after_weight",after_weight)
        

        pingjun_weight = ((befor_weight-after_weight)/befor_total).toFixed(2)

        //透后凝血
        var cruorNewArr = []
        if(this.afterList!=null && this.afterList.length>0){
           for(let i=0;i<this.afterList.length;i++){
            cruorNewArr.push(this.afterList[i].cruor)
           }
        }

       let dialysisCrruorObj = {}
        let dialysisCrruorStr = ""
        if(cruorNewArr!=null && cruorNewArr.length>0){
          cruorNewArr.forEach(item => {
            dialysisCrruorObj[item] = (dialysisCrruorObj[item] + 1) || 1
            })
          }


        dialysisCrruorStr =  JSON.stringify(dialysisCrruorObj).replace(/^{|}$/g, '')

        //监测
        var blood_flow_volume_total = 0
        var ultrafiltration_volume_total = 0
        var ultrafiltration_rate_total = 0
        var total_length = 0
        var pingjun_blood_flow_volume = 0
        var pingjun_ultrafiltration_volume_total = 0
        var pingjun_ultrafiltration_rate_total = 0
        if(this.monitorList!=null && this.monitorList.length>0){
          for(let i=0;i<this.monitorList.length;i++){
            blood_flow_volume_total+=this.monitorList[i].blood_flow_volume
            ultrafiltration_volume_total+=this.monitorList[i].ultrafiltration_volume
            ultrafiltration_rate_total += this.monitorList[i].ultrafiltration_rate
            total_length = this.monitorList.length
          }
        }
        pingjun_blood_flow_volume =  (blood_flow_volume_total/total_length).toFixed(2)
        if(pingjun_blood_flow_volume=="NaN"){
          pingjun_blood_flow_volume = ""
        }
        pingjun_ultrafiltration_volume_total = (ultrafiltration_volume_total/total_length).toFixed(2)
        if(pingjun_ultrafiltration_volume_total=="NaN"){
          pingjun_ultrafiltration_volume_total = ""
        }
        pingjun_ultrafiltration_rate_total = (ultrafiltration_rate_total/total_length).toFixed(2)
        if(pingjun_ultrafiltration_rate_total == "NaN"){
          pingjun_ultrafiltration_rate_total = ""
        }
        var dry_weight_str = ""
        //干体重
        if(this.dryweightList!=null && this.dryweightList.length>0){
           for(let i=0;i<this.dryweightList.length;i++){
            dry_weight_str =  this.getTimeOne(this.dryweightList[i].ctime)+" " +this.dryweightList[i].adjusted_value.slice(4,6)+ this.dryweightList[i].adjusted_value.slice(0,3)+"kg" + "调整到" +" "+ this.dryweightList[i].dry_weight+"kg"+","
           }
        }

        //血管通路
        var vascularAccess_str = ""
        var created_time = ""

        if(this.patientVascularAccess!=undefined){
          vascularAccess_str  = this.patientVascularAccess.blood_access_part_id + this.patientVascularAccess.blood_access_part_opera_id
          created_time  = this.getTime(this.patientVascularAccess.first_start_time)
        }

        //并发症
        var complication = ""
        if(this.lastBefor!=undefined){
            complication = this.lastBefor.complication
        }



        if(this.inpectionList!=null&& this.inpectionList.length>0){
           for(let i=0;i<this.inpectionList.length;i++){
            this.inpectionList[i].group_no = ""
             this.inpectionList[i].group_no = this.inpectionList[i].project_id.toString()+"_"+this.inpectionList[i].inspect_date.toString()
           }
        }


        if(this.inpectionList!=null && this.inpectionList.length>0){
          let dataInfo = {}
          this.inpectionList.forEach((item, index) => {
          let { group_no } = item
          if (!dataInfo[group_no]) {
            dataInfo[group_no] = {
              group_no:group_no,
              project_id:item.project_id,
              name:item.project_name,
              date:this.getTime(item.inspect_date),
              child:[],
              left: [],
              right:[]
            }
          }
        })
        let arr = Object.values(dataInfo)
        console.log("arr----------------------",arr)

        if(arr!=null && arr.length>0){
          for(let i=0;i<arr.length;i++){
            for(let j=0;j<this.inpectionList.length;j++){
              if(arr[i].group_no == this.inpectionList[j].group_no){
                  arr[i].child.push(this.inpectionList[j])
              }
            }
          }
        }

        for(let i=0;i<arr.length;i++){
          for(let j=0;j<arr[i].child.length;j++){
             if(j%2 ==0){
               arr[i].left.push(arr[i].child[j])
             }
             if(j%2 == 1){
              arr[i].right.push(arr[i].child[j])
             }
          }
        }

        this.Inspect = []
        this.Inspect = arr
        console.log("newarr----------------",arr)
       }
      //  const contents = `<table border="1" class="table" style="border-collapse: collapse;width: 100%;">
      //         <tr>
      //           <th colspan="2" style="padding: 5px;">透析阶段小结(${this.start_date}~${this.end_date})</th>
      //         </tr>
      //         <tr>
      //           <td width="130" style="padding: 5px;">基本信息</td>
      //           <td style="padding: 5px;">
      //             <span>姓名：${this.patient.name}</span>  <span>性别：${this.patient.gender_name}</span>  <span>年龄：${this.patient.age}</span>  <span>透析号：${this.patient.dialysis_no}</span>
      //           </td>
      //         </tr>
      //         <tr>
      //           <td style="align-items: center;padding: 5px;">透析处方</td>
      //           <td style='padding:5px'>
      //             <p style='font-weight: bold;'>总次数：${total_count}次 ；</p>
      //             <p>其中；${hd_str}${hdf_str}${hdhp_str}${hp_str}${hf_str}${scuf_str}${iuf_str}${hfhd_str}${hfhdhp_str}${phf_str}${hdfhp_str}${crrt_str}${iuf_str}${uf_str}${hdjia_str}${ihdf_str}${hdgaotong_str}${cvvhd_str}${pe_str}
      //               ${hpd_str}${hfd_str}${hdf100str}${hdf600str}${hdf1000str}${hdf80str}${hf16str}${hdwuganstr}${hdf17str}${hddianstr}${hd2str}</p>
      //             <p style='font-weight: bold;'>透析器：</p>
      //             <p>${dialyzerPerfusionApparatusStr}${dialyzer_str}${dialysisStrainerStr}${dialysisIrrigationStr}</p>
      //             <p style='font-weight: bold;'>透析液处方：</p>
      //             <p>${kalium}${sodium}${calcium}${bicarbonate}</p>
      //             <p style='font-weight: bold;'>抗凝方式：</p>
      //             <p >${anticoagulant_str}</p>
      //           </td>
      //         </tr>
      //         <tr>
      //           <td style="align-items: center;padding: 5px;">透析情况</td>
      //           <td style='padding:5px'>
      //             <p>透析间期平均体重增加：${pingjun_weight}kg；</p>
      //             <p>凝血：${dialysisCrruorStr}；</p>
      //             <p>平均血流量：${pingjun_blood_flow_volume}mL/min；最大血流量：${this.max_blood_flow_volume}mL/min；</p>
      //             <p>平均超滤量：${pingjun_ultrafiltration_volume_total}ml/次；平均超滤率：${pingjun_ultrafiltration_rate_total}mL/h；</p>
      //             <p><span style='font-weight: bold;'>透前血压：</span>&nbsp;<span class="">收缩压：${this.min_befor_systolic_blood_pressure}mmHg~${this.max_befor_systolic_blood_pressure}mmHg；舒张压：${this.min_befor_diastolic_blood_pressure}mmHg~${this.max_after_systolic_blood_pressure}mmHg；</span></p>
      //             <p><span style='font-weight: bold;'>透后血压：</span>&nbsp;<span class="">收缩压：${this.min_after_systolic_blood_pressure}mmHg~${this.max_after_systolic_blood_pressure}mmHg；舒张压：${this.min_after_diastolic_blood_pressure}~${this.max_after_diastolic_blood_pressure}mmHg；</span></p>
      //             <p><span style='font-weight: bold;'>透中最低血压：</span>&nbsp;<span class="">收缩压：${this.min_monitor_systolic_blood_pressure}mmHg~${this.max_monitor_systolic_blood_pressure}mmHg</span></p>
      //             <p><span style='font-weight: bold;'>透中最高血压：</span>&nbsp;<span class="">舒张压：${this.min_monitor_diastolic_blood_pressure}mmHg~${this.max_monitor_diastolic_blood_pressure}mmHg；</span></p>
      //           </td>
      //         </tr>
      //         <tr>
      //           <td style="align-items: center;padding: 5px;">干体重</td>
      //           <td style='padding: 5px;'>
      //             <p><span style='font-weight: bold;'>当前干体重：${this.berforList[this.berforList.length-1].dry_weight}</span>&nbsp;<span class="">kg;</span></p>
      //             <p><span style='font-weight: bold;'>调整记录：${dry_weight_str}</span>&nbsp;<span class=""></span></p>
      //           </td>
      //         </tr>
      //         <tr>
      //           <td style="align-items: center;padding: 5px;">血管通路</td>
      //           <td style='padding: 5px;'>
      //             <p><span style='font-weight: bold;'>使用的血管通路：${vascularAccess_str }</span>&nbsp;<span class=""> &nbsp;&nbsp;建立时间：${ created_time }</span></p>
      //           </td>
      //         </tr>
      //         <tr>
      //           <td style="align-items: center;padding: 5px;">合并症/并发症</td>
      //           <td style='padding: 5px;'>
      //             <p><span style='font-weight: bold;'>合并症：</span>&nbsp;<span class="">无</span></p>
      //             <p><span style='font-weight: bold;'>透析并发症：</span>&nbsp;<span class="">${complication}</span></p>
      //           </td>
      //         </tr>
      //         <tr>
      //           <td style="align-items: center;padding: 5px;">检查结果</td>
      //           <td style='padding: 5px;'><span class="">无</span></td>
      //         </tr>
      //         <tr>
      //           <td style="align-items: center;padding: 5px;">检验结果</td>
      //           <td></td>
      //         </tr>
      //         <tr>
      //           <td style="align-items: center;padding: 5px;">医嘱用药</td>
      //           <td  class='' style="padding: 0;">
      //             <p style="display: flex;text-align: center;border-bottom: 1px solid black;"><span style="width: 30%;display: inline-block;padding: 5px 0;border-right: 1px solid black;">药物名称</span><span style="width:20% ;display: inline-block;padding: 5px 0;border-right: 1px solid black;">医嘱类型</span><span style="width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;">开始时间</span><span style="width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;">单次用量</span><span style="width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;">执行频率</span><span style="width: 10%;padding: 5px 0;display: inline-block;">状态</span></p>
      //           </td>
      //         </tr>


      //         <tr>
      //           <td style="align-items: center;padding: 5px;">透析总评价和建议</td>
      //           <td style='padding: 5px;'>
      //             <p class="">1、血压控制不良，随时监测血压，并加用口服降压药，将血压控制在正常范围；</p>
      //             <p class="">2、透析间期体重增加稳定，继续保持；</p>
      //             <p class="">3、血液透析时血流量达标，注意保护内瘘避免狭窄；</p>
      //           </td>
      //         </tr>
      //         <tr>
      //           <td style="align-items: center;padding: 5px;">医师签名</td>
      //           <td style='padding: 5px;'>
      //             <p class=""></p>
      //           </td>
      //         </tr>
      //       </table>`
      const contents = `<table border="1" class="table" style="border-collapse: collapse;width: 100%;">
              <tr><th colspan="2" style="padding: 5px;">透析阶段小结(${this.start_date}~${this.end_date})</th></tr>
              <tr>
                <td width="130" style="padding: 5px;">基本信息</td>
                <td style="padding: 5px;">
                  <span>姓名：${this.patient.name}</span>  <span>性别：${this.patient.gender_name}</span>  <span>年龄：${this.patient.age}</span>  <span>透析号：${this.patient.dialysis_no}</span>
                </td>
              </tr>
              <tr>
                <td style="align-items: center;padding: 5px;">透析处方</td>
                <td style='padding:5px'>
                  <span style='font-weight: bold;'>总次数：${total_count}次 ；</span><br/><span>其中；${hd_str}${hdf_str}${hdhp_str}${hp_str}${hf_str}${scuf_str}${iuf_str}${hfhd_str}${hfhdhp_str}${phf_str}${hdfhp_str}${crrt_str}${iuf_str}${uf_str}${hdjia_str}${ihdf_str}${hdgaotong_str}${cvvhd_str}${pe_str}
${hpd_str}${hfd_str}${hdf100str}${hdf600str}${hdf1000str}${hdf80str}${hf16str}${hdwuganstr}${hdf17str}${hddianstr}${hd2str}</span><br/>
<span style='font-weight: bold;'>透析器：</span><br/><span>${dialyzerPerfusionApparatusStr}${dialyzer_str}${dialysisStrainerStr}${dialysisIrrigationStr}</span><br/>
<span style='font-weight: bold;'>透析液处方：</span><br/><span>${kalium}${sodium}${calcium}${bicarbonate}</span><br/><span style='font-weight: bold;'>抗凝方式：</span><br/><span >${anticoagulant_str}</span>
                </td>
              </tr>
              <tr>
                <td style="align-items: center;padding: 5px;">透析情况</td>
                <td style='padding:5px'>
                  <span>透析间期平均体重增加：${pingjun_weight}kg；</span><br/><span>凝血：${dialysisCrruorStr}；</span><br/>
<span>平均血流量：${pingjun_blood_flow_volume}mL/min；最大血流量：${this.max_blood_flow_volume}mL/min；</span><br/>
<span>平均超滤量：${pingjun_ultrafiltration_volume_total}ml/次；平均超滤率：${pingjun_ultrafiltration_rate_total}mL/h；</span><br/>
<span style='font-weight: bold;'>透前血压：</span>&nbsp;<span class="">收缩压：${this.min_befor_systolic_blood_pressure}mmHg~${this.max_befor_systolic_blood_pressure}mmHg；舒张压：${this.min_befor_diastolic_blood_pressure}mmHg~${this.max_after_systolic_blood_pressure}mmHg；</span><br/>
<span style='font-weight: bold;'>透后血压：</span>&nbsp;<span class="">收缩压：${this.min_after_systolic_blood_pressure}mmHg~${this.max_after_systolic_blood_pressure}mmHg；舒张压：${this.min_after_diastolic_blood_pressure}~${this.max_after_diastolic_blood_pressure}mmHg；</span><br/>
<span style='font-weight: bold;'>透中最低血压：</span>&nbsp;<span class="">收缩压：${this.min_monitor_systolic_blood_pressure}mmHg~${this.max_monitor_systolic_blood_pressure}mmHg</span><br/>
<span style='font-weight: bold;'>透中最高血压：</span>&nbsp;<span class="">舒张压：${this.min_monitor_diastolic_blood_pressure}mmHg~${this.max_monitor_diastolic_blood_pressure}mmHg；</span>
                </td>
              </tr>
              <tr>
                <td style="align-items: center;padding: 5px;">干体重</td>
                <td style='padding: 5px;'>
<span style='font-weight: bold;'>当前干体重：${this.berforList[this.berforList.length-1].dry_weight}</span>&nbsp;<span class="">kg;</span>
<span style='font-weight: bold;'>调整记录：${dry_weight_str}</span>&nbsp;<span class=""></span>
                </td>
              </tr>
              <tr>
                <td style="align-items: center;padding: 5px;">血管通路</td>
                <td style='padding: 5px;'>
<span style='font-weight: bold;'>使用的血管通路：${vascularAccess_str }</span>&nbsp;<span class=""> &nbsp;&nbsp;建立时间：${ created_time }</span>
                </td>
              </tr>
              <tr>
                <td style="align-items: center;padding: 5px;">合并症/并发症</td>
                <td style='padding: 5px;'>
<span style='font-weight: bold;'>合并症：</span>&nbsp;<span class="">无</span><br/>
<span style='font-weight: bold;'>透析并发症：</span>&nbsp;<span class="">${complication}</span>
                </td>
              </tr>
              <tr>
                <td style="align-items: center;padding: 5px;">检查结果</td>
                <td style='padding: 5px;'><span class="">无</span></td>
              </tr>
              <tr>
                <td style="align-items: center;padding: 5px;">检验结果</td>
                <td></td>
              </tr>
              <tr>
                <td style="align-items: center;padding: 5px;">医嘱用药</td>
                <td  class='' style="padding: 0;">
                  <p style="display: flex;text-align: center;border-bottom: 1px solid black;"><span style="width: 30%;display: inline-block;padding: 5px 0;border-right: 1px solid black;">药物名称</span><span style="width:20% ;display: inline-block;padding: 5px 0;border-right: 1px solid black;">医嘱类型</span><span style="width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;">开始时间</span><span style="width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;">单次用量</span><span style="width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;">执行频率</span><span style="width: 10%;padding: 5px 0;display: inline-block;">状态</span></p>
                </td>
              </tr>


              <tr>
                <td style="align-items: center;padding: 5px;">透析总评价和建议</td>
                <td style='padding: 5px;'>
<span class="">1、血压控制不良，随时监测血压，并加用口服降压药，将血压控制在正常范围；</span><br/><span class="">2、透析间期体重增加稳定，继续保持；</span><br/>
<span class="">3、血液透析时血流量达标，注意保护内瘘避免狭窄；</span>
                </td>
              </tr>
              <tr>
                <td style="align-items: center;padding: 5px;">医师签名</td>
                <td style='padding: 5px;'>
                  <p class=""></p>
                </td>
              </tr>
            </table>`
          
        this.textcontent = contents
        this.$nextTick(()=>{
          console.log('document.getElementById(editer)',document.getElementById('editer').getElementsByTagName('tbody')[0].children[9]);
          const iframeDoc = document.getElementById('editer').getElementsByTagName('tbody')[0].children[9].children[1]
          const jiancDoc = document.getElementById('editer').getElementsByTagName('tbody')[0].children[8].children[1]
          console.log('document.getElementById(editer)1111',iframeDoc,jiancDoc);
          if(this.Inspect.length<1){
            let newList = document.createElement('p');
            newList.style.cssText = 'padding: 5px;'
            newList.textContent = '无';
            jiancDoc.appendChild(newList)
          }else{
            let newList = document.createElement('p');
                newList.style.cssText='display: flex;text-align: center;border-bottom: 1px solid black;';
                let newListItem1 = document.createElement('span');
                newListItem1.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem2 = document.createElement('span');
                newListItem2.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem3 = document.createElement('span');
                newListItem3.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem4 = document.createElement('span');
                newListItem4.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem5 = document.createElement('span');
                newListItem5.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem6 = document.createElement('span');
                newListItem6.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;'
                newListItem1.textContent = '检验项目';
                newListItem2.textContent = '检验时间';
                newListItem3.textContent = '检验内容';
                newListItem4.textContent = '结果';
                newListItem5.textContent = '检验内容';
                newListItem6.textContent = '结果';
                newList.appendChild(newListItem1);
                newList.appendChild(newListItem2);
                newList.appendChild(newListItem3);
                newList.appendChild(newListItem4);
                newList.appendChild(newListItem5);
                newList.appendChild(newListItem6);
                jiancDoc.appendChild(newList)
            for(let i in this.Inspect){
              let newList1 = document.createElement('p');
              const child1 = document.createElement('span')
              const child2 = document.createElement('span')
              newList1.appendChild(child1);
              newList1.appendChild(child2);
              newList1.style.cssText='display: flex;text-align: center;border-bottom: 1px solid black;';
              child1.style.cssText= 'width: 40%;display: inline-block;border-right: 1px solid black;display: flex;'
              child2.style.cssText= 'width: 80%;display: inline-block;display: flex;flex-wrap: wrap;'
              // child3.style.cssText= 'width: 40%;display: inline-block;display: flex;flex-wrap: wrap;'

              let newListItem1 = document.createElement('span');
              newListItem1.style.cssText= 'flex:1;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
              let newListItem2 = document.createElement('span');
              newListItem2.style.cssText= 'flex:1;display: inline-block;padding: 5px 0;'
              newListItem1.textContent = this.Inspect[i].name;
              newListItem2.textContent = this.Inspect[i].date;
              child1.appendChild(newListItem1);
              child1.appendChild(newListItem2);
              for(let j in this.Inspect[i].left){
                let newListItem3 = document.createElement('span');
                newListItem3.style.cssText= 'border-bottom: 1px solid black;width:25%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem4 = document.createElement('span');
                newListItem4.style.cssText= 'border-bottom: 1px solid black;width:25%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                newListItem3.textContent = this.Inspect[i].left[j].item_name;
                newListItem4.textContent = this.Inspect[i].left[j].inspect_value;
                child2.appendChild(newListItem3);
                child2.appendChild(newListItem4);
              }
              for(let x in this.Inspect[i].right){
                let newListItem5 = document.createElement('span');
                newListItem5.style.cssText= 'width: 25%;display: inline-block;padding: 5px 0;border-right: 1px solid black;border-bottom: 1px solid black;'
                let newListItem6 = document.createElement('span');
                newListItem6.style.cssText= 'width: 25%;display: inline-block;padding: 5px 0;border-bottom: 1px solid black;border-right: 1px solid black;'
                newListItem5.textContent = this.Inspect[i].right[x].item_name;
                newListItem6.textContent = this.Inspect[i].right[x].inspect_value;
                child2.appendChild(newListItem5);
                child2.appendChild(newListItem6);

              }
              jiancDoc.appendChild(newList1)
            }
          }
          var newListArr =[]
          for(let j in this.longAdvice){
            const obj={
              id:this.longAdvice[j].id,
              newlist:'newList'+j
            }
            newListArr.push(obj)
          }
          for(let i in this.longAdvice){
            for(let j in newListArr){
              if(this.longAdvice[i].id==newListArr[j].id){
                let newList = document.createElement('p');
                newList.style.cssText='display: flex;text-align: center;border-bottom: 1px solid black;';
                let newListItem1 = document.createElement('span');
                newListItem1.style.cssText= 'width: 30%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem2 = document.createElement('span');
                newListItem2.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem3 = document.createElement('span');
                newListItem3.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem4 = document.createElement('span');
                newListItem4.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem5 = document.createElement('span');
                newListItem5.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem6 = document.createElement('span');
                newListItem6.style.cssText= 'width: 10%;display: inline-block;padding: 5px 0;'
                newListItem1.textContent = this.longAdvice[i].advice_name;
                newListItem2.textContent = this.longAdvice[i].advice_type_name;
                newListItem3.textContent = this.getTime(this.longAdvice[i].start_time)
                newListItem4.textContent = this.longAdvice[i].single_dose +this.longAdvice[i].single_dose_unit ;
                newListItem5.textContent = this.longAdvice[i].execution_frequency;
                newListItem6.textContent = this.longAdvice[i].stop_state_name;
                newList.appendChild(newListItem1);
                newList.appendChild(newListItem2);
                newList.appendChild(newListItem3);
                newList.appendChild(newListItem4);
                newList.appendChild(newListItem5);
                newList.appendChild(newListItem6);
                iframeDoc.appendChild(newList)
              }
            }
          }
        })
        this.new_content = this.textcontent
        this.$refs.editor.contents = this.new_content

        this.$nextTick(()=>{
          const iframeDoc1 = document.getElementsByClassName('edui-editor-iframeholder')[0].getElementsByTagName('iframe')[0].contentDocument.getElementsByTagName('tbody')[0].children[9].children[1]
          const jiancDoc1 = document.getElementsByClassName('edui-editor-iframeholder')[0].getElementsByTagName('iframe')[0].contentDocument.getElementsByTagName('tbody')[0].children[8].children[1]
          console.log('document.getElementById(editer)2222',jiancDoc1,iframeDoc1);
          jiancDoc1.getElementsByTagName('br')[0].remove()
          jiancDoc1.style.cssText='padding: 0'
            if(this.Inspect.length<1){
              let newList2 = document.createElement('p');
              newList2.style.cssText = 'padding: 5px;'
              newList2.textContent = '无';
              jiancDoc.appendChild(newList2)
            }else{
              let newList = document.createElement('p');
                  newList.style.cssText='display: flex;text-align: center;border-bottom: 1px solid black;';
                  let newListItem1 = document.createElement('span');
                  newListItem1.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                  let newListItem2 = document.createElement('span');
                  newListItem2.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                  let newListItem3 = document.createElement('span');
                  newListItem3.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                  let newListItem4 = document.createElement('span');
                  newListItem4.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                  let newListItem5 = document.createElement('span');
                  newListItem5.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                  let newListItem6 = document.createElement('span');
                  newListItem6.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;'
                  newListItem1.textContent = '检验项目';
                  newListItem2.textContent = '检验时间';
                  newListItem3.textContent = '检验内容';
                  newListItem4.textContent = '结果';
                  newListItem5.textContent = '检验内容';
                  newListItem6.textContent = '结果';
                  newList.appendChild(newListItem1);
                  newList.appendChild(newListItem2);
                  newList.appendChild(newListItem3);
                  newList.appendChild(newListItem4);
                  newList.appendChild(newListItem5);
                  newList.appendChild(newListItem6);
                  jiancDoc1.appendChild(newList)
              for(let i in this.Inspect){
                let newList1 = document.createElement('p');
                const child1 = document.createElement('span')
                const child2 = document.createElement('span')
                // const child3 = document.createElement('span')
                newList1.appendChild(child1);
                newList1.appendChild(child2);
                // newList1.appendChild(child3);
                newList1.style.cssText='display: flex;text-align: center;border-bottom: 1px solid black;';
                child1.style.cssText= 'width: 40%;display: inline-block;border-right: 1px solid black;display: flex;'
                child2.style.cssText= 'width: 80%;display: inline-block;display: flex;flex-wrap: wrap;'

                let newListItem1 = document.createElement('span');
                newListItem1.style.cssText= 'flex:1;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem2 = document.createElement('span');
                newListItem2.style.cssText= 'flex:1;display: inline-block;padding: 5px 0;'
                newListItem1.textContent = this.Inspect[i].name;
                newListItem2.textContent = this.Inspect[i].date;
                child1.appendChild(newListItem1);
                child1.appendChild(newListItem2);
                for(let j in this.Inspect[i].left){
                  let newListItem3 = document.createElement('span');
                  newListItem3.style.cssText= 'border-bottom: 1px solid black;width:25%;box-sizing: border-box;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                  let newListItem4 = document.createElement('span');
                  newListItem4.style.cssText= 'border-bottom: 1px solid black;width:25%;box-sizing: border-box;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                  newListItem3.textContent = this.Inspect[i].left[j].item_name;
                  newListItem4.textContent = this.Inspect[i].left[j].inspect_value;
                  child2.appendChild(newListItem3);
                  child2.appendChild(newListItem4);
                }
                for(let x in this.Inspect[i].right){
                  let newListItem5 = document.createElement('span');
                  newListItem5.style.cssText= 'width: 25%;box-sizing: border-box;display: inline-block;padding: 5px 0;border-right: 1px solid black;border-bottom: 1px solid black;'
                  let newListItem6 = document.createElement('span');
                  newListItem6.style.cssText= 'width: 25%;box-sizing: border-box;display: inline-block;padding: 5px 0;border-bottom: 1px solid black;border-right: 1px solid black;'
                  newListItem5.textContent = this.Inspect[i].right[x].item_name;
                  newListItem6.textContent = this.Inspect[i].right[x].inspect_value;
                  child2.appendChild(newListItem5);
                  child2.appendChild(newListItem6);
                }
                jiancDoc1.appendChild(newList1)
              }
            }

          var newListArr2 =[]
          for(let j in this.longAdvice){
            const obj={
              id:this.longAdvice[j].id,
              newlist:'newList'+j
            }
            newListArr2.push(obj)
          }
          for(let i in this.longAdvice){
            for(let j in newListArr2){
              if(this.longAdvice[i].id==newListArr2[j].id){
                let newList = document.createElement('p');
                newList.style.cssText='display: flex;text-align: center;border-bottom: 1px solid black;';
                let newListItem1 = document.createElement('span');
                newListItem1.style.cssText= 'width: 30%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem2 = document.createElement('span');
                newListItem2.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem3 = document.createElement('span');
                newListItem3.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem4 = document.createElement('span');
                newListItem4.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem5 = document.createElement('span');
                newListItem5.style.cssText= 'width: 20%;display: inline-block;padding: 5px 0;border-right: 1px solid black;'
                let newListItem6 = document.createElement('span');
                newListItem6.style.cssText= 'width: 10%;display: inline-block;padding: 5px 0;'
                newListItem1.textContent = this.longAdvice[i].advice_name;
                newListItem2.textContent = this.longAdvice[i].advice_type_name;
                newListItem3.textContent = this.getTime(this.longAdvice[i].created_time)
                newListItem4.textContent = this.longAdvice[i].single_dose +this.longAdvice[i].single_dose_unit ;
                newListItem5.textContent = this.longAdvice[i].execution_frequency;
                newListItem6.textContent = this.longAdvice[i].stop_state_name;
                newList.appendChild(newListItem1);
                newList.appendChild(newListItem2);
                newList.appendChild(newListItem3);
                newList.appendChild(newListItem4);
                newList.appendChild(newListItem5);
                newList.appendChild(newListItem6);
                iframeDoc1.appendChild(newList)
              }
            }
          }
        })
         this.AuToShow = true
         console.log('document.getElementById(editer)1111',this.new_content);
       }
       })
      },
      blood_chang(val){
        if(val == 1){
          this.start_date1 = this.getTime(new Date())
          this.end_date1 = this.getTime(new Date())
        }else if (val == 2){
          this.start_date1 = this.timeForMat(7)
          this.end_date1 = this.getTime(new Date())
        }else if (val == 3){
          this.start_date1 = this.timeForMat(30)
          this.end_date1 = this.getTime(new Date())
        }else if (val == 4){
          this.start_date1 = this.getFirstDayOfWeek(new Date())
          this.end_date1 = this.getTime(new Date())
        }else if (val == 5){
          this.getlastweek(new Date())
        }else if (val == 6){
          this.start_date1 = this.getFirstDayOfMonth(new Date())
          this.end_date1 = this.getTime(new Date())
        }else if (val == 7){
          this.start_date1 = this.getLastMonthFirstDay()
          this.end_date1 = this.getLastMonthLastDay()
        }else if (val == 8){
          this.start_date1 = this.getquarterstart(0,1)
          this.end_date1 = this.getquarterend(2,31)
        }else if (val == 9){
          this.start_date1 = this.getquarterstart(3,1)
          this.end_date1 = this.getquarterend(5,30)
        }else if (val == 10){
          this.start_date1 = this.getquarterstart(6,1)
          this.end_date1 = this.getquarterend(8,30)
        }else if (val == 11){
          this.start_date1 = this.getquarterstart(9,1)
          this.end_date1 = this.getquarterend(11,31)
        }else if (val == 12){
          this.start_date1 = this.getquarterstart(0,1)
          this.end_date1 = this.getquarterend(5,30)
        }else if (val == 13){
          this.start_date1 = this.getquarterstart(6,1)
          this.end_date1 = this.getquarterend(11,31)
        }else if (val == 14){
          this.start_date1 = this.getFirstDayOfYear(new Date())
          this.end_date1 = this.getTime(new Date())
        }else if (val == 15){
          this.start_date1 = this.getLastYearFirstDay()
          this.end_date1 = this.getLastYearLastDay()
        }else{
          this.start_date1 = this.getPreviousDate(7)
          this.end_date1 = this.getTime(new Date())
        }
      },
      // 最近七,30天
      timeForMat(count) {
        // 拼接时间
        const time1 = new Date()
        const time2 = new Date()
        if (count === 1) {
          time1.setTime(time1.getTime() - (24 * 60 * 60 * 1000))
        } else {
          time1.setTime(time1.getTime())
        }

        const Y1 = time1.getFullYear()
        const M1 = ((time1.getMonth() + 1) > 9 ? (time1.getMonth() + 1) : '0' + (time1.getMonth() + 1))
        const D1 = (time1.getDate() > 9 ? time1.getDate() : '0' + time1.getDate())
        const timer1 = Y1 + '-' + M1 + '-' + D1 + ' ' + '23:59:59' // 当前时间

        time2.setTime(time2.getTime() - (24 * 60 * 60 * 1000 * count))
        const Y2 = time2.getFullYear()
        const M2 = ((time2.getMonth() + 1) > 9 ? (time2.getMonth() + 1) : '0' + (time2.getMonth() + 1))
        const D2 = (time2.getDate() > 9 ? time2.getDate() : '0' + time2.getDate())
        const timer2 = Y2 + '-' + M2 + '-' + D2  // 之前的7天或者30天
        console.log('timer2, timer1',timer2, timer1);
        return timer2
      },
      // 本周
      getFirstDayOfWeek(date){
        var weekday = date.getDay()
        date.setDate(date.getDate()-weekday+1);//往前算（weekday-1）天，年份、月份会自动变化
        return this.timeFormat(date);
      },
      // 上周
      getlastweek(date){
        date.setDate(date.getDate()-7 - date.getDay() + 1);
        var m =''
        var d = ''
        if(date.getMonth() + 1<10){
          m = '0'+(date.getMonth() + 1)
        }else{
            m = date.getMonth() + 1
        }
        if(date.getDate()<10){
            d = '0'+date.getDate()
        }else{
          d = date.getDate()
        }
        // this.start_date = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() ;
        this.start_date = date.getFullYear() + "-" + m + "-" + d ;
        this.start_date1 = date.getFullYear() + "-" + m + "-" + d ;
        date.setDate(date.getDate() +6);
        var mm = ''
        var dd = ''
        if(date.getMonth() + 1<10){
          mm = '0'+(date.getMonth() + 1)
        }else{
          mm = date.getMonth() + 1
        }
        if(date.getDate()<10){
          dd = '0'+date.getDate()
        }else{
          dd = date.getDate()
        }
        this.end_date = date.getFullYear() + "-" + mm + "-" + dd ;
        this.end_date1 = date.getFullYear() + "-" + mm + "-" + dd ;
      },
      // 本月
      getFirstDayOfMonth (date) {
        date.setDate(1);
        return this.timeFormat(date);
      },
       //上个月第一天
      getLastMonthFirstDay() {
          var date = new Date();
          date.setDate(0);
          var y = date.getFullYear(); //获取年份
          var m = date.getMonth() + 1; //获取月份
          m = m < 10 ? "0" + m : m;
          // this.start_date = [y, m, '01'].join("-")
          return [y, m, '01'].join("-");
      },
      // 上个月最后一天
      getLastMonthLastDay() {
          var date = new Date();
          date.setDate(0);
          var y = date.getFullYear(); //获取年份
          var m = date.getMonth() + 1; //获取月份
          var d = new Date(y, m, 0).getDate(); //获取当月最后一日
          m = m < 10 ? "0" + m : m; //月份补 0
          d = d < 10 ? "0" + d : d; //日数补 0
          // this.end_date = [y, m, d].join("-")
          return [y, m, d].join("-");
      },
      // 本年
      getFirstDayOfYear (date) {
        date.setDate(1);
        date.setMonth(0);
        return this.timeFormat(date);
      },
      // 上一年第一天
      getLastYearFirstDay() {
          let date = new Date();
         const year= date.setFullYear(date.getFullYear() - 1); // 设置年份为前一年
         const start_month= date.setMonth(0); // 设置月份为1月（注意月份是从0开始的）
         const start_day = date.setDate(1); // 设置日期为1日
        //  const last_month = date.setMonth(11); // 设置月份为12月
        //  const last_day = date.setDate(0); // 设置日期为0，这将自动设置为该月的最后一天
        //  this.start_date = year+ "-" +start_month+ "-" +start_day
        //  this.start_date = this.getTime(start_day)
         return this.getTime(start_day)
      },
      // 上一年最后一天
      getLastYearLastDay() {
          let date = new Date();
          const year= date.setFullYear(date.getFullYear() - 1); // 设置年份为前一年
          const last_month = date.setMonth(12); // 设置月份为12月
          const last_day = date.setDate(0);// 设置日期为0，这将自动设置为该月的最后一天
          // this.end_date =  year+ "-" +last_month+ "-" +last_day
          // this.end_date = this.getTime(last_day)
          console.log('this.end_date',this.end_date);
          return this.getTime(last_day)
      },
      // 季度第一天
      getquarterstart(index,number){
        const currentYear = new Date().getFullYear();
        const Start = this.timeFormat(new Date(currentYear, index, number));
        return Start
      },
      // 季度最后一天
      getquarterend(index,number){
        const currentYear = new Date().getFullYear();
        const End = this.timeFormat(new Date(currentYear, index, number));
        return End
      },

      // 日期格式化
      timeFormat(date) {
          if (!date || typeof(date) === "string") {
            this.error("参数异常，请检查...");
          }
          var y = date.getFullYear(); //年
          if(date.getMonth() + 1<10){
            var m ='0'+(date.getMonth() + 1); //月
          }else{
            var m =date.getMonth() + 1; //月
          }
          if(date.getDate()<10){
            var d ='0'+date.getDate(); //日
          }else{
            var d = date.getDate(); //日
          }
          // var d = date.getDate(); //日

          return y + "-" + m + "-" + d;
      },

      requestCourseRecords: function() {
        this.loading = true
        getCourseOfDiseaseRecords(this.patient_id, this.start_time, this.end_time).then(rs => {
          this.loading = false
          var resp = rs.data
          if (resp.state == 1) {
            this.current_select_record = null
            this.records = resp.data.records
            console.log("records232322332323232323223",this.records)
            this.doctors = resp.data.doctors

          } else {
            this.$message.error(resp.msg)
          }
        }).catch(error => {
          this.loading = false
          this.$message.error(error)
        })
      },

      didChangeCurrentRecord: function(record) {
        this.current_select_record = record
      },
      recordTime: function(timestamp) {
        var time = new Date(timestamp * 1000)
        return parseTime(time, '{y}-{m}-{d} {h}:{i}:{s}')
      },
      doctorName: function(doctor_id) {
        for (let index = 0; index < this.doctors.length; index++) {
          const doctor = this.doctors[index]
          if (doctor.id == doctor_id) {
            return doctor.name
          }
        }
        return ''
      },
      modifyAction: function() {

        this.edit_new_content = this.$refs.edit_neditor.content
        if (this.edit_new_content.length == 0) {
          this.$message.error('请填写病程内容')
          return
        }
        this.uploading_new_record = true
        modifyCourseOfDiseaseRecord(this.patient_id, this.edit_new_content, this.edit_course_of_disease_time, this.edit_current_id, this.edit_title).then(rs => {
          this.uploading_new_record = false
          var resp = rs.data
          if (resp.state == 1) {
            this.records[this.table_current_index].content = resp.data.record.content
            this.records[this.table_current_index].record_time = resp.data.record.record_time
            this.records[this.table_current_index].recorder = resp.data.record.recorder
            this.records[this.table_current_index].title = resp.data.record.title

            this.show_edit_dialog = false
            this.edit_new_content = ''
            this.table_current_index = -1

          } else {
            this.table_current_index = -1
            this.$message.error(resp.msg)
          }

        }).catch(error => {
          this.table_current_index = -1
          this.uploading_new_record = false
          this.$message.error(error)
        })

      },

      getAutoPatientContent(){
        if(this.start_date == ""){
          this.$message.error("请选择开始时间")
        }
        if(this.end_date == ""){
          this.$message.error("请选择结束时间")
        }
        var params = {
          start_time:this.start_date,
          end_time:this.end_date,
          patient_id:this.patient_id,
        }
        console.log("start_time==============",params)
       getAutoPatientContent(params).then(response=>{
          if(response.data.state == 1){

            var prescription =  response.data.data.prescription
            this.prescription=[]
            this.prescription = prescription

            var berfor = response.data.data.berfor
            this.berforList = []
            this.berforList = berfor

            var monitorList  = response.data.data.monitorList
            this.monitorList = []
            this.monitorList = monitorList

            var dryweightList = response.data.data.dryweightList

            this.dryweightList = []
            this.dryweightList = dryweightList

            var inpectionList = response.data.data.inpectionList

            this.inpectionList = []

            this.inpectionList = inpectionList


            var patient = response.data.data.patient

            if(patient.gender == 1){
               patient.gender_name = "男"
            }
            if(patient.gender == 2){
               patient.gender_name = "女"
            }

           this.patient = patient
           var dialysisOrderList =response.data.data.dialysisOrder

           this.dialysisOrderList = []
           this.dialysisOrderList = dialysisOrderList

           var longAdvice = response.data.data.longAdvice

           this.longAdvice = []
           this.longAdvice = longAdvice

           this.groupPrescriptionList = []
           this.groupPrescriptionList = response.data.data.groupPrescriptionList

           this.afterList = response.data.data.after

           this.max_blood_flow_volume = response.data.data.max_blood_flow_volume

           this.max_befor_systolic_blood_pressure = response.data.data.max_befor_systolic_blood_pressure

         this.min_befor_systolic_blood_pressure = response.data.data.min_befor_systolic_blood_pressure

         this.max_befor_diastolic_blood_pressure  = response.data.data.max_befor_diastolic_blood_pressure

         this.min_befor_diastolic_blood_pressure = response.data.data.min_befor_diastolic_blood_pressure


         this.max_after_systolic_blood_pressure = response.data.data.max_after_systolic_blood_pressure

         this.min_after_systolic_blood_pressure = response.data.data.min_after_systolic_blood_pressure

         this.max_after_diastolic_blood_pressure = response.data.data.max_after_diastolic_blood_pressure


         this.min_after_diastolic_blood_pressure = response.data.data.min_after_diastolic_blood_pressure

         this.max_monitor_systolic_blood_pressure = response.data.data.max_monitor_systolic_blood_pressure


         this.min_monitor_systolic_blood_pressure = response.data.data.min_monitor_systolic_blood_pressure


         this.max_monitor_diastolic_blood_pressure = response.data.data.max_monitor_diastolic_blood_pressure


         this.min_monitor_diastolic_blood_pressure = response.data.data.min_monitor_diastolic_blood_pressure


         this.lastDryWeight = response.data.data.lastDryWeight

         this.patientVascularAccess = response.data.data.patientVascularAccess

         this.lastBefor = response.data.data.lastBefor

         this.auto_dialog  =  true



          }
       })

    },
      didSelectTemplate: function(templateContent) {
        this.new_content = this.new_content.length > 0 ? (this.new_content + templateContent) : templateContent

      }, didEditSelectTemplate: function(templateContent) {
        this.edit_new_content = this.edit_new_content.length > 0 ? (this.edit_new_content + templateContent) : templateContent
      },

      didSelectionChange: function(selectRows) {

        var arr = []
        for(let i=0;i<selectRows.length;i++){
           arr.push(selectRows[i].id)
        }
        var newArr = arr.join(',')
        this.ids = newArr
        console.log("select23322332",this.ids)
        this.selectingRows = selectRows
      },
      deleteAction(){
        if(this.id == 0){
          this.$message.error("请选择要删除的信息!")
          return false
        }
        this.$confirm('确定要取消吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteNewCouseOfDisease(this.id).then(response=>{
            if (response.data.state==1) {
              var msg = response.data.data.msg
              this.$message.success("删除成功!")
              this.getlist()
            }
          });
        }).catch(() => {

        });


      },
      showEdit() {
        this.add_index =1
        this.disabled = false
        console.log('时间',this.record_date);
        
      }, tableRow({ row, rowIndex }) {
        // 把每一行的索引放进row
        row.index = rowIndex
      }, onRowClick(row, event, column) {
        this.table_current_index = row.index
      },
      prints(){
        if(this.ids.length == 0){
          this.$message.error('请选择要打印的病程')
          return
        }
        this.$router.push({ path: "/course/print?ids="+this.ids+"&patient_id="+this.patient_id});

      },

      GetAnticoagulant(id){
        var  anticoagulant_name = ""
        if(id == 1){
        anticoagulant_name = "无肝素"
        }
        if(id == 2){
          anticoagulant_name = "普通肝素"
        }
        if(id == 3){
          anticoagulant_name = "低分子肝素"
        }
        if(id == 4){
          anticoagulant_name = "阿加曲班"
        }

        if(id == 5){
        anticoagulant_name = "枸橼酸钠"
        }
        if(id == 6){
          anticoagulant_name = "低分子肝素钙"
        }
        if(id == 7){
          anticoagulant_name = "低分子肝素钠"
        }
        if(id == 8){
          anticoagulant_name = "依诺肝素"
        }

        if(id == 9){
          anticoagulant_name = "达肝素"
        }
        if(id == 10){
          anticoagulant_name = "体外抗凝"
        }

        if(id == 11){
          anticoagulant_name = "那屈肝素"
        }
        if(id == 12){
          anticoagulant_name = "无抗凝剂"
        }

        if(id == 13){
          anticoagulant_name = "那屈肝素钙"
        }
        if(id == 14){
          anticoagulant_name = "肝素钙注射液"
        }
        if(id == 15){
          anticoagulant_name = "甲磺酸萘莫司他"
        }

        return anticoagulant_name
      },
      getTime (time) {
      return uParseTime(time, '{y}-{m}-{d}')
      },
      getTimeOne (time) {
      return uParseTime(time, '{y}-{m}-{d}')
      },
      getTimeTwo (time) {
      return uParseTime(time, '{y}-{m}-{d} {h}:{i}')
      },
      getTimeThree (time) {
      return uParseTime(time, '{y}-{m}-{d} {h}:{i}:{s}')
      },
      newcontent(val){
        this.new_content =''
        this.new_content = val
        console.log('1111112323',val);
        this.$refs.editor.contents = this.new_content
      },
      bloodChange(val){
        this.bloodRows = []
        const text = val.content
        this.blood_context = text
        console.log('this.blood_context',this.blood_context);
      },
      summaryChange(val){
        this.summary_context=""
        if(val!=undefined){
          if(val.summary!=null && val.summary!=undefined){
            this.summary_context = val.summary.dialysis_summary
          }

        }
      },
      toSummaryPint(){
        this.$refs.editor.contents = this.$refs.editor.contents +this.summary_context
        this.summary_dialog = false
      },
      weightChange(val){
        var text = this.getTimeTwo(val.ctime) + " " + "调整值"+val.adjusted_value.slice(0,3)+"kg"+"("+val.adjusted_value.slice(4,6)+")"+"," +"干体重:"+val.dry_weight+"kg"
        this.weight_context = text
      },
      toDryWeightPint(){
        this.$refs.editor.contents = this.$refs.editor.contents +this.weight_context
        this.weight_dialog = false
      },
      type_chang(val){
        this.advice_type = val
        this.getPatientAdviceList()
      },
      status_chang(val){
        this.advice_status = val
        this.getPatientAdviceList()
      },
      selectionchange(val){
        this.bloodRows = val
        this.gettext(val)
        console.log('血压',this.bloodRows);
      },
      selectionchange2(val){

        this.summaryRows = val
        this.summary_context=""
        if(val!=null){
          // if(val.summary!=null && val.summary!=undefined){
          //   this.summary_context = val.summary.dialysis_summary
          // }
          for(let i=0;i<val.length;i++){
            this.summary_context += val[i].summary.dialysis_summary+"</br>"
          }
         this.summary_context = this.summary_context

        }
        // this.getsummary(val)
        // console.log('透析小结',this.summaryRows);
      },
      selectionchange3(val){
        this.weightRows = val
        this.getweight(val)
        console.log('透析小结',this.weightRows);
      },
      selectionchange4(val){

        this.optionRows = val
        this.getoption(val)
        console.log('透析小结',this.weightRows);
      },
      selectionchange5(val){

        this.adviceRows = val
        this.getNewPatientAdviceList(val)
      },
      gettext(val){
        const arr= []
        if(val.length>0){
          for(let i in val){
            arr.push(val[i].content)
          }
        }
        this.blood_context = arr.join('<br/>')
        console.log('拼接val.content.join()',arr.join('<br/>'));

      },
      getsummary(val){
        const arr= []
        if(val.length>0){
          for(let i in val){
            const obj = val[i].date +'('+ val[i].mode + ')'+'透析过程平稳，无不适主诉，顺利结束透析治疗。'
            arr.push(obj)
          }
        }
        console.log('1111111',arr);

        this.summary_context = `${arr.join('<br/>')}`
      },
      getweight(val){
        const arr= []
        if(val.length>0){
          for(let i in val){
            const obj = val[i].date + '调整值'+ val[i].value + 'kg' + '干体重'+ val[i].weight+'kg'
            arr.push(obj)
          }
        }
        console.log('1111111',arr);
        this.weight_context = `${arr.join('<br/>')}`
      },
      getoption(val){

        var newArr = []
        for(let i=0;i<this.systemPrescritpionList.length;i++){
          for(let j=0;j<val.length;j++){
            if(val[j].mode == this.systemPrescritpionList[i].mode_name){
              newArr.push(this.systemPrescritpionList[i])
            }
          }

        }
        const arr= []

        if(newArr.length>0){
          for(let i=0;i<newArr.length;i++){
            const text = `<table border="1" style="border-collapse: collapse;width: 100%;">
      <tr><td colspan="4">${newArr[i].mode_name}，启用</td></tr>
      <tr>
        <td>透析时长：${newArr[i].dialysis_duration_hour}时${newArr[i].dialysis_duration_minute}分</td>
        <td>置换方式：${newArr[i].displace_name}</td>
        <td>血流量（ml/min）：${newArr[i].blood_flow_volume}</td>
        <td></td>
      </tr>
      <tr>
        <td>透析器：${newArr[i].dialysis_dialyszers}</td>
        <td>灌流器：${newArr[i].dialysis_irrigation}</td>
        <td>透析液流量（ml/min）：${newArr[i].dialysate_flow}</td>
      </tr>
      <tr>
        <td>钾（mmol/L）：${newArr[i].kalium}</td>
        <td>钠（mmol/L）：${newArr[i].sodium}</td>
        <td>钙（mmol/L）：${newArr[i].calcium}</td>
        <td>碳酸氢根（mmol/L）：${newArr[i].bicarbonates}</td>
      </tr>
      <tr>
        <td>抗凝剂：${newArr[i].anticoagulant_name}</td>
        <td>首剂（iu）：${newArr[i].anticoagulant_shouji}</td>
        <td>维持（iu）：${newArr[i].anticoagulant_weichi}</td>
        <td>总量（iu）：${newArr[i].anticoagulant_zongliang}</td>
      </tr>
      <tr><td colspan="4"></td></tr>
            </table>`
            arr.push(text)
          }
        }
        const contenttext = `${arr.join('<br/>')}`
        this.option_context = contenttext
        // console.log('option_context',this.option_context);
        this.$refs.editorOne.contents = this.option_context
      },
      // 血压搜索
      bloodsearch(val){

      },
      blood_click(){
        this.blood_dialog =true
        this.start_date1 = this.timeForMat(7)
        this.end_date1 = this.getTime(new Date())
        this.$nextTick(()=>{
          this.$refs.blood_table.setCurrentRow(this.bloodList[0])
        })

      },
      summary_click(){
        this.summary_dialog = true
        this.start_date1 = this.timeForMat(7)
        this.end_date1 = this.getTime(new Date())
        this.$nextTick(()=>{
          this.$refs.blood_table.setCurrentRow(this.bloodList[0])
        })
      },
      weight_click(){
        this.weight_dialog =true
        this.start_date1 = this.timeForMat(7)
        this.end_date1 = this.getTime(new Date())
        this.$nextTick(()=>{
          this.$refs.weight_table.setCurrentRow(this.weightlist[0])
        })
      },
      option_click(val){

        this.option_dialog =true
        // this.start_date1 = this.timeForMat(7)
        // this.end_date1 = this.getTime(new Date())
        // this.$nextTick(()=>{
        //   this.$refs.option_table.setCurrentRow(this.weightlist[0])
        // })

         this.getDilaysisSystemList()
      },
      advice_click(){
        const text =`<p class='advice_table'></p>`
        this.advice_context = text
        this.getPatientAdviceList()
        this.advice_dialog = true
      },
      diagnosis_click(){
        const text =`<table border="1" style="border-collapse: collapse;text-align: center;">
          <tr><td>1</td><td>高尿酸血症</td></tr>
          <tr><td>2</td><td>继发性甲状旁腺功能亢进</td></tr>
        </table>`
        // this.$refs.editor.contents = this.new_content
        this.$refs.editor.contents = this.$refs.editor.contents +text
      },
      hospital_click(){
        const text = `<p style="line-height: 50px;display: flex;"><span style="display: inline-block;flex: 1;">住院日期:</span><span style="display: inline-block;flex: 1;">出院日期:</span></p>
    <p style="line-height: 50px;display: flex;"><span style="display: inline-block;flex: 1;">入院诊断:</span><span style="display: inline-block;flex: 1;">出院诊断:</span></p>`

        this.$refs.editor.contents =  this.$refs.editor.contents + text
      },
      Inspect_click(){
        this.Inspect_dialog = true
        this.start_date1 = this.timeForMat(7)
        this.end_date1 = this.getTime(new Date())
        for(let i in this.Inspectlist){
          this.activeNames.push(this.Inspectlist[i].id)
        }
      },
      handleChange(val){

      },
      childclick(i){

          var params = {
            patient_id:i.patient_id,
            project_id:i.project_id,
            inspect_date:i.inspect_date,

          }
        getInspectionByProjectId(params).then(response=>{
          if(response.data.state == 1){
            var inspection =  response.data.data.inspection
            var referenceList = response.data.data.referenceList
            console.log("referenctLit=====",referenceList)
            var inspection_str = i.project_name + "-"+"检验日期:"+this.getTime(i.inspect_date)+";"
            if(inspection!=null && inspection.length>0){
              for(let i=0;i<inspection.length;i++){
                inspection[i].unit = ""
               for(let j=0;j<referenceList.length;j++){
                 if(inspection[i].item_id == referenceList[j].id){
                    inspection[i].unit = referenceList[j].unit
                 }
               }
                if(inspection[i].inspect_value!=""){
                  inspection_str += inspection[i].item_name+ "("+inspection[i].unit+")"+":" + inspection[i].inspect_value+","
                }

              }
            }
            this.inspect_context = inspection_str

          }
        })
        // // const inspect_arr = []
        // if(this.InspectRows.length ==0){
        //   this.InspectRows.push(eve)
        // }else{
        //   let index = this.InspectRows.findIndex((obj) => obj.c_id === eve.c_id && obj.pater_id == eve.pater_id);
        //   if (index === -1) {
        //     this.InspectRows.push(eve);
        //   } else {
        //     this.InspectRows.splice(index, 1);
        //   }
        // }
        // this.getinspect(this.InspectRows)
        // console.log('检查',this.InspectRows.includes(eve));
      },
      toInpectionContentPint(){
        this.$refs.editor.contents = this.$refs.editor.contents +this.inspect_context
        this.Inspect_dialog = false
      },
      getinspect(val){
        const arr = []
        if(val != ''){
          for(let i in val){
              arr.push(val[i].text)
          }
          const contenttext = `${arr.join('<br/>')}`
          this.Inspect_context = contenttext
        }else{
          this.Inspect_context = ''
        }
      },
      check_change(){

        const arr = []
        if(this.checked==true){
          for(let i in this.Inspectlist){
            for(let j in this.Inspectlist[i].child){
              if(this.InspectRows.length ==0){
                this.InspectRows.push(this.Inspectlist[i].child[j])
              }else{
                this.InspectRows.push(this.Inspectlist[i].child[j])
                for(let x=0;x<this.InspectRows.length;x++){
                  for(let y =x+1;y<this.InspectRows.length;y++){
                    if(this.InspectRows[x].c_id === this.InspectRows[y].c_id &&
                      this.InspectRows[x].pater_id == this.InspectRows[y].pater_id
                    ){
                      this.InspectRows.splice(y,1)
                    }
                  }
                }
              }

            }
          }
        }else{
          this.InspectRows = []
        }
        this.getinspect(this.InspectRows)
        // console.log('this',this.InspectRows);
      },
    //血压
    getMonitorSearchList(){

       var params = {
         start_time:this.start_date1,
         end_time:this.end_date1,
         patient_id:this.patient_id,
       }

       getMonitorSearchList(params).then(response=>{
          if(response.data.state == 1){
            var monitorList = response.data.data.monitorList
            this.monitorListOne = monitorList
          }
       })
     },
     getSummarySearchList(){
      var params = {
         start_time:this.start_date1,
         end_time:this.end_date1,
         patient_id:this.patient_id,
       }
       getSummarySearchList(params).then(response=>{
          if(response.data.state ==1){
            this.summaryList =[]
            this.summaryList = response.data.data.summaryList
          }
       })
     },
     getPatientDryWeightList(){
       var params = {
        start_time:this.start_date1,
         end_time:this.end_date1,
         patient_id:this.patient_id,
       }
      getPatientDryWeightList(params).then(response=>{
         if(response.data.state == 1){

           var dryWeightList = response.data.data.dryWeightList
           this.dryWeightList = []
           this.dryWeightList = dryWeightList
         }
      })
     },
      getDilaysisSystemList(){
         var params = {
          start_time:this.start_date1,
          end_time:this.end_date1,
          patient_id:this.patient_id,
        }
        getDilaysisSystemList(params).then(response=>{
           if(response.data.state == 1){
              this.systemPrescritpionList = []
              var systemPrescritpionList =  response.data.data.prescription

              if(systemPrescritpionList!=null && systemPrescritpionList.length>0){
                 for(let i=0;i<systemPrescritpionList.length;i++){
                   systemPrescritpionList[i].mode_name = ""
                   systemPrescritpionList[i].mode_name = this.getModeId(systemPrescritpionList[i].mode_id)
                   systemPrescritpionList[i].displace_name = this.getDisplaceLiqu(systemPrescritpionList[i].displace_liqui)
                   systemPrescritpionList[i].anticoagulant_name = this.getAnticoagulantName(systemPrescritpionList[i].anticoagulant)
                 }
              }
              this.systemPrescritpionList = systemPrescritpionList

           }
        })
      },
      getDisplaceLiqu(id){
        var  displace_liqui_List = this.$store.getters.displace_liqui

        var name = ""
        for(let i=0;i<displace_liqui_List.length;i++){
          if(id == displace_liqui_List[i].id){
            name = displace_liqui_List[i].name
          }
        }
        return name
      },
      getPatientAdviceList(){
        var ids = this.newIds.join()
        var params = {
          start_time:this.start_date1,
          end_time:this.end_date1,
          patient_id:this.patient_id,
          advice_type:this.advice_type,
          advice_status:this.advice_status,
        }
        getPatientAdviceList(params).then(response=>{
          if(response.data.state == 1){
             var advicelist = response.data.data.advicelist
             this.adviceList = []
             this.adviceList =advicelist
          }
        })
      },
      getNewPatientAdviceList(val){

         var newArr= []
         for(let i=0;i<val.length;i++){
           for(let j=0;j<this.adviceList.length;j++){
             if(val[i].id == this.adviceList[j].id){
                newArr.push(this.adviceList[j])
             }
           }
         }


         this.adviceNewList = []
         this.adviceNewList = newArr
         this.all_select = 1

      },
      handleMonitorChange(val){

         var str = ""
         var monitor_str =""
         if(val.monitor!=null && val.monitor.length>0){
           for(let i=0;i<val.monitor.length;i++){
              monitor_str += val.monitor[i].systolic_blood_pressure+"/"+val.monitor[i].diastolic_blood_pressure+";"
           }
         }
         if(val!=undefined){
          str += this.getTime(val.schedule_date) + "("+this.getModeId(val.mode_id)+")"+" "+"透前血压:"+val.befor.systolic_blood_pressure+"/"+val.befor.diastolic_blood_pressure
          +" " +"监测记录:"+monitor_str+" "+"透后血压:"+val.after.systolic_blood_pressure +"/"+ val.after.diastolic_blood_pressure
         }

          this.monitor_blood_context =""
          this.monitor_blood_context = str
      },
      toMonitorPint(){
        this.$refs.editor.contents = this.$refs.editor.contents+this.monitor_blood_context
        this.blood_dialog = false
      },
      toInspection(){
          var params = {
            start_time:this.start_date1,
            end_time:this.end_date1,
            patient_id:this.patient_id,
          }
        getPatientInspectionList(params).then(response=>{
           if(response.data.state == 1){

             var groupList = response.data.data.groupList
             var inspection = response.data.data.inspection
             this.inspectionList = inspection

             if(groupList.length!=null && groupList.length>0){
                for(let i=0;i<groupList.length;i++){
                  groupList[i].child = []
                  for(let j=0;j<inspection.length;j++){
                    if(groupList[i].project_id == inspection[j].project_id && groupList[i].inspect_date == inspection[j].inspect_date){
                      groupList[i].child.push(inspection[j])
                    }
                  }
                }
             }

             for(let i=0;i<groupList.length;i++){
               for(let j=0;j<groupList[i].child.length;j++){
                  groupList[i].child =this.getInspection(groupList[i].child)
               }
             }

             this.newInspectionList = groupList

           }
        })
      },
      getInspection(tempArr) {
          let newArr = [];
          for (let i = 0; i < tempArr.length; i++) {
              if (newArr.indexOf(tempArr[i].inspect_date) == -1) {
                  newArr.push(tempArr[i].inspect_date);
              } else {
                  tempArr.splice(i, 1);
                  i--;
              };
          };
          return tempArr;
      },
      changeInspetion(){

        for(let i=0;i<this.newInspectionList.length;i++){
           this.newInspectionList[i].childOne =[]
          for(let j=0;j<this.inspectionList.length;j++){
            if(this.newInspectionList[i].project_id == this.inspectionList[j].project_id &&this.newInspectionList[i].inspect_date== this.inspectionList[j].inspect_date ){
                this.newInspectionList[i].childOne.push(this.inspectionList[j])
            }
          }
        }

         var new_inspection_str =""
        if(this.newInspectionList!=null&& this.newInspectionList.length>0){
           for(let i=0;i<this.newInspectionList.length;i++){
            if(this.newInspectionList[i].childOne!=null && this.newInspectionList[i].childOne.length>0){
              new_inspection_str += "<br/>"+ this.newInspectionList[i].project_name +"-" +"检验日期:"+ this.getTime(this.newInspectionList[i].childOne[0].inspect_date) +" "
              for(let j=0;j<this.newInspectionList[i].childOne.length;j++){
                if(this.newInspectionList[i].childOne[j].inspect_value!=""){
                  new_inspection_str+= this.newInspectionList[i].childOne[j].item_name+":" + this.newInspectionList[i].childOne[j].inspect_value+","+" "
                }

              }
            }

           }
        }
         this.inspect_context = new_inspection_str
      },
      toSystemContentPint(){

        this.$refs.editor.contents = this.$refs.editor.contents +this.option_context
        this.option_dialog = false
      },
      toContentPint(){
        console.log("hhhhhhhhhhhhhhhhhhhh",this.$refs.editor)
        this.$refs.editor.contents =  this.$refs.editor.contents + this.$refs.editorOne.contents
        this.library_dialog = false
      }


    },
    beforeMount(){

    },
    mounted(){

    },


  }
</script>

<style rel="stylesheet/css" lang="scss" scoped>
  .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;
  }

  }
  .eldialog{
    .el-dialog{
      .el-dialog__body{
        max-height: calc(100vh - 80px) !important;
        padding: 0px 20px;
      }
    }

  }
  .Second_title{
    border-left: 5px solid #3891f1f5;
    text-align: left;
    padding-left: 5px;
    // margin-left: 10px;
    margin-bottom: 5px;
    font-size: 16px;
  }

  .text_margin{
    display: block;
  }
  .blood_text{
    border: 1px solid #cfcaca;
    min-height: 400px;
    padding: 5px;
  }
  .inspect{
    line-height: 40px;
    text-align: center;
    border: 1px solid gainsboro;
  }
  .Selectli{
    color: #409eff;
    border-color: #409eff;
  }

</style>
<style lang="scss">
.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;
}

.eldialog{
    .el-dialog{
      .el-dialog__body{
        max-height: calc(100vh - 80px) !important;
        padding: 0px 20px;
      }
    }

  }
  .lirary{
    .el-dialog__body{
      padding: 0px 20px !important;
    }
    .el-dialog__footer{
      text-align: center;
    }
  }
  .course{
    .el-dialog{
      height: 90%;
      // position: fixed !important;
      // top: 10% !important;
    }
  }
  .elcollapseitem{
    .el-collapse-item__header{
      font-size: 16px;
      color: white;
      background: #409eff;
    }

  }
</style>
