Commit cb147e2c by lanyulei Committed by GitHub

Merge pull request #25 from lanyulei/dev

完善表单设计器上传图片功能。
parents 78b1812b 4ddb58be
...@@ -20,19 +20,10 @@ ...@@ -20,19 +20,10 @@
<template v-else-if="widget.type=='imgupload'"> <template v-else-if="widget.type=='imgupload'">
<fm-upload <fm-upload
v-model="dataModel" v-model="dataModel"
:disabled="true"
:style="{'width': widget.options.width}" :style="{'width': widget.options.width}"
:width="widget.options.size.width" :width="widget.options.size.width"
:height="widget.options.size.height" :height="widget.options.size.height"
:token="widget.options.token" :preview="preview"
:domain="widget.options.domain"
:multiple="widget.options.multiple"
:length="widget.options.length"
:is-qiniu="widget.options.isQiniu"
:is-delete="widget.options.isDelete"
:min="widget.options.min"
:is-edit="widget.options.isEdit"
:action="widget.options.action"
/> />
</template> </template>
<template v-else-if="widget.type =='rate'"> <template v-else-if="widget.type =='rate'">
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
</draggable> </draggable>
<div <div
v-if="!preview"
v-show="(!isQiniu || (isQiniu && token)) && fileList.length < length" v-show="(!isQiniu || (isQiniu && token)) && fileList.length < length"
class="el-upload el-upload--picture-card" class="el-upload el-upload--picture-card"
:class="{'is-disabled': disabled}" :class="{'is-disabled': disabled}"
...@@ -126,6 +127,10 @@ export default { ...@@ -126,6 +127,10 @@ export default {
disabled: { disabled: {
type: Boolean, type: Boolean,
default: false default: false
},
preview: {
type: Boolean,
default: false
} }
}, },
data() { data() {
...@@ -219,11 +224,16 @@ export default { ...@@ -219,11 +224,16 @@ export default {
xhr.onreadystatechange = () => { xhr.onreadystatechange = () => {
if (xhr.readyState === 4) { if (xhr.readyState === 4) {
const resData = JSON.parse(xhr.response) const resData = JSON.parse(xhr.response)
resData.url = resData.data var uploadUrl = ''
if (resData && resData.url) { if (resData.url !== undefined && resData.url !== null && resData.url !== '') {
uploadUrl = resData.url
} else if (resData.data !== undefined && resData.data !== null && resData.data !== '') {
uploadUrl = resData.data
}
if (resData && uploadUrl) {
this.$set(this.fileList, this.fileList.findIndex(item => item.key === key), { this.$set(this.fileList, this.fileList.findIndex(item => item.key === key), {
...this.fileList[this.fileList.findIndex(item => item.key === key)], ...this.fileList[this.fileList.findIndex(item => item.key === key)],
url: resData.url, url: uploadUrl,
percent: 100 percent: 100
}) })
setTimeout(() => { setTimeout(() => {
......
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