提交 0abd7ba3 authored 作者: 王鹏飞's avatar 王鹏飞

图片大小增加限制

上级 ea2f40fa
{ {
"name": "@ezijing/vue-form", "name": "@ezijing/vue-form",
"version": "2.1.9", "version": "2.2.0",
"private": false, "private": false,
"description": "基于Vue Element-UI的表单", "description": "基于Vue Element-UI的表单",
"scripts": { "scripts": {
......
...@@ -71,4 +71,4 @@ export default { ...@@ -71,4 +71,4 @@ export default {
install, install,
// 以下是具体的组件列表 // 以下是具体的组件列表
...components ...components
} }
\ No newline at end of file
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
:on-error="handleError" :on-error="handleError"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:file-list="fileList" :file-list="fileList"
:before-upload="beforeUploadFile"
ref="upload" ref="upload"
:class="classes" :class="classes"
> >
...@@ -76,6 +77,9 @@ export default { ...@@ -76,6 +77,9 @@ export default {
limit() { limit() {
return this.attrs.limit return this.attrs.limit
}, },
maxSize() {
return this.attrs.maxSize || 10
},
hasUpload() { hasUpload() {
if (this.limit) { if (this.limit) {
return this.fileList.length < this.limit return this.fileList.length < this.limit
...@@ -89,6 +93,13 @@ export default { ...@@ -89,6 +93,13 @@ export default {
} }
}, },
methods: { methods: {
beforeUploadFile(file) {
const isLt10M = file.size / 1024 / 1024 < this.maxSize
if (!isLt10M) {
this.$message.error(`上传文件大小不能超过 ${this.maxSize}MB!`)
}
return isLt10M
},
// 上传接口请求 // 上传接口请求
handleHttpRequest(xhr) { handleHttpRequest(xhr) {
let { action, data = {}, headers = {} } = this.options.attrs let { action, data = {}, headers = {} } = this.options.attrs
...@@ -126,13 +137,14 @@ export default { ...@@ -126,13 +137,14 @@ export default {
// 删除 // 删除
handleRemove(file, fileList) { handleRemove(file, fileList) {
let { deleteAction, headers = {} } = this.options.attrs let { deleteAction, headers = {} } = this.options.attrs
httpRequest file.id &&
.post(deleteAction, { item_id: file.id }, { headers }) httpRequest
.then(res => { .post(deleteAction, { item_id: file.id }, { headers })
this.data[this.options.model] = fileList .then(res => {
this.$message.success(res.message) this.data[this.options.model] = fileList
}) this.$message.success(res.message)
.catch(error => this.$message.error(error.message)) })
.catch(error => this.$message.error(error.message))
}, },
// 新窗口预览 // 新窗口预览
newWindowPreview(url) { newWindowPreview(url) {
......
...@@ -15,7 +15,7 @@ module.exports = { ...@@ -15,7 +15,7 @@ module.exports = {
}, },
proxy: { proxy: {
'/api/enrollment': { '/api/enrollment': {
target: 'http://enrollment-test.c3f0f1f4826b94e23a2c355a9dac8a299.cn-beijing.alicontainer.com', target: 'http://test-enrollment.ezijing.com',
ws: true, ws: true,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论