Commit 0b439b72 by YuleiLan

fix: 修复图片上传失败bug。

parent 0a7f1506
......@@ -20,7 +20,7 @@
<template v-else-if="widget.type=='imgupload'">
<fm-upload
v-model="dataModel"
:disabled="widget.options.disabled"
:disabled="true"
:style="{'width': widget.options.width}"
:width="widget.options.size.width"
:height="widget.options.size.height"
......@@ -60,7 +60,7 @@
</span>
</el-divider>
</template>
<template v-if="widget.type === 'input' && widget.options.showPassword">
<template v-else-if="widget.type === 'input' && widget.options.showPassword">
<input :value="dataModel" type="password" style="border: none; background-color: #ffffff; color: #303133" disabled="disabled">
</template>
<template v-else>
......
......@@ -41,19 +41,32 @@
@click.self="handleAdd"
>
<i class="el-icon-plus" :style="{fontSize:miniWidth/4+'px',marginTop: (-miniWidth/8)+'px', marginLeft: (-miniWidth/8)+'px'}" @click.self="handleAdd" />
<input v-if="multiple" ref="uploadInput" accept="image/*" multiple type="file" :style="{width: 0, height: 0}" name="file" class="el-upload__input upload-input"
@change="handleChange">
<input
v-if="multiple"
ref="uploadInput"
accept="image/*"
multiple
type="file"
:style="{width: 0, height: 0}"
name="file"
class="el-upload__input upload-input"
@change="handleChange"
>
<input v-else ref="uploadInput" accept="image/*" type="file" :style="{width:0, height: 0}" name="file" class="el-upload__input upload-input" @change="handleChange">
</div>
</div>
</template>
<script>
import Viewer from 'viewerjs'
import Draggable from 'vuedraggable'
import * as qiniu from 'qiniu-js'
require('viewerjs/dist/viewer.css')
export default {
import Vue from 'vue'
import Viewer from 'viewerjs'
import Draggable from 'vuedraggable'
import * as qiniu from 'qiniu-js'
require('viewerjs/dist/viewer.css')
import VueI18n from 'vue-i18n'
Vue.use(VueI18n)
export default {
components: {
Draggable
},
......@@ -191,6 +204,7 @@
this.$refs.uploadInput.value = []
},
uplaodAction(res, file, key) {
// eslint-disable-next-line no-unused-vars
const changeIndex = this.fileList.findIndex(item => item.key === key)
const xhr = new XMLHttpRequest()
......@@ -205,6 +219,7 @@
xhr.onreadystatechange = () => {
if (xhr.readyState === 4) {
const resData = JSON.parse(xhr.response)
resData.url = resData.data
if (resData && resData.url) {
this.$set(this.fileList, this.fileList.findIndex(item => item.key === key), {
...this.fileList[this.fileList.findIndex(item => item.key === key)],
......@@ -246,6 +261,7 @@
next(res) {
_this.$set(_this.fileList[_this.fileList.findIndex(item => item.key === key)], 'percent', parseInt(res.total.percent))
},
// eslint-disable-next-line handle-callback-err
error(err) {
_this.$set(_this.fileList, _this.fileList.findIndex(item => item.key === key), {
..._this.fileList[_this.fileList.findIndex(item => item.key === key)],
......@@ -296,7 +312,7 @@
})
}
}
}
}
</script>
<style lang="scss">
......
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