<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="printTitle">库存盘点核单数</div>
                <div style="float:right;">调价日期：</div>
                <table class="printTable" border="1">
                    <tr>
                        <td>序号</td>
                        <td>药品名称</td>
                        <td>规格</td>
                        <td>单位</td>
                        <td>零售价</td>
                        <td>当前库存</td>
                        <td>盘点数</td>
                        <td>亏损金额</td>
                    </tr>
                    <tr v-for="(item,index) in tableData" :key="index">
                        <td>{{index+1}}</td>
                        <td>{{item.drug_name}}</td>
                        <td>{{item.warehouseing_unit}}</td>
                        <td>{{item.retail_price}}</td>
                        <td>{{item.total}}</td>
                        <td>{{item.count}}</td>
                        <td></td>       
                    </tr>
                </table>
                <div style="margin-top:10px;">
                    <span>合计：库存金额</span>
                    <span>    库存盘点金额：亏损总计</span>
                </div>
                <div style="display:flex;float:right;margin-top:10px;border-top:1px solid #000;padding-top:10px;width:100%;">
                    <div style="width:80px;">审批：</div><div style="width:100px;"></div>
                    <div style="width:100px;">药材主任：</div><div style="width:60px;"></div>
                    <div style="width:50px;">会计：</div><div style="width:100px;"></div>
                    <div style="width:50px;">审核：</div><div style="width:100px;"></div>
                    <div style="width:70px;">制单人：</div><div style="width:100px;"></div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import BreadCrumb from '@/xt_pages/components/bread-crumb'
const moment = require('moment');
import { uParseTime } from '@/utils/tools'
import { getDrugInventoryPrintList } from "@/api/drug/drug"
export default {
    components:{
        BreadCrumb
    },
    data(){
        return{
          crumbs: [
            { path: false, name: '库存管理' },
            { path: false, name: '药品管理' },
            { path: false, name: '药品盘点打印' },
          ],
          ids:"",
          tableData:[]
        }
    },
    methods:{
        printAction: function() {
            const style = '@media print { .printTitle{font-size: 22px;text-align: center;}.flex{display: flex;justify-content: space-between;}.tableTitle{display: flex;border-top:1px solid #000;border-bottom: 1px solid #000;padding: 10px 0;}.tableTr{display: flex;border-bottom: 1px dashed #000;padding: 10px 0;}.tableBottom{display: flex;border-bottom: 1px solid #000;padding: 10px 0;}.printTable td{padding:5px;} }';
            printJS({
            printable: 'print_content',
            type: 'html',
            documentTitle: '  ',
            style: style,
            scanStyles: false
            })
        },
        getDrugInventoryPrintList(ids){
             var params = {
                 ids:ids,
             }
          console.log("parasm2232",params)
          getDrugInventoryPrintList(params).then(response=>{
              if(response.data.state == 1){
                 this.tableData = response.data.data.list
              }
          })    
        }

    },
    created(){
      this.ids = this.$route.query.ids
      this.getDrugInventoryPrintList(this.ids)
    }
}
</script>


<style rel="stylesheet/scss" lang="scss" scoped>
.printTitle{font-size: 22px;text-align: center;}
.flex{display: flex;justify-content: space-between;}
.tableTitle{display: flex;border-top:1px solid #000;border-bottom: 1px solid #000;padding: 10px 0;}
.tableTr{display: flex;border-bottom: 1px dashed #000;padding: 10px 0;}
.tableBottom{display: flex;border-bottom: 1px solid #000;padding: 10px 0;}
.printTable{width:100%;border-collapse: collapse;}
.printTable td{padding:5px;}
</style>
