<template>
    <el-dialog
    title="透析参数统计"
    width="800px"
    :visible.sync="visible"
    :before-close="_close"
    >
    <div>
        <el-date-picker
        style="width:150px;margin-right:10px"
        v-model="startTime"
        type="date"
        placeholder="选择日期"
        @change="selectStartime">
        </el-date-picker>
        <el-date-picker
        style="width:150px;margin-right:10px"
        v-model="endTime"
        type="date"
        placeholder="选择日期">
        </el-date-picker>
        <el-button icon="el-icon-printer" type="primary" @click="toPrint">打印</el-button>

    </div>
    <div style="margin-top:10px;">
        <el-table :data="tableData" border style="width: 100%" height="300">
            <el-table-column align="center" prop="address" label="商品类型">
                <template slot-scope="scope">
                   抗凝剂
                </template>
            </el-table-column>
            <el-table-column align="center" prop="name" label="规格名称">
                <template slot-scope="scope">
                   <span v-if="scope.row.anticoagulant==1">无肝素</span>
                   <span v-if="scope.row.anticoagulant==2">普通肝素</span>
                   <span v-if="scope.row.anticoagulant==3">低分子肝素</span>
                   <span v-if="scope.row.anticoagulant==4">阿加曲班</span>
                   <span v-if="scope.row.anticoagulant==5">枸橼酸钠</span>
                   <span v-if="scope.row.anticoagulant==6">低分子肝素钙</span>
                   <span v-if="scope.row.anticoagulant==7">低分子肝素钠</span>
                   <span v-if="scope.row.anticoagulant==8">依诺肝素</span>
                   <span v-if="scope.row.anticoagulant==9">达肝素</span>
                   <span v-if="scope.row.anticoagulant==10">体外抗凝</span>
                   <span v-if="scope.row.anticoagulant==11">那曲肝素</span>
                </template>
            </el-table-column>
            <el-table-column align="center" prop="name"label="数量">
              <template slot-scope="scope">
                 {{scope.row.count}}
              </template>
            </el-table-column>
        </el-table>
    </div>
    <!-- <div slot="footer" class="dialog-footer">
      <el-button @click="hide">取 消</el-button>
      <el-button type="primary" @click="submitAction()">保 存</el-button>
    </div> -->
  </el-dialog>
</template>



<script>
const moment = require('moment')
import { parseTime } from '@/utils'
import { GetAllZone } from "@/api/dialysis";
import { GetAnticoagulantCount} from "@/api/consumable"
export default {
    data(){
        return{
            visible: false,
            startTime:moment(new Date()).add('year', 0).format('YYYY-MM-DD'),
            endTime:moment(new Date()).add('year', 0).format('YYYY-MM-DD'),
            schedulArr: [
                {value: 0, label: '全部班'},
                {value: 1, label: '上午'},
                {value: 2, label: '中午'},
                {value: 3, label: '下午'},
            ],
            schedulType: 0,
            partitionArr:[],
            partitionType: 0,
            tableData: [],
            query:{
             start_time: moment(new Date()).add('year', 0).format('YYYY-MM-DD'),
             end_time:moment(new Date()).add('year', 0).format('YYYY-MM-DD')
          },
        }
    },
    created(){
        this.getAllZone()
        this.getlist()
    },
    methods:{
        _close: function(done) {
            done();
        },
        show() {
            this.visible = true;
        },
        getAllZone: function() {
            GetAllZone().then(response => {
                if (response.data.state == 0) {
                this.$message.error(response.data.msg);
                return false;
                } else {
                this.partitionArr = response.data.data.zone;
                this.partitionArr.unshift({ id: 0, name: "全部分区" });
                }
            });
        },
        toPrint(){
            this.$router.push({
                // path: '/dialysis/dialysisParameters_print',
                // query: { date: date }
                path:"/dialysis/dialysisdrugs_print?startime="+this.query.start_time+"&endtime="+this.query.end_time + "&type=2"
            })
        },
       selectStartime() {
        this.start_time = parseTime(this.startTime, '{y}-{m}-{d}')
        this.query.start_time = parseTime(this.startTime, '{y}-{m}-{d}')
        this.getlist()

      },
      selectEndtime() {
        this.end_time = parseTime(this.endTime, '{y}-{m}-{d}')
        this.query.end_time = parseTime(this.endTime, '{y}-{m}-{d}')
        this.getlist()

      },
        getlist(){
          GetAnticoagulantCount(this.query).then(response=>{
             if(response.data.state == 1){
               var count =  response.data.data.count
               console.log("count22222",count)
               this.tableData = count
             }
          })
        }
    }
}
</script>
