<template>
    <div class="page_dialysisParameters">
        <el-table :data="tableData" ref="tab" border :height="tableHeight" style="width: 100%" :row-style="{ color: '#303133' }" :header-cell-style="{backgroundColor: 'rgb(245, 247, 250)', color: '#606266'}"
          v-loadmore="loadMore" v-loading="loading">
            <el-table-column prop="date" fixed label="姓名" width="80" align="center">
               <template slot-scope="scope">

                  {{scope.row.name?scope.row.name:""}}
               </template>
            </el-table-column>
            <el-table-column prop="date" fixed label="床位号" width="80" align="center">
               <template slot-scope="scope">

                  {{scope.row.number?scope.row.number:""}}
               </template>
            </el-table-column>
            <el-table-column prop="name" label="透析模式" width="90" align="center">
                <template slot-scope="scope">
                    {{scope.row.mode_id}}
                </template>
            </el-table-column>
            <el-table-column prop="address" :label="'上次透后体重\n(kg)'" width="120" align="center">
                <template slot-scope="scope">
                   {{getLastWeight(scope.row.patient_id)?getLastWeight(scope.row.patient_id):""}}
                </template>
            </el-table-column>
            <el-table-column prop="address" :label="'透前体重\n(kg)'" width="100" align="center">
                <template slot-scope="scope">
                   {{getWeightBefor(scope.row.patient_id)?getWeightBefor(scope.row.patient_id):""}}
                </template>
            </el-table-column>
            <el-table-column prop="address" :label="'干体重\n(kg)'" width="100" align="center">
                <template slot-scope="scope">
                   {{getDryWeight(scope.row.patient_id)?getDryWeight(scope.row.patient_id):""}}
                </template>
            </el-table-column>
            <el-table-column prop="address" :label="'透前血压\n(mmhg)'" width="100" align="center">
                <template slot-scope="scope">
                  {{getSysBloodPressure(scope.row.patient_id)?getSysBloodPressure(scope.row.patient_id):""}}
                </template>
            </el-table-column>
            <el-table-column prop="address" label="目标超滤量" width="100" align="center">
                <template slot-scope="scope">
                   {{getTargetUltrafiltration(scope.row.patient_id)?getTargetUltrafiltration(scope.row.patient_id):""}}
                </template>
            </el-table-column>
            <el-table-column prop="address" label="血流量" width="100" align="center">
                <template slot-scope="scope">
                  {{getBloodFlowVolume(scope.row.patient_id)?getBloodFlowVolume(scope.row.patient_id):""}}
                </template>
            </el-table-column>
            <el-table-column prop="address" label="抗凝剂(首剂)(维持)(总量)" width="120" align="center">
                <template slot-scope="scope">
                  <span v-if="getAnticoagulant(scope.row.patient_id)!=''">
                    <span v-if="getAnticoagulant(scope.row.patient_id) == 0"></span>
                    <span v-if="getAnticoagulant(scope.row.patient_id) == 1">无肝素</span>
                    <span v-if="getAnticoagulant(scope.row.patient_id) == 2">普通肝素</span>
                    <span v-if="getAnticoagulant(scope.row.patient_id) == 3">低分子肝素</span>
                    <span v-if="getAnticoagulant(scope.row.patient_id) == 4">阿加曲班</span>
                    <span v-if="getAnticoagulant(scope.row.patient_id) == 5">枸橼酸钠</span>
                    <span v-if="getAnticoagulant(scope.row.patient_id)== 6">低分子肝素钙</span>
                    <span v-if="getAnticoagulant(scope.row.patient_id) == 7">低分子肝素钠</span>
                    <span v-if="getAnticoagulant(scope.row.patient_id) == 8">依诺肝素</span>
                    <span v-if="getAnticoagulant(scope.row.patient_id) == 9">达肝素</span>
                    <span v-if="getAnticoagulant(scope.row.patient_id) == 10">体外抗凝</span>
                    <span v-if="getAnticoagulant(scope.row.patient_id) == 11">那屈肝素</span>
                    <span v-if="getAnticoagulant(scope.row.patient_id) == 12">无抗凝剂</span>

                    <span>
                      {{getAnticoagulantShouji(scope.row.patient_id)?getAnticoagulantShouji(scope.row.patient_id):''}}
                      <span v-if="getAnticoagulant(scope.row.patient_id) ==1 && getAnticoagulantShouji(scope.row.patient_id)!=''">mg)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 2 && getAnticoagulantShouji(scope.row.patient_id)!=''">iu/h)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 3 && getAnticoagulantShouji(scope.row.patient_id)!=''">iu)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 4 && getAnticoagulantShouji(scope.row.patient_id)!=''">mg)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 5 && getAnticoagulantShouji(scope.row.patient_id)!=''">mg)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 6 && getAnticoagulantShouji(scope.row.patient_id)!=''">iu)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 7 && getAnticoagulantShouji(scope.row.patient_id)!=''">iu)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id)== 8 && getAnticoagulantShouji(scope.row.patient_id)!=''">iu)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 9 && getAnticoagulantShouji(scope.row.patient_id)!=''">iu)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id)== 10 && getAnticoagulantShouji(scope.row.patient_id)!=''">mg)</span>
                    </span>
                    <span>
                       {{getAnticoagulantWeichi(scope.row.patient_id)?getAnticoagulantWeichi(scope.row.patient_id):''}}
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 1 && getAnticoagulantWeichi(scope.row.patient_id)!=''">mg/h)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 2 && getAnticoagulantWeichi(scope.row.patient_id)!=''">iu/h)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 3 && getAnticoagulantWeichi(scope.row.patient_id)!=''">iu/h)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 4 && getAnticoagulantWeichi(scope.row.patient_id)!=''">mg/h)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 5 && getAnticoagulantWeichi(scope.row.patient_id)!=''">ml/h)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 6 && getAnticoagulantWeichi(scope.row.patient_id)!=''">iu/h)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 7 && getAnticoagulantWeichi(scope.row.patient_id)!=''">iu/h)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 8 && getAnticoagulantWeichi(scope.row.patient_id)!=''">iu/h)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 9 && getAnticoagulantWeichi(scope.row.patient_id)!=''">iu/h)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 10 && getAnticoagulantWeichi(scope.row.patient_id)!=''">mg)</span>
                    </span>
                    <span>
                      {{getAnticoagulantZongliang(scope.row.patient_id)?getAnticoagulantZongliang(scope.row.patient_id):''}}
                       <span v-if="getAnticoagulant(scope.row.patient_id) == 1 && getAnticoagulantZongliang(scope.row.patient_id)!=''">mg)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 2 && getAnticoagulantZongliang(scope.row.patient_id)!=''">iu)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 3 && getAnticoagulantZongliang(scope.row.patient_id)!=''">iu)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 4 && getAnticoagulantZongliang(scope.row.patient_id)!=''">mg)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 5 && getAnticoagulantZongliang(scope.row.patient_id)!=''">mg)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 6 && getAnticoagulantZongliang(scope.row.patient_id)!=''">iu/h)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 7 && getAnticoagulantZongliang(scope.row.patient_id)!=''">iu)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 8 && getAnticoagulantZongliang(scope.row.patient_id)!=''">iu)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 9 && getAnticoagulantZongliang(scope.row.patient_id)!=''">iu/h)</span>
                      <span v-if="getAnticoagulant(scope.row.patient_id) == 10 && getAnticoagulantZongliang(scope.row.patient_id)!=''">mg)</span>
                    </span>
                  </span>

                  <span v-if="getAnticoagulant(scope.row.patient_id)==''">
                       <span v-if="scope.row.dialysis_solution.anticoagulant == 1">无肝素</span>
                       <span v-if="scope.row.dialysis_solution.anticoagulant == 2">普通肝素</span>
                       <span v-if="scope.row.dialysis_solution.anticoagulant == 3">低分子肝素</span>
                       <span v-if="scope.row.dialysis_solution.anticoagulant == 4">阿加曲班</span>
                       <span v-if="scope.row.dialysis_solution.anticoagulant == 5">枸橼酸钠</span>
                       <span v-if="scope.row.dialysis_solution.anticoagulant == 6">低分子肝素钙</span>
                       <span v-if="scope.row.dialysis_solution.anticoagulant == 7">低分子肝素钠</span>
                       <span v-if="scope.row.dialysis_solution.anticoagulant == 8">依诺肝素</span>
                       <span v-if="scope.row.dialysis_solution.anticoagulant == 9">达肝素</span>
                       <span v-if="scope.row.dialysis_solution.anticoagulant == 10">体外抗凝</span>
                       <span v-if="scope.row.dialysis_solution.anticoagulant == 11">那屈肝素</span>
                       <span v-if="scope.row.dialysis_solution.anticoagulant == 12">无抗凝剂</span>
                       （{{scope.row.dialysis_solution.anticoagulant_shouji}}iu) 
                       （{{scope.row.dialysis_solution.anticoagulant_weichi}} iu/h)
                       （{{scope.row.dialysis_solution.anticoagulant_zongliang}} iu)
                  </span>
                  
                  
                </template>
            </el-table-column>
             <el-table-column prop="address" label="透析器/灌流器" width="100" align="center" v-if="org_id!=10721">
                <template slot-scope="scope">
                    {{getDialyzerPerfusionApparatus(scope.row.patient_id)?getDialyzerPerfusionApparatus(scope.row.patient_id):""}}

                </template>
             </el-table-column>

             <el-table-column prop="address" label="透析器" width="100" align="center">
                <template slot-scope="scope">
                   <span v-if="getDialyzerPerfusionApparatusOne(scope.row.patient_id)!=''"> {{getDialyzerPerfusionApparatusOne(scope.row.patient_id)?getDialyzerPerfusionApparatusOne(scope.row.patient_id):""}}</span>
                   <span v-if="getDialyzerPerfusionApparatusOne(scope.row.patient_id) ==''"> {{scope.row.dialysis_solution.dialysis_dialyszers}}</span>
                </template>
             </el-table-column>

             <el-table-column prop="address" label="灌流器" width="100" align="center">
                <template slot-scope="scope">
                  <span v-if="getDialyzerPerfusionApparatusTwo(scope.row.patient_id)!=''"> {{getDialyzerPerfusionApparatusTwo(scope.row.patient_id)?getDialyzerPerfusionApparatusTwo(scope.row.patient_id):""}}</span>
                  <span v-if="getDialyzerPerfusionApparatusTwo(scope.row.patient_id) ==''">{{scope.row.dialysis_solution.dialysis_irrigation}}</span>
                </template>
             </el-table-column>

             
             <el-table-column prop="address" label="滤过器" width="100" align="center">
                <template slot-scope="scope">
                  <span v-if="getDialyzerPerfusionApparatusThree(scope.row.patient_id)!=''">{{getDialyzerPerfusionApparatusThree(scope.row.patient_id)?getDialyzerPerfusionApparatusThree(scope.row.patient_id):""}}</span> 

                  <span v-if="getDialyzerPerfusionApparatusThree(scope.row.patient_id)==''">{{ scope.row.dialysis_solution.dialysis_strainer }}</span> 
                </template>
             </el-table-column>

             <el-table-column prop="address" label="血管通路" width="100" align="center">
                <template slot-scope="scope">
                  <!-- {{ scope.row.dialysbefor.blood_access_part_id }} {{getBloodAccess(scope.row.dialysbefor.blood_access_part_opera_id)}} -->

                  {{getLastbloodAccessPartentid(scope.row.patient_id)?getLastbloodAccessPartentid(scope.row.patient_id):""}}

                  {{getLastbloodAccesspartOperaId(scope.row.patient_id)?getLastbloodAccesspartOperaId(scope.row.patient_id):""}}
                </template>
             </el-table-column>
        </el-table>
        <img class="statisticsImg" @click="toStarticList()" src="@/assets/images/statistics.png" />
    </div>
</template>

<script>
import {getMobileDialysisParameters } from '@/api/consumable'
import {getDataConfig} from '@/utils/data'
const moment = require('moment')
export default {
  props: {
    selected_date: String,
    zone_selected: Number,
    selected_date_str: String,
    schedual_type_selected: Number,
    search_keyword: String
  },
  data () {
    return {
      tableHeight: '',
      tableData: [],
      search_input: '',
      limit: 500,
      page: 1,
      prescriptionList: [],
      dialysisBefor: [],
      prescriptions: [],
      dialysisbefor: [],
      isStop: false,
      loading: true,
      datalist: [],
      org_id:0,
    }
  },
  created () {
     this.org_id = this.$store.getters.user.template_info.org_id
    this.tableHeight = (document.documentElement.clientHeight - (Number(document.documentElement.style.fontSize.slice(0, -2)) * 4)) + 'px'
    // 获取透析参数统计表
    this.getlist()
    // 获取统计表数据
  },
  methods: {
    getBloodAccess (id) {
      let vascular_access_desc_name = ''
      let vascular_access_desc = getDataConfig('hemodialysis', 'vascular_access_desc')
      var name = ''
      for (let i = 0; i < vascular_access_desc.length; i++) {
        if (vascular_access_desc[i].id == id) {
          name = vascular_access_desc[i].name
        }
      }
      return name
    },
    // 获取透析参数统计表
    getlist (val) {
      console.log("hhhhhhhhhhhhhhhhhhhhhhhhhhhhh",val)
      this.limit = 500
      this.page =1
      const params = {
        start_time: this.selected_date_str,
        keyword: this.search_input,
        scheduleType: this.schedual_type_selected,
        partitionType: this.zone_selected,
        limit: this.limit,
        page: this.page,
        keyword: val || ''
      }
      console.log("params==================",params)
      getMobileDialysisParameters(params).then(response => {
        if (response.data.state == 1) {
          var schedule =  response.data.data.schedule

          console.log("schedule=================",schedule)
          this.loading = false
          //  var total = response.data.data.total
          var prescription = response.data.data.prescription
          this.prescriptionList = prescription
          this.prescriptions = prescription
          var dialysbefor = response.data.data.dialysbefor
          this.dialysisbefor = dialysbefor
          this.dialysisBefor = dialysbefor
          var patient = response.data.data.patient
          console.log("patient---------------------",patient)
            
          if(schedule!=null && schedule.length>0){
           
           for(let j=0;j<patient.length;j++){
             patient[j].sort = 0
             patient[j].number= ""
             for(let i=0;i<schedule.length;i++){
             
                if(patient[j].patient_id == schedule[i].patient_id){
                    patient[j].sort = schedule[i].device_number.sort
                    patient[j].number = schedule[i].device_number.number
                }
             }
            }
        }


          if (response.data.data.patient.length <= 0) {
            this.isStop = true
          } else {
            this.isStop = false
          }
          for (let i = 0; i < patient.length; i++) {
            if (patient[i].mode_id == 1) {
              patient[i].mode_id = 'HD'
            }
            if (patient[i].mode_id == 2) {
              patient[i].mode_id = 'HDF'
            }
            if (patient[i].mode_id == 3) {
              patient[i].mode_id = 'HD+HP'
            }
            if (patient[i].mode_id == 4) {
              patient[i].mode_id = 'HP'
            }
            if (patient[i].mode_id == 5) {
              patient[i].mode_id = 'HF'
            }
            if (patient[i].mode_id == 6) {
              patient[i].mode_id = 'SCUF'
            }
            if (patient[i].mode_id == 7) {
              patient[i].mode_id = 'IUF'
            }
            if (patient[i].mode_id == 8) {
              patient[i].mode_id = 'HFHD'
            }
            if (patient[i].mode_id == 9) {
              patient[i].mode_id = 'HFHD+HP'
            }
            if (patient[i].mode_id == 10) {
              patient[i].mode_id = 'PHF'
            }
            if (patient[i].mode_id == 11) {
              patient[i].mode_id = 'HFR'
            }
            if (patient[i].mode_id == 12) {
              patient[i].mode_id = 'HDF+HP'
            }
            if (patient[i].mode_id == 13) {
              patient[i].mode_id = 'CRRT'
            }
            if (patient[i].mode_id == 14) {
              patient[i].mode_id = '腹水回输'
            }
            if (patient[i].mode_id == 15) {
              patient[i].mode_id = 'HD前置换'
            }
            if (patient[i].mode_id == 16) {
              patient[i].mode_id = 'HD后置换'
            }
            if (patient[i].mode_id == 17) {
              patient[i].mode_id = 'HDF前置换'
            }
            if (patient[i].mode_id == 18) {
              patient[i].mode_id = 'HDF后置换'
            }
            if (patient[i].mode_id == 19) {
              patient[i].mode_id = 'IUF+HD'
            }
            if (patient[i].mode_id == 21) {
              patient[i].mode_id = 'HD+'
            }
            if (patient[i].mode_id == 24) {
              patient[i].mode_id = 'I-HDF'
            }
            if (patient[i].mode_id == 25) {
              patient[i].mode_id = 'HD高通'
            }
            if (patient[i].mode_id == 26) {
              patient[i].mode_id = 'CVVH'
            }
            if (patient[i].mode_id == 27) {
              patient[i].mode_id = 'CVVHD'
            }
            if (patient[i].mode_id == 28) {
              patient[i].mode_id = 'CVVHDF'
            }
            if (patient[i].mode_id == 29) {
              patient[i].mode_id = 'PE'
            }
            if (patient[i].mode_id == 30) {
              patient[i].mode_id = '血浆胆红素吸附+HP'
            }
            if (patient[i].mode_id == 31) {
              patient[i].mode_id = 'HPD'
            }
            if (patient[i].mode_id == 32) {
              patient[i].mode_id = 'HDP'
            }
            if (patient[i].mode_id == 33) {
              patient[i].mode_id = 'HFD'
            }
            if (patient[i].mode_id == 34) {
              patient[i].mode_id = 'HDF100'
            }
            if (patient[i].mode_id == 35) {
              patient[i].mode_id = 'HDF600'
            }
            if (patient[i].mode_id == 36) {
              patient[i].mode_id = 'HDF800'
            }
            if (patient[i].mode_id == 37) {
              patient[i].mode_id = 'HDF1000'
            }
            if (patient[i].mode_id == 38) {
              patient[i].mode_id = 'HDF80'
            }
            if (patient[i].mode_id == 39) {
              patient[i].mode_id = 'HF16'
            }
            if (patient[i].mode_id == 40) {
              patient[i].mode_id = 'HD(无肝素)'
            }
            if (patient[i].mode_id == 41) {
              patient[i].mode_id = 'HDF17H'
            }
            if (patient[i].mode_id == 42) {
              patient[i].mode_id = 'HD.'
            }
            if (patient[i].mode_id == 43) {
              patient[i].mode_id = 'HD(2)'
            }
            if (patient[i].mode_id == 44) {
              patient[i].mode_id = '导管溶栓'
            }
          
          }
            this.datalist = []
            this.datalist = patient.sort((a, b) => a.sort - b.sort)
            
            this.tableData = []
            this.tableData = patient.sort((a, b) => a.sort - b.sort)

            console.log("patinet====================",this.tableData)
            this.$nextTick(() => {
              this.$refs.tab.doLayout()
            })
        } else {
          this.loading = false
        }
      })
    },

    toStarticList () {
      this.$router.push('/dialysis/dialysisParameters')
    },
    getLastWeight (id) {
      var lastweight = ''
      if(this.dialysisBefor!=undefined || this.dialysisBefor!=null ){
        for (let i = 0; i < this.dialysisBefor.length; i++) {
          if (this.dialysisBefor[i].patient_id == id) {
            lastweight = this.dialysisBefor[i].weight_after_last_transparency
          }
        }
      }
     
      return lastweight
    },
    getLastbloodAccessPartentid(id){
       var blood_access_part_id  = ""
       if(this.dialysisBefor!=undefined ||  this.dialysisBefor!=null){
        for (let i = 0; i < this.dialysisBefor.length; i++) {
         if (this.dialysisBefor[i].patient_id == id) {
          blood_access_part_id = this.dialysisBefor[i].blood_access_part_id
         }

        }
       }
       return blood_access_part_id

    },
    getLastbloodAccesspartOperaId(id){
      var blood_access_part_id  = ""
      if(this.dialysisBefor!=undefined && this.dialysisBefor!=null){
        for (let i = 0; i < this.dialysisBefor.length; i++) {
        if (this.dialysisBefor[i].patient_id == id) {
          blood_access_part_id = this.getBloodAccess(this.dialysisBefor[i].blood_access_part_opera_id)
        }
       }
      }
       
      return blood_access_part_id

    },
    getWeightBefor (id) {
      if(this.dialysisBefor!=undefined && this.dialysisBefor!=null){
        var assessmentBeforWeight = ''
        for (let i = 0; i < this.dialysisBefor.length; i++) {
          if (this.dialysisBefor[i].patient_id == id) {
            assessmentBeforWeight = this.dialysisBefor[i].weight_before
          }
        }
      }
      
      return assessmentBeforWeight
    },
    getDryWeight (id) {
      var dryWeight = ''
      if(this.dialysisBefor!=undefined && this.dialysisBefor!=null){
        for (let i = 0; i < this.dialysisBefor.length; i++) {
          if (this.dialysisBefor[i].patient_id == id) {
            dryWeight = this.dialysisBefor[i].dry_weight
          }
        }
      }
     
      return dryWeight
    },
    getSysBloodPressure (id) {
      var sysBloodPressure = ''
      if(this.dialysisBefor!=undefined || this.dialysisBefor!=null){
        for (let i = 0; i < this.dialysisBefor.length; i++) {
        if (this.dialysisBefor[i].patient_id == id) {
          sysBloodPressure = this.dialysisBefor[i].systolic_blood_pressure
        }
       }
      }
      
      return sysBloodPressure
    },
    getTargetUltrafiltration (id) {
      var targetUltrafiltration = ''
      if(this.prescriptionList!=undefined || this.prescriptionList!=null){
        for (let i = 0; i < this.prescriptionList.length; i++) {
          if (this.prescriptionList[i].patient_id == id) {
            targetUltrafiltration = this.prescriptionList[i].target_ultrafiltration
          }
       }
      }
     
      return targetUltrafiltration
    },
    getBloodFlowVolume (id) {
      var bloodFlowVolume = ''
      if(this.prescriptionList!=undefined && this.prescriptionList!=null){
        for (let i = 0; i < this.prescriptionList.length; i++) {
        if (this.prescriptionList[i].patient_id == id) {
          bloodFlowVolume = this.prescriptionList[i].blood_flow_volume
        }
       }
      }
    
      return bloodFlowVolume
    },
    getDialyzerPerfusionApparatus (id) {
      var dialyzerPerfusionApparatus = ''
      if(this.prescriptionList!=undefined && this.prescriptionList!=null){
        for (let i = 0; i < this.prescriptionList.length; i++) {
          if (this.prescriptionList[i].patient_id == id) {
            dialyzerPerfusionApparatus = this.prescriptionList[i].dialyzer_perfusion_apparatus
          }
        }
      }
   
      return dialyzerPerfusionApparatus
    },
    getDialyzerPerfusionApparatusOne(id){
      var dialyzerPerfusionApparatus = ''
      if(this.prescriptionList!=undefined || this.prescriptionList!=null){
        for (let i = 0; i < this.prescriptionList.length; i++) {
          if (this.prescriptionList[i].patient_id == id) {
            dialyzerPerfusionApparatus = this.prescriptionList[i].dialysis_dialyszers
          }
       }
      }
     
      return dialyzerPerfusionApparatus
    },
    getDialyzerPerfusionApparatusTwo(id){
      var dialyzerPerfusionApparatus = ''
      if(this.prescriptionList!=undefined || this.prescriptionList!=null){
        for (let i = 0; i < this.prescriptionList.length; i++) {
        if (this.prescriptionList[i].patient_id == id) {
          dialyzerPerfusionApparatus = this.prescriptionList[i].dialysis_irrigation
        }
       }
      }
     
      return dialyzerPerfusionApparatus
    },
    getDialyzerPerfusionApparatusThree(id){
   
      var dialyzerPerfusionApparatus = ''
      if(this.prescriptionList!=undefined || this.prescriptionList!=null ){
        for (let i = 0; i < this.prescriptionList.length; i++) {
          if (this.prescriptionList[i].patient_id == id) {
            dialyzerPerfusionApparatus = this.prescriptionList[i].dialysis_strainer
          }
        }
      }
    
      return dialyzerPerfusionApparatus
    },
    getAnticoagulant (id) {
      var anticoagulant = ''
      if(this.prescriptionList!=undefined || this.prescriptionList!=null){
        for (let i = 0; i < this.prescriptionList.length; i++) {
          if (this.prescriptionList[i].patient_id == id) {
            anticoagulant = this.prescriptionList[i].anticoagulant
          }
       }
      }
     
      return anticoagulant
    },
    getAnticoagulantShouji (id) {
      var shouji = ''
      if(this.prescriptionList!=undefined || this.prescriptionList!=null){
        for (let i = 0; i < this.prescriptionList.length; i++) {
          if (this.prescriptionList[i].patient_id == id && this.prescriptionList[i].anticoagulant_shouji != 0) {
            shouji = '(' + this.prescriptionList[i].anticoagulant_shouji
          }
       }
      }
      
      return shouji
    },
    getAnticoagulantWeichi (id) {
      var weichi = ''
      if(this.prescriptionList!=undefined || this.prescriptionList!=null){
        for (let i = 0; i < this.prescriptionList.length; i++) {
        if (this.prescriptionList[i].patient_id == id && this.prescriptionList[i].anticoagulant_weichi != 0) {
          weichi = '(' + this.prescriptionList[i].anticoagulant_weichi
        }
       
       }
      }
      return weichi
    },
    getAnticoagulantZongliang (id) {
      var zongliang = ''
      if(this.prescriptionList!=undefined || this.prescriptionList!=null){
        for (let i = 0; i < this.prescriptionList.length; i++) {
        if (this.prescriptionList[i].patient_id == id && this.prescriptionList[i].anticoagulant_zongliang != 0) {
          zongliang = '(' + this.prescriptionList[i].anticoagulant_zongliang
        }
       }
      }
     
      return zongliang
    },

    loadMore () {
      if (!this.isStop) {
        this.isStop = true
        this.page++
        const params = {
          start_time: this.selected_date_str,
          keyword: this.search_input,
          scheduleType: this.schedual_type_selected,
          partitionType: this.zone_selected,
          limit: this.limit,
          page: this.page,
          keyword: ''
        }
        getMobileDialysisParameters(params).then(response => {
          if (response.data.state == 1) {
            var schedule =  response.data.data.schedule
            this.loading = false
            //  var total = response.data.data.total
            var prescription = response.data.data.prescription
            this.prescriptions.push(...prescription)
            var pre = this.uniquetwo(this.prescriptions)

            if (response.data.data.prescription.length <= 0) {
              this.isStop = true
            } else {
              this.isStop = false
            }
            this.prescriptionList = pre
            var dialysbefor = response.data.data.dialysbefor
            this.dialysisbefor.push(...dialysbefor)
            var dia = this.uniquetwo(this.dialysisbefor)
            this.dialysisBefor = dia
            if (response.data.data.dialysbefor.length <= 0) {
              this.isStop = true
            } else {
              this.isStop = false
            }
            //  this.dialysisBefor = dialysbefor
            var patient = response.data.data.patient

            if(schedule!=null && schedule.length>0){
           
           for(let j=0;j<patient.length;j++){
             patient[j].sort = 0
             patient[j].number= ""
             for(let i=0;i<schedule.length;i++){
             
                if(patient[j].patient_id == schedule[i].patient_id){
                    patient[j].sort = schedule[i].device_number.sort
                    patient[j].number = schedule[i].device_number.number
                }
             }
            }
        }
          
            if (response.data.data.patient.length <= 0) {
              this.isStop = true
            } else {
              this.isStop = false
            }
            for (let i = 0; i < patient.length; i++) {
              if (patient[i].mode_id == 1) {
                patient[i].mode_id = 'HD'
              }
              if (patient[i].mode_id == 2) {
                patient[i].mode_id = 'HDF'
              }
              if (patient[i].mode_id == 3) {
                patient[i].mode_id = 'HD+HP'
              }
              if (patient[i].mode_id == 4) {
                patient[i].mode_id = 'HP'
              }
              if (patient[i].mode_id == 5) {
                patient[i].mode_id = 'HF'
              }
              if (patient[i].mode_id == 6) {
                patient[i].mode_id = 'SCUF'
              }
              if (patient[i].mode_id == 7) {
                patient[i].mode_id = 'IUF'
              }
              if (patient[i].mode_id == 8) {
                patient[i].mode_id = 'HFHD'
              }
              if (patient[i].mode_id == 9) {
                patient[i].mode_id = 'HFHD+HP'
              }
              if (patient[i].mode_id == 10) {
                patient[i].mode_id = 'PHF'
              }
              if (patient[i].mode_id == 11) {
                patient[i].mode_id = 'HFR'
              }
              if (patient[i].mode_id == 12) {
                patient[i].mode_id = 'HDF+HP'
              }
              if (patient[i].mode_id == 13) {
                patient[i].mode_id = 'CRRT'
              }
              if (patient[i].mode_id == 14) {
                patient[i].mode_id = '腹水回输'
              }
              if (patient[i].mode_id == 15) {
                patient[i].mode_id = 'HD前置换'
              }
              if (patient[i].mode_id == 16) {
                patient[i].mode_id = 'HD后置换'
              }
              if (patient[i].mode_id == 17) {
                patient[i].mode_id = 'HDF前置换'
              }
              if (patient[i].mode_id == 18) {
                patient[i].mode_id = 'HDF后置换'
              }
              if (patient[i].mode_id == 19) {
                patient[i].mode_id = 'IUF+HD'
              }
              if (patient[i].mode_id == 21) {
                patient[i].mode_id = 'HD+'
              }
              if (patient[i].mode_id == 24) {
              patient[i].mode_id = 'I-HDF'
            }
            if (patient[i].mode_id == 25) {
              patient[i].mode_id = 'HD高通'
            }
            if (patient[i].mode_id == 26) {
              patient[i].mode_id = 'CVVH'
            }
            if (patient[i].mode_id == 27) {
              patient[i].mode_id = 'CVVHD'
            }
            if (patient[i].mode_id == 28) {
              patient[i].mode_id = 'CVVHDF'
            }
            if (patient[i].mode_id == 29) {
              patient[i].mode_id = 'PE'
            }
            if (patient[i].mode_id == 30) {
              patient[i].mode_id = '血浆胆红素吸附+HP'
            }
            if (patient[i].mode_id == 31) {
              patient[i].mode_id = 'HPD'
            }
            if (patient[i].mode_id == 32) {
              patient[i].mode_id = 'HDP'
            }
            if (patient[i].mode_id == 33) {
              patient[i].mode_id = 'HFD'
            }
            if (patient[i].mode_id == 34) {
              patient[i].mode_id = 'HDF100'
            }
            if (patient[i].mode_id == 35) {
              patient[i].mode_id = 'HDF600'
            }
            if (patient[i].mode_id == 36) {
              patient[i].mode_id = 'HDF800'
            }
            if (patient[i].mode_id == 37) {
              patient[i].mode_id = 'HDF1000'
            }
            if (patient[i].mode_id == 38) {
              patient[i].mode_id = 'HDF80'
            }
            if (patient[i].mode_id == 39) {
              patient[i].mode_id = 'HF16'
            }
            if (patient[i].mode_id == 40) {
              patient[i].mode_id = 'HD(无肝素)'
            }
            if (patient[i].mode_id == 41) {
              patient[i].mode_id = 'HDF17H'
            }
            if (patient[i].mode_id == 42) {
              patient[i].mode_id = 'HD.'
            }
            if (patient[i].mode_id == 43) {
              patient[i].mode_id = 'HD(2)'
            }
            if (patient[i].mode_id == 44) {
              patient[i].mode_id = '导管溶栓'
            }
              this.datalist.push(...patient)
              var arr = this.unique(this.datalist)

              this.tableData = arr.sort((a, b) => a.sort - b.sort)
              this.$nextTick(() => {
                this.$refs.tab.doLayout()
              })
            }
          } else {
            this.loading = false
          }
        })
      }
    },
    unique (arr) {
      const res = new Map()
      return arr.filter((arr) => !res.has(arr.id) && res.set(arr.id, 1))
    },
    uniquetwo (arr) {
      const res = new Map()
      return arr.filter((arr) => !res.has(arr.patient_id) && res.set(arr.patient_id, 1))
    }
  }
}
</script>

<style lang="scss">
.page_dialysisParameters{
  .el-table td, .el-table th{
    font-size: 15px;
    padding: 12px 0;
  }
  .statisticsImg{
    position: fixed;
    bottom: 0.625rem;
    right: 0.2rem;
    width: 1.875rem;
    height: 1.875rem;
  }
  .el-table th .cell {
    white-space: pre-line;/*保留换行符*/
  }
}
</style>
