<template>
  <div class="page_consumables">
    <div class="cell clearfix">
      <label class="title"> <span class="name">排班班次</span> : </label>
      <div class="time">
        <ul class>
          <li
            :class="item.value == schedulType ? 'active' : ''"
            @click="selectSchedulType(item.value)"
            v-for="item in schedulArr"
            :key="item.value"
          >
            {{ item.label }}
          </li>
        </ul>
      </div>

      <label class="title"><span class="name">日期查询</span> : </label>
      <el-date-picker size="small" v-model="selected_date" prefix-icon="el-icon-date" @change="handleScheduleDateChange"
                      :editable="false" :clearable="false" style="width: 196px;margin-right:10px;" type="date"
                      format="yyyy-MM-dd"
                      value-format="yyyy-MM-dd"
                      placeholder="选择日期时间" align="right"
                      ></el-date-picker>
      <el-input size="small" style="width: 180px;" @keyup.enter.native='searchAction' v-model.trim="search_input"
                class="filter-item" v-model="query.keywords"/>
      <el-button size="small" class="filter-item" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
    </div>
    <div class="cell clearfix" style="justify-content: space-between;">
      <!-- <div style="display:flex;">
        <label class="title"> <span class="name">分区</span> : </label>
        <div class="time">
          <ul class>
            <li
              :class="item.id == partitionType ? 'active' : ''"
              @click="selectPartitionType(item.id)"
              v-for="item in partitionArr"
              :key="item.id"
            >
              {{ item.name }}
            </li>
          </ul>
        </div>
      </div> -->
      <label class="title"><span class="name">分区</span> : </label>
      <el-select v-model="partition_id" multiple  placeholder="请选择分区" style="margin-left:-400px"  @change="selectPartitionType">
        <el-option
          v-for="item in partitionArrOne"
          :key="item.id"
          :label="item.name"
          :value="item.id">
        </el-option>
      </el-select>
      <div>
        <el-button size="small" icon="el-icon-printer" @click="toDialog" type="primary">设置</el-button>
        <el-button size="small" icon="el-icon-printer" @click="toSign" type="primary">标签打印</el-button>
        <el-button size="small" icon="el-icon-printer" @click="printAction" type="primary">标签打印设置</el-button>
        
        <el-button size="small"  @click="exportList" type="primary">导出</el-button>
        <el-button size="small"  @click="toPrint" icon="el-icon-printer" type="primary">打印</el-button>
        <el-button size="small" type="primary" @click="statistics">统计表</el-button>
        
      </div>
    </div>
  
    <div>
      <el-table
        :data="list"
        border
        :row-style="{ color: '#303133' }"
        :header-cell-style="{
          backgroundColor: 'rgb(245, 247, 250)',
          color: '#606266'
        }"
       @selection-change="handleSelectionChange"
      >
        <el-table-column align="center"  type="selection" width="55">
        </el-table-column>
        <el-table-column align="center" label="序号" width="55">
           <template slot-scope="scope">
             {{scope.$index + 1}}
           </template>
        </el-table-column>
         <el-table-column align="center" label="透析机号"  v-if="dialysisSett.device_number==1">
           <template slot-scope="scope">
             {{scope.row.device_number.zone.name}}  {{scope.row.device_number.number}}
           </template>
        </el-table-column>
        <el-table-column align="center" label="姓名" v-if="dialysisSett.name==1">
           <template slot-scope="scope">
            {{scope.row.patient.name}}
           </template>
        </el-table-column>
        <el-table-column align="center" label="透析模式" v-if="dialysisSett.name==1">
           <template slot-scope="scope">
            <span v-if="scope.row.mode_id == 1">HD</span>
            <span v-if="scope.row.mode_id == 2">HDF</span>
            <span v-if="scope.row.mode_id == 3">HD+HP</span>
            <span v-if="scope.row.mode_id == 4">HP</span>
            <span v-if="scope.row.mode_id == 5">HF</span>
            <span v-if="scope.row.mode_id == 6">SCUF</span>
            <span v-if="scope.row.mode_id == 7">IUF</span>
            <span v-if="scope.row.mode_id == 8">HFHD</span>
            <span v-if="scope.row.mode_id == 9">HFHD+HP</span>
            <span v-if="scope.row.mode_id == 10">PHF</span>
            <span v-if="scope.row.mode_id == 11">HFR</span>
            <span v-if="scope.row.mode_id == 12">HDF+HP</span>
            <span v-if="scope.row.mode_id == 13">CRRT</span>
            <span v-if="scope.row.mode_id == 19">IUF+HD</span>
            <span v-if="scope.row.mode_id == 20">UF</span>
            <span v-if="scope.row.mode_id == 21">HD+</span>
            <span v-if="scope.row.mode_id == 22">血浆胆红素吸附+HDF</span>
            <span v-if="scope.row.mode_id == 23">血浆胆红素吸附</span>
            <span v-if="scope.row.mode_id == 24">I-HDF</span>
            <span v-if="scope.row.mode_id == 25">HD高通F</span>
            <span v-if="scope.row.mode_id == 26">CVVH</span>
            <span v-if="scope.row.mode_id == 27">CVVHD</span>
            <span v-if="scope.row.mode_id == 28">CVVHDF</span>
            <span v-if="scope.row.mode_id == 29">PE</span>
            <span v-if="scope.row.mode_id == 30">血浆胆红素吸附+HP</span>
            <span v-if="scope.row.mode_id == 31">HPD</span>
            <span v-if="scope.row.mode_id == 32">HDP</span>
            <span v-if="scope.row.mode_id == 33">HFD</span>
            <span v-if="scope.row.mode_id == 34">HDF100</span>
            <span v-if="scope.row.mode_id == 35">HDF600</span>
            <span v-if="scope.row.mode_id == 36">HDF800</span>
            <span v-if="scope.row.mode_id == 37">HDF1000</span>
           </template>
        </el-table-column>
        <el-table-column align="center" label="透析号" v-if="dialysisSett.dialysis_no==1">
           <template slot-scope="scope">
            {{scope.row.patient.dialysis_no}}
           </template>
        </el-table-column>
        <el-table-column align="center" label="住院(门诊)号"  v-if="dialysisSett.admission_number==1">
           <template slot-scope="scope">
             {{scope.row.xt_receive_treatment_asses.admission_number}}
           </template>
        </el-table-column>
        <el-table-column align="center" label="透前体重"  v-if="dialysisSett.weight_befor==1">
           <template slot-scope="scope">
             {{scope.row.assessment_befor_dislysis.weight_before?scope.row.assessment_befor_dislysis.weight_before:""}}
           </template>
        </el-table-column>
         <el-table-column align="center" label="干体重" v-if="dialysisSett.dry_weight==1">
           <template slot-scope="scope">
            {{scope.row.assessment_befor_dislysis.dry_weight?scope.row.assessment_befor_dislysis.dry_weight:""}}
           </template>
        </el-table-column>
         <el-table-column align="center" label="透前血压"  v-if="dialysisSett.blood_pressure==1">
           <template slot-scope="scope">
            <span v-if="scope.row.assessment_befor_dislysis.systolic_blood_pressure>0">{{scope.row.assessment_befor_dislysis.systolic_blood_pressure}}</span>
            <span v-if="scope.row.assessment_befor_dislysis.diastolic_blood_pressure>0">/{{scope.row.assessment_befor_dislysis.diastolic_blood_pressure}}</span> 
           </template>
        </el-table-column>
         <el-table-column align="center" label="目标脱水量"  v-if="dialysisSett.ultrafiltration_volume==1">
           <template slot-scope="scope">
             <span v-if="scope.row.dialysis_solution.target_ultrafiltration>0">{{scope.row.dialysis_solution.target_ultrafiltration}}</span>
           </template>
        </el-table-column>
        <el-table-column align="center" label="抗凝剂(首剂)(维持)(总量)"  v-if="dialysisSett.anticoagulant==1">
           <template slot-scope="scope">
             <span>{{getAnticoagualnt(scope.row.dialysis_solution.anticoagulant)}}</span>
             <span v-if="scope.row.dialysis_solution.anticoagulant_shouji > 0">({{scope.row.dialysis_solution.anticoagulant_shouji}})</span>
             <span v-if="scope.row.dialysis_solution.anticoagulant_weichi > 0">({{scope.row.dialysis_solution.anticoagulant_weichi}})</span>
             <span v-if="scope.row.dialysis_solution.anticoagulant_zongliang > 0">({{scope.row.dialysis_solution.anticoagulant_zongliang}})</span>
           </template>
        </el-table-column>

        <el-table-column align="center" label="透析时长" v-if="dialysisSett.dialysis_time ==1">
           <template slot-scope="scope">
             <span v-if="scope.row.dialysis_solution.dialysis_duration_hour >0">{{scope.row.dialysis_solution.dialysis_duration_hour}}时</span>
             <span v-if="scope.row.dialysis_solution.dialysis_duration_minute >0">{{scope.row.dialysis_solution.dialysis_duration_minute}}分</span>
           </template>
        </el-table-column>

       <el-table-column align="center" label="设备型号"  v-if="dialysisSett.device_type==1">
           <template slot-scope="scope">
             <span>{{scope.row.assessment_befor_dislysis.machine_type}}</span>
           </template>
        </el-table-column>

        <el-table-column align="center" label="透析器/灌流器"  v-if="dialysisSett.dialyzer_perfusion_apparatus == 1">
           <template slot-scope="scope">
             <span>{{scope.row.dialysis_solution.dialyzer_perfusion_apparatus}}</span>
           </template>
        </el-table-column>

        <el-table-column align="center" label="透析器"  v-if="dialysisSett.dialysis_dialyszers == 1">
           <template slot-scope="scope">
             <span>{{scope.row.dialysis_solution.dialysis_dialyszers}}</span>
           </template>
        </el-table-column>

         <el-table-column align="center" label="灌流器"  v-if="dialysisSett.dialysis_irrigation ==1">
           <template slot-scope="scope">
             <span>{{scope.row.dialysis_solution.dialysis_irrigation}}</span>
           </template>
        </el-table-column>

        <el-table-column align="center" label="滤过器"  v-if="dialysisSett.dialysis_irrigation ==1">
           <template slot-scope="scope">
             <span>{{scope.row.dialysis_solution.dialysis_strainer}}</span>
           </template>
        </el-table-column>
        
        
        <el-table-column align="center" label="置换液" v-if="dialysisSett.displace_liqui_part==1">
           <template slot-scope="scope">
             <span>{{getDisplaceLiquiPart(scope.row.dialysis_solution.displace_liqui_part)}}</span>
           </template>
        </el-table-column>

        <el-table-column align="center" label="置换液总量" v-if="dialysisSett.displace_liqui_value==1">
           <template slot-scope="scope">
             <span v-if="scope.row.dialysis_solution.displace_liqui_value>0">{{scope.row.dialysis_solution.displace_liqui_value}}</span>
           </template>
        </el-table-column>
       

        <el-table-column align="center" label="钾"  v-if="dialysisSett.kalium==1">
           <template slot-scope="scope">
             <span v-if="scope.row.dialysis_solution.kalium>0">{{scope.row.dialysis_solution.kalium}}</span>
           </template>
        </el-table-column>

        <el-table-column align="center" label="钠" v-if="dialysisSett.sodium==1">
           <template slot-scope="scope">
             <span v-if="scope.row.dialysis_solution.sodium>0">{{scope.row.dialysis_solution.sodium}}</span>
           </template>
        </el-table-column>



        <el-table-column align="center" label="钙" v-if="dialysisSett.calcium==1">
           <template slot-scope="scope">
             <span v-if="scope.row.dialysis_solution.calcium>0">{{scope.row.dialysis_solution.calcium}}</span>
           </template>
        </el-table-column>

        <el-table-column align="center" label="碳酸氢盐"  v-if="dialysisSett.bicarbonate == 1">
           <template slot-scope="scope">
              <span v-if="scope.row.dialysis_solution.bicarbonate>0">{{scope.row.dialysis_solution.bicarbonate}}</span>
           </template>
        </el-table-column>

        <el-table-column align="center" label="血管通路" v-if="dialysisSett.blood_access==1">
           <template slot-scope="scope">
             <span>{{getBloodAccessOption(scope.row.dialysis_solution.blood_access)}}</span>
           </template>
        </el-table-column>

        <el-table-column align="center" label="封管液" v-if="dialysisSett.blood_access==1">
           <template slot-scope="scope">
             <span v-if="getBloodAccessOption(scope.row.dialysis_solution.blood_access).indexOf('导管')!==-1">1</span>
           </template>
        </el-table-column>

        <el-table-column align="center" label="促红" v-if="org_id!=10599">
           <template slot-scope="scope">
              {{ scope.row.advice_spc }}
           </template>
        </el-table-column>
       <el-table-column align="center" label="封管液" v-if="dialysisSett.sealing_fluid_dispose == 1">
           <template slot-scope="scope">
             <span>{{scope.row.xt_assesment_after_dislysis.sealing_fluid_dispose}} </span> 
           </template>
        </el-table-column>

        <el-table-column align="center" label="葡萄糖"  v-if="dialysisSett.glucose==1">
           <template slot-scope="scope">
             <span>{{scope.row.dialysis_solution.amylaceum?scope.row.dialysis_solution.amylaceum:""}} </span> 
           </template>
        </el-table-column>

       <el-table-column align="center" label="血流量"  v-if="dialysisSett.blood_flow_volume==1">
           <template slot-scope="scope">
             <span>{{scope.row.dialysis_solution.blood_flow_volume?scope.row.dialysis_solution.blood_flow_volume:""}} </span> 
           </template>
        </el-table-column>
      </el-table>

      <el-dialog
        title="统计类型设置"
        :visible.sync="dialogVisible"
        width="30%">
        <span>
           <el-checkbox v-model="device_number" label="透析机号"></el-checkbox>
           <el-checkbox v-model="device_type" label="设备型号"></el-checkbox>
           <el-checkbox v-model="name" label="姓名"></el-checkbox>
           <el-checkbox v-model="admission_number" label="住院(门诊)号"></el-checkbox>
           <el-checkbox v-model="dialysis_no" label="透析号"></el-checkbox>
           <el-checkbox v-model="weight_befor" label="透前体重"></el-checkbox>
           <el-checkbox v-model="dry_weight" label="干体重"></el-checkbox>
           <el-checkbox v-model="blood_pressure" label="透前血压"></el-checkbox>
           <el-checkbox v-model="ultrafiltration_volume" label="目标脱水量"></el-checkbox>
           <!-- <el-checkbox v-model="internal_fistula" label="血管通路"></el-checkbox> -->
           <el-checkbox v-model="blood_flow_volume" label="血流量"></el-checkbox>
           <el-checkbox v-model="anticoagulant" label="抗凝剂(首剂)(维持)(总量)"></el-checkbox>
           <el-checkbox v-model="sealing_fluid_dispose" label="封管液"></el-checkbox>
           <el-checkbox v-model="mode_id" label="透析模式"></el-checkbox>
           <el-checkbox v-model="dialysis_time" label="透析时长"></el-checkbox>
         
           <el-checkbox v-model="dialysis_dialyszers" label="透析器"></el-checkbox>
           <el-checkbox v-model="dialysis_irrigation" label="灌流器"></el-checkbox>
           <el-checkbox v-model="kalium" label="钾"></el-checkbox>
           <el-checkbox v-model="displace_liqui_value" label="置换液总量"></el-checkbox>
           <el-checkbox v-model="bicarbonate" label="碳酸氢根"></el-checkbox>
           <el-checkbox v-model="glucose" label="葡萄糖"></el-checkbox>

           <el-checkbox v-model="dialyzer_perfusion_apparatus" label="透析器/灌流器"></el-checkbox>
           <el-checkbox v-model="displace_liqui_part" label="置换液"></el-checkbox>
           <el-checkbox v-model="sodium" label="钠"></el-checkbox>
           <el-checkbox v-model="calcium" label="钙"></el-checkbox>
           <el-checkbox v-model="blood_access" label="血管通路"></el-checkbox>
        </span>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="saveDialysisSetting">确 定</el-button>
       </span>
      </el-dialog>


  <el-dialog
    title="打印设置"
    :visible.sync="dialogVisibleOne"
    width="30%"
    >
     <span>
       <ul>
         <li>
          <el-checkbox v-model="prescription_status">透析处方状态</el-checkbox>
         </li>
         <li>
          <el-checkbox v-model="week">星期</el-checkbox>
         </li>
         <li>
          <el-checkbox v-model="name">姓名</el-checkbox>
         </li>
         <li>
          <el-checkbox v-model="zone_name">分区</el-checkbox>
         </li>
         <li>
          <el-checkbox v-model="classes">班次</el-checkbox>
         </li>
         <li>
          <el-checkbox v-model="number">机号</el-checkbox>
         </li>
         <li>
          <el-checkbox v-model="mode">透析模式</el-checkbox>
         </li>
         <li>
          <el-checkbox v-model="dialyzers">透析器</el-checkbox>
         </li>
         <li>
          <el-checkbox v-model="perfusion_apparatus">灌流器</el-checkbox>
         </li>
         <li>
          <el-checkbox v-model="anticoagulant">抗凝剂(商品名称)</el-checkbox>
         </li>
         <li>
          <el-checkbox v-model="anticoagulant_zongliang">总量</el-checkbox>
         </li>
         <li>
          <el-checkbox v-model="doctor_advice">长期医嘱</el-checkbox>
         </li>
       </ul>

     </span>
            <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisibleOne = false">取 消</el-button>
      <el-button type="primary" @click="saveRemindPrint">保 存</el-button>
     </span>
    </el-dialog>

    </div>

    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :page-sizes="[100, 200, 300,500,1000]"
      :page-size="100"
      background
      align="right"
      style="margin-top:20px;"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>


   <el-dialog
      title="透析参数统计表"
      :visible.sync="startdialogVisible"
      width="70%">
      <span>
        <div class="cell clearfix">
          <label class="title"> <span class="name">排班班次</span> : </label>
           <el-select v-model="schedule_type" placeholder="请选择" @change="changeScheduleType">
            <el-option
              v-for="item in schedulArr"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
           </el-select>
           <label class="title"> <span class="name">病区选择</span> : </label>
           <el-select v-model="partion_type" placeholder="请选择" @change="changePartionType">
            <el-option
              v-for="item in partitionArr"
              :key="item.id"
              :label="item.name"
              :value="item.id">
            </el-option>
           </el-select>
           <el-button size="small" @click="toPrintOne" icon="el-icon-printer" type="primary">打印</el-button>
           <el-button size="small"  @click="exportListOne" type="primary">导出</el-button>
        </div> 
       <el-table
        :data="tableList"
        border
        :row-style="{ color: '#303133' }"
        :header-cell-style="{
          backgroundColor: 'rgb(245, 247, 250)',
          color: '#606266'
        }"
      >
         <el-table-column  align="center"  label="序号">
           <template slot-scope="scope">
              {{scope.$index+1}}
           </template>
        </el-table-column>
        <el-table-column  align="center"   label="名称">
         <template slot-scope="scope">
             {{scope.row.name}}
         </template>
        </el-table-column>
        <el-table-column  align="center"  label="规格">
           <template slot-scope="scope">
             {{scope.row.specification_name}}
           </template>
        </el-table-column>
       
        <el-table-column  align="center"   label="数量">
           <template slot-scope="scope">
            {{scope.row.count}}
           </template>
        </el-table-column>
        
     

      </el-table>
      </span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="startdialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="startdialogVisible = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>


<script>
  import { GetAllZone,saveDialysisSetting,getDialysisSetting,getDialysisParameter,getDialysisParameterGoodList } from '@/api/dialysis'
  import { uParseTime } from "@/utils/tools";
  import {getRemindPrintList,saveRemindPrint} from '@/api/schedule'
  import { getDataConfig } from '@/utils/data'
  import store from "@/store";
  const moment = require('moment')
  export default {
    components: {
      
    },
    data() {
      return {
        query:{
          total:"",
          schedule_date:"",
          schedule_type:0,
          partition_id:0,
          page:1,
          limit:100,
          keywords:"",
          good_type:0,
          ids:"",
        },
        schedulType: 0,
        schedulArr: [
          { value: 0, label: '全部' },
          { value: 1, label: '上午' },
          { value: 2, label: '下午' },
          { value: 3, label: '晚上' }
        ],
        selected_date: "",
        partitionArr: [],
        goodList:[
          { id: 0, name: '全部' },
          { id: 1, name: '已出库' },
          { id: 2, name: '未出库' },
        ],
        partitionType: 0,
        goodType:0,
        tableData: [{
          date: '2016-05-03',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }
        ],
        search_input: '',
        searchAction: '',
        allGoodInfo:[],
        list:[],
        new_list:[],

        good_types: [],
        arrKey:[],
        arrList:[],
        total:0,
        dialogVisible:false,
        predialysisConditionOptions:[],
        predialysis_condition:false,

        device_number:false,
        device_type:false,
        name:false,
        admission_number:false,
        dialysis_no:false,
        weight_befor:false,
        dry_weight:false,
        blood_pressure:false,
        ultrafiltration_volume:false,
        internal_fistula:false,
        blood_flow_volume:false,
        anticoagulant:false,
        sealing_fluid_dispose:false,
        mode_id:false,
        dialysis_time:false,
        dialysis_dialyszers:false,
        dialysis_irrigation:false,
        gaijiliang:false,
        kalium:false,
        displace_liqui_value:false,
        bicarbonate:false,
        glucose:false,
        dialyzer_perfusion_apparatus:false,
        sodium:false,
        calcium:false,
        blood_access:false,
        displace_liqui_part:false,
        blood_access_option:[],
        startdialogVisible:false,

        schedule_type:0,
        partion_type:0,
        tableList:[],
        dialysisSett:{},
        partitionArrOne:[],
        dialogVisibleOne: false,
        prescription_status: false,
        week: false,
        name: false,
        zone_name: false,
        classes: false,
        number: false,
        mode: false,
        dialyzers: false,
        perfusion_apparatus: false,
        anticoagulant: false,
        anticoagulant_zongliang: false,
        doctor_advice: false,
        displace_liqui_part_option:[],
        ids:"",
        form: {
          id: 0,
          prescription_status: '',
          week: '',
          name: '',
          zone: '',
          classes: '',
          number: '',
          mode: '',
          dialyzers: '',
          perfusion_apparatus: '',
          anticoagulant: '',
          anticoagulant_zongliang: '',
          doctor_advice: ''
        },
        pickerOptions:{ //禁用当前日期之前的日期
           disabledDate(v) {
            //Date.now()是javascript中的内置函数，它返回自1970年1月1日00:00:00 UTC以来经过的毫秒数。
            return v.getTime() < new Date().getTime() - 86400000;
          },
        },
        partition_id:0,
        zoneList:[],
        org_id:0,
       
      }
    },
    open(){
     
    },
    created() {
      this.org_id = this.$store.getters.xt_user.org.id
       this.blood_access_option  = getDataConfig('hemodialysis', 'vascular_access_desc')
       this.displace_liqui_part_option = this.$store.getters.displace_liqui
    
       var filedList = store.getters.xt_user.fileds
       var newArr = [
        {value:999999,filed_name_cn:"姓名"},
        {value:888888,filed_name_cn:"透析号"},
        {value:777777,filed_name_cn:"透析机号"}
        ]
       for (let i = 0; i < filedList.length; i++) {
        if (filedList[i].module == 1 && filedList[i].is_show == 1) {
           newArr.push(filedList[i])
        }
        if (filedList[i].module == 3 && filedList[i].is_show == 1 &&(filedList[i].filed_name_cn == "干体重"  || filedList[i].filed_name_cn == "透前称重" || filedList[i].filed_name_cn == "收缩压" || filedList[i].filed_name_cn == "舒张压" )) {
           newArr.push(filedList[i])
        }
        this.predialysisConditionOptions = newArr
       }
      let date = uParseTime(new Date(), "{y}-{m}-{d}")
      var newDate = new Date();
      var y = newDate.getFullYear();
      var m = newDate.getMonth() + 1;
      var d = newDate.getDate();
      var schedule_date =
        y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d);

      this.selected_date = date
      this.query.schedule_date = schedule_date
      this.query.schedule_type = 0
      this.query.partition_id = 0
      this.query.page = 1
      this.getAllZone()
     
     
     
    },
    methods: {
      getlist(){
      
        
        var str = ""
         if(this.partition_id==0){
            str = this.zoneList.join(",")
         }

         if(this.partition_id!=0){
           str = this.partition_id.join(",")
         }
         this.query.partition_id = ""
         this.query.partition_id = str 
      
        getDialysisParameter(this.query).then(response=>{
            if(response.data.state == 1){
              var list = response.data.data.list
              
              if(list!=null &&list.length>0){
                for(let i=0;i<list.length;i++){
                  list[i].sort = 0
                  list[i].sort = list[i].device_number.sort
                }
      
              }
              list.sort(this.compare('sort'))
            

              for(let i=0;i<list.length;i++){
                list[i].advice_spc =""
                 for(let j=0;j<list[i].advice.length;j++){
                     if((list[i].advice[j].advice_name).indexOf("促红")!=-1){
                        list[i].advice_spc+= (list[i].advice[j].single_dose + "iu"+"/"+ list[i].advice[j].prescribing_number_unit)+","
                     }
                 }
              }
              console.log("listwowowowowowo日本",this.list)
              this.list = list
              this.total = response.data.data.total
              this.dialysisSett = response.data.data.dialysisSett
              // console.log("设置",this.dialysisSett)
            }
        }) 
      },
      compare(p) { //这是比较函数
        return function (m, n) {
          var a = m[p];
          var b = n[p];
          return a - b; //升序
        }
      },
      handleSizeChange(val) {
        this.query.limit = val;
        this.getlist();
      },
      handleCurrentChange(val) {
        this.query.page = val;
        this.getlist();
      },

      calCount(query_warehouseout_info) {
        let total = 0
        var array = []
        array = query_warehouseout_info
        for (let i = 0; i < array.length; i++) {
          total = total + array[i].count
        }
        return total

      },
      getGoodUserInfo(good_type_id,good_user,last_good_user) {
        var arrlist =[]
        if (good_user != null && good_user.length > 0) {
          let desc = ""
          for (let b = 0; b < good_user.length; b++){
            if(good_type_id == good_user[b].good_type_id)
              desc = desc + "\n" + good_user[b].info.specification_name +"*" +good_user[b].count
          }
          arrlist.push(desc)
          return desc
        }
        return ""

        // else if (good_user != null && good_user.length <= 0) {
        //   if (last_good_user != null && last_good_user.length > 0) {
        //     let desc = ""
        //     for (let b = 0; b < last_good_user.length; b++){
        //       if(good_type_id == last_good_user[b].good_type_id)
        //         desc = desc+ "\n" + last_good_user[b].info.specification_name +"*" +last_good_user[b].count
        //     }
        //     console.log(desc)
        //
        //     return desc
        //
        //   }
        //   return ""
        // }
      },
   
      selectSchedulType(scheduleType) {
        this.schedulType = scheduleType
        this.query.schedule_type = scheduleType
        this.query.page = 1
        this.getlist()

      },
      selectPartitionType(partitionType) {
        // this.partitionType = partitionType
        this.query.partition_id = partitionType
        this.query.page = 1

        this.getlist()

      },
      selectGoodType(goodType){
        this.goodType = goodType
        this.query.good_type = goodType
        this.getlist()
      },
      getAllZone: function() {
        GetAllZone().then(response => {
          if (response.data.state == 0) {
            this.$message.error(response.data.msg)
            return false
          } else {
           

            for(let i=0;i<response.data.data.zone.length;i++){
               this.partitionArrOne.push(response.data.data.zone[i])
               this.zoneList.push(response.data.data.zone[i].id)
            }
            this.partitionArr = response.data.data.zone
           
            console.log("全部中",this.partitionArrOne)
            this.partitionArr.unshift({ id: 0, name: '全部' })
            this.getlist()
            
          }
        })
      },
      statistics() {
         this.tableList = []
       
         var params = {
          schedule_type:this.schedule_type,
          partion_type:this.partitionType,
          selected_date:this.query.schedule_date,
        }
    
        var timeStamp = Date.parse(this.query.schedule_date)
       
        var arrDateOne = (timeStamp/1000) -28800
        console.log("时间搓",arrDateOne) 
        let dateone =  moment().format('YYYY-MM-DD')//获取标准时间 //Tue Aug 16 2022 15:06:24 GMT+0800 (中国标准时间)
        //方式一
        let timeStampOne = Date.parse(dateone)
        
        var arrDateTwo = (timeStampOne/1000)-28800

        console.log("时间搓2222",arrDateTwo)
     
        getDialysisParameterGoodList(params).then(response=>{
           if(response.data.state == 1){
            this.startdialogVisible = true
            var list = response.data.data.list
            var anticoagulantList = []
            
            if(arrDateOne > arrDateTwo){
              console.log("简单阿凡达2332322332")
              if(list!=null && list.length>0){
                  for(let i=0;i<list.length;i++){
                    list[i].dialysis_dialyszers_arr = []
                    list[i].dialyzer_perfusion_apparatus_arr = []
                    list[i].dialysis_irrigation_arr = []
                    list[i].dialysis_strainer_arr =[]
                    if(list[i].dialysis_solution.dialysis_dialyszers!=""){
                      list[i].dialysis_dialyszers_arr = list[i].dialysis_solution.dialysis_dialyszers.split(",")
                    }
                    if(list[i].dialysis_solution.dialyzer_perfusion_apparatus!=""){
                      list[i].dialyzer_perfusion_apparatus_arr = list[i].dialysis_solution.dialyzer_perfusion_apparatus.split(",")
                    }
                    if(list[i].dialysis_solution.dialysis_irrigation!=""){
                      list[i].dialysis_irrigation_arr = list[i].dialysis_solution.dialysis_irrigation.split(",")
                    }
                    if(list[i].dialysis_solution.dialysis_strainer!=""){
                        list[i].dialysis_strainer_arr = list[i].dialysis_solution.dialysis_strainer.split(",")
                    }

                    
                    if(list[i].dialysis_solution.anticoagulant == 1){
                        anticoagulantList.push(list[i].dialysis_solution)
                    }
                    if(list[i].dialysis_solution.anticoagulant == 2){
                        anticoagulantList.push(list[i].dialysis_solution)
                    }
                    if(list[i].dialysis_solution.anticoagulant == 3){
                        anticoagulantList.push(list[i].dialysis_solution)
                    }
                    if(list[i].dialysis_solution.anticoagulant == 4){
                        anticoagulantList.push(list[i].dialysis_solution)
                    }
                    if(list[i].dialysis_solution.anticoagulant == 5){
                      anticoagulantList.push(list[i].dialysis_solution)
                    }
                      if(list[i].dialysis_solution.anticoagulant == 6){
                        anticoagulantList.push(list[i].dialysis_solution)
                    }
                      if(list[i].dialysis_solution.anticoagulant == 7){
                      anticoagulantList.push(list[i].dialysis_solution)
                    }
                      if(list[i].dialysis_solution.anticoagulant == 8){
                      anticoagulantList.push(list[i].dialysis_solution)
                    }
                    if(list[i].dialysis_solution.anticoagulant == 9){
                      anticoagulantList.push(list[i].dialysis_solution)
                    }
                      if(list[i].dialysis_solution.anticoagulant == 10){
                        anticoagulantList.push(list[i].dialysis_solution)
                    }
                      if(list[i].dialysis_solution.anticoagulant == 11){
                        anticoagulantList.push(list[i].dialysis_solution)
                    }
                      if(list[i].dialysis_solution.anticoagulant == 12){
                        anticoagulantList.push(list[i].dialysis_solution)
                    }
                    if(list[i].dialysis_solution.anticoagulant == 13){
                      anticoagulantList.push(list[i].dialysis_solution)
                    }
                  }
              }
            }

            if(arrDateOne <= arrDateTwo){
               console.log("简哈哈哈发232我")

              if(list!=null && list.length>0){
                for(let i=0;i<list.length;i++){
                    list[i].dialysis_dialyszers_arr = []
                    list[i].dialyzer_perfusion_apparatus_arr = []
                    list[i].dialysis_irrigation_arr = []
                    list[i].dialysis_strainer_arr =[]
                    if(list[i].dialysis_prescription.dialysis_dialyszers!=""){
                      list[i].dialysis_dialyszers_arr = list[i].dialysis_prescription.dialysis_dialyszers.split(",")
                    }
                    if(list[i].dialysis_prescription.dialyzer_perfusion_apparatus!=""){
                      list[i].dialyzer_perfusion_apparatus_arr = list[i].dialysis_prescription.dialyzer_perfusion_apparatus.split(",")
                    }
                    if(list[i].dialysis_prescription.dialysis_irrigation!=""){
                      list[i].dialysis_irrigation_arr = list[i].dialysis_prescription.dialysis_irrigation.split(",")
                    }
                    console.log("list[i].dialysis_prescription.dialysis_strainer",list[i].dialysis_prescription.dialysis_strainer)
                    if(list[i].dialysis_prescription.dialysis_strainer!=""){
                        list[i].dialysis_strainer_arr = list[i].dialysis_prescription.dialysis_strainer.split(",")
                    }

                    
                    if(list[i].dialysis_prescription.anticoagulant == 1){
                        anticoagulantList.push(list[i].dialysis_prescription)
                    }
                    if(list[i].dialysis_prescription.anticoagulant == 2){
                        anticoagulantList.push(list[i].dialysis_prescription)
                    }
                    if(list[i].dialysis_prescription.anticoagulant == 3){
                        anticoagulantList.push(list[i].dialysis_prescription)
                    }
                    if(list[i].dialysis_prescription.anticoagulant == 4){
                        anticoagulantList.push(list[i].dialysis_prescription)
                    }
                    if(list[i].dialysis_prescription.anticoagulant == 5){
                      anticoagulantList.push(list[i].dialysis_prescription)
                    }
                      if(list[i].dialysis_prescription.anticoagulant == 6){
                        anticoagulantList.push(list[i].dialysis_prescription)
                    }
                      if(list[i].dialysis_prescription.anticoagulant == 7){
                      anticoagulantList.push(list[i].dialysis_prescription)
                    }
                      if(list[i].dialysis_prescription.anticoagulant == 8){
                      anticoagulantList.push(list[i].dialysis_prescription)
                    }
                    if(list[i].dialysis_prescription.anticoagulant == 9){
                      anticoagulantList.push(list[i].dialysis_prescription)
                    }
                      if(list[i].dialysis_prescription.anticoagulant == 10){
                        anticoagulantList.push(list[i].dialysis_prescription)
                    }
                      if(list[i].dialysis_prescription.anticoagulant == 11){
                        anticoagulantList.push(list[i].dialysis_prescription)
                    }
                      if(list[i].dialysis_prescription.anticoagulant == 12){
                        anticoagulantList.push(list[i].dialysis_prescription)
                    }
                    if(list[i].dialysis_prescription.anticoagulant == 13){
                      anticoagulantList.push(list[i].dialysis_prescription)
                    }
                  }
              }
            }
            console.log("listoope2233232",list)
            // var NewAllList=[]
            // for(let i=0;i<list.length;i++){
            //    if(list[i].dialysis_machine_name =="OCI150"){
            //         NewAllList.push(list[i]) 
            //    }
            // }
            // console.log("NewAllList",NewAllList)
          
         
           this.tableList = []
           if(anticoagulantList!=null && anticoagulantList.length > 0){
                let dataInfoOne = {}
                anticoagulantList.forEach((item, index) => {
                let { anticoagulant } = item
                if (!dataInfoOne[anticoagulant]) {
                  dataInfoOne[anticoagulant] = {
                    anticoagulant:item.anticoagulant,
                    name: "抗凝剂",
                    specification_name:this.getAnticoagualnt(item.anticoagulant),
                    count:0,
                    child:[]
                  }
                }
              })
            let hisarr = Object.values(dataInfoOne)
            if(hisarr!=null && hisarr.length > 0){
              for(let i=0;i<anticoagulantList.length;i++){
                for(let j=0;j<hisarr.length;j++){
                  if(anticoagulantList[i].anticoagulant == hisarr[j].anticoagulant){
                     hisarr[j].child.push(anticoagulantList[i])
                  }
                }
              }
            }
            for(let i=0;i<hisarr.length;i++){
              hisarr[i].count = hisarr[i].child.length
              this.tableList.push(hisarr[i])
            }
            console.log("hisarr",hisarr)

           }
            var dialysisDialyszersArr = []
            var dialyzerPerfusionApparaArr = []
            var dialysisIrrigationArr = []

            var dialysisStrainerArr = []
            for(let i=0;i<list.length;i++){
             for(let j=0;j<list[i].dialysis_dialyszers_arr.length;j++){
               dialysisDialyszersArr.push(list[i].dialysis_dialyszers_arr[j])  
             }
             for(let z=0;z<list[i].dialyzer_perfusion_apparatus_arr.length;z++){
              dialyzerPerfusionApparaArr.push(list[i].dialyzer_perfusion_apparatus_arr[z])
             }
             for(let y=0;y<list[i].dialysis_irrigation_arr.length;y++){
              dialysisIrrigationArr.push(list[i].dialysis_irrigation_arr[y])
             }
             for(let p=0;p<list[i].dialysis_strainer_arr.length;p++){
              dialysisStrainerArr.push(list[i].dialysis_strainer_arr[p])
             }
            }
          console.log("dialysisDialyszersArrooo2oo2o2o2o2",dialysisStrainerArr)
           let obj = {}
           let objOne = {}
           let objTwo = {}
           let objThree = {}
           for(let i = 0 ; i < dialysisDialyszersArr.length; i++){
            if(obj[dialysisDialyszersArr[i]]){
               obj[dialysisDialyszersArr[i]] +=1
            }else{
              obj[dialysisDialyszersArr[i]] = 1
            }
           }
           let Arr = [];
            for (let i in obj) {
              let a = {};
              a[i] = obj[i];
              a.name = "透析器"
              a.count = obj[i]
              a.specification_name = i
              Arr.push(a);
            }
          
           for(let i=0;i<dialyzerPerfusionApparaArr.length;i++){
            if(objOne[dialyzerPerfusionApparaArr[i]]){
                objOne[dialyzerPerfusionApparaArr[i]] +=1
             }else{
              objOne[dialyzerPerfusionApparaArr[i]] = 1
             }   
           }
           
           for (let i in objOne) {
              let a = {};
              a[i] = objOne[i];
              a.name = "透析器/灌流器"
              a.count = objOne[i]
              a.specification_name = i
              Arr.push(a);
            }

         

           for(let i=0;i<dialysisIrrigationArr.length;i++){
            if(objTwo[dialysisIrrigationArr[i]]){
              objTwo[dialysisIrrigationArr[i]] +=1
             }else{
              objTwo[dialysisIrrigationArr[i]] = 1
             }   
           }

           for (let i in objTwo) {
              let a = {};
              a[i] = objTwo[i];
              a.name = "灌流器"
              a.count = objTwo[i]
              a.specification_name = i
              Arr.push(a);
            }
            console.log("newa",Arr)

           for (let i in objThree) {
              let a = {};
              a[i] = objThree[i];
              a.name = "滤过器"
              a.count = objThree[i]
              a.specification_name = i
              Arr.push(a);
            }

            for(let i=0;i<dialysisStrainerArr.length;i++){
            if(objThree[dialysisStrainerArr[i]]){
              objThree[dialysisStrainerArr[i]] +=1
             }else{
              objThree[dialysisStrainerArr[i]] = 1
             }   
           }

           for (let i in objThree) {
              let a = {};
              a[i] = objThree[i];
              a.name = "滤过器"
              a.count = objThree[i]
              a.specification_name = i
              Arr.push(a);
            }

            console.log("Arrowowwwwwwwwwww",Arr)
            if(Arr.length >0){
              for(let i=0;i<Arr.length;i++){
                 this.tableList.push(Arr[i])
              }
            }
           }
        })
      },

    
      getModeName(id){
         var mode_name =""
         if(id == 1){
          mode_name = "HD"
         }
         if(id == 2){
          mode_name = "HDF"
         }
         if(id == 3){
          mode_name = "HD+HP"
         }
         if(id == 4){
          mode_name = "HP"
         }
         if(id == 5){
          mode_name = "HF"
         }
         if(id == 6){
          mode_name = "SCUF"
         }
         if(id == 7){
          mode_name = "IUF"
         }
         if(id == 8){
          mode_name = "HFHD"
         }
         if(id == 9){
          mode_name = "HFHD+HP"
         }
         if(id == 10){
          mode_name = "PHF"
         }
         if(id ==11){
           mode_name ="HFR"
         }
         if(id ==12){
           mode_name ="HDF+HP"
         }
         if(id ==25){
           mode_name ="HD高通"
         }
         if(id ==31){
           mode_name ="HPD"
         }
         if(id ==32){
           mode_name ="HDP"
         }
         if(id ==33){
           mode_name ="HFD"
         }
         if(id ==34){
           mode_name ="HDF100"
         }
         if(id ==35){
           mode_name ="HDF600"
         }
         if(id ==36){
           mode_name ="HDF800"
         }
         if(id ==37){
           mode_name ="HDF1000"
         }
        
         return mode_name
      },
      getAnticoagulantName(id){
         var name = ""
         if(id ==1){
            name ="无肝素"
         }
         if(id == 2){
            name ="普通肝素"
         }
         if(id ==3){
            name ="低分子肝素"
         }
         if(id == 6){
           name ="低分子肝素钙"
         }
         if(id == 7){
           name ="低分子肝素钠"
         }
         return name
      },
      handleScheduleDateChange(val) {
        this.query.schedule_date = val
        this.query.page = 1
        this.getlist()
      },
      search() {
        this.query.page = 1
        this.getlist()
      },

       exportList(){
         import('@/vendor/Export2Excel').then(excel => {
      
         if(this.list!=null && this.list.length > 0){
            console.log("hhhahhah",this.list)
            for(let i=0;i<this.list.length;i++){
              this.list[i].index = i+1
              this.list[i].mode_name = this.getModeName(this.list[i].mode_id)
              this.list[i].device_number_one =  this.list[i].device_number.zone.name + this.list[i].device_number.number
              this.list[i].patient_name = this.list[i].patient.name
              this.list[i].dialysis_no = this.list[i].patient.dialysis_no
              this.list[i].admission_number = this.list[i].xt_receive_treatment_asses.admission_number
              this.list[i].weight_before = this.list[i].assessment_befor_dislysis.weight_before?this.list[i].assessment_befor_dislysis.weight_before:"",
              this.list[i].dry_weight = this.list[i].assessment_befor_dislysis.dry_weight?this.list[i].assessment_befor_dislysis.dry_weight:""
              this.list[i].blood_pressure = this.list[i].assessment_befor_dislysis.systolic_blood_pressure?this.list[i].assessment_befor_dislysis.systolic_blood_pressure:"" + "/" + this.list[i].assessment_befor_dislysis.diastolic_blood_pressure? this.list[i].assessment_befor_dislysis.diastolic_blood_pressure:""
              if(this.list[i].blood_pressure == 0){
                this.list[i].blood_pressure = ""
              }
              this.list[i].ultrafiltration_volume = this.list[i].dialysis_solution.target_ultrafiltration?this.list[i].dialysis_solution.target_ultrafiltration:""
             
              
              this.list[i].anticoagulant_one=""
              this.list[i].anticoagulant_one = (this.getAnticoagualnt(this.list[i].dialysis_solution.anticoagulant)) + "(" + (this.list[i].dialysis_solution.anticoagulant_shouji) +")" + "("+(this.list[i].dialysis_solution.anticoagulant_weichi) +")"+"("+(this.list[i].dialysis_solution.anticoagulant_zongliang)+")"
             
              this.list[i].dialysis_time = this.list[i].dialysis_solution.dialysis_duration_hour?this.list[i].dialysis_solution.dialysis_duration_hour:"" + "时"+ this.list[i].dialysis_solution.dialysis_duration_minute?this.list[i].dialysis_solution.dialysis_duration_minute:"" + "分"
              if(this.list[i].dialysis_time == 0){
               this.list[i].dialysis_time = ""
              }
              this.list[i].device_type = this.list[i].assessment_befor_dislysis.machine_type
              this.list[i].dialyzer_perfusion_apparatus = this.list[i].dialysis_solution.dialyzer_perfusion_apparatus
              this.list[i].dialysis_dialyszers = this.list[i].dialysis_solution.dialysis_dialyszers
              this.list[i].dialysis_irrigation = this.list[i].dialysis_solution.dialysis_irrigation
              this.list[i].displace_liqui_part = this.getDisplaceLiquiPart(this.list[i].dialysis_solution.displace_liqui_part)
              this.list[i].displace_liqui_value = this.list[i].dialysis_solution.displace_liqui_value? this.list[i].dialysis_solution.displace_liqui_value:""
              this.list[i].kalium = this.list[i].dialysis_solution.kalium?this.list[i].dialysis_solution.kalium:""
              this.list[i].sodium = this.list[i].dialysis_solution.sodium?this.list[i].dialysis_solution.sodium:""
              this.list[i].calcium = this.list[i].dialysis_solution.calcium?this.list[i].dialysis_solution.calcium:""
              this.list[i].blood_access = this.getBloodAccessOption(this.list[i].dialysis_solution.blood_access)
              this.list[i].sealing_fluid_dispose =this.list[i].xt_assesment_after_dislysis.sealing_fluid_dispose
              this.list[i].glucose = this.list[i].dialysis_solution.glucose?this.list[i].dialysis_solution.glucose:""
              this.list[i].blood_flow_volume = this.list[i].dialysis_solution.blood_flow_volume?this.list[i].dialysis_solution.blood_flow_volume:""
              this.list[i].bicarbonate = this.list[i].dialysis_solution.bicarbonate? this.list[i].dialysis_solution.bicarbonate:""
              this.list[i].count =0
              if(this.getBloodAccessOption(this.list[i].dialysis_solution.blood_access).indexOf("导管")!=-1){
                this.list[i].count =1
              }
            }
         }

         console.log("list23323232322323wode",this.list)
         
         var arr= []
         var arrTwo = []
         arr.push('序号')
         arrTwo.push("index")
         if(this.dialysisSett.device_number == 1){
           arr.push("透析机号")
           arrTwo.push("device_number_one")
         }
         if(this.dialysisSett.name == 1){
           arr.push("姓名")
           arrTwo.push("patient_name")
         }
         arr.push("透析模式")
         arrTwo.push("mode_name")
         if(this.dialysisSett.dialysis_no == 1){
           arr.push("透析号")
           arrTwo.push("dialysis_no")
         }
         if(this.dialysisSett.admission_number == 1){
           arr.push("住院(门诊)号")
           arrTwo.push("admission_number")
         }
         if(this.dialysisSett.weight_befor == 1){
           arr.push("透前体重")
           arrTwo.push("weight_before")
         }
         if(this.dialysisSett.dry_weight == 1){
           arr.push("干体重")
           arrTwo.push("dry_weight")
         }
         if(this.dialysisSett.blood_pressure == 1){
            arr.push("透前血压")
            arrTwo.push("blood_pressure")
         }
         if(this.dialysisSett.ultrafiltration_volume == 1){
           arr.push("目标脱水量")
           arrTwo.push("ultrafiltration_volume")
         }
         if(this.dialysisSett.anticoagulant == 1){
           arr.push("抗凝剂(首剂)(维持)(总量)")
           arrTwo.push("anticoagulant_one")
         }
         if(this.dialysisSett.dialysis_time == 1){
           arr.push("透析时长")
           arrTwo.push("dialysis_time")
         }
         if(this.dialysisSett.device_type == 1){
           arr.push("设备型号")
           arrTwo.push("device_type")
         } 
         if(this.dialysisSett.dialyzer_perfusion_apparatus == 1){
            arr.push("透析器/灌流器")
            arrTwo.push("dialyzer_perfusion_apparatus")
         }
         if(this.dialysisSett.dialysis_dialyszers == 1){
           arr.push("透析器")
           arrTwo.push("dialysis_dialyszers")
         }
         if(this.dialysisSett.dialysis_irrigation == 1){
           arr.push("灌流器")
           arrTwo.push("dialysis_irrigation")
         }
         if(this.dialysisSett.displace_liqui_part == 1){
           arr.push("置换液")
           arrTwo.push("displace_liqui_part")
         }
         if(this.dialysisSett.displace_liqui_value == 1){
           arr.push("置换液总量")
           arrTwo.push("displace_liqui_value")
         }
         if(this.dialysisSett.kalium == 1){
           arr.push("钾")
           arrTwo.push("kalium")
         }
         if(this.dialysisSett.sodium == 1){
           arr.push("钠")
           arrTwo.push("sodium")
         }
         if(this.dialysisSett.calcium == 1){
           arr.push("钙")
           arrTwo.push("calcium")
         }
         if(this.dialysisSett.bicarbonate == 1){
           arr.push("碳酸氢盐")
           arrTwo.push("bicarbonate")
         }
         if(this.dialysisSett.blood_access == 1){
           arr.push("血管通路")
           arrTwo.push("blood_access")
         }

        if(this.dialysisSett.sealing_fluid_dispose == 1){
           arr.push("封管液")
           arrTwo.push("sealing_fluid_dispose")
         }

        if(this.dialysisSett.glucose == 1){
           arr.push("葡萄糖")
           arrTwo.push("glucose")
        }
       if(this.dialysisSett.blood_flow_volume == 1){
           arr.push("血流量")
           arrTwo.push("blood_flow_volume")
        }
         
        arr.push("封管液")
        arrTwo.push("count")

        arr.push("促红")
        arrTwo.push("advice_spc")
       
        const tHeader = arr
        const filterVal = arrTwo
        
        const data = this.formatJson(filterVal, this.list)
        console.log("DATWOWOWOWO",data)
       
         excel.export_json_to_excel({
           header: tHeader,
           data,
           filename: '透析参数查询'
         })
          this.downloadLoading = false
        })
       },
      formatJson(filterVal, jsonData) {
        return jsonData.map(v => filterVal.map(j => v[j]));
      },
      exportListOne(){
        import('@/vendor/Export2Excel').then(excel => { 
        if(this.tableList!=null && this.tableList.length > 0){
           for(let i=0;i<this.tableList.length;i++){
             this.tableList[i].index = i+1
           }
        }
        const tHeader = ['序号','名称','规格','数量']
        const filterVal = ['index', 'name','specification_name','count']

        const data = this.formatJson(filterVal, this.tableList)
         excel.export_json_to_excel({
           header: tHeader,
           data,
           filename: '透析参数统计'
         })
          this.downloadLoading = false
        })  
      },
     toDialog(){
      getDialysisSetting().then(response=>{
        if(response.data.state == 1){
           this.dialogVisible = true
          var dialysisSett = response.data.data.dialysisSett
          if(dialysisSett!=undefined){
           if(dialysisSett.device_number == 1){
                this.device_number = true
            }else{
              this.device_number = false
            }
            if(dialysisSett.device_type == 1){
                this.device_type = true
            }else{
              this.device_type = false
            }
            if(dialysisSett.name == 1){
              this.name = true
            }else{
              this.name = false
            }
            if(dialysisSett.admission_number == 1){
              this.admission_number = true
            }else{
              this.admission_number = false
            }
            if(dialysisSett.dialysis_no == 1){
              this.dialysis_no = true
            }else{
              this.dialysis_no = false
            }
            if(dialysisSett.weight_befor == 1){
              this.weight_befor = true
            }else{
              this.weight_befor = false
            }
            if(dialysisSett.dry_weight == 1){
              this.dry_weight = true
            }else{
              this.dry_weight = false
            }
            if(dialysisSett.blood_pressure == 1){
              this.blood_pressure = true
            }else{
              this.blood_pressure = false
            }
            if(dialysisSett.ultrafiltration_volume == 1){
                this.ultrafiltration_volume = true
            }else{
              this.ultrafiltration_volume = false
            }
            if(dialysisSett.internal_fistula == 1){
              this.internal_fistula = true
            }else{
              this.internal_fistula = false
            }
            if(dialysisSett.blood_flow_volume == 1){
              this.blood_flow_volume = true
            }else{
              this.blood_flow_volume = false
            }
            if(dialysisSett.anticoagulant == 1){
              this.anticoagulant = true
            }else{
              this.anticoagulant = false
            }
            if(dialysisSett.sealing_fluid_dispose == 1){
              this.sealing_fluid_dispose = true
            }else{
              this.sealing_fluid_dispose = false
            }
            if(dialysisSett.mode_id == 1){
              this.mode_id = true
            }else{
              this.mode_id = false
            }
            if(dialysisSett.dialysis_time == 1){
                this.dialysis_time = true
            }else{
              this.dialysis_time = false
            }
            if(dialysisSett.dialysis_dialyszers == 1){
              this.dialysis_dialyszers = true
            }else{
              this.dialysis_dialyszers = false
            }

            if(dialysisSett.dialysis_irrigation == 1){
              this.dialysis_irrigation = true
            }else{
              this.dialysis_irrigation = false
            }

            if(dialysisSett.gaijiliang ==1){
              this.gaijiliang =true
            }else{
              this.gaijiliang = false
            }
            if(dialysisSett.kalium == 1){
              this.kalium =true
            }else{
              this.kalium = false
            }
            if(dialysisSett.displace_liqui_value == 1){
              this.displace_liqui_value = true
            }else{
              this.displace_liqui_value = false
            }
            if(dialysisSett.bicarbonate == 1){
              this.bicarbonate =true
            }else{
              this.bicarbonate = false
            }
            if(dialysisSett.glucose == 1){
            this.glucose =true
            }else{
              this.glucose = false
            }
            if(dialysisSett.sodium == 1){
               this.sodium = true
            }else{
              this.sodium = false
            }
            if(dialysisSett.calcium == 1){
              this.calcium = true
            }else{
              this.calcium = false
            }
            if(dialysisSett.blood_access == 1){
              this.blood_access = true
            }else{
              this.blood_access = false
            }
            if(dialysisSett.dialyzer_perfusion_apparatus == 1){
               this.dialyzer_perfusion_apparatus = true
            }else{
              this.dialyzer_perfusion_apparatus = false
            }
            if(dialysisSett.displace_liqui_part == 1){
              this.displace_liqui_part = true
            }else{
              this.displace_liqui_part = false
            }
          }
     
        }
      })
      
     },
     saveDialysisSetting(){
       var device_number_set = 0 
       var device_type_set = 0
       var name_set = 0
       var admission_number_set = 0
       var dialysis_no_set = 0
       var weight_befor_set = 0
       var dry_weight_set = 0
       var blood_pressure_set = 0
       var ultrafiltration_volume_set= 0
       var internal_fistula_set = 0
       var blood_flow_volume_set = 0
       var anticoagulant_set = 0
       var sealing_fluid_dispose_set = 0
       var mode_id_set =0
       var dialysis_time_set =0
       var dialysis_dialyszers_set =0
       var dialysis_irrigation_set =0
       var gaijiliang_set = 0
       var kalium_set = 0
       var displace_liqui_value_set =0
       var bicarbonate_set =0
       var glucose_set = 0
       var sodium_set = 0
       var calcium_set =0
       var blood_access_set =0
       var dialyzer_perfusion_apparatus_set =0
       var displace_liqui_part_set =0
       
       if(this.sodium == false){
         sodium_set = 2
       }
       if(this.sodium == true){
         sodium_set = 1
       }

       if(this.calcium ==false){
         calcium_set = 2
       }
       if(this.calcium == true){
          calcium_set = 1
       }

      if(this.blood_access ==false){
         blood_access_set = 2
       }
       if(this.blood_access == true){
          blood_access_set = 1
       }

       if(this.dialyzer_perfusion_apparatus == false){
         dialyzer_perfusion_apparatus_set = 2
       }
       if(this.dialyzer_perfusion_apparatus == true){
         dialyzer_perfusion_apparatus_set =1
       }

       if(this.displace_liqui_part == false){
          displace_liqui_part_set = 2
       }
       
       if(this.displace_liqui_part == true){
          displace_liqui_part_set = 1
       }
    

       if(this.device_number == false){
          device_number_set = 2
        }
       if(this.device_number == true){
          device_number_set = 1
        }
        if(this.device_type == false){
          device_type_set = 2
        }
        if(this.device_type == true){
          device_type_set = 1
        }
        if(this.name == false){
          name_set = 2
        }
        if(this.name == true){
          name_set = 1
        }
        if(this.admission_number == false){
          admission_number_set = 2
        }
        if(this.admission_number== true){
          admission_number_set = 1
        }
        if(this.dialysis_no == false){
           dialysis_no_set = 2
        }
        if(this.dialysis_no == true){
           dialysis_no_set = 1
        }
        if(this.weight_befor == false){
           weight_befor_set = 2
        } 
        if(this.weight_befor == true){
           weight_befor_set = 1
        }
        if(this.dry_weight == false){
           dry_weight_set = 2
        }
        if(this.dry_weight == true){
           dry_weight_set = 1
        }   
        if(this.blood_pressure == false){
          blood_pressure_set = 2
        }
        if(this.blood_pressure == true){
           blood_pressure_set = 1
        }
        if(this.ultrafiltration_volume == false){
           ultrafiltration_volume_set = 2
        }
        if(this.ultrafiltration_volume == true){
           ultrafiltration_volume_set = 1
        }
        if(this.internal_fistula == false){
            internal_fistula_set = 2
        }
        if(this.internal_fistula == true){
          internal_fistula_set= 1
        }
        if(this.blood_flow_volume == false){
           blood_flow_volume_set = 2
        }
        if(this.blood_flow_volume == true){
         blood_flow_volume_set = 1
        }
        if(this.anticoagulant == false){
           anticoagulant_set = 2
        }
        if(this.anticoagulant == true){
          anticoagulant_set = 1
        }
        if(this.sealing_fluid_dispose == false){
          sealing_fluid_dispose_set = 2
        }
        if(this.sealing_fluid_dispose == true){
          sealing_fluid_dispose_set = 1
        }
        if(this.mode_id == false){
          mode_id_set = 2
        }
        if(this.mode_id == true){
          mode_id_set = 1
        }
        if(this.dialysis_time == false){
          dialysis_time_set = 2
        }
         if(this.dialysis_time == true){
          dialysis_time_set = 1
        }
        if(this.dialysis_dialyszers == false){
          dialysis_dialyszers_set = 2
        }
        if(this.dialysis_dialyszers == true){
           dialysis_dialyszers_set = 1
        }
        if(this.dialysis_irrigation == false){
           dialysis_irrigation_set = 2
        }
        if(this.dialysis_irrigation == true){
           dialysis_irrigation_set = 1
        }
        if(this.gaijiliang == false){
          this.gaijiliang = 2
        }
        if(this.gaijiliang == true){
          this.gaijiliang = 1
        }
        if(this.kalium == false){
          kalium_set = 2
        }
        if(this.kalium == true){
          kalium_set = 1
        }
        if(this.displace_liqui_value == false){
          displace_liqui_value_set = 2
        }
        if(this.displace_liqui_value == true){
          displace_liqui_value_set = 1
        }
        if(this.bicarbonate == false){
          bicarbonate_set = 2
        }
        if(this.bicarbonate == true){
          bicarbonate_set = 1
        }
        if(this.glucose == false){
           glucose_set = 2
        }
        if(this.glucose == true){
           glucose_set = 1
        }
        var params = {
          device_number_set:device_number_set,
          device_type_set:device_type_set,
          name_set:name_set,
          admission_number_set:admission_number_set,
          dialysis_no_set:dialysis_no_set,
          weight_befor_set:weight_befor_set,
          dry_weight_set:dry_weight_set,
          blood_pressure_set:blood_pressure_set,
          ultrafiltration_volume_set:ultrafiltration_volume_set,
          internal_fistula_set:internal_fistula_set,
          blood_flow_volume_set:blood_flow_volume_set,
          anticoagulant_set:anticoagulant_set,
          sealing_fluid_dispose_set:sealing_fluid_dispose_set,
          mode_id_set:mode_id_set,
          dialysis_time_set:dialysis_time_set,
          dialysis_dialyszers_set:dialysis_dialyszers_set,
          dialysis_irrigation_set:dialysis_irrigation_set,
          gaijiliang_set:gaijiliang_set,
          kalium_set:kalium_set,
          displace_liqui_value_set:displace_liqui_value_set,
          bicarbonate_set:bicarbonate_set,
          glucose_set:glucose_set,
          sodium_set:sodium_set,
          calcium_set:calcium_set,
          blood_access_set:blood_access_set,
          dialyzer_perfusion_apparatus_set:dialyzer_perfusion_apparatus_set,
          displace_liqui_part_set:displace_liqui_part_set,
        }
       
       saveDialysisSetting(params).then(response=>{
         if(response.data.state == 1){
           var dialysisSetting = response.data.data.dialysisSetting
           this.$message.success("保存成功!")
           this.dialogVisible = false
           this.getlist()
         }
       })
     },
     getAnticoagualnt(id){
       var name = ""
       if(id == 1){
         name = "无肝素"
       }
       if(id == 2){
        name = "普通肝素"
       }
       if(id == 3){
         name ="低分子肝素"
       }
       if(id == 4){
         name ="阿加曲班"
       }
       if(id == 5){
         name ="枸橼酸钠"
       }
       if(id == 6){
         name ="低分子肝素钙"
       }
       if(id == 7){
         name ="低分子肝素钠"
       }
       if(id == 8){
         name ="依诺肝素"
       }
       if(id == 9){
         name ="达肝素"
       }
       if(id == 10){
         name ="体外抗凝"
       }
       if(id == 11){
         name ="那屈肝素"
       }
       if(id == 12){
         name ="无抗凝剂"
       }
       if(id == 13){
         name ="那屈肝素钙"
       }
       return name
     },
     getBloodAccessOption(id){
       var name = ""
       for(let i=0;i<this.blood_access_option.length;i++){
         if(id == this.blood_access_option[i].id){
            name = this.blood_access_option[i].name
         }
       }
       return name
     },
     toSign(){
       this.$router.push({path: '/dialysis/consumable/dialysis/print?schedule_type='+this.query.schedule_type+"&partion_id="+this.query.partition_id+"&schedule_date="+this.query.schedule_date+"&keyword="+this.query.keywords+"&page="+this.query.page+"&limit="+this.query.limit})
     },
     printAction(){
      this.getRemindPrintList()
      this.dialogVisibleOne = true

     },
    getRemindPrintList() {
        getRemindPrintList().then(response => {
          if (response.data.state == 1) {
            var list = response.data.data.list
            console.log('list222332', list)
            if (list.anticoagulant == 1) {
              // console.log('进来22222')
              this.anticoagulant = true
            }
            if (list.anticoagulant == 2) {
              this.anticoagulant = false
            }
            if (list.anticoagulant_zongliang == 1) {
              this.anticoagulant_zongliang = true
            }
            if (list.anticoagulant_zongliang == 2) {
              this.anticoagulant_zongliang = false
            }
            if (list.classes == 1) {
              this.classes = true
            }
            if (list.classes == 2) {
              this.classes = false
            }
            if (list.dialyzers == 1) {
              this.dialyzers = true
            }
            if (list.dialyzers == 2) {
              this.dialyzers = false
            }
            if (list.doctor_advice == 1) {
              this.doctor_advice = true
            }
            if (list.doctor_advice == 2) {
              this.doctor_advice = false
            }
            if (list.name == 1) {
              this.name = true
            }
            if (list.name == 2) {
              this.name = false
            }
            if (list.number == 1) {
              this.number = true
            }
            if (list.number == 2) {
              this.number = false
            }
            if (list.perfusion_apparatus == 1) {
              this.perfusion_apparatus = true
            }
            if (list.perfusion_apparatus == 2) {
              this.perfusion_apparatus = false
            }
            if (list.prescription_status == 1) {
              this.prescription_status = true
            }
            if (list.prescription_status == 2) {
              this.prescription_status = false
            }
            if (list.week == 1) {
              this.week = true
            }
            if (list.week == 2) {
              this.week = false
            }
            if (list.zone == 1) {
              this.zone_name = true
            }
            if (list.zone == 2) {
              this.zone_name = false
            }
            if (list.mode == 1) {
              this.mode = true
            }
            if (list.mode == 2) {
              this.mode = false
            }
            this.form.id = list.id
          }
        })
      },
    
      saveRemindPrint() {
       

        if (this.perfusion_apparatus == true) {
          // console.log('3333')
          this.form.perfusion_apparatus = 1
        }
        if (this.perfusion_apparatus == false) {
          this.form.perfusion_apparatus = 2
        }
        if (this.prescription_status == true) {
          this.form.prescription_status = 1
        }
        if (this.prescription_status == false) {
          this.form.prescription_status = 2
        }
        if (this.week == true) {
          this.form.week = 1
        }
        if (this.week == false) {
          this.form.week = 2
        }
        if (this.name == true) {
          this.form.name = 1
        }
        if (this.name == false) {
          this.form.name = 2
        }
        if (this.zone_name == true) {
          this.form.zone = 1
        }
        if (this.zone_name == false) {
          this.form.zone = 2
        }
        if (this.classes == true) {
          this.form.classes = 1
        }
        if (this.classes == false) {
          this.form.classes = 2
        }
        if (this.number == true) {
          this.form.number = 1
        }
        if (this.number == false) {
          this.form.number = 2
        }
        if (this.mode == true) {
          this.form.mode = 1
        }
        if (this.mode == false) {
          this.form.mode = 2
        }
        if (this.dialyzers == true) {
          this.form.dialyzers = 1
        }
        if (this.dialyzers == false) {
          this.form.dialyzers = 2
        }

        if (this.anticoagulant == true) {
          this.form.anticoagulant = 1
        }
        if (this.anticoagulant == false) {
          this.form.anticoagulant = 2
        }
        if (this.anticoagulant_zongliang == true) {
          this.form.anticoagulant_zongliang = 1
        }
        if (this.anticoagulant_zongliang == false) {
          this.form.anticoagulant_zongliang = 2
        }
        if (this.doctor_advice == true) {
          this.form.doctor_advice = 1
        }
        if (this.doctor_advice == false) {
          this.form.doctor_advice = 2
        }
        // console.log('555555555', this.form.prescription_status)
        var params = {
          id: this.form.id,
          prescription_status: this.form.prescription_status,
          week: this.form.week,
          name: this.form.name,
          zone: this.form.zone,
          classes: this.form.classes,
          number: this.form.number,
          mode: this.form.mode,
          dialyzers: this.form.dialyzers,
          perfusion_apparatus: this.form.perfusion_apparatus,
          anticoagulant: this.form.anticoagulant,
          anticoagulant_zongliang: this.form.anticoagulant_zongliang,
          doctor_advice: this.form.doctor_advice
        }
        // console.log('params', params)
        saveRemindPrint(params).then(response => {
          if (response.data.state == 1) {
            var settting = response.data.data.setting
            this.$message.success('保存成功')
            this.dialogVisibleOne = false
            this.getRemindPrintList()
          }
        })
      },
      toPrint(){
        this.$router.push({path: '/dialysis/consumable/dialysis/parameter/print?schedule_type='+this.query.schedule_type+"&partion_id="+this.query.partition_id+"&schedule_date="+this.query.schedule_date+"&keyword="+this.query.keywords+"&page="+this.query.page+"&limit="+this.query.limit+"&ids="+this.ids})
      },
      toPrintOne(){
        this.$router.push({path:"/dialysis/consumable/dialysis/count/print?schedule_type="+this.schedule_type+"&partion_type="+this.partion_type+"&schedule_date="+this.query.schedule_date})
      },
      handleSelectionChange(val){
        
        var arr = []
        for(let i=0;i<val.length;i++){
          arr.push(val[i].id)
        }
        this.ids = arr.join(",")
     }, 
     changeScheduleType(){
      this.tableList = []
      this.statistics()
     },
     changePartionType(){
      this.tableList = []
      this.statistics()
     },
     getDisplaceLiquiPart(id){
       var name = ""
       for(let i=0;i<this.displace_liqui_part_option.length;i++){
         if(id == this.displace_liqui_part_option[i].id){
            name = this.displace_liqui_part_option[i].name
         }
       }
       return name
     }
    }
  }
</script>


<style lang="scss" scoped>
  .page_consumables {

  .clearfix:after {
    content: none;
  }

  }
</style>
