<template>
  <div>
    <div :class="Screencasting==true ? 'fullscreenbroad' : 'scheduleTablePrint'" >
      <div class="butt" style="text-align: right;">
        <el-button  type="primary" @click="touping">{{Screencasting==true ? '取消投屏':'投屏'}}</el-button>
        <el-button  type="primary" @click="printAction">打印</el-button>
      </div>
      <div class="tab" style="margin-top: 10px;">
        <table id="scheduleTable" class="scheduleTable" border="1" cellspacing="0" style='width: 100%;table-layout:fixed;text-align: center;word-break: break-all;word-wrap: break-word;'>
            <tr>
                <td rowspan="2">分区</td>
                <td rowspan="2">机号</td>
                <td colspan="3" v-if="first_day == 1">周一({{ weekTitle[0] }})</td>
                <td colspan="3" v-if="second_day == 2">周二({{ weekTitle[1] }})</td>
                <td colspan="3" v-if="three_day == 3">周三({{ weekTitle[2] }})</td>
                <td colspan="3" v-if="four_day == 4">周四({{ weekTitle[3] }})</td>
                <td colspan="3" v-if="five_day == 5">周五({{ weekTitle[4] }})</td>
                <td colspan="3" v-if="six_day == 6">周六({{ weekTitle[5] }})</td>
                <td colspan="3" v-if="seven_day == 7">周日({{ weekTitle[6] }})</td>
                 <!-- <td>总数</td>  -->
            </tr>
            <tr>
                <td v-if="first_day == 1">上午</td>
                <td v-if="first_day == 1">下午</td>
                <td v-if="first_day == 1">晚上</td>
                <td v-if="second_day == 2">上午</td>
                <td v-if="second_day == 2">下午</td>
                <td v-if="second_day == 2">晚上</td>
                <td v-if="three_day == 3">上午</td>
                <td v-if="three_day == 3">下午</td>
                <td v-if="three_day == 3">晚上</td>
                <td  v-if="four_day == 4">上午</td>
                <td  v-if="four_day == 4">下午</td>
                <td  v-if="four_day == 4">晚上</td>
                <td v-if="five_day == 5">上午</td>
                <td v-if="five_day == 5">下午</td>
                <td v-if="five_day == 5">晚上</td>
                <td  v-if="six_day == 6">上午</td>
                <td  v-if="six_day == 6">下午</td>
                <td  v-if="six_day == 6">晚上</td>
                <td v-if="seven_day == 7">上午</td>
                <td v-if="seven_day == 7">下午</td>
                <td v-if="seven_day == 7">晚上</td>
            </tr>
            <tr v-for="(item,index) in scheduleZone" :key="index">
                <td style="min-width:50px;">{{ item.area }}</td>
                <td style="min-width:50px;">{{ item.cut }}</td>
                <td style="min-width:50px;" v-if="first_day == 1">
                  <span v-if="item.Mon_M.patient_id">
                    <span>{{ item.Mon_M.patient }} </span><br/>
                    <span >{{ item.Mon_M.mode_name }}</span><br/>
                    <span v-if="org_id==10469 || org_id ==0">{{getAnticoagulant(item.Mon_M.anticoagulant)}}</span><br/>
                    <span v-show="showflag">{{item.Mon_M.dialysis_machine_name}}
                   
                    </span>
                  </span>
                </td>
                <td style="min-width:50px;" v-if="first_day == 1">
                  <span v-if="item.Mon_A.patient_id">
                    <span>{{ item.Mon_A.patient }} </span><br/>
                    <span >{{ item.Mon_A.mode_name }}</span><br/>
                     <span v-if="org_id==10469 || org_id == 0">{{getAnticoagulant(item.Mon_A.anticoagulant)  }}</span>
                    <span v-show="showflag">{{item.Mon_A.dialysis_machine_name}}
                     
                    </span>
                  </span>
                </td>
                <td style="min-width:50px;" v-if="first_day == 1">
                    <span v-if="item.Mon_N.patient_id">
                        <span>{{ item.Mon_N.patient }} </span><br/>
                        <span >{{ item.Mon_N.mode_name }}</span><br/>
                        <span v-if="org_id ==10469 || org_id == 0">{{getAnticoagulant(item.Mon_N.anticoagulant)  }}</span>
                        <span v-show="showflag">{{item.Mon_N.dialysis_machine_name}}
                         
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;"  v-if="second_day == 2">
                    <span v-if="item.Tue_M.patient_id">
                        <span>{{ item.Tue_M.patient }} </span><br/>
                        <span >{{ item.Tue_M.mode_name }}</span><br/>
                        <span v-if="org_id==0||org_id==10469">{{getAnticoagulant(item.Tue_M.anticoagulant )  }}</span><br/>
                        <span v-show="showflag">{{item.Tue_M.dialysis_machine_name}}
                         
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;"  v-if="second_day == 2">
                    <span v-if="item.Tue_A.patient_id">
                      <span>{{ item.Tue_A.patient }} </span><br/>
                        <span >{{ item.Tue_A.mode_name }}</span><br/>
                        <span v-if="org_id ==0||org_id == 10469">{{ getAnticoagulant(item.Tue_A.anticoagulant)}}</span>
                        <span v-show="showflag">{{item.Tue_A.dialysis_machine_name}}
                         
                        </span>

                    </span>
                </td>
                <td style="min-width:50px;"  v-if="second_day == 2">
                    <span v-if="item.Tue_N.patient_id">
                      <span>{{ item.Tue_N.patient }} </span><br/>
                        <span >{{ item.Tue_N.mode_name }}</span><br/>
                        <span v-if="org_id==0||org_id ==10469">{{getAnticoagulant(item.Tue_N.anticoagulant)  }}</span>
                        <span v-show="showflag">{{item.Tue_N.dialysis_machine_name}}
                          
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;" v-if="three_day == 3">
                    <span v-if="item.Wed_M.patient_id">
                      <span>{{ item.Wed_M.patient }} </span><br/>
                        <span >{{ item.Wed_M.mode_name }}</span><br/>
                        <span v-if="org_id == 0 || org_id ==10469">{{getAnticoagulant(item.Wed_M.anticoagulant)  }}</span><br/>
                        <span v-show="showflag">{{item.Wed_M.dialysis_machine_name}}
                          
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;" v-if="three_day == 3">
                    <span v-if="item.Wed_A.patient_id">
                      <span>{{ item.Wed_A.patient }} </span><br/>
                        <span >{{ item.Wed_A.mode_name }}</span><br/>
                        <span v-if="org_id ==0||org_id ==10469">{{getAnticoagulant(item.Wed_A.anticoagulant)}}</span>
                        <span v-show="showflag">{{item.Wed_A.dialysis_machine_name}}
                         
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;" v-if="three_day == 3">
                    <span v-if="item.Wed_N.patient_id">
                      <span>{{ item.Wed_N.patient }} </span><br/>
                        <span >{{ item.Wed_N.mode_name }}</span><br/>
                        <span v-if="org_id ==0 || org_id ==10469">{{ getAnticoagulant(item.Wed_N.anticoagulant) }}</span>
                        <span v-show="showflag">{{item.Wed_N.dialysis_machine_name}}
                         
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;" v-if="four_day == 4">
                    <span v-if="item.Thurs_M.patient_id">
                      <span>{{ item.Thurs_M.patient }} </span><br/>
                        <span >{{ item.Thurs_M.mode_name }}</span><br/>
                        <span v-if="org_id == 0||org_id ==10469">{{ getAnticoagulant(item.Thurs_M.anticoagulant) }}</span>
                        <span v-show="showflag">{{item.Thurs_M.dialysis_machine_name}}
                         
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;" v-if="four_day == 4">
                    <span v-if="item.Thurs_A.patient_id">
                      <span>{{ item.Thurs_A.patient }} </span><br/>
                        <span >{{ item.Thurs_A.mode_name }}</span><br/>
                        <span v-if="org_id ==0||org_id ==10469">{{getAnticoagulant(item.Thurs_A.anticoagulant) }}</span> 

                        <span v-show="showflag">{{item.Thurs_A.dialysis_machine_name}}
                        
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;" v-if="four_day == 4">
                    <span v-if="item.Thurs_N.patient_id">
                      <span>{{ item.Thurs_N.patient }} </span><br/>
                        <span >{{ item.Thurs_N.mode_name }}</span><br/>
                        <span v-if="org_id ==0 || org_id ==10469" >{{ getAnticoagulant(item.Thurs_N.anticoagulant) }}</span> 
                        <span v-show="showflag">{{item.Thurs_N.dialysis_machine_name}}
                         
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;" v-if="five_day == 5">
                    <span v-if="item.Fri_M.patient_id">
                      <span>{{ item.Fri_M.patient }} </span><br/>
                        <span >{{ item.Fri_M.mode_name }}</span><br/>
                        <span v-if="org_id ==0||org_id ==10469">{{ getAnticoagulant(item.Fri_M.anticoagulant) }} </span><br/>
                        <span v-show="showflag">{{item.Fri_M.dialysis_machine_name}}
                          
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;" v-if="five_day == 5">
                    <span v-if="item.Fri_A.patient_id">
                      <span>{{ item.Fri_A.patient }} </span><br/>
                        <span >{{ item.Fri_A.mode_name }}</span><br/>
                        <span v-if="org_id ==0||org_id ==10469">{{ getAnticoagulant(item.Fri_A.anticoagulant) }}</span> 
                        <span v-show="showflag">{{item.Fri_A.dialysis_machine_name}}
                          
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;" v-if="five_day == 5">
                    <span v-if="item.Fri_N.patient_id">
                      <span>{{ item.Fri_N.patient }} </span><br/>
                        <span >{{ item.Fri_N.mode_name }}</span><br/>
                        <span v-if="org_id == 0||org_id ==10469">{{getAnticoagulant(item.Fri_N.anticoagulant)  }}</span>
                        <span v-show="showflag">{{item.Fri_N.dialysis_machine_name}}
                          
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;" v-if="six_day == 6">
                    <span v-if="item.Sat_M.patient_id">
                      <span>{{ item.Sat_M.patient }} </span><br/>
                        <span >{{ item.Sat_M.mode_name }}</span><br/>
                        <span v-if="org_id ==0 || org_id ==10469">{{ getAnticoagulant(item.Sat_M.anticoagulant) }}</span> 
                        <span v-show="showflag">{{item.Sat_M.dialysis_machine_name}}
                         
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;" v-if="six_day == 6">
                    <span v-if="item.Sat_A.patient_id">
                      <span>{{ item.Sat_A.patient }} </span><br/>
                        <span >{{ item.Sat_A.mode_name }}</span><br/>
                        <span v-if="org_id ==0||org_id ==10469">{{ getAnticoagulant(item.Sat_A.anticoagulant) }}</span> 
                        <span v-show="showflag">{{item.Sat_A.dialysis_machine_name}}
                          
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;" v-if="six_day == 6">
                    <span v-if="item.Sat_N.patient_id">
                      <span>{{ item.Sat_N.patient }} </span><br/>
                        <span >{{ item.Sat_N.mode_name }}</span><br/>
                        <span v-if="org_id ==0||org_id ==10469">{{ getAnticoagulant(item.Sat_N.anticoagulant) }}</span> 
                        <span v-show="showflag">{{item.Sat_N.dialysis_machine_name}}
                         
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;" v-if="seven_day == 7">
                    <span v-if="item.Sun_M.patient_id">
                      <span>{{ item.Sun_M.patient }} </span><br/>
                        <span >{{ item.Sun_M.mode_name }}</span><br/>
                        <span v-if="org_id ==0||org_id ==10469">{{ getAnticoagulant(item.Sun_M.anticoagulant) }}</span>
                        <span v-show="showflag">{{item.Sun_M.dialysis_machine_name}}
                         
                        </span>
                    </span>
                </td>
                <td style="min-width:50px;" v-if="seven_day == 7">
                    <span v-if="item.Sun_A.patient_id">
                      <span>{{ item.Sun_A.patient }} </span><br/>
                        <span >{{ item.Sun_A.mode_name }}</span><br/>
                        <span v-if="org_id ==0 || org_id ==10469">{{getAnticoagulant(item.Sun_A.anticoagulant)}}</span>
                        <span v-show="showflag">{{item.Sun_A.dialysis_machine_name}}
                         
                        </span>

                    </span>
                </td>
                <td style="min-width:50px;" v-if="seven_day == 7">
                    <span v-if="item.Sun_N.patient_id">
                      <span>{{ item.Sun_N.patient }} </span><br/>
                        <span >{{ item.Sun_N.mode_name }}</span><br/>
                        <span v-if="org_id ==0||org_id ==10469">{{ getAnticoagulant(item.Sun_N.anticoagulant ) }}</span>
                        <span v-show="showflag">{{item.Sun_N.dialysis_machine_name}}
                          
                        </span>
                    </span>
                </td>
                <!-- <td>{{item.total}}</td> -->
            </tr>
        </table>
      </div>
    </div>
  </div>
</template> 

<script>
import {getSchedulesTwo,getWeekPanelsOne,getPatientSheduleCount,getAllZones,getSolutionSchedule} from "@/api/schedule";
import print from 'print-js'
export default {
    props:{
        scheduleZoneProp: {
            type: Array,
            dafault: []
        },
    },
    data(){
        return{
            showflag:sessionStorage.getItem('value1'),
            schedule_type:'',
            partition_id:'',
            theType:2,
            scheduleZone:[],
            weekTitle:[],
            scheduleZoneRow: [],
            partitions: {},
            theWeek: {
              lastWeek: 0,
              thisWeek: 0,
              nextWeek: 0,
              nextTwoWeek: 0
           },
           scheduleCountList:[],
           total:0,
           zones:[],
           zoneIdList:[],
           strArr:"",
           solutionList:[],
           week_date:"",
           Screencasting:false,//投屏
           first_day:0,
           second_day:0,
           three_day:0,
           four_day:0,
           five_day:0,
           six_day:0,
           seven_day:0,
           org_id:0
        }
    },
    created(){
        this.org_id = this.$store.getters.xt_user.org.id
        this.getAllZones()
        this.modeOptions = this.$store.getters.treatment_mode;
        this.partition_id = this.$route.query.partition_id
        var newList = []
        var arr =  this.$route.query.week_date

        if(arr!=""){
          var newArr = arr.split(",")

          if(newArr!=null&&newArr.length > 0){
             for(let i=0;i<newArr.length;i++){
               if(newArr[i] == "周一"){
                  newList.push(1)
                  this.first_day = 1
               }
              if(newArr[i] == "周二"){
                  newList.push(2)
                  this.second_day = 2
               }
              if(newArr[i] == "周三"){
                  newList.push(3)
                  this.three_day = 3
               }
               if(newArr[i] == "周四"){
                  newList.push(4)
                  this.four_day = 4
               }
               if(newArr[i] == "周五"){
                  newList.push(5)
                  this.five_day = 5
               }
              if(newArr[i] == "周六"){
                  newList.push(6)
                  this.six_day = 6
               }
               if(newArr[i] == "周日"){
                  newList.push(7)
                  this.seven_day = 7
               }
             }

            this.week_date = newList.join(",")
          }

        }else{
             newList = [1,2,3,4,5,6,7]
            this.first_day = 1
            this.second_day = 2
            this.three_day = 3
            this.four_day = 4
            this.five_day = 5
            this.six_day = 6
            this.seven_day = 7
            this.week_date = newList.join(",")

        }
        // this.getSolutionSchedule()
    },
    methods:{
      getAllZones(){
          getAllZones().then(response=>{
            if(response.data.state == 1){
              var zones = response.data.data.zones
              for(let i=0;i<zones.length;i++){
                  this.zoneIdList.push(zones[i].id)
              }
              this.zones.push(...zones)
              var strArr =  this.zoneIdList.join(",")

              this.strArr = strArr
              this.getWeekPanels()
              //统计患者排班数量
              this.getPatientSheduleCount()
          }
        })
      },  
      compare(p) { //这是比较函数
      return function (m, n) {
        var a = m[p];
        var b = n[p];
        return a - b; //升序
      }
      },
      getWeekPanels() {
            this.scheduleZone = []
            var partionStr = this.partition_id
            var arr = this.zoneIdList.join(',')
              var str = ""
              if(partionStr == 0){
                  str = arr
              }
              if(partionStr != 0){
                  str = partionStr
              }
          getWeekPanelsOne(1,str).then(response => {
              if (response.data.state == 0) {
                  return false
              }
              var partitions = response.data.data.partitions
              console.log("分区",partitions)
              this.theWeek.thisWeek = response.data.data.theWeek
              this.theWeek.lastWeek = this.theWeek.thisWeek - 1
              this.theWeek.nextWeek = this.theWeek.thisWeek + 1
              this.theWeek.nextTwoWeek = this.theWeek.thisWeek + 2
              var that = this
              if (partitions.length > 0) {

                  partitions.forEach(function(partition) {
                      if (partition.jihaos.length == 0) {
                          return false
                      }
                      that.scheduleZoneRow.push(partition.jihaos.length)
                      that.partitions[partition.id] = partition
                      partition.jihaos.forEach(function(jihao) {
                          var thisPa = {
                          area: partition.name,
                          zone_id: partition.id,
                          zone_type: partition.type,
                          cut: jihao.number,
                          jihao_id: jihao.id,
                            sort:jihao.sort,
                            Mon_M: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:"",
                          },
                          Mon_A: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Mon_N: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Tue_M: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Tue_A: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""


                          },
                          Tue_N: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Wed_M: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Wed_A: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Wed_N: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Thurs_M: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Thurs_A: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Thurs_N: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Fri_M: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Fri_A: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Fri_N: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Sat_M: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Sat_A: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Sat_N: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Sun_A: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Sun_N: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          Sun_M: {
                              schedule_id: 0,
                              mode_id: 0,
                              mode_name: '',
                              patient_id: 0,
                              patient: '',
                              type:1,
                            dialysis_machine_name:"",
                            anticoagulant:""

                          },
                          total: 0
                          }
                          that.scheduleZone.push(thisPa)

                      })
                  })
              }
            this.scheduleZone.sort(this.compare('sort'))

            this.getSchedules()
          })
      },
      getSchedules() {
          var theType = 2;
          if(this.$route.query.weekTime == "lastWeek"){
              theType = 1
          }
          if(this.$route.query.weekTime == "thisWeek"){
              theType = 2
          }
          if(this.$route.query.weekTime == "nextWeek"){
              theType = 3
          }
          if(this.$route.query.weekTime == "nextTwoWeek"){
              theType = 4
          }
          var partionStr = this.partition_id
          var arr = this.zoneIdList.join(',')
          var str = ""
          if(partionStr == 0){
              str = arr
          }
          if(partionStr != 0){
              str = partionStr
          }
          const params = {
              weekTime:theType,
              patitionid:str,
              schedule_type:this.schedule_type,
              week_date:this.week_date,
          }
          getSchedulesTwo(params).then(response => {
              if (response.data.state == 1) {
                  this.weekTitle = response.data.data.weekTitle;
                  console.log("weekTitle99923232",this.weekTitle)
                  this.weekDays = response.data.data.days;
                  this.toDay = response.data.data.today;
                  var theSchedules = response.data.data.schdules;
                  var that = this;
                  that.scheduleZone.forEach(function(zone, index) {

                      that.scheduleZone[index].Mon_M = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Mon_A = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Mon_N = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Tue_M = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Tue_A = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Tue_N = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Wed_M = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Wed_A = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Wed_N = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Thurs_M = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Thurs_A = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Thurs_N = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Fri_M = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Fri_A = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Fri_N = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Sat_M = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Sat_A = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Sat_N = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Sun_A = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Sun_N = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",

                      };
                      that.scheduleZone[index].Sun_M = {
                          mode_id: 0,
                          mode_name: "",
                          patient_id: 0,
                          patient: "",
                          type:1,
                        dialysis_machine_name:"",
                        anticoagulant:"",


                      };
                      that.scheduleZone[index].total = 0;

                      if (response.data.data.schdules.length > 0) {
                          theSchedules.forEach(function(schedule, sindex) {

                              if (zone.jihao_id == schedule.bed_id) {
                                  // if(zone.zone_id == schedule.partition_id && zone.jihao_id == schedule.bed_id) {
                                  var weekPath = that.weekPath(
                                      schedule.schedule_week,
                                      schedule.schedule_type
                                  );

                                  if (weekPath.length == 2) {
                                      // console.log(schedule);

                                      var weekPathKey = weekPath[0] + "_" + weekPath[1];
                                      that.scheduleZone[index][weekPathKey] = {
                                      schedule_id: schedule.id,
                                      mode_id: schedule.mode_id,
                                      patient_id: schedule.patient_id,
                                      patient: schedule.patient,
                                      patient_contagions: schedule.patient_contagions,
                                      dialysis_machine_name: schedule.dialysis_machine_name,
                                      mode_name:typeof that.modeOptions[schedule.mode_id] ==="undefined"? "": that.modeOptions[schedule.mode_id].name,
                                      anticoagulant:schedule.dialysissolution.anticoagulant
                                      };
                                      that.scheduleZone[index].total += 1;

                                  }

                              }

                          });
                      }

                  });
                  var newArr= [{"area":"总数","cut":0,"Fri_A":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Fri_M":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Fri_N":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Mon_A":{mode_id:0,mode_name:"",patient:"",patient_id:"1",type:0},"Mon_M":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Mon_N":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Sat_A":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Sat_M":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Sat_N":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Sun_A":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Sun_M":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Sun_N":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Thurs_A":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Thurs_M":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Thurs_N":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Tue_A":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Tue_M":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Tue_N":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Wed_A":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Wed_M":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"Wed_N":{mode_id:0,mode_name:"",patient:"0",patient_id:"1",type:0},"jihao_id":"","total":"","zone_id":"","zone_type":"",sort:""}]

                    for(let i=0;i<newArr.length;i++){
                      for(let j=0;j<this.scheduleCountList.length;j++){
                          newArr[i].cut = this.total
                        //礼拜一上午
                        if(this.scheduleCountList[j].schedule_week == 1 && this.scheduleCountList[j].schedule_type == 1){

                            newArr[i].Mon_M.patient = this.scheduleCountList[j].Count
                        }
                      //礼拜一下午
                        if(this.scheduleCountList[j].schedule_week == 1 && this.scheduleCountList[j].schedule_type == 2){

                            newArr[i].Mon_A.patient = this.scheduleCountList[j].Count
                        }

                        //礼拜一晚上
                        if(this.scheduleCountList[j].schedule_week == 1 && this.scheduleCountList[j].schedule_type == 3){

                            newArr[i].Mon_N.patient = this.scheduleCountList[j].Count
                        }

                      //礼拜二上午
                        if(this.scheduleCountList[j].schedule_week == 2 && this.scheduleCountList[j].schedule_type == 1){

                            newArr[i].Tue_M.patient = this.scheduleCountList[j].Count
                        }
                        //礼拜二下午
                        if(this.scheduleCountList[j].schedule_week == 2 && this.scheduleCountList[j].schedule_type == 2){

                            newArr[i].Tue_A.patient = this.scheduleCountList[j].Count
                        }

                        //礼拜二晚上
                        if(this.scheduleCountList[j].schedule_week == 2 && this.scheduleCountList[j].schedule_type == 3){

                            newArr[i].Tue_N.patient = this.scheduleCountList[j].Count
                        }

                        //礼拜三上午
                        if(this.scheduleCountList[j].schedule_week == 3 && this.scheduleCountList[j].schedule_type == 1){

                            newArr[i].Wed_M.patient = this.scheduleCountList[j].Count
                        }

                        //礼拜三下午
                        if(this.scheduleCountList[j].schedule_week == 3 && this.scheduleCountList[j].schedule_type == 2){

                            newArr[i].Wed_A.patient = this.scheduleCountList[j].Count
                        }

                        //礼拜三晚上
                        if(this.scheduleCountList[j].schedule_week == 3 && this.scheduleCountList[j].schedule_type == 3){

                            newArr[i].Wed_N.patient = this.scheduleCountList[j].Count
                        }



                      //礼拜四上午
                        if(this.scheduleCountList[j].schedule_week == 4 && this.scheduleCountList[j].schedule_type == 1){

                            newArr[i].Thurs_M.patient = this.scheduleCountList[j].Count
                        }

                        //礼拜四下午
                        if(this.scheduleCountList[j].schedule_week == 4 && this.scheduleCountList[j].schedule_type == 2){

                            newArr[i].Thurs_A.patient = this.scheduleCountList[j].Count
                        }

                        //礼拜四晚上
                        if(this.scheduleCountList[j].schedule_week == 4 && this.scheduleCountList[j].schedule_type == 3){

                            newArr[i].Thurs_N.patient = this.scheduleCountList[j].Count
                        }


                      //礼拜五上午
                        if(this.scheduleCountList[j].schedule_week == 5 && this.scheduleCountList[j].schedule_type == 1){

                            newArr[i].Fri_M.patient = this.scheduleCountList[j].Count
                        }

                        //礼拜五下午
                        if(this.scheduleCountList[j].schedule_week == 5 && this.scheduleCountList[j].schedule_type == 2){

                            newArr[i].Fri_A.patient = this.scheduleCountList[j].Count
                        }

                        //礼拜五晚上
                        if(this.scheduleCountList[j].schedule_week == 5 && this.scheduleCountList[j].schedule_type == 3){

                            newArr[i].Fri_N.patient = this.scheduleCountList[j].Count
                        }


                      //礼拜六上午
                        if(this.scheduleCountList[j].schedule_week == 6 && this.scheduleCountList[j].schedule_type == 1){

                            newArr[i].Sat_M.patient = this.scheduleCountList[j].Count
                        }

                        //礼拜六下午
                        if(this.scheduleCountList[j].schedule_week == 6 && this.scheduleCountList[j].schedule_type == 2){

                            newArr[i].Sat_A.patient = this.scheduleCountList[j].Count
                        }

                        //礼拜六晚上
                        if(this.scheduleCountList[j].schedule_week == 6 && this.scheduleCountList[j].schedule_type == 3){

                            newArr[i].Sat_N.patient = this.scheduleCountList[j].Count
                        }


                        //礼拜日上午
                        if(this.scheduleCountList[j].schedule_week == 7 && this.scheduleCountList[j].schedule_type == 1){

                            newArr[i].Sun_M.patient = this.scheduleCountList[j].Count
                        }

                        //礼拜日下午
                        if(this.scheduleCountList[j].schedule_week == 7 && this.scheduleCountList[j].schedule_type == 2){

                            newArr[i].Sun_A.patient = this.scheduleCountList[j].Count
                        }

                        //礼拜日晚上
                        if(this.scheduleCountList[j].schedule_week == 7 && this.scheduleCountList[j].schedule_type == 3){

                            newArr[i].Sun_N.patient = this.scheduleCountList[j].Count
                        }
                      }
                    }
                  console.log("newArr222222222",newArr)
                  that.scheduleZone.push(...newArr)
                  for(let i=0;i<that.scheduleZone.length;i++){
                    if(that.scheduleZone[i].area == "总数"){
                        that.scheduleZone[i].sort = 999999
                    }
                  }
                  that.scheduleZone.sort(this.compare('sort'))
                  console.log('总数据77777777777',that.scheduleZone)
              } else {
                  this.$message.error("网络错误");
                  return false;
              }
          });
      },
      weekPath(week, schedule_type) {
          var weekArr = {
              1: "Mon",
              2: "Tue",
              3: "Wed",
              4: "Thurs",
              5: "Fri",
              6: "Sat",
              7: "Sun"
          };
          var typeArr = { 1: "M", 2: "A", 3: "N" };
          if (
              typeof weekArr[week] === "undefined" ||
              typeof typeArr[schedule_type] === "undefined"
          ) {
              return [];
          }
          return [weekArr[week], typeArr[schedule_type]];
      },
      printAction: function() {
          // const style = '@media print {#scheduleTable{font-size:16px;} .scheduleTable tr td{text-align: center;padding: 5px;}}'
          const style = '@media print {#scheduleTable{font-size:14px;} }'
          printJS({
          printable: 'scheduleTable',
          type: 'html',
          documentTitle: '  ',
          style: style,
          scanStyles: false
          })
      },
      getPatientSheduleCount(){
          var theType = 2;
          if(this.$route.query.weekTime == "lastWeek"){
              theType = 1
          }
          if(this.$route.query.weekTime == "thisWeek"){
              theType = 2
          }
          if(this.$route.query.weekTime == "nextWeek"){
              theType = 3
          }
          if(this.$route.query.weekTime == "nextTwoWeek"){
              theType = 4
          }
          var partionStr = this.partition_id
          console.log("partionStr",partionStr)
          var arr = this.zoneIdList.join(',')
          var str = ""
          if(partionStr == 0){
              str = arr
          }
          if(partionStr != 0){
              str = partionStr
          }
          var params = {
            weekTime:theType,
            partition_id:str,

          }
          getPatientSheduleCount(params).then(response=>{
              if(response.data.state == 1){
                var list = response.data.data.list
                console.log("list22222",list)

                this.scheduleCountList = list
                var total = response.data.data.total
                console.log("totalw222",total)
                this.total = total
              }
          })
      },
      getSolutionSchedule(){
        getSolutionSchedule().then(response=>{
            if(response.data.state ==1){
              var solution = response.data.data.solution
              console.log("solution",solution)
              for(let i=0;i<solution.length;i++){
                if(solution[i].mode_id == 1){
                  solution[i].mode_name = "HD"
                }
                if(solution[i].mode_id == 2){
                  solution[i].mode_name = "HDF"
                }
                if(solution[i].mode_id == 3){
                  solution[i].mode_name = "HD+HP"
                }
                if(solution[i].mode_id == 4){
                  solution[i].mode_name = "HP"
                }
                if(solution[i].mode_id == 5){
                  solution[i].mode_name = "HF"
                }
                if(solution[i].mode_id == 6){
                  solution[i].mode_name = "SCUF"
                }
                if(solution[i].mode_id == 7){
                  solution[i].mode_name = "IUF"
                }
                if(solution[i].mode_id == 8){
                  solution[i].mode_name = "HFHD"
                }
                if(solution[i].mode_id == 9){
                  solution[i].mode_name = "HFHD+HP"
                }
                if(solution[i].mode_id == 10){
                  solution[i].mode_name = "PHF"
                }
                if(solution[i].mode_id == 11){
                  solution[i].mode_name = "HFR"
                }
                if(solution[i].mode_id == 12){
                  solution[i].mode_name = "HDF+HP"
                }
                if(solution[i].mode_id == 13){
                  solution[i].mode_name = "CRRT"
                }
                if(solution[i].mode_id == 14){
                  solution[i].mode_name = "腹水回输"
                }
                if(solution[i].mode_id == 19){
                  solution[i].mode_name = "IUF+HD"
                }
                if(solution[i].mode_id == 20){
                  solution[i].mode_name = "UF"
                }
                if(solution[i].mode_id == 21){
                  solution[i].mode_name = "HD+"
                }
                if(solution[i].mode_id == 18){
                  solution[i].mode_name = "SCUF"
                }
                if(solution[i].mode_id == 19){
                  solution[i].mode_name = "SCUF"
                }
                if(solution[i].mode_id == 20){
                  solution[i].mode_name = "SCUF"
                }
                if(solution[i].mode_id == 21){
                  solution[i].mode_name = "HD+"
                }
                if(solution[i].mode_id == 22){
                  solution[i].mode_name = "血浆胆红素吸附+HDF"
                }
                if(solution[i].mode_id == 23){
                  solution[i].mode_name = "血浆胆红素吸附"
                }
                if(solution[i].mode_id == 24){
                  solution[i].mode_name = "I-HDF"
                }
                if(solution[i].mode_id == 25){
                  solution[i].mode_name = "HD高通"
                }
                if(solution[i].mode_id == 26){
                  solution[i].mode_name = "CVVH"
                }
                if(solution[i].mode_id == 27){
                  solution[i].mode_name = "CVVH"
                }
                if(solution[i].mode_id == 28){
                  solution[i].mode_name = "CVVHDF"
                }
                if(solution[i].mode_id == 29){
                  solution[i].mode_name = "PE"
                }
              if(solution[i].mode_id == 30){
                  solution[i].mode_name = "血浆胆红素吸附+HP"
                }
                if(solution[i].solution!=undefined){
                  solution[i].dialysis_dialyszers = solution[i].solution.dialysis_dialyszers
                  solution[i].dialysis_irrigation = solution[i].solution.dialysis_irrigation
                  solution[i].dialyzer_perfusion_apparatus = solution[i].solution.dialyzer_perfusion_apparatus
                }

              }
              this.solutionList = solution
            }
        })
      },
      getDialyzer(patient_id,mode){
        var diazers = ""
        var irrigation = ""
        for(let i=0;i<this.solutionList.length;i++){
          if(patient_id == 0){
            return ""
          }
          if(patient_id == this.solutionList[i].patient_id && mode == this.solutionList[i].mode_name){
              if(this.solutionList[i].dialyzer_perfusion_apparatus!=""){
                diazers = this.solutionList[i].dialyzer_perfusion_apparatus
                irrigation = this.solutionList[i].dialysis_irrigation
              }else{
                diazers = this.solutionList[i].dialysis_dialyszers
                irrigation = this.solutionList[i].dialysis_irrigation

              }

          }
        }
        if(irrigation!=""){
            return diazers + "/" + irrigation
        }else{
          return diazers
        }
      },
      compare (property) {
          return function (a, b) {
              var value1 = a[property]
              var value2 = b[property]
              return value1 - value2
          }
      },
      // 投屏
      touping(){
        if(this.Screencasting ==false){
         
          return this.Screencasting =true
        }else{
          return this.Screencasting =false
        }
        
      },
      getAnticoagulant(val){
        var name= ""
        if(val == 1){
          name ="无肝素"
        }
        if(val == 2){
          name ="普通肝素"
        }
        if(val == 3){
          name ="低分子肝素"
        }
        if(val == 4){
          name ="阿加曲班"
        }
        if(val == 5){
          name ="枸橼酸钠"
        }
        if(val == 6){
          name ="低分子肝素钙"
        }
        if(val == 7){
          name ="低分子肝素钠"
        }
        if(val == 8){
          name ="依诺肝素"
        }
        if(val == 9){
          name ="达肝素"
        }
        if(val == 10){
          name ="体外抗凝"
        }
        if(val == 11){
          name ="那屈肝素"
        }
        if(val == 12){
          name ="无抗凝剂"
        }
        if(val == 13){
          name ="那屈肝素钙"
        }
        if(val == 14){
          name ="肝素钙注射液"
        }
        if(val == 15){
          name ="甲磺酸萘莫司他"
        }

        return name
      }
    }
}
</script>


<style lang="scss">
.scheduleTablePrint{
  width: 100%;
  height: 100vh;
  .butt{
    height: 50px;
    line-height: 50px;
  }
  .tab{
    table{
      td{
        text-align: center;
        padding: 5px;
        word-wrap:break-word;
      }
    }
  }
  
}
</style>
<style lang="scss" scoped>
.fullscreenbroad{
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: auto;
  margin: 0;
  background: #fff;
  padding: 20px;
  z-index:5000;
  height: 100%;
  // .butt{
  //   margin-bottom: ;
  // }
}

</style>
