<template>
    <div class="bodyBoxs">
        <div class="boxs">
          <el-upload
            class="upload-demo"
            drag
            action="https://h5.km-china.cn/index.php?s=admin/impExcel"
            multiple
            :on-success="impExcel"
            accept = "xlsx" :before-upload = 'beforeUpload'>
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            <div class="el-upload__tip" slot="tip">只能上传xlsx文件，且不超过50MB</div>
            <div class="el-upload__tip" slot="tip">下载 &nbsp;<a style="color: red" href="https://jingji-h5.ecps.com.cn//3341_amjjtr3b19iw/static/file/示例.xlsx">示例</a></div>
          </el-upload>
        </div>
    </div>
</template>
<script>
import { getToken } from "@/utils/auth";
export default {
    data(){
        return{
            loading:false,
            token : getToken()
        }
    },
    created(){

    },
    methods:{
      beforeUpload(res){
        // console.log(res)
        // if (res == false){
        //   this.$message({
        //     message: '只支持xlsx格式的文件',
        //     type: 'warning'
        //   });
        // }
      },
      impExcel(res){
        if (res.code == 0){
          this.$message({
            message: res.message,
            type: 'success'
          });
        }else {
          this.$message({
            message: res.message,
            type: 'warning'
          });
        }

      }

    }
}
</script>
<style scoped>
 .bodyBoxs{
        padding: 40px;
    }
    .boxs{
        width: 100%;
        background: #fff;
        border-radius: 15px;
    }
</style>
