UpLoadComponentDialog.vue 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <!--文件上传组件-->
  2. <template>
  3. <div>
  4. <el-dialog
  5. :title="title"
  6. :close-on-click-modal="false"
  7. draggable
  8. width="1400px"
  9. height="500px"
  10. @close="close"
  11. append-to-body
  12. v-model="visible">
  13. <UpLoadComponentV2 ref="upLoadComponentV2"></UpLoadComponentV2>
  14. <span slot="footer" class="dialog-footer">
  15. <el-button @click="close()" icon="el-icon-circle-close">关闭</el-button>
  16. <el-button type="primary" icon="el-icon-circle-check" @click="doSubmit()">确定</el-button>
  17. </span>
  18. </el-dialog>
  19. </div>
  20. </template>
  21. <script>
  22. import UpLoadComponentV2 from './UpLoadComponentV2'
  23. export default {
  24. data () {
  25. return {
  26. visible: false,
  27. title: '',
  28. index: ''
  29. }
  30. },
  31. computed: {
  32. },
  33. watch: {
  34. },
  35. created () {
  36. },
  37. components: {
  38. UpLoadComponentV2
  39. },
  40. mounted () {
  41. },
  42. methods: {
  43. /**
  44. * 文件上传组件初始化
  45. * @param auth
  46. * auth的值为"view"时,不可上传/编辑文件
  47. * auth为其他值时,可上传/编辑文件
  48. * @param fileList 要显示到文件上传列表中的文件。
  49. * 注:文件必须要有url属性并且文件的url属性值必须是在oss中的路径值
  50. * 例:'/attachment-file/xxx/xxx/2022/9/08/xxx.jpg'
  51. * @param directory 要存放到oss的哪个文件夹下。
  52. * 注:值为空时,默认存放到"public"文件夹
  53. * @param maxValue 上传文件允许的最大值,单位:MB
  54. * 注:值为空时,默认值为300MB
  55. * @param dividerName 组件中divider的名称
  56. * 注:值为空时,默认值为‘附件’
  57. * @param uploadFlag ‘上传文件’按钮是否禁用
  58. * 注:值为空时,默认值为false
  59. * auth=view&&uploadFlag=false时 ‘上传文件’按钮禁用
  60. * @param delFlag ‘删除’按钮是否禁用
  61. * 注:值为空时,默认值为false
  62. * auth=view&&delFlag=false时 ‘删除’按钮禁用
  63. * @param showDivider ‘附件‘Divider是否展示
  64. * 注:值为空时,默认值为true
  65. * showDivider=false时 ‘附件‘Divider隐藏
  66. */
  67. newUpload (auth, fileList, directory, maxValue, dividerName, uploadFlag, delFlag, showDivider, index) {
  68. this.index = index
  69. this.title = '附件'
  70. this.visible = true
  71. this.$nextTick(() => {
  72. this.$refs.upLoadComponentV2.newUpload(auth, fileList, directory, maxValue, dividerName, uploadFlag, delFlag, showDivider)
  73. })
  74. },
  75. doSubmit () {
  76. if (!this.$refs.upLoadComponentV2.checkProgress()) {
  77. this.$emit('getUpload', this.$refs.upLoadComponentV2.getDataList(), this.index)
  78. this.close()
  79. }
  80. },
  81. close () {
  82. this.$refs.upLoadComponentV2.clearUpload()
  83. this.visible = false
  84. }
  85. }
  86. }
  87. </script>