<template>
    <div class="main-contain">
        <div class="position">
        <bread-crumb :crumbs="crumbs"></bread-crumb>
        <el-row style="float:right;">
            <el-col :span="24">
            <el-button size="small" icon="el-icon-printer" type="primary" @click="printAction">打印</el-button>
            </el-col>
        </el-row>
        </div>
        <div class="app-container" style="background-color: white;" v-show="show">
            <div id="dialysisTable">
                <div class="order_title_panl">
                    <span class="main_title">透析医嘱</span>
                </div>
                <p style="width: 960px;text-align: right;margin: 0 auto 10px;">日期：{{ time }}</p>
                <table class="table dialysisTable" border="1" cellspacing="0" cellpadding="0">
                    <tr>
                    <th width="40px">姓名</th>
                    <th width="40px">透析器</th>
                    <!-- <th width="50px">类型</th> -->
                    <th width="50px">开始时间</th>
                    <th width="100px">医嘱内容</th>
                    <th width="50px">执行时间</th>
                    <th width="50px">执行护士</th>
                    <th width="50px">校对护士</th>
                    <th width="50px">校对时间</th>
                    <th width="50px">开嘱医生</th>
                    <th width="50px">开嘱时间</th>
                    </tr>
                    <template v-for="(schedules, zone_name, index) in scheduleMap">
                    <tr :key="index">
                        <td>{{ zone_name }}</td>
                        <!-- <td></td> -->
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <template v-for="schedule in schedules">
                        <template v-for="(group, group_index) in schedule.new_advice">
                        <tr v-for="(advice, advice_index) in group.advices" :key="advice_index">
                            <td
                            v-if="advice_index == 0"
                            :rowspan="group.advices.length"
                            >{{ advice.parent_id == 0 ? schedule.patient.name : "" }}
                            <br>
                            （{{ advice.parent_id == 0 ? schedule.dialysis_no : ""}}）
                            <br>
                            <span v-if="schedule.mode_id == 1">(HD)</span>
                            <span v-if="schedule.mode_id == 2">(HDF)</span>
                            <span v-if="schedule.mode_id == 3">(HD+HP)</span>
                            <span v-if="schedule.mode_id == 4">(HP)</span>
                            <span v-if="schedule.mode_id == 5">(HF)</span>
                            <span v-if="schedule.mode_id == 6">(SCUF)</span>
                            <span v-if="schedule.mode_id == 7">(IUF)</span>
                            <span v-if="schedule.mode_id == 8">(HFHD)</span>
                            <span v-if="schedule.mode_id == 9">(HFHD+HP)</span>
                            <span v-if="schedule.mode_id == 10">(PHF)</span>
                            <span v-if="schedule.mode_id == 11">(HFR)</span>
                            <span v-if="schedule.mode_id == 12">(HDF+HP)</span>
                            <span v-if="schedule.mode_id == 13">(CRRT)</span>
                            <span v-if="schedule.mode_id == 14">(腹水回输)</span>
                            <span v-if="schedule.mode_id == 24">I-HDF</span>   
                            </td>
                            <td v-if="advice_index == 0" :rowspan="group.advices.length">
                            {{advice.parent_id == 0 && schedule.prescription!=null ?  schedule.prescription.dialyzer_perfusion_apparatus : ""}}
                            </td>
                            <!-- <td
                            v-if="advice_index == 0"
                            :rowspan="group.advices.length"
                            >{{ getAdaviceType(advice.advice_type, advice.parent_id) }}</td>-->
                            <td v-if="advice_index == 0" :rowspan="group.advices.length">
                            {{
                            advice.parent_id == 0
                            ? parseTime(advice.start_time, "{m}-{d} {h}:{i}")
                            : ""
                            }}
                            </td>
                            <td
                            :class="
                                advice.parent_id == 0
                                ? 'advice_content'
                                : 'subadvice_content'
                            "
                            >
                            <span>{{ advice.advice_name }}</span>
                            <span>{{ advice.advice_desc }}{{ advice.drug_spec_unit }}</span>
                            <span v-if="advice.prescribing_number">
                                {{ advice.prescribing_number
                                }}{{ advice.prescribing_number_unit }}
                            </span>
                            <span v-if="advice.single_dose">
                                单次用量 {{ advice.single_dose
                                }}{{ advice.single_dose_unit }}
                            </span>
                            <span>{{ advice.delivery_way }}</span>
                            <span>{{ advice.execution_frequency }}</span>
                            <span
                                v-if="advice.parent_id == 0 && advice.remark.length > 0"
                            >({{ advice.remark }})</span>
                            </td>
                            <td>{{ parseTime(advice.execution_time, "{m}-{d} {h}:{i}") }}</td>
                            <td>{{ getName(advice.execution_staff) }}</td>
                            <td>{{ getName(advice.checker) }}</td>
                            <td>{{ parseTime(advice.check_time, "{m}-{d} {h}:{i}") }}</td>
                            <td>{{ getName(advice.advice_doctor) }}</td>
                            <td>{{ parseTime(advice.created_time, "{m}-{d} {h}:{i}") }}</td>
                        </tr>
                        </template>
                    </template>
                    </template>
                </table>
            </div>
        </div>

          <div class="app-container" style="background-color: white;" v-show="showOne">
            <div id="dialysisTable">
                <div class="order_title_panl">
                    <span class="main_title">透析医嘱</span>
                </div>
                <p style="width: 960px;text-align: right;margin: 0 auto 10px;">日期：{{ time }}</p>
                <table class="table dialysisTable" border="1" cellspacing="0" cellpadding="0">
                    <tr>
                    <th width="40px">姓名</th>
                    <th width="40px">透析器</th>
                    <!-- <th width="50px">类型</th> -->
                    <th width="50px">开始时间</th>
                    <th width="100px">医嘱内容</th>
                    <th width="50px">执行时间</th>
                    <th width="50px">执行护士</th>
                    <th width="50px">校对护士</th>
                    <th width="50px">校对时间</th>
                    <th width="50px">开嘱医生</th>
                    <th width="50px">开嘱时间</th>
                    </tr>
                    <template v-for="(schedules, zone_name, index) in scheduleMap">
                    <tr :key="index">
                        <td>{{ zone_name }}</td>
                        <!-- <td></td> -->
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <template v-for="schedule in schedules">
                        <template v-for="(group, group_index) in schedule.new_advice">
                        <tr v-for="(advice, advice_index) in group.advices" :key="advice_index">
                            <td
                            v-if="advice_index == 0"
                            :rowspan="group.advices.length"
                            >{{ advice.parent_id == 0 ? schedule.patient.name : "" }}
                            <br>
                            （{{ advice.parent_id == 0 ? schedule.dialysis_no : ""}}）
                            <br>
                            <span v-if="schedule.mode_id == 1">(HD)</span>
                            <span v-if="schedule.mode_id == 2">(HDF)</span>
                            <span v-if="schedule.mode_id == 3">(HD+HP)</span>
                            <span v-if="schedule.mode_id == 4">(HP)</span>
                            <span v-if="schedule.mode_id == 5">(HF)</span>
                            <span v-if="schedule.mode_id == 6">(SCUF)</span>
                            <span v-if="schedule.mode_id == 7">(IUF)</span>
                            <span v-if="schedule.mode_id == 8">(HFHD)</span>
                            <span v-if="schedule.mode_id == 9">(HFHD+HP)</span>
                            <span v-if="schedule.mode_id == 10">(PHF)</span>
                            <span v-if="schedule.mode_id == 11">(HFR)</span>
                            <span v-if="schedule.mode_id == 12">(HDF+HP)</span>
                            <span v-if="schedule.mode_id == 13">(CRRT)</span>
                            <span v-if="schedule.mode_id == 14">(腹水回输)</span>
                            <span v-if="schedule.mode_id == 24">I-HDF</span>   
                            </td>
                            <td v-if="advice_index == 0" :rowspan="group.advices.length">
                            {{advice.parent_id == 0 && schedule.prescription!=null ?  schedule.prescription.dialyzer_perfusion_apparatus : ""}}
                            </td>
                            <!-- <td
                            v-if="advice_index == 0"
                            :rowspan="group.advices.length"
                            >{{ getAdaviceType(advice.advice_type, advice.parent_id) }}</td>-->
                            <td v-if="advice_index == 0" :rowspan="group.advices.length">
                            {{
                            advice.parent_id == 0
                            ? parseTime(advice.start_time, "{m}-{d} {h}:{i}")
                            : ""
                            }}
                            </td>
                            <td
                            :class="
                                advice.parent_id == 0
                                ? 'advice_content'
                                : 'subadvice_content'
                            "
                            >
                            <span>{{ advice.advice_name }}</span>
                            <span>{{ advice.advice_desc }}{{ advice.drug_spec_unit }}</span>
                            <span v-if="advice.prescribing_number">
                                {{ advice.prescribing_number
                                }}{{ advice.prescribing_number_unit }}
                            </span>
                            <span v-if="advice.single_dose">
                                单次用量 {{ advice.single_dose
                                }}{{ advice.single_dose_unit }}
                            </span>
                            <span>{{ advice.delivery_way }}</span>
                            <span>{{ advice.execution_frequency }}</span>
                            <span
                                v-if="advice.parent_id == 0 && advice.remark.length > 0"
                            >({{ advice.remark }})</span>
                            </td>
                            <td>{{ parseTime(advice.execution_time, "{m}-{d} {h}:{i}") }}</td>
                            <td>{{ getName(advice.execution_staff) }}</td>
                            <td>{{ getName(advice.checker) }}</td>
                            <td>{{ parseTime(advice.check_time, "{m}-{d} {h}:{i}") }}</td>
                            <td>{{ getName(advice.advice_doctor) }}</td>
                            <td>{{ parseTime(advice.created_time, "{m}-{d} {h}:{i}") }}</td>
                        </tr>
                        </template>
                    </template>
                    </template>
                </table>
            </div>
        </div>
    </div>
</template>

<script>
import BreadCrumb from '@/xt_pages/components/bread-crumb'
import { getSchedualDoctors } from '@/api/advice'
import { parseTime } from '@/utils'
import print from 'print-js'
const moment = require('moment')
export default {
    components:{
        BreadCrumb
    },
    data(){
        return{
            crumbs: [
                { path: false, name: '耗材药品' },
                { path: false, name: '打印' }
            ],
            tableData:[],
            start_time:"",
            end_time:"",
            print_time:moment(new Date()).add('year', 0).format('YYYY-MM-DD'),

            zone_selected: 0,
            scheduleMap:[],
            time:'',
            show:true,
            showOne:false,
            delivery_way:""
        }
    },
    methods:{
        printAction: function() {
            const style = '@media print { .dialysisTable{width:960px;margin: 0 auto;text-align: center;border-collapse: collapse;}.order_title_panl {text-align: center;.main_title {font-size: 18px;line-height: 40px;font-weight: 500;}}.dialysisTable tr{padding: 10px 0;}.dialysisTable th {color: #000;padding: 0;margin: 0;height: 30px;}.dialysisTable tr td {padding: 12px 0;}.subadvice_content {text-align: left;padding-left: 25px !important;padding-right: 5px !important;}.advice_content {text-align: left;padding-left: 5px !important;padding-right: 5px !important;padding: 15px 5px !important;} }'

            printJS({
            printable: 'dialysisTable',
            type: 'html',
            documentTitle: '  ',
            style: style,
            scanStyles: false
            })
        },
        requestSchedualDoctors (time) {
            let newTime =  moment(time).format('YYYY-MM-DD')
            getSchedualDoctors({
            date: newTime,
            patient_type: 0,
            advice_type: 2,
            delivery_way:this.delivery_way,
            }).then(rs => {
                var resp = rs.data
                if (resp.state == 1) {
                this.admin_user = resp.data.adminUser
                var config = resp.data.config
                let project_config = resp.data.project_config
                console.log('project_config',resp.data.project_config)
                if(project_config.is_open == 1){
                    this.project = resp.data.project
                    resp.data.hisAdvices.map((item,index) => {
                    item.new_advice = item.new_advice ? item.new_advice : []
                    if(this.project[index].project.length > 0){
                        this.project[index].project.map(it => {
                        let obj = {
                            advice_doctor: it.doctor,
                            start_time:it.start_time,
                            advice_name: it.type == 2 ? it.project.project_name : it.good_info.good_name,
                            execution_time:it.execution_time,
                            execution_state:it.execution_state,
                            execution_staff:it.execution_staff,
                            check_time:it.check_time,
                            check_state:it.check_state,
                            checker:it.checker,
                            created_time:it.ctime,
                            remark:'',
                            id:it.id,
                            parent_id:0,
                            groupno:0
                        }
                        // let advice = []
                        // advice.push(obj)
                        // let advices = {
                        //   advices: advice,
                        //   group_no: 123
                        // }

                        // console.log(11111,item.new_advice)
                        item.doctor_advice.push(obj)
                        })
                    }
                    })
                }
                if(config.is_open == 0 || config.is_open == 2){
                
                   var schedulesArr = resp.data.scheduals
                   let schedules = []
                   var ids = this.$store.getters.temp_params.advice_ids
                   console.log('ids',ids)
                   schedulesArr.map(item => {
                    if(ids.indexOf(item.patient_id) > -1){
                        schedules.push(item)
                    }
                    
                })
               
                for (let i = 0; i < schedules.length; i++) {
                    schedules[i].dialysis_no = schedules[i].patient.dialysis_no
                }
           

                var arr = []
                for (let j = 0; j < schedules.length; j++) {
                    arr.push(schedules[j].dialysis_no)
                }
                arr.sort(function (a, b) {
                    return a - b
                })
               

                var arrTwo = []
                for (let i = 0; i < arr.length; i++) {
                    for (let j = 0; j < schedules.length; j++) {
                    if (arr[i] == schedules[j].dialysis_no) {
                        arrTwo.push(schedules[j])
                    }
                    }
                }

                arrTwo.map((item, index) => {
                  
                    item.doctor_advice.sort(this.compare('start_time'))
                })
                

                const res = new Map()
                let a = arrTwo.filter(
                    a => !res.has(a.dialysis_no) && res.set(a.dialysis_no, 1)
                )

               

                schedules = a
                var zoneMap = {}
                var scheduleMap = {}
                for (let index = 0; index < schedules.length; index++) {
                    const schedule = schedules[index]
                    if (schedule.doctor_advice.length == 0) {
                    continue
                    }
                    if (scheduleMap[schedule.device_number.zone.name] == null) {
                    scheduleMap[schedule.device_number.zone.name] = []
                    }
                    scheduleMap[schedule.device_number.zone.name].push(schedule)
                    if (zoneMap[schedule.device_number.zone.name] == null) {
                    zoneMap[schedule.device_number.zone.name] =
                        schedule.device_number.zone
                    }
                }

                var zones = []
                zones.push({ value: 0, text: '全部分区' })
                for (var zoneName in zoneMap) {
                    zones.push({ value: zoneMap[zoneName].id, text: zoneName })
                }

                zones = zones.sort(function (a, b) {
                    return a.value > b.value
                })
                this.zones = zones
                for (var key in scheduleMap) {
                    let mapArr = scheduleMap[key]
                    for (let i = 0; i < mapArr.length; i++) {
                    mapArr[i]['new_advice'] = []
                    }
                }

                for (var key in scheduleMap) {
                    let mapArr = scheduleMap[key]
                    for (let i = 0; i < mapArr.length; i++) {
                    var maps = mapArr[i]
                    var resp_advices = maps.doctor_advice
                    if (resp_advices.length > 0) {
                        var newGroupObject = function () {
                        return Object.assign(
                            {},
                            {
                            group_no: 0,
                            advices: []
                            }
                        )
                        }
                        var initGroupBlock = function (group, advice) {
                        group.group_no = advice.groupno
                        }

                        var advice_groups = []
                        var group = newGroupObject()
                        for (let index = 0; index < resp_advices.length; index++) {
                        const advice = resp_advices[index]
                        if (advice.groupno == 0) {
                            // 老版本的医嘱
                            if (advice.parent_id > 0) {
                            if (advice_groups.length > 0) {
                                var parent_group = advice_groups[advice_groups.length - 1]
                                if (parent_group.advices.length > 0) {
                                if (parent_group.advices[0].id == advice.parent_id) {
                                    parent_group.advices.push(advice)
                                }
                                }
                            }
                            continue
                            } else {
                            if (group.group_no > 0) {
                                advice_groups.push(group)
                                group = newGroupObject()
                            }

                            initGroupBlock(group, advice)
                            group.advices.push(advice)
                            advice_groups.push(group)
                            group = newGroupObject()
                            continue
                            }
                        } else {
                            if (group.group_no > 0 && group.group_no != advice.groupno) {
                            advice_groups.push(group)
                            group = newGroupObject()
                            }
                            if (group.group_no == 0) {
                            initGroupBlock(group, advice)
                            }
                            if (group.group_no == advice.groupno) {
                            group.advices.push(advice)
                            }
                        }
                        }
                        if (group.group_no > 0) {
                        // 上述的算法会导致最后一组没有加到advice_groups，这里要手动加
                        advice_groups.push(group)
                        }
                        advice_groups = advice_groups
                    } else {
                        advice_groups = []
                    }
                    maps.new_advice = advice_groups
                    }
                 }
                

                 this.scheduleMap = scheduleMap  
                }
               
                 if(config.is_open == 1){
                   var schedulesArr = resp.data.hisAdvices
                   let schedules = []
                   var ids = this.$store.getters.temp_params.advice_ids
                   console.log('ids',ids)
                   schedulesArr.map(item => {
                    if(ids.indexOf(item.patient_id) > -1){
                        schedules.push(item)
                    }
                    
                })
               
                for (let i = 0; i < schedules.length; i++) {
                    schedules[i].dialysis_no = schedules[i].patient.dialysis_no
                }
           

                var arr = []
                for (let j = 0; j < schedules.length; j++) {
                    arr.push(schedules[j].dialysis_no)
                }
                arr.sort(function (a, b) {
                    return a - b
                })
               

                var arrTwo = []
                for (let i = 0; i < arr.length; i++) {
                    for (let j = 0; j < schedules.length; j++) {
                    if (arr[i] == schedules[j].dialysis_no) {
                        arrTwo.push(schedules[j])
                    }
                    }
                }

                arrTwo.map((item, index) => {
                  
                    item.doctor_advice.sort(this.compare('start_time'))
                })
                

                const res = new Map()
                let a = arrTwo.filter(
                    a => !res.has(a.dialysis_no) && res.set(a.dialysis_no, 1)
                )

               

                schedules = a
                var zoneMap = {}
                var scheduleMap = {}
                for (let index = 0; index < schedules.length; index++) {
                    const schedule = schedules[index]
                    if (schedule.doctor_advice.length == 0) {
                    continue
                    }
                    if (scheduleMap[schedule.device_number.zone.name] == null) {
                    scheduleMap[schedule.device_number.zone.name] = []
                    }
                    scheduleMap[schedule.device_number.zone.name].push(schedule)
                    if (zoneMap[schedule.device_number.zone.name] == null) {
                    zoneMap[schedule.device_number.zone.name] =
                        schedule.device_number.zone
                    }
                }

                var zones = []
                zones.push({ value: 0, text: '全部分区' })
                for (var zoneName in zoneMap) {
                    zones.push({ value: zoneMap[zoneName].id, text: zoneName })
                }

                zones = zones.sort(function (a, b) {
                    return a.value > b.value
                })
                this.zones = zones
                for (var key in scheduleMap) {
                    let mapArr = scheduleMap[key]
                    for (let i = 0; i < mapArr.length; i++) {
                    mapArr[i]['new_advice'] = []
                    }
                }

                for (var key in scheduleMap) {
                    let mapArr = scheduleMap[key]
                    for (let i = 0; i < mapArr.length; i++) {
                    var maps = mapArr[i]
                    var resp_advices = maps.doctor_advice
                    if (resp_advices.length > 0) {
                        var newGroupObject = function () {
                        return Object.assign(
                            {},
                            {
                            group_no: 0,
                            advices: []
                            }
                        )
                        }
                        var initGroupBlock = function (group, advice) {
                        group.group_no = advice.groupno
                        }

                        var advice_groups = []
                        var group = newGroupObject()
                        for (let index = 0; index < resp_advices.length; index++) {
                        const advice = resp_advices[index]
                        if (advice.groupno == 0) {
                            // 老版本的医嘱
                            if (advice.parent_id > 0) {
                            if (advice_groups.length > 0) {
                                var parent_group = advice_groups[advice_groups.length - 1]
                                if (parent_group.advices.length > 0) {
                                if (parent_group.advices[0].id == advice.parent_id) {
                                    parent_group.advices.push(advice)
                                }
                                }
                            }
                            continue
                            } else {
                            if (group.group_no > 0) {
                                advice_groups.push(group)
                                group = newGroupObject()
                            }

                            initGroupBlock(group, advice)
                            group.advices.push(advice)
                            advice_groups.push(group)
                            group = newGroupObject()
                            continue
                            }
                        } else {
                            if (group.group_no > 0 && group.group_no != advice.groupno) {
                            advice_groups.push(group)
                            group = newGroupObject()
                            }
                            if (group.group_no == 0) {
                            initGroupBlock(group, advice)
                            }
                            if (group.group_no == advice.groupno) {
                            group.advices.push(advice)
                            }
                        }
                        }
                        if (group.group_no > 0) {
                        // 上述的算法会导致最后一组没有加到advice_groups，这里要手动加
                        advice_groups.push(group)
                        }
                        advice_groups = advice_groups
                    } else {
                        advice_groups = []
                    }
                    maps.new_advice = advice_groups
                    }
                 }
                

                     this.scheduleMap = scheduleMap  
                 }

                
                }
            })
        },
        compare (property) {
            return function (a, b) {
                var value1 = a[property]
                var value2 = b[property]
                return value1 - value2
            }
        },
        parseTime: function (time, layout) {
            if (time == 0) {
                return ''
            }
            return parseTime(time, layout)
        },
        getName (val) {
            for (let i = 0; i < this.admin_user.length; i++) {
                if (this.admin_user[i].id == val) {
                    return this.admin_user[i].name
                }
            }
        },
    },
    computed: {
    filtedScheduals: function () {
        var scheduleMap = new Object()
        if (this.zone_selected == 0) {
            for (const key in this.scheduleMap) {
            scheduleMap[key] = this.scheduleMap[key]
            }
        } else {
            var zone_name = this.zones[this.zone_selected].text
            scheduleMap[zone_name] = this.scheduleMap[zone_name]
        }

        if (this.schedule_type_selected != 0) {
            var _scheduleMap = {}
            for (const key in scheduleMap) {
            var origin_schedules = scheduleMap[key]
            var schedules = []
            for (let index = 0; index < origin_schedules.length; index++) {
                const schedule = origin_schedules[index]
                if (schedule.schedule_type == this.schedule_type_selected) {
                schedules.push(schedule)
                }
            }
            if (schedules.length > 0) {
                _scheduleMap[key] = schedules
            }
            }

            scheduleMap = _scheduleMap
        }
        for (var key in scheduleMap) {
            let mapArr = scheduleMap[key]
            for (let i = 0; i < mapArr.length; i++) {
            mapArr[i]['new_advice'] = []
            }
        }

        for (var key in scheduleMap) {
            let mapArr = scheduleMap[key]
            for (let i = 0; i < mapArr.length; i++) {
            var maps = mapArr[i]
            var resp_advices = maps.doctor_advice
            if (resp_advices.length > 0) {
                var newGroupObject = function () {
                return Object.assign(
                    {},
                    {
                    group_no: 0,
                    advices: []
                    }
                )
                }
                var initGroupBlock = function (group, advice) {
                group.group_no = advice.groupno
                }

                var advice_groups = []
                var group = newGroupObject()
                for (let index = 0; index < resp_advices.length; index++) {
                const advice = resp_advices[index]
                if (advice.groupno == 0) {
                    // 老版本的医嘱
                    if (advice.parent_id > 0) {
                    if (advice_groups.length > 0) {
                        var parent_group = advice_groups[advice_groups.length - 1]
                        if (parent_group.advices.length > 0) {
                        if (parent_group.advices[0].id == advice.parent_id) {
                            parent_group.advices.push(advice)
                        }
                        }
                    }
                    continue
                    } else {
                    if (group.group_no > 0) {
                        advice_groups.push(group)
                        group = newGroupObject()
                    }

                    initGroupBlock(group, advice)
                    group.advices.push(advice)
                    advice_groups.push(group)
                    group = newGroupObject()
                    continue
                    }
                } else {
                    if (group.group_no > 0 && group.group_no != advice.groupno) {
                    advice_groups.push(group)
                    group = newGroupObject()
                    }
                    if (group.group_no == 0) {
                    initGroupBlock(group, advice)
                    }
                    if (group.group_no == advice.groupno) {
                    group.advices.push(advice)
                    }
                }
                }
                if (group.group_no > 0) {
                // 上述的算法会导致最后一组没有加到advice_groups，这里要手动加
                advice_groups.push(group)
                }
                advice_groups = advice_groups
            } else {
                advice_groups = []
            }
            maps.new_advice = advice_groups
            }
        }
        console.log("222222",scheduleMap)
        return scheduleMap
        }
    },
    created(){
      var time = this.$route.query.time
      var delivery_way = this.$route.query.delivery_way
      console.log("delivery_Way",delivery_way)
      this.delivery_way = delivery_way
      this.time = moment(time).format('YYYY-MM-DD')
      console.log(11,this.$route.query)
      this.requestSchedualDoctors(time)
    }
}
</script>


<style rel="stylesheet/scss" lang="scss" scoped>
.dialysisTable{
    width:960px;
    margin: 0 auto;
    text-align: center;
    border-collapse: collapse;
}
.order_title_panl {
    text-align: center;

    .main_title {
      font-size: 18px;
      line-height: 40px;
      font-weight: 500;
    }
}
.dialysisTable tr{
    padding: 10px 0;
}
.dialysisTable th {
    color: #000;
    padding: 0;
    margin: 0;
    height: 30px;
}
.dialysisTable tr td {
    padding: 12px 0;
}
.subadvice_content {
    text-align: left;
    padding-left: 25px !important;
    padding-right: 5px !important;
}
.advice_content {
    text-align: left;
    padding-left: 5px !important;
    padding-right: 5px !important;
    padding: 15px 5px !important;
}
</style>
