importFile.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <template>
  2. <div class="cmain" style="display: flex;justify-content: center;align-items: center;">
  3. <el-upload
  4. class="upload-demo"
  5. drag
  6. action="#"
  7. :http-request="AvatarUpload"
  8. multiple
  9. :auto-upload="true"
  10. >
  11. <i class="el-icon-upload"></i>
  12. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  13. </el-upload>
  14. <div class="mfooter">
  15. <el-button @click="$layer.close(layerid)">取 消</el-button>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. import { importData } from "@/api/portal/GARDENTRADEDATA/GARDENTRADEDATA.js";
  21. export default {
  22. data() {
  23. return {};
  24. },
  25. props:{
  26. layerid: {
  27. type: String
  28. }
  29. },
  30. methods: {
  31. AvatarUpload(file) {
  32. let formData = new FormData()
  33. formData.append('file',file.file)
  34. importData(formData).then(res=>{
  35. if(res.code == 200){
  36. this.$modal.msgSuccess(res.msg);
  37. this.$parent.getList();
  38. this.$layer.close(this.layerid);
  39. }
  40. })
  41. },
  42. },
  43. };
  44. </script>
  45. <style>
  46. </style>