| 21dfdeae  梁保满
 
平台管理员 | 1
2
3
4
5
6
7 |   <template>
    <div>
      <slot name="down"></slot>
      <div class="d1">
        <el-upload
          class="upload-demo"
          ref="upload"
 | 
| ef16e57e  LH_PC
 
fix:前端版本迭代 | 8 |           :action="uploadUrl"
 | 
| 21dfdeae  梁保满
 
平台管理员 | 9
10 |           :multiple="false"
          :data="{ ...query }"
 | 
| 21dfdeae  梁保满
 
平台管理员 | 11
12
13
14 |           :limit="1"
          :on-change="change"
          :on-success="upSuccess"
          :on-error="upError"
 | 
| e371f2dc  梁保满
 
软件下载,学校,班级老师等报表导入... | 15 |           accept=".zip"
 | 
| 21dfdeae  梁保满
 
平台管理员 | 16
17
18 |         >
          <!-- accept="application/vnd.ms-excel" -->
          <div class="upload-btn">
 | 
| e371f2dc  梁保满
 
软件下载,学校,班级老师等报表导入... | 19 |             <el-button class="btn" size="mini" type="primary">选择zip文件</el-button>
 | 
| 21dfdeae  梁保满
 
平台管理员 | 20
21
22
23
24
25
26 |           </div>
        </el-upload>
      </div>
    </div>
  </template>
  
  <script>
 | 
| ef16e57e  LH_PC
 
fix:前端版本迭代 | 27
28 |   import conf from "@/config/index";  // 路径配置
  
 | 
| 21dfdeae  梁保满
 
平台管理员 | 29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47 |   export default {
    name: "downUpData",
    props: {
      query: {
        type: Object,
        default: function () {
          return {};
        },
      },
      url: {
        type: String,
        default: "",
      },
    },
    data() {
      return {
        file: null,
      };
    },
 | 
| ef16e57e  LH_PC
 
fix:前端版本迭代 | 48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65 |     computed: {
      uploadUrl: function () {
  
        var requestUrl = '';
  
        var ogrinUrl = this.$props.url;
  
        var baseUrl = conf.baseURL;
  
        if (baseUrl == '/' && ogrinUrl.indexOf('/') == 0) {
          requestUrl = ogrinUrl;
        }
        else {
          requestUrl = baseUrl + ogrinUrl
        } 
        return requestUrl;
      }
    },
 | 
| 21dfdeae  梁保满
 
平台管理员 | 66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115 |     methods: {
      async submitUpload() {
        this.$refs.upload.submit();
  
        // const formData = new FormData()
        // formData.append('id',this.componentId)
        // formData.append('file',new File(this.file.raw))
        // let {status,info} = await uploadExcel(formData);
        // if(status===0){
        //   this.$message.success(info);
        //   this.$emit("upSuccess")
        // } else {
        //   this.$message.error(info);
        // }
      },
      upSuccess(res) {
        if (res && res.status == 0) {
          this.$message.success("上传成功");
          this.$emit("upSuccess", res);
        } else {
          this.$message.error(res.info);
        }
      },
      upError(res) {
        if (res && res.status == 0) {
          this.$message.error("上传失败");
        } else {
          this.$message.error(res.message);
        }
      },
      change(file) {
        this.file = file;
      },
    },
  };
  </script>
  
  <style lang="scss" scoped>
  .btn {
    border-radius: 8px;
    font-weight: normal;
  }
  .upload-btn {
    .el-icon-upload {
      font-size: 48px;
      margin-bottom: 6px;
      color: #667ffd;
    }
  }
  </style>
 |