<template>
  <div class="main-contain">

    <div class="position">
      <bread-crumb :crumbs='crumbs'></bread-crumb>
      <el-button :loading="loading" size="small" icon="el-icon-printer" @click="printAction" type="primary">打印
      </el-button>
    </div>
    <div class="app-container">
      <div id="print_content">
        <div class="print_page_main_content">
          <div class="order-yy-name">{{orgname}}</div>
          <div class="order_title" style="padding-top:12px;"> 病程记录</div>
          <div class="row" style="border-bottom:1px solid #000; display: flex;padding-bottom: 10px;padding-top: 12px;">

            <div  style="flex:1;text-align: center;">
              姓名：
              <div  style="width: 120px;text-align: left;display:inline-block;">{{patient.name }}</div>
            </div>

            <div style="flex:1;text-align: center;">
              科别：
              <div  style="width: 120px;text-align: left;display:inline-block;">{{"内科"}}</div>
            </div>

            <div style="flex:1;text-align: center;">
              床位：
              <div  style="width: 120px;text-align: left;display:inline-block;">{{patient.DialysisSchedule&&patient.DialysisSchedule.device_number?patient.DialysisSchedule.device_number.number:''}}</div>
            </div>

            <div  style="flex:1;text-align: center;">
              住院号：
              <div style="width: 100px;text-align: left;display:inline-block;" v-if="patient.admission_number">
                {{patient.admission_number}}
              </div>
              <div style="width: 100px;;display:inline-block;" v-else>
                {{'/'}}
              </div>
            </div>

          </div>
          <div class="row" style="padding: 2px 0;line-height:24px;margin-top:10px;">
            <div class="inline_block">
              <div>{{getTime(record.record_time,'{y}-{m}-{d} {h}:{i}')}}</div>
            </div>
            <div class="inline_block" style="margin-left: 30px">
              <div>{{record.title}}</div>
            </div>
          </div>

          <div class="row" style="padding: 2px 0;line-height:24px;">
            <div class="inline_block" style="width:100%;">
              <div v-html="record.content">{{record.content}}</div>
            </div>
          </div>

        </div>
      </div>
    </div>
  </div>

</template>


<script>
  import { jsGetAge, uParseTime } from '@/utils/tools'
  import BreadCrumb from '@/xt_pages/components/bread-crumb'
  import { GetCoursePrintData } from '@/api/patient'

  export default {
    name: 'coursePrint',
    components: {
      BreadCrumb
    },
    data() {
      return {
        crumbs: [
          { path: false, name: '病人管理' },
          { path: false, name: '病程打印' }
        ],

        loading: false,
        orgname: '',
        record: {},
        patient: {}
      }
    },
    created() {
      var xtuser = this.$store.getters.xt_user
      this.orgname = xtuser.org.org_name

    },
    mounted() {
      this.loading = true
      var id = this.$route.query.id
      if (id == 0) {
        this.$router.back(-1)
        return
      }
      GetCoursePrintData(id).then(rs => {
        var resp = rs.data
        if (resp.state == 1) {
          this.record = resp.data.record
          this.patient = resp.data.patient

          this.loading = false
        } else {
          this.loading = false
          this.$message.error(resp.msg)
        }
      }).catch(err => {
        this.$message.error(err)
      })
    },
    methods: {
      printAction: function() {
        const style = '@media print {.option_panel { margin: 0 5px 0 0; } .option_panel .check_box_panel { white-space: nowrap; outline: none; display: inline-block; line-height: 1; position: relative; vertical-align: middle; } .dialysis-print-order .order-title{margin:auto;font-weight:600;text-align:center;font-size:22px;padding:10px}.option_panel .check_box_panel .check_box { display: inline-block; position: relative; border: 1px solid #000; box-sizing: border-box; width: 14px; height: 12px; background-color: #fff; } .check_box_panel .did_checked::after { content: "√"; font-size: 15px; } .print_page_main_content {background-color: white;width: 960px;margin: 0 auto 50px;padding: 0 0 0 0; page-break-after: always;}.print_page_main_content .order-yy-name {margin: auto;text-align: center;font-size: 20px;letter-spacing: 5px;}.print_page_main_content .order_title {text-align: center;font-size: 23px; line-height: 50px;font-weight: 500;} .row {font-size: 14px;line-height: 20px;padding: 5px 0;}.inline_block { display: inline-block;}.under_line_two {display: inline-block;border-bottom: 1px solid #999;text-align: left;white-space: nowrap;width: 50%;}.under_line {display: inline-block;border-bottom: 1px solid #999;text-align: center;white-space: nowrap; width: 50%;}.flex {display: -webkit-box;display: -moz-box; display: -ms-flexbox; display: -webkit-flex;display: flex;align-items: center;-webkit-align-items: center;box-align: center;-moz-box-align: center;-webkit-box-align: center;text-align: center;-webkit-justify-content: space-between;justify-content: space-between;-moz-box-pack: space-between;-webkit--moz-box-pack: space-between;box-pack: space-between;}.print_page_main_content .proj_table {width: 100%;border: 1px solid;border-collapse: collapse;padding: 2px;}.print_page_main_content .proj_table tbody tr td {border: 1px solid;font-size: 16px;padding: 5px 8px;line-height: 30px;}.print_page_main_content .proj_table .inside_table {width: 100%;border: hidden; border-collapse: collapse;}.print_page_main_content .proj_table .inside_table tr td {border: 1px solid; text-align: center;font-size: 14px;padding: 6px 5px;line-height: 16px;}.print-table-no {width: 100%;text-align: center;border-collapse: collapse;font-size: 14px;}.es-img {height: 30px;}.advice-name {text-align: left !important;line-height: 16px !important;}.advice-children {display: flex;}}.margin-bottom-300 {margin-bottom:450px;}.margin-bottom-600 {margin-bottom:600px;}.margin-bottom-900 {margin-bottom:1000px;}.print-yema{ position: absolute;top: 920px;left: 50%;} .print-yema2{ position: absolute;top: 400px;left: 50%;}.print-yema3{position: absolute;top: 1230px;left: 50%;}.print-yema4{position: absolute;top:1050px;left: 50%;}.print-yema5{position: absolute;top:1370px;left: 50%;}.check_box{width:15px !important;height:15px !important;}.did_checke::after {font-size: 8px;margin-left: 2px;margin-top: 12px !important;position: absolute;}'
        printJS({
          printable: 'print_content',
          type: 'html',
          documentTitle: '  ',
          style: style,
          scanStyles: false
        })
      }, getTime(value, temp) {
        if (value != undefined) {
          return uParseTime(value, temp)
        }
        return ''
      }
    }
  }
</script>

<style scoped>
  .print_page_main_content {
    background-color: white;
    width: 960px;
    margin: 0 auto 50px;
    padding: 0 0 0 0;
    page-break-after: always;
  }

  .print_page_main_content .order-yy-name {
    margin: auto;
    text-align: center;
    font-size: 20px;
    letter-spacing: 5px;
  }

  .print_page_main_content .order_title {
    text-align: center;
    font-size: 23px;
    line-height: 40px;
    font-weight: 500;
  }

  .row {
    font-size: 14px;
    line-height: 20px;
    padding: 5px 0;
  }

  .inline_block {
    display: inline-block;
  }

  .under_line {
    display: inline-block;
    border-bottom: 1px solid #999;
    text-align: center;
    white-space: nowrap;
    width: 50%;
  }

  .under_line::before {
    content: "\00A0";
  }

  .under_line::after {
    content: "\00A0";
  }

  .under_line_two {
    display: inline-block;
    border-bottom: 1px solid #999;
    text-align: left;
    white-space: nowrap;
    width: 50%;
  }

  .under_line_two::before {
    content: "\00A0";
  }

  .under_line_two::after {
    content: "\00A0";
  }

  .flex {
    display: -webkit-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    align-items: center;
    -webkit-align-items: center;
    box-align: center;
    -moz-box-align: center;
    -webkit-box-align: center;
    text-align: center;
    -webkit-justify-content: space-between;
    justify-content: space-between;
    -moz-box-pack: space-between;
    -webkit--moz-box-pack: space-between;
    box-pack: space-between;
  }

  .print_page_main_content .proj_table {
    width: 100%;
    border: 1px solid;
    border-collapse: collapse;
    padding: 2px;
  }

  .print_page_main_content .proj_table tbody tr td {
    border: 1px solid;
    /* text-align: center; */
    font-size: 16px;
    padding: 6px 8px;
    line-height: 30px;
  }

  .print_page_main_content .proj_table .inside_table {
    width: 100%;
    border: hidden; /* 解决边框冲突 */
    border-collapse: collapse;
  }

  .print_page_main_content .proj_table .inside_table tr td {
    border: 1px solid;
    text-align: center;
    font-size: 14px;
    padding: 8px 5px;
    line-height: 16px;
  }

  .print-table-no {
    width: 100%;
    text-align: center;
    border-collapse: collapse;
    font-size: 14px;
  }

  .es-img {
    height: 30px;
  }

  .advice-name {
    text-align: left !important;
    line-height: 16px !important;
  }

  .advice-children {
    display: flex;
  }
  .margin-bottom-300 {
    margin-bottom:450px;
  }
  .margin-bottom-600 {
    margin-bottom:600px;
  }
  .margin-bottom-900 {
    margin-bottom:900px;
  }
  .print-yema{
    position: absolute;
    left: 50%;
  }
  .print-yema2{
    position: absolute;
    left: 50%;
  }
  .print-yema3{
    position: absolute;
    left: 50%;
  }
  .print-yema4{
    position: absolute;
    left: 50%;
  }
  .print-yema5{
    position: absolute;
    left: 50%;
  }
  .did_checke::after {content: "\221A";font-size: 8px;margin-left: 2px;margin-top: 2px;position: absolute;}
</style>



