| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <template>
- <div style="width: 200px;height:28px;" class="upMain">
- <el-upload
- ref="upload"
- :action="'/pdcApi/bis/insp/pblm/plist/upload'"
- :multiple="false"
- :headers="header"
- accept=".xls,.xlsx"
- :limit='1'
- :auto-upload="true"
- :on-success="uploadSuccess"
- :on-error="Error"
- >
- <el-button type="primary">点击上传</el-button>
- <div slot="tip" class="el-upload__tip">只能上传xls/xlsx文件</div>
- </el-upload>
- </div>
- </template>
- <script>
- export default {
- data() {
- return {
- header: {
- 'persId': localStorage.getItem('userid'),
- 'accessToken' : localStorage.getItem('accessToken'),
- 'orgId': localStorage.getItem('currentOrgId')
- },
- };
- },
- computed:{
- userid(){
- return localStorage.getItem('userid') ? localStorage.getItem('userid') : ''
- }
- },
- methods: {
- // 初始化,
- init() {
- this.$refs.upload.clearFiles();
- },
- // 上传出错,向上触发结束
- upError(err, file, fileList) {
- this.$message.error("上传失败,请修改文件!");
- this.init();
- },
- // 全部上传成功,向上触发结束
- uploadSuccess(response, file, fileList) {
- if(response.success){
- this.$message.success("上传成功");
- this.init();
- }else{
- this.$message.error("上传失败,请修改文件!");
- this.init();
- }
- }
- }
- };
- </script>
- <style scoped>
- .upMain div{
- display: flex;
- }
- /deep/ .el-upload__tip{
- margin-top: 0;
- }
- </style>
|