<template>
  <div>
    <template>
      <el-buttonc
        style="position:fixed;right:25px;z-index:999"
        :loading="loading"
        size="small"
        icon="el-icon-printer"
        @click="printThisPage"
        type="primary"
        >打印</el-buttonc
      >
    </template>
    <div class="app-container" style="padding-top:40px;">
        <div class='dialysisPage'>
            <printOne v-bind:childResponse="childResponse" :paramsObj="paramsObj"></printOne>
        </div>
    </div>
  </div>
</template>

<script>

import { jsGetAge, uParseTime } from "@/utils/tools";
// import LabelBox from "./printItem/LabelBox";
import print from "print-js";
import printOne from "./settlementTemplate/hospitalPrintOne"
export default {
  name: "dialysisPrintOrder",
  components: {
    printOne
  },
  props:{
    paramsObj:Object
  },
  data() {
    return {
      crumbs: [
        { path: false, name: "透析管理" },
        { path: false, name: "打印单" }
      ],
      childResponse: {},
      paramsObj:{}


    };
  },
  methods: {
    getAdminUser(id) {
      if (id == 0) {
        return "";
      }
      if (id == undefined) {
        return "";
      }
      for (let i = 0; i < this.adminUser.length; i++) {
        if (this.adminUser[i].id == id) {
          return this.adminUser[i].name;
        }
      }
    },
    getTime(value, temp) {
      if (value == 0) {
        return "";
      }
      if (value != undefined) {
        return uParseTime(value, temp);
      }
      return "";
    },
    printThisPage() {
      var ptime = Math.round(new Date().getTime() / 1000);
      this.print_time = uParseTime(ptime, "{y}-{m}-{d} {h}:{i}");

      const style =
        '@media print {.printTitle{font-size: 22px;text-align: center;font-weight: bold;}.infoMain{display: flex;flex-wrap: wrap;padding:0 10px;margin-top:10px;}.infoMain .infoP{width: 33%;}.chargeBox{border: 1px solid #000;}.chargeUl{display:flex;justify-content: space-between;text-align: center;}.chargeUl p{line-height: 1px;}.chargeP{line-height: 1px;padding-bottom:16px;}.moneyBox{display: flex;justify-content: space-between;padding: 0 10px;background: #eeeeee;-webkit-print-color-adjust:exact;-moz-print-color-adjust:exact;-ms-print-color-adjust:exact;print-color-adjust:exact;height: 40px;align-items: center;border:1px solid #000; border-top:none}.actionBar{display: flex;justify-content: space-between; line-height: 24px;padding:0 10px;}.actionBar div{width:150px;}}';
        const style1 = "@media print{#prescription-print{font-size:14px;}.title{text-align: center;font-size: 22px;font-weight: bold;}.row{display: flex;justify-content: space-between;}.under_line{border-bottom: 1px solid #999;width: 95%;text-align: center;margin-left: 2px;display: inline-block;}.inline_block{display: inline-block;}.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: 14px;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;}}";
        printJS({
            printable: "prescription-print",
            type: "html",
            style: style1,
            scanStyles: false
        });

      // if (this.org_template_info.template_id == 1) {
      //   printJS({
      //     printable: "dialysis-print-box",
      //     type: "html",
      //     style: style,
      //     scanStyles: false
      //   });
      // }
    },
  },
  created() {
  },
  watch:{
    paramsObj:{//深度监听，可监听到对象、数组的变化
      handler(val, oldVal){
        this.paramsObj = val

      },
      deep:true
    }
  }
};
</script>

<style lang="scss" scoped>
.printTitle{
    font-size: 22px;
    text-align: center;
    font-weight: bold;
}
.infoMain{
    display: flex;
    flex-wrap: wrap;
    border-bottom: 2px solid #000;
    padding:0 10px;
}
.infoMain .infoP{
    width: 33%;
    line-height: 24px;
}
.prescriptionBox{
    padding:0 10px;
    height:600px;
}
.Rp{
    font-size: 22px;
    font-weight: bold;
}
.drugsBox{
    padding-left: 40px;
    margin-bottom: 10px;
}
.drugsBox p{
    line-height: 30px;
}
.drugsOne{
    line-height: 24px;
}
.drugsOne span{
    margin-right: 20px;
}
.doctorBox{
    display: flex;
    justify-content: space-between;
    padding:0 10px;
    line-height: 24px;
    border-bottom: 2px solid #000;
}
.actionBar{
    display: flex;
    justify-content: space-between;
    line-height: 24px;
    padding:0 10px;
}
.actionBar p{
    width:150px;
}
</style>
