plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.6 KiB

3 years ago
3 years ago
  1. <template>
  2. <div>
  3. <!-- 弹窗, 上传文件 -->
  4. <el-upload
  5. @close="closeHandle"
  6. :action="url"
  7. :before-upload="beforeUploadHandle"
  8. :on-success="successHandle"
  9. multiple
  10. :show-file-list="false"
  11. >
  12. <el-button type="primary">点击上传</el-button>
  13. </el-upload>
  14. </div>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. url: '',
  21. num: 0,
  22. successNum: 0,
  23. fileList: {},
  24. folder: '系统文件'
  25. }
  26. },
  27. methods: {
  28. init(id) {
  29. this.url = this.$http.adornUrl(`/ftp/file/upload?token=${this.$cookie.get('token_plm')}&folder=` + this.folder)
  30. this.visible = true
  31. },
  32. // 上传之前
  33. beforeUploadHandle(file) {
  34. // if (file.type !== 'image/jpg' && file.type !== 'image/jpeg' && file.type !== 'image/png' && file.type !== 'image/gif') {
  35. // this.$message.error('只支持jpg、png、gif格式的图片!')
  36. // return false
  37. // }
  38. this.num++
  39. },
  40. // 上传成功
  41. successHandle(response, file, fileList) {
  42. this.fileList = response.ossEntity
  43. this.childClick()
  44. return response.ossEntity
  45. },
  46. childClick() {
  47. // childByValue是在父组件on监听的方法
  48. this.$emit('childByValue', this.fileList)
  49. this.$emit('refreshDataList')
  50. },
  51. // 弹窗关闭时
  52. closeHandle () {
  53. this.fileList = []
  54. this.$emit('refreshDataList')
  55. }
  56. },
  57. created() {
  58. this.init()
  59. }
  60. }
  61. </script>
  62. <style scoped>
  63. </style>