Commit 633fb5ba by lanyulei Committed by GitHub

Merge pull request #45 from lanyulei/dev

fix: 修复上传文件bug
parents 7122fa86 792a119e
...@@ -265,7 +265,7 @@ ...@@ -265,7 +265,7 @@
</template> </template>
<template v-if="widget.type=='file'"> <template v-if="widget.type=='file'">
<FileUpload :element="widget" /> <FileUpload :element="widget" :data-model="dataModel" @fileList="fileList" />
</template> </template>
<template v-if="widget.type === 'editor'"> <template v-if="widget.type === 'editor'">
...@@ -414,6 +414,9 @@ export default { ...@@ -414,6 +414,9 @@ export default {
} }
}, },
methods: { methods: {
fileList(files) {
this.dataModel = files
}
} }
} }
</script> </script>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
:limit="element.options.length" :limit="element.options.length"
:headers="element.options.headers" :headers="element.options.headers"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:file-list="element.options.defaultValue" :file-list="dataModel"
:disabled="element.options.disabled" :disabled="element.options.disabled"
:style="{'width': element.options.width}" :style="{'width': element.options.width}"
> >
...@@ -26,15 +26,15 @@ ...@@ -26,15 +26,15 @@
export default { export default {
name: 'FileUpload', name: 'FileUpload',
// eslint-disable-next-line vue/require-prop-types // eslint-disable-next-line vue/require-prop-types
props: ['element', 'preview'], props: ['element', 'preview', 'dataModel'],
data() { data() {
return { return {
currentRemoveUid: '' fileListTmp: []
} }
}, },
methods: { methods: {
handleRemove(file, fileList) { handleRemove(file, fileList) {
this.element.options.defaultValue = fileList this.$emit('fileList', fileList)
}, },
handlePreview(file) { handlePreview(file) {
window.open(file.url, '_blank') window.open(file.url, '_blank')
...@@ -43,14 +43,15 @@ export default { ...@@ -43,14 +43,15 @@ export default {
this.$message.warning(`最多允许上传 ${this.element.options.length} 个文件。`) this.$message.warning(`最多允许上传 ${this.element.options.length} 个文件。`)
}, },
beforeRemove(file, fileList) { beforeRemove(file, fileList) {
this.currentRemoveUid = file.uid
return this.$confirm(`确定要移除 ${file.name}?`) return this.$confirm(`确定要移除 ${file.name}?`)
}, },
handleSuccess(response, file, fileList) { handleSuccess(response, file, fileList) {
this.element.options.defaultValue.push({ this.fileListTmp.push({
uid: file.uid,
name: file.name, name: file.name,
url: response.data url: response.data
}) })
this.$emit('fileList', this.fileListTmp)
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment