1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <template>
- <div class="datacenter-upload">
- <el-upload :action="action" name="uploadFile" ref="upload" :headers="headers" :on-success="successFile"
- :before-upload="beforeUpload" :on-error="errorUpload" :show-file-list="false" :on-progress="progress">
- <div class="bim-update-button">
- <i class="el-icon-plus"></i>
- </div>
- </el-upload>
- </div>
- </template>
- <script>
- import config from '@/config';
- import {
- getToken
- } from '@/uitls/auth';
- export default {
- props: ['parentId'],
- data() {
- return {
- action: '',
- headers: {}
- };
- },
- created() {
- this.action = config.baseURL + '/file/filenode/' + this.parentId;
- this.headers.token = getToken();
- },
- methods: {
- beforeUpload() {
- this.$loading();
- },
- progress(e) {
- let percent = e.percent >= 100 ? 99 : parseInt(e.percent)
- this.$loading({
- percent: (percent + '%')
- });
- },
- reloadUpload() {
- this.$refs['upload'].$children[0].$refs.input.click();
- },
- errorUpload() {
- this.$loading.close();
- this.$message.error('上传失败');
- },
- successFile(data) {
- this.$message.success('上传成功');
- this.$emit('reload');
- this.$loading.close();
- },
- },
- watch: {
- parentId() {
- this.action = config.baseURL + '/file/filenode/' + this.parentId;
- }
- },
- };
- </script>
- <style lang="scss">
- .datacenter-upload {}
- </style>
|