Commit d3891df8 by Mr. Lan

fix: fix bug.

parent d6ad63cf
...@@ -265,7 +265,25 @@ ...@@ -265,7 +265,25 @@
</template> </template>
<template v-if="widget.type=='file'"> <template v-if="widget.type=='file'">
<FileUpload :element="widget" /> <el-upload
:action="widget.options.action"
:on-success="handleSuccess"
:on-preview="handlePreview"
:on-remove="handleRemove"
:before-remove="beforeRemove"
multiple
:limit="widget.options.length"
:headers="widget.options.headers"
:on-exceed="handleExceed"
:file-list="widget.options.defaultValue"
:disabled="widget.options.disabled"
:style="{'width': widget.options.width}"
>
<div v-if="!preview">
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">{{ widget.options.tip }}</div>
</div>
</el-upload>
</template> </template>
<template v-if="widget.type === 'editor'"> <template v-if="widget.type === 'editor'">
...@@ -325,18 +343,17 @@ ...@@ -325,18 +343,17 @@
<script> <script>
import FmUpload from './Upload' import FmUpload from './Upload'
import FileUpload from './Upload/file'
export default { export default {
name: 'GenetateFormItem', name: 'GenetateFormItem',
components: { components: {
FmUpload, FmUpload
FileUpload
}, },
/* eslint-disable */ /* eslint-disable */
props: ['widget', 'models', 'rules', 'remote', 'data', 'disabled', 'preview', 'isLabel', 'subformIndex', 'subformModel'], props: ['widget', 'models', 'rules', 'remote', 'data', 'disabled', 'preview', 'isLabel', 'subformIndex', 'subformModel'],
data() { data() {
return { return {
currentRemoveUid: '',
widgetLabelWidth: '', widgetLabelWidth: '',
dataModel: this.subformIndex===undefined? dataModel: this.subformIndex===undefined?
this.models[this.widget.model]: this.models[this.widget.model]:
...@@ -370,7 +387,7 @@ export default { ...@@ -370,7 +387,7 @@ export default {
models: { models: {
deep: true, deep: true,
handler(val) { handler(val) {
if (val.status === undefined && val.status === null) { if (val.status === undefined || val.status === null) {
if (this.subformIndex === undefined) { if (this.subformIndex === undefined) {
this.dataModel = val[this.widget.model] this.dataModel = val[this.widget.model]
} else { } else {
...@@ -414,6 +431,25 @@ export default { ...@@ -414,6 +431,25 @@ export default {
} }
}, },
methods: { methods: {
handleRemove(file, fileList) {
this.widget.options.defaultValue = fileList
},
handlePreview(file) {
window.open(file.url, '_blank')
},
handleExceed(files, fileList) {
this.$message.warning(`最多允许上传 ${this.widget.options.length} 个文件。`)
},
beforeRemove(file, fileList) {
this.currentRemoveUid = file.uid
return this.$confirm(`确定要移除 ${file.name}?`)
},
handleSuccess(response, file, fileList) {
// this.widget.options.defaultValue.push({
// name: file.name,
// url: response.data
// })
}
} }
} }
</script> </script>
......
...@@ -321,7 +321,7 @@ export const advanceComponents = [ ...@@ -321,7 +321,7 @@ export const advanceComponents = [
headers: {}, headers: {},
// isQiniu: false, // isQiniu: false,
tip: '', // 提示说明 tip: '', // 提示说明
action: 'https://jsonplaceholder.typicode.com/photos/', action: 'http://ipaddress:port/api/v1/public/uploadFile',
labelWidth: 100, labelWidth: 100,
labelWidthDisabled: false, labelWidthDisabled: false,
labelWidthStatus: true labelWidthStatus: true
......
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