<template>
 <div class="main-contain">
    <div class="position">
      <bread-crumb :crumbs='crumbs'></bread-crumb>
    </div>
    <div class="app-container" id="outcome-indicators-query">
      <person-info :patient="patientInfo"></person-info>
      <person-nav activeName="lapseto" :patientID="patientID"></person-nav>

      <div class="cqd-dataTitle">统计表</div>
      <el-table
        ref="multipleTable"
        :data="tableData"
        border
        fit
        highlight-current-row
        style="width: 100%;margin-top: 10px;"
        :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}"
      >
        
        <el-table-column  label="时间" min-width="80" property="lapseto_time" align="center">
          <template slot-scope="scope"><span>{{getTime(scope.row.lapseto_time,'{y}-{m}-{d} {h}:{i}')}}</span></template>
        </el-table-column>
        <el-table-column  label="归转状态" min-width="80" property="lapseto_type" align="center">
          <template slot-scope="scope"><span>{{getPatientLapseto(scope.row.lapseto_type)}}</span></template>
        </el-table-column>
        
      </el-table>

      <!-- <pagi-nation title="分页"></pagi-nation> -->

      <el-pagination
      align="right"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="listQuery.pate"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="10"
        background
        style="margin-top:20px;"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>


<script>
import { GetPersonLapsetoData  } from "@/api/qcd";
import {jsGetAge, uParseTime} from "@/utils/tools";
import personNav from './components/personNav'
import personInfo from './components/personInfo'
import BreadCrumb from "@/xt_pages/components/bread-crumb";
export default {
  name: "totalAnalysis",
  data() {
    return {
      crumbs:[
        {path:false, name:'质控管理'},
        {path:false, name:'患者分析'},
        {path:false, name:'统计'},
        {path:false, name:'转归'},
      ],
      total: 0,
      patientMap:{},
      listQuery: {
        page: 1,
        limit: 10,
      },
      CompletionOptions:{
        legend:[],
        series:[],
      },
      tableData: [],
      patientInfo:null,
      patientID:0,
    };
  },
  created() {
    var patientID = this.$route.query && this.$route.query.id
    console.log(this.patientID);
    if(typeof(patientID) == 'undefined' || !patientID || patientID<=0) {
      this.$message.error('参数错误，无法请求');
      return false;
    }
    patientID = parseInt(patientID);
    this.patientID = patientID;
    this.listQuery.patient_id = patientID;
    // if (this.patientID==0)
    this.getList();
  },
  methods: {
    getList() {
      GetPersonLapsetoData(this.listQuery).then(response => {
        if (response.data.state == 0) {
          this.$message.error(response.data.msg);
          return false;
        } else {
            this.tableData = [];
            this.total = response.data.data.total;
            this.patientInfo = response.data.data.patient;
            var lapsetos = response.data.data.lapsetos;
            for (const index in lapsetos) {
                this.tableData.push(lapsetos[index]);
            }
        }
      });
    },
    changeTime() {
      this.getList();
    },
    onSearch(){
      this.getList();
    },
    changeModel() {
      this.getList();
    },
    handleSizeChange(val) {
      this.listQuery.limit = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.listQuery.page = val;
      this.getList();
    },
    getTime(value, temp) {
        if (value != undefined) {
          return uParseTime(value, temp)
        }
        return ""
    },
    getProjectName(id) {
      return (id in this.projectOptions) ? this.projectOptions[id].project_name:'';
    },
    getPatientName(id) {
      return (id in this.patientMap) ? this.patientMap[id].name:'';
    },
    getPatientLapseto(lapseto) {
      if(lapseto==1) {
        return '留治';
      }else if(lapseto == 2) {
        return '转出';
      }
      return '--';
    },
    getPatientSource(srouce){
      if(srouce==1) {
        return '门诊';
      }else if(srouce == 2) {
        return '住院';
      }
      return '其他';
    },
    getPatientGender(gender) {
      if (gender == 1) {
        return '男';
      } else if(gender == 2) {
        return '女';
      }
      return '';
    },
    tranAge(birthday) {
        var birth = uParseTime(birthday, '{y}-{m}-{d}');
        return jsGetAge(birth, '-');
    },
    getPatientDialysisNo(id) {
      return (id in this.patientMap) ? this.patientMap[id].dialysis_no:'';
    },
    getItemVulue(project_id, item_id, row) {
        var key = project_id + '_' + item_id;
        return (typeof(row.items) !== 'undefined' && (key in row.items)) ? row.items[key].inspect_value:'';
    },
    renderheader(h, { column, $index }) {
        return h('span', {}, [
            h('span', {}, column.label.split('//')[0]),
            h('br'),
            h('span', {}, column.label.split('//')[1])
        ])
    },
  },
  components: {
      personNav,
      BreadCrumb,
      personInfo
  }
};
</script>
<style>
#oictable ::-webkit-scrollbar {
  height: 15px;
}
#outcome-indicators-query .el-form-item {
    margin-bottom: 0px !important;
}
</style>


<style rel="stylesheet/scss" lang="scss" scoped>
.app-container {
//   margin: 20px;
  font-size: 15px;
  .filter-container {
    padding-bottom: 5px;
  }
  .cqd-dataTitle{
    color: #303133;
    font-size: 14px;
    border-bottom: 2px #E4E7ED solid;
    height: 36px;
    line-height: 36px;
    margin: 0 0 25px 0;
    position: relative;
  }
  .cqd-dataTitle::before {
      position: absolute;
      left: 0;
      bottom: -2px;
      content: "";
      width: 42px;
      height: 2px;
      background: #409eff;
  }
  .search-component {
    width: 500px;
    .searchBox {
      width: 300px;
      height: 36px;
      line-height: 36px;
      padding-left: 15px;
      border: 1px #dcdfe6 solid;
      border-right: none;
      outline: none;
      float: left;
      border-radius: 6px 0 0 6px;
      font-size: 14px;
      color: #333;
      background: #fff;
      box-shadow: 3px 3px 4px rgba(135, 135, 135, 0.05);
    }
    .searchBtn {
      background-color: #409eff;
      color: #fff;
      font-size: 15px;
      text-align: center;
      height: 36px;
      line-height: 36px;
      float: left;
      outline: none;
      width: 70px;
      border: none;
      border-radius: 0 6px 6px 0;
      font-family: "Microsoft Yahei";
      cursor: pointer;
    }
  }
  .amount {
    font-weight: normal;
    padding: 10px 0 0 0;
    color: #606266;
    font-size: 14px;
    span {
      color: #ef2525;
      font-family: "Arial";
      padding: 0 2px;
    }
  }
}
</style>