| bb778c90  阿宝
 
设备状态 | 1
2 |   <template>
    <div>
 | 
| db11048f  阿宝
 
设备状态,学校管理 | 3 |       <slot name="down"></slot>
 | 
| 530a37c8  梁保满
 
上传组件 | 4 |       <div class="d1">
 | 
| 530a37c8  梁保满
 
上传组件 | 5
6
7 |         <el-upload
          class="upload-demo"
          ref="upload"
 | 
| db11048f  阿宝
 
设备状态,学校管理 | 8 |           :action="url"
 | 
| 530a37c8  梁保满
 
上传组件 | 9 |           :multiple="false"
 | 
| 9309dc5d  梁保满
 
任课老师接口完成 | 10 |           :data="{ ...query }"
 | 
| 530a37c8  梁保满
 
上传组件 | 11
12
13
14
15
16
17 |           :with-credentials="true"
          :limit="1"
          :on-change="change"
          :on-success="upSuccess"
          :on-error="upError"
        >
          <!-- accept="application/vnd.ms-excel" -->
 | 
| db11048f  阿宝
 
设备状态,学校管理 | 18
19
20
21
22
23 |           <div class="upload-btn">
            <i class="el-icon-upload"></i>
            <el-button class="btn" size="mini" type="primary"
              >选择文件并上传</el-button
            >
          </div>
 | 
| 530a37c8  梁保满
 
上传组件 | 24
25 |         </el-upload>
      </div>
 | 
| bb778c90  阿宝
 
设备状态 | 26
27
28
29 |     </div>
  </template>
  
  <script>
 | 
| bb778c90  阿宝
 
设备状态 | 30 |   export default {
 | 
| 530a37c8  梁保满
 
上传组件 | 31
32 |     name: "downUpData",
    props: {
 | 
| 8ea67428  梁保满
 
飞书bug | 33
34 |       id: "",
      examId: "",
 | 
| db11048f  阿宝
 
设备状态,学校管理 | 35
36
37
38
39
40
41
42
43 |       url: {
        type: String,
        default: "",
      },
  
      fileName: {
        type: String,
        default: "模板",
      },
 | 
| 530a37c8  梁保满
 
上传组件 | 44 |     },
 | 
| 9309dc5d  梁保满
 
任课老师接口完成 | 45
46
47
48
49
50
51
52
53
54
55
56
57 |     computed: {
      query: function () {
        if (this.id) {
          return {
            id: this.id,
          };
        } else if (this.examId) {
          return {
            examId: this.examId,
          };
        }
      },
    },
 | 
| 530a37c8  梁保满
 
上传组件 | 58
59
60
61
62
63
64
65 |     data() {
      return {
        file: null,
      };
    },
    methods: {
      async submitUpload() {
        this.$refs.upload.submit();
 | 
| bb778c90  阿宝
 
设备状态 | 66 |   
 | 
| 530a37c8  梁保满
 
上传组件 | 67
68
69
70
71
72
73
74
75
76
77
78 |         // 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) {
 | 
| 255e2506  梁保满
 
飞书bug及优化 | 79 |         if (res && res.status == 0 ) {
 | 
| 530a37c8  梁保满
 
上传组件 | 80 |           this.$message.success("上传成功");
 | 
| 191d5bfa  梁保满
 
学生管理、基站管理下载名称设置,上... | 81 |           this.$emit("upSuccess",res);
 | 
| 530a37c8  梁保满
 
上传组件 | 82 |         } else {
 | 
| 255e2506  梁保满
 
飞书bug及优化 | 83 |           this.$message.error(res.info);
 | 
| 530a37c8  梁保满
 
上传组件 | 84
85
86 |         }
      },
      upError(res) {
 | 
| 530a37c8  梁保满
 
上传组件 | 87 |         if (res && res.status == 0) {
 | 
| 255e2506  梁保满
 
飞书bug及优化 | 88 |           this.$message.error("上传失败");
 | 
| 530a37c8  梁保满
 
上传组件 | 89
90
91
92
93
94
95 |         } else {
          this.$message.error(res.message);
        }
      },
      change(file) {
        this.file = file;
      },
 | 
| 530a37c8  梁保满
 
上传组件 | 96
97 |     },
  };
 | 
| bb778c90  阿宝
 
设备状态 | 98
99 |   </script>
  
 | 
| 530a37c8  梁保满
 
上传组件 | 100
101
102
103
104 |   <style lang="scss" scoped>
  .d1 {
    padding: 10px;
  }
  .btn {
 | 
| 530a37c8  梁保满
 
上传组件 | 105
106
107 |     border-radius: 8px;
    font-weight: normal;
  }
 | 
| db11048f  阿宝
 
设备状态,学校管理 | 108
109
110
111
112
113
114
115
116
117
118
119
120
121
122 |   .upload-demo {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .upload-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    .el-icon-upload {
      font-size: 48px;
      margin-bottom: 6px;
      color: #667ffd;
    }
  }
 | 
| 530a37c8  梁保满
 
上传组件 | 123 |   </style>
 |