<template>
    <div>
      <el-button style="float:right;" type="primary" @click="printAction">打印</el-button>

<!--      <el-button type="primary" @click="printAction">打印</el-button>-->
        <table id="scheduleTable" class="scheduleTable" border="1" cellspacing="0">
            <tr>
                <td rowspan="2">分区</td>
                <td rowspan="2">机号</td>
                <td colspan="3">周一({{ weekTitle[0] }})</td>
                <td colspan="3">周二({{ weekTitle[1] }})</td>
                <td colspan="3">周三({{ weekTitle[2] }})</td>
                <td colspan="3">周四({{ weekTitle[3] }})</td>
                <td colspan="3">周五({{ weekTitle[4] }})</td>
                <td colspan="3">周六({{ weekTitle[5] }})</td>
                <td colspan="3">周日({{ weekTitle[6] }})</td>
                <td>总数</td>
            </tr>
            <tr>
                <td>上午</td>
                <td>下午</td>
                <td>晚上</td>
                <td>上午</td>
                <td>下午</td>
                <td>晚上</td>
                <td>上午</td>
                <td>下午</td>
                <td>晚上</td>
                <td>上午</td>
                <td>下午</td>
                <td>晚上</td>
                <td>上午</td>
                <td>下午</td>
                <td>晚上</td>
                <td>上午</td>
                <td>下午</td>
                <td>晚上</td>
                <td>上午</td>
                <td>下午</td>
                <td>晚上</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;">
                    <span v-if="item.Mon_M.patient_id">
                        <div>{{ item.Mon_M.patient }} </div>
                        <div v-if="item.Mon_M.mode_name != 'HD'">
                            {{ item.Mon_M.mode_name }}
                     </div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Mon_A.patient_id">
                        <div>{{ item.Mon_A.patient }} </div>
                        <div v-if="item.Mon_A.mode_name != 'HD'">{{ item.Mon_A.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Mon_N.patient_id">
                        <div>{{ item.Mon_N.patient }}</div>
                        <div v-if="item.Mon_N.mode_name != 'HD'">{{ item.Mon_N.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Tue_M.patient_id">
                        <div>{{ item.Tue_M.patient }}</div>
                        <div v-if="item.Tue_M.mode_name != 'HD'">{{ item.Tue_M.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Tue_A.patient_id">
                        <div>{{ item.Tue_A.patient }}</div>
                        <div v-if="item.Tue_A.mode_name != 'HD'">{{ item.Tue_A.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Tue_N.patient_id">
                        <div>{{ item.Tue_N.patient }}</div>
                        <div v-if="item.Tue_N.mode_name != 'HD'">{{ item.Tue_N.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Wed_M.patient_id">
                        <div>{{ item.Wed_M.patient }}</div>
                        <div v-if="item.Wed_M.mode_name != 'HD'">{{ item.Wed_M.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Wed_A.patient_id">
                        <div>{{ item.Wed_A.patient }}</div>
                        <div v-if="item.Wed_A.mode_name != 'HD'">{{ item.Wed_A.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Wed_N.patient_id">
                        <div>{{ item.Wed_N.patient }}</div>
                        <div v-if="item.Wed_N.mode_name != 'HD'">{{ item.Wed_N.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Thurs_M.patient_id">
                        <div>{{ item.Thurs_M.patient }}</div>
                        <div v-if="item.Thurs_M.mode_name != 'HD'">{{ item.Thurs_M.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Thurs_A.patient_id">
                        <div>{{ item.Thurs_A.patient }}</div>
                        <div v-if="item.Thurs_A.mode_name != 'HD'">{{ item.Thurs_A.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Thurs_N.patient_id">
                        <div>{{ item.Thurs_N.patient }}</div>
                        <div v-if="item.Thurs_N.mode_name != 'HD'">{{ item.Thurs_N.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Fri_M.patient_id">
                        <div>{{ item.Fri_M.patient }}</div>
                        <div v-if="item.Fri_M.mode_name != 'HD'">{{ item.Fri_M.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Fri_A.patient_id">
                        <div>{{ item.Fri_A.patient }}</div>
                        <div v-if="item.Fri_A.mode_name != 'HD'">{{ item.Fri_A.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Fri_N.patient_id">
                        <div>{{ item.Fri_N.patient }}</div>
                        <div v-if="item.Sat_M.mode_name != 'HD'">{{ item.Sat_M.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Sat_M.patient_id">
                        <div>{{ item.Sat_M.patient }}</div>
                        <div v-if="item.Sat_M.mode_name != 'HD'">{{ item.Sat_M.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Sat_A.patient_id">
                        <div>{{ item.Sat_A.patient }}</div>
                        <div v-if="item.Sat_A.mode_name != 'HD'">{{ item.Sat_A.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Sat_N.patient_id">
                        <div>{{ item.Sat_N.patient }}</div>
                        <div v-if="item.Sat_N.mode_name != 'HD'">{{ item.Sat_N.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Sun_M.patient_id">
                        <div>{{ item.Sun_M.patient }}</div>
                        <div v-if="item.Sun_M.mode_name != 'HD'">{{ item.Sun_M.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Sun_A.patient_id">
                        <div>{{ item.Sun_A.patient }}</div>
                        <div v-if="item.Sun_A.mode_name != 'HD'">{{ item.Sun_A.mode_name }}</div>
                    </span>
                </td>
                <td style="min-width:50px;">
                    <span v-if="item.Sun_N.patient_id">
                        <div>{{ item.Sun_N.patient }}</div>
                        <div v-if="item.Sun_N.mode_name != 'HD'">{{ item.Sun_N.mode_name }}</div>
                    </span>
                </td>
                <td>{{item.total}}</td>
            </tr>
        </table>
    </div>
</template>



<script>
import {getSchedulesTwo,getWeekPanelsOne,getPatientSheduleCount,getAllZones} from "@/api/schedule";
import print from 'print-js'
export default {
    props:{
        scheduleZoneProp: {
            type: Array,
            dafault: []
        },
    },
    data(){
        return{
            schedule_type:'',
            partition_id:'',
            theType:2,
            scheduleZone:[],
            weekTitle:[],
            scheduleZoneRow: [],
            partitions: {},
            theWeek: {
              historyWeek: 0,
              lastWeek: 0,
              thisWeek: 0,
              nextWeek: 0,
              nextTwoWeek: 0
           },
           scheduleCountList:[],
           total:0,
           zones:[],
           zoneIdList:[],
           strArr:"",
           week_date:"",
        }
    },
    created(){
        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
        console.log('1234325431',this.$route.query);
        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)
               }
              if(newArr[i] == "周二"){
                  newList.push(2)
               }
              if(newArr[i] == "周三"){
                  newList.push(3)
               }
               if(newArr[i] == "周四"){
                  newList.push(4)
               }
               if(newArr[i] == "周五"){
                  newList.push(5)
               }
              if(newArr[i] == "周六"){
                  newList.push(6)
               }
               if(newArr[i] == "周日"){
                  newList.push(7)
               }
             }

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

        }else{
             newList = [1,2,3,4,5,6,7]

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

        }

    },
    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()
            }
          })
        },
        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.historyWeek = this.theWeek.thisWeek - 2 
                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: ''
                            },
                            Mon_A: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Mon_N: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Tue_M: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Tue_A: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Tue_N: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Wed_M: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Wed_A: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Wed_N: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Thurs_M: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Thurs_A: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Thurs_N: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Fri_M: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Fri_A: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Fri_N: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Sat_M: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Sat_A: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Sat_N: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Sun_A: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Sun_N: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            Sun_M: {
                                schedule_id: 0,
                                mode_id: 0,
                                mode_name: '',
                                patient_id: 0,
                                patient: ''
                            },
                            total: 0
                            }
                            that.scheduleZone.push(thisPa)

                        })
                    })
                }
                this.getSchedules()
            })
        },
        getSchedules() {
            var theType = 2;
            if(this.$route.query.weekTime == "historyWeek"){
                theType =0
            }
            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
            }
            console.log("week_day=",this.week_date)
            const params = {
                weekTime:theType,
                patitionid:str,
                schedule_type:this.schedule_type,
                week_date:this.week_date,
            }
            console.log("param23232323wo",params)
            getSchedulesTwo(params).then(response => {
                if (response.data.state == 1) {
                    this.weekTitle = response.data.data.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: ""
                        };
                        that.scheduleZone[index].Mon_A = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Mon_N = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Tue_M = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Tue_A = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Tue_N = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Wed_M = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Wed_A = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Wed_N = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Thurs_M = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Thurs_A = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Thurs_N = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Fri_M = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Fri_A = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Fri_N = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Sat_M = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Sat_A = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Sat_N = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Sun_A = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Sun_N = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        that.scheduleZone[index].Sun_M = {
                            mode_id: 0,
                            mode_name: "",
                            patient_id: 0,
                            patient: ""
                        };
                        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,
                                        mode_name:
                                            typeof that.modeOptions[schedule.mode_id] ===
                                            "undefined"
                                            ? ""
                                            : that.modeOptions[schedule.mode_id].name
                                        };
                                        that.scheduleZone[index].total += 1;

                                    }

                                }

                            });
                        }

                    });
                    var newArr= [{"area":"总数","cut":0,"Fri_A":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Fri_M":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Fri_N":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Mon_A":{mode_id:0,mode_name:"",patient:"",patient_id:"1"},"Mon_M":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Mon_N":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Sat_A":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Sat_M":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Sat_N":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Sun_A":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Sun_M":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Sun_N":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Thurs_A":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Thurs_M":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Thurs_N":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Tue_A":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Tue_M":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Tue_N":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Wed_A":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Wed_M":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"Wed_N":{mode_id:0,mode_name:"",patient:"0",patient_id:"1"},"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;}}'

            printJS({
            printable: 'scheduleTable',
            type: 'html',
            documentTitle: '  ',
            style: style,
            scanStyles: false
            })
        },
        getPatientSheduleCount(){
            var theType = 2;
            if(this.$route.query.weekTime == "historyWeek"){
                theType =0
            }
            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)
                    console.log('asdfgfffffff',response.data.data);
                  this.scheduleCountList = list
                  var total = response.data.data.total
                  console.log("totalw222",total)
                  this.total = total
               }
           })
        },
        compare (property) {
            return function (a, b) {
                var value1 = a[property]
                var value2 = b[property]
                return value1 - value2
            }
        },
    }
}
</script>


<style lang="scss">
td{
    text-align: center;
    padding: 5px;
}
</style>
