<template> <div class="app-container"> <!--查询结果Table显示--> <div> <el-divider content-position="left" >请选择考勤月</el-divider> <el-form ref="dataForm" :rules="rules" :model="form" label-well-code="right" label-width="120px"> <el-row style="margin-top: 60px"> <el-col :span="8"> <el-form-item label="考勤月" prop="month"> <el-date-picker v-model="form.month" :picker-options="pickerOptions" type="month" format="yyyy-MM" value-format="yyyy-MM" placeholder="必填"/> </el-form-item> </el-col> <el-col :span="4"> <el-button type="primary" size="medium" style="width: 180px" @click="makeReport">生成报表</el-button> </el-col> </el-row> </el-form> </div> </div> </template> <script> import { makeReport } from '@/api/attendance' import { downloadFile } from '@/utils/downloadUtils' export default { name: 'MakeReport', data() { return { form: { month: '' }, rules: { month: [{ required: true, message: '请选择考勤月', trigger: ['blur', 'change'] }] }, pickerOptions: { disabledDate: (time) => { // const v = 24 * 60 * 60 * 1000 * 30 return time.getTime() > Date.now() } } } }, mounted() {}, methods: { makeReport() { // 表单校验 this.$refs['dataForm'].validate((valid) => { if (valid) { // 全屏加载动画 const loading = this.$loading({ lock: true, text: '数据处理中,请稍后...', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.7)' }) makeReport(this.form).then(response => { loading.close() downloadFile(response.data, '考勤报表') this.$message.success('生成报表成功') }).catch((res) => { loading.close() }) } }) } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> $tableTitleHeight:46px; .table{ margin-bottom: 20px; } .pagination-container{ margin-bottom: 50px; } .table-title{ background-color:rgba(243, 243, 243, 1); height: $tableTitleHeight; .title-header{ line-height:$tableTitleHeight; color: #606266; font-size: 15px; i{ margin-left: 5px; margin-right: 5px; } } } .edit_btns{ .edit_btn{ float:right; margin:7px 3px;//为了需要居中显示margin-top和bottom要用$tableTitleHeight减去按钮原高度除以2 } } </style>