<template>
  <div class="main-contain">
    <div class="position">
      <bread-crumb :crumbs='crumbs'></bread-crumb>
    </div>
    <div class="app-container">
      <div class="service-box">
        <el-tabs v-model="activeName">
          <el-tab-pane label="透析处方" name="first">
            <dialysis-prescription :dialysis_prescription_data="dialysis_prescription_data" @change="changePrescriptionData"></dialysis-prescription>
          </el-tab-pane>
          <el-tab-pane label="接诊评估">
            <receive-treatment-asses :receive_treatment_asses_data="receive_treatment_asses_data" @change="changeAssesData"></receive-treatment-asses>
          </el-tab-pane>
          <el-tab-pane label="透前评估">
            <dialysis-before :dialysis_before_data="dialysis_before_data" @change="changeBeforeData"></dialysis-before>
          </el-tab-pane>
          <el-tab-pane label="透析监测">
            <dialysis-monitor :dialysis_monitor_data="dialysis_monitor_data" @change="changeMonitorData"></dialysis-monitor>
          </el-tab-pane>
          <el-tab-pane label="透后评估">
            <dialysis-after :dialysis_after_data="dialysis_after_data" @change="changeAfterData"></dialysis-after>
          </el-tab-pane>

        </el-tabs>
      </div>
    </div>
  </div>
</template>

<script>

  import BreadCrumb from '@/xt_pages/components/bread-crumb'
  import DialysisAfter from './components/dialysisAfter'
  import DialysisPrescription from './components/dialysisPrescription'
  import DialysisBefore from './components/dialysisBefore'
  import DialysisMonitor from './components/dialysisMonitor'
  import ReceiveTreatmentAsses from './components/receiveTreatmentAsses'
  import { getFiledConfigList } from '@/utils/data_config' // getConfigList from sessionStorage
  import store from '@/store'

  export default {
    name: 'showConfig',
    components: {
      ReceiveTreatmentAsses,
      DialysisMonitor,
      DialysisBefore,
      DialysisPrescription,
      DialysisAfter,
      BreadCrumb
    },
    data() {
      return {
        crumbs: [
          { path: false, name: '管理中心' },
          { path: '/data/showconfig', name: '显示配置' }
        ],
        activeName: 'first',
        dialysis_prescription_data:[],
        receive_treatment_asses_data:[],
        dialysis_before_data:[],
        dialysis_monitor_data:[],
        dialysis_after_data:[],
      }
    },
    methods: {
      handleClick(tab, event) {
        console.log(tab, event, this.activeName)
      },changePrescriptionData:function(object) {
        for (let i = 0; i< this.dialysis_prescription_data.length; i++){
          if( this.dialysis_prescription_data[i].id ==object.id){
            this.dialysis_prescription_data[i].is_show = object.is_show
          }

        }

      },changeAssesData:function(object) {
        for (let i = 0; i< this.receive_treatment_asses_data.length; i++){
          if( this.receive_treatment_asses_data[i].id ==object.id){
            this.receive_treatment_asses_data[i].is_show = object.is_show
          }

        }


      },changeBeforeData:function(object) {
        for (let i = 0; i< this.dialysis_before_data.length; i++){
          if( this.dialysis_before_data[i].id ==object.id){
            this.dialysis_before_data[i].is_show = object.is_show
          }

        }


      },changeMonitorData:function(object) {
        for (let i = 0; i< this.dialysis_monitor_data.length; i++){
          if( this.dialysis_monitor_data[i].id ==object.id){
            this.dialysis_monitor_data[i].is_show = object.is_show
          }

        }


      },changeAfterData:function(object) {
        for (let i = 0; i< this.dialysis_after_data.length; i++){
          if( this.dialysis_after_data[i].id ==object.id){
            this.dialysis_after_data[i].is_show = object.is_show
          }

        }


      }
    },
    created(){
      var filedList = store.getters.xt_user.fileds
      for (let i = 0; i < filedList.length;i++){
        switch (filedList[i].module) {
          case 1:
            this.dialysis_prescription_data.push(filedList[i])
            break
          case 2:
            this.receive_treatment_asses_data.push(filedList[i])
            break
          case 3:
            this.dialysis_before_data.push(filedList[i])
            break
          case 4:
            this.dialysis_monitor_data.push(filedList[i])
            break
          case 5:
            this.dialysis_after_data.push(filedList[i])
            break
        }
      }


    }
  }
</script>


