<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;">
            <div id="print_content">
                <div class="print_main_content">
                    <div class="order_title_panl">
                        <span class="main_title">透析参数统计表</span>
                    </div>
                    <div style="display:flex;justify-content: space-between;margin-bottom:10px;">
                        <p>统计时间：{{start_time}}-{{end_time}}</p>
                        <p>印单日期：{{print_time}}</p>
                    </div>
                    <div class="table_panel">
                        <table class="table">
                            <thead>
                                <tr>
                                    <td width="120">商品类型</td>
                                    <td width="120">规格名称</td>
                                     <td width="120">数量</td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr v-for='(item,index) in tableData' :key="index">
                                    <td>抗凝剂</td>
                                    <td>
                                      <span v-if="item.anticoagulant==1">无肝素</span>
                                      <span v-if="item.anticoagulant==2">普通肝素</span>
                                      <span v-if="item.anticoagulant==4">阿加曲班</span>
                                      <span v-if="item.anticoagulant==5">枸橼酸钠</span>
                                      <span v-if="item.anticoagulant==6">低分子肝素钙</span>
                                      <span v-if="item.anticoagulant==7">低分子肝素钠</span>
                                      <span v-if="item.anticoagulant==8">依诺肝素</span>
                                      <span v-if="item.anticoagulant==9">达肝素</span>
                                      <span v-if="item.anticoagulant==10">体外抗凝</span> 
                                    </td>
                                    <td>
                                      {{item.count}}
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import BreadCrumb from '@/xt_pages/components/bread-crumb'
import { GetAnticoagulantCount} from "@/api/consumable"
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'),
        }
    },
    methods:{
        printAction: function() {
            const style = '@media print { .print_main_content { background-color: white; width:960px;  margin:0 auto; padding: 0 0 20px 0; } .order_title_panl { text-align: center; } .main_title { font-size: 18px; line-height: 40px; font-weight: 500; } .table_panel { } .table { width: 100%; border: 1px solid; border-collapse: collapse; padding: 2px; } thead tr td { border: 1px solid; text-align: center; font-size: 20px; padding: 15px 5px; } tbody tr td { border: 1px solid; text-align: center; font-size: 18px; padding: 10px 5px; } .proj { padding: 5px 0; text-align: left; } .proj_title { font-size: 16px; font-weight: 500; line-height: 25px; } .proj_item { font-size: 15px; line-height: 20px; } .zone_name { font-weight: 500; } }'

            printJS({
            printable: 'print_content',
            type: 'html',
            documentTitle: '  ',
            style: style,
            scanStyles: false
            })
        },
        getlist(startime,endtime){
             const params= {
               start_time:startime,
               end_time:endtime
             }
           GetAnticoagulantCount(params).then(response=>{
             if(response.data.state == 1){
               var count =  response.data.data.count
               console.log("99999count",count)
               this.tableData = count
             }
           })
        }
    },
    created(){
      var startime = this.$route.query.startime
      console.log("startime3333",startime)
      var endtime = this.$route.query.endtime
      console.log("endtime6666",endtime)
      this.getlist(startime,endtime)
      this.start_time = startime
      this.end_time = endtime
    }
}
</script>


<style rel="stylesheet/scss" lang="scss" scoped>
.print_main_content {
  background-color: white;
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 0 20px 0;

  .order_title_panl {
    text-align: center;

    .main_title {
      font-size: 18px;
      line-height: 40px;
      font-weight: 500;
    }
  }
  .table_panel {
    .table {
      width: 100%;
      border: 1px solid;
      border-collapse: collapse;
      padding: 2px;

      thead {
        tr {
          td {
            border: 1px solid;
            text-align: center;
            font-size: 20px;
            padding: 15px 5px;
          }
        }
      }
      tbody {
        tr {
          td {
            border: 1px solid;
            text-align: center;
            font-size: 18px;
            padding: 10px 5px;

            .proj {
              padding: 5px 0;
              text-align: left;

              .proj_title {
                font-size: 16px;
                font-weight: 500;
                line-height: 25px;
              }

              .proj_item {
                font-size: 15px;
                line-height: 20px;

                .zone_name {
                  font-weight: 500;
                }
              }
            }
          }
        }
      }
    }
  }
}
</style>
