From 5186227a467bd34dc253e64b23bc96d3a07bb399 Mon Sep 17 00:00:00 2001 From: zhangzengfei <zhangzengfei@smartai.com> Date: 星期三, 17 十一月 2021 17:39:53 +0800 Subject: [PATCH] 添加用户权限控制 --- src/components/VabUpload/index.vue | 300 ++++++++++++++++++++++++++++++------------------------------ 1 files changed, 150 insertions(+), 150 deletions(-) diff --git a/src/components/VabUpload/index.vue b/src/components/VabUpload/index.vue index 31d83a5..a8c6412 100644 --- a/src/components/VabUpload/index.vue +++ b/src/components/VabUpload/index.vue @@ -75,181 +75,181 @@ </template> <script> - import { baseURL, tokenName } from '@/config' +import { baseURL, tokenName } from "@/config"; - export default { - name: 'VabUpload', - props: { - url: { - type: String, - default: '/upload', - required: true, - }, - name: { - type: String, - default: 'file', - required: true, - }, - limit: { - type: Number, - default: 50, - required: true, - }, - size: { - type: Number, - default: 1, - required: true, - }, +export default { + name: "VabUpload", + props: { + url: { + type: String, + default: "/upload", + required: true, }, - data() { - return { - show: false, - loading: false, - dialogVisible: false, - dialogImageUrl: '', - action: 'https://vab-unicloud-3a9da9.service.tcloudbase.com/upload', - headers: {}, - fileList: [], - picture: 'picture', - imgNum: 0, - imgSuccessNum: 0, - imgErrorNum: 0, - typeList: null, - title: '涓婁紶', - dialogFormVisible: false, - data: {}, + name: { + type: String, + default: "file", + required: true, + }, + limit: { + type: Number, + default: 50, + required: true, + }, + size: { + type: Number, + default: 1, + required: true, + }, + }, + data() { + return { + show: false, + loading: false, + dialogVisible: false, + dialogImageUrl: "", + action: "https://vab-unicloud-3a9da9.service.tcloudbase.com/upload", + headers: {}, + fileList: [], + picture: "picture", + imgNum: 0, + imgSuccessNum: 0, + imgErrorNum: 0, + typeList: null, + title: "涓婁紶", + dialogFormVisible: false, + data: {}, + }; + }, + computed: { + percentage() { + if (this.allImgNum == 0) return 0; + return this.$baseLodash.round(this.imgNum / this.allImgNum, 2) * 100; + }, + }, + methods: { + submitUpload() { + this.$refs.upload.submit(); + }, + handleProgress(event, file, fileList) { + this.loading = true; + this.show = true; + }, + handleChange(file, fileList) { + if (file.size > 1048576 * this.size) { + fileList.map((item, index) => { + if (item === file) { + fileList.splice(index, 1); + } + }); + this.fileList = fileList; + } else { + this.allImgNum = fileList.length; } }, - computed: { - percentage() { - if (this.allImgNum == 0) return 0 - return this.$baseLodash.round(this.imgNum / this.allImgNum, 2) * 100 - }, - }, - methods: { - submitUpload() { - this.$refs.upload.submit() - }, - handleProgress(event, file, fileList) { - this.loading = true - this.show = true - }, - handleChange(file, fileList) { - if (file.size > 1048576 * this.size) { - fileList.map((item, index) => { - if (item === file) { - fileList.splice(index, 1) - } - }) - this.fileList = fileList - } else { - this.allImgNum = fileList.length - } - }, - handleSuccess(response, file, fileList) { - this.imgNum = this.imgNum + 1 - this.imgSuccessNum = this.imgSuccessNum + 1 - if (fileList.length === this.imgNum) { - setTimeout(() => { - this.$baseMessage( - `涓婁紶瀹屾垚! 鍏变笂浼�${fileList.length}寮犲浘鐗嘸, - 'success' - ) - }, 1000) - } + handleSuccess(response, file, fileList) { + this.imgNum = this.imgNum + 1; + this.imgSuccessNum = this.imgSuccessNum + 1; + if (fileList.length === this.imgNum) { + setTimeout(() => { + this.$baseMessage( + `涓婁紶瀹屾垚! 鍏变笂浼�${fileList.length}寮犲浘鐗嘸, + "success" + ); + }, 1000); + } - setTimeout(() => { - this.loading = false - this.show = false - }, 1000) - }, - handleError(err, file, fileList) { - this.imgNum = this.imgNum + 1 - this.imgErrorNum = this.imgErrorNum + 1 - this.$baseMessage( - `鏂囦欢[${file.raw.name}]涓婁紶澶辫触,鏂囦欢澶у皬涓�${this.$baseLodash.round( - file.raw.size / 1024, - 0 - )}KB`, - 'error' - ) - setTimeout(() => { - this.loading = false - this.show = false - }, 1000) - }, - handleRemove(file, fileList) { - this.imgNum = this.imgNum - 1 - this.allNum = this.allNum - 1 - }, - handlePreview(file) { - this.dialogImageUrl = file.url - this.dialogVisible = true - }, - handleExceed(files, fileList) { - this.$baseMessage( - `褰撳墠闄愬埗閫夋嫨 ${this.limit} 涓枃浠讹紝鏈閫夋嫨浜� + setTimeout(() => { + this.loading = false; + this.show = false; + }, 1000); + }, + handleError(err, file, fileList) { + this.imgNum = this.imgNum + 1; + this.imgErrorNum = this.imgErrorNum + 1; + this.$baseMessage( + `鏂囦欢[${file.raw.name}]涓婁紶澶辫触,鏂囦欢澶у皬涓�${this.$baseLodash.round( + file.raw.size / 1024, + 0 + )}KB`, + "error" + ); + setTimeout(() => { + this.loading = false; + this.show = false; + }, 1000); + }, + handleRemove(file, fileList) { + this.imgNum = this.imgNum - 1; + this.allNum = this.allNum - 1; + }, + handlePreview(file) { + this.dialogImageUrl = file.url; + this.dialogVisible = true; + }, + handleExceed(files, fileList) { + this.$baseMessage( + `褰撳墠闄愬埗閫夋嫨 ${this.limit} 涓枃浠讹紝鏈閫夋嫨浜� ${files.length} 涓枃浠禶, - 'error' - ) - }, - handleShow(data) { - this.title = '涓婁紶' - this.data = data - this.dialogFormVisible = true - }, - handleClose() { - this.fileList = [] - this.picture = 'picture' - this.allImgNum = 0 - this.imgNum = 0 - this.imgSuccessNum = 0 - this.imgErrorNum = 0 - /* if ("development" === process.env.NODE_ENV) { + "error" + ); + }, + handleShow(data) { + this.title = "涓婁紶"; + this.data = data; + this.dialogFormVisible = true; + }, + handleClose() { + this.fileList = []; + this.picture = "picture"; + this.allImgNum = 0; + this.imgNum = 0; + this.imgSuccessNum = 0; + this.imgErrorNum = 0; + /* if ("development" === process.env.NODE_ENV) { this.api = process.env.VUE_APP_BASE_API; } else { this.api = `${window.location.protocol}//${window.location.host}`; } this.action = this.api + this.url; */ - this.dialogFormVisible = false - }, + this.dialogFormVisible = false; }, - } + }, +}; </script> <style lang="scss" scoped> - .upload { - height: 500px; +.upload { + height: 500px; - .upload-content { - .el-upload__tip { - display: block; - height: 30px; - line-height: 30px; + .upload-content { + .el-upload__tip { + display: block; + height: 30px; + line-height: 30px; + } + + ::v-deep { + .el-upload--picture-card { + width: 128px; + height: 128px; + margin: 3px 8px 8px 8px; + border: 2px dashed #c0ccda; } - ::v-deep { - .el-upload--picture-card { + .el-upload-list--picture { + margin-bottom: 20px; + } + + .el-upload-list--picture-card { + .el-upload-list__item { width: 128px; height: 128px; margin: 3px 8px 8px 8px; - border: 2px dashed #c0ccda; - } - - .el-upload-list--picture { - margin-bottom: 20px; - } - - .el-upload-list--picture-card { - .el-upload-list__item { - width: 128px; - height: 128px; - margin: 3px 8px 8px 8px; - } } } } } +} </style> -- Gitblit v1.8.0