修复bug:系统配置文件上传bug

pull/57/head
李强 2022-05-14 01:20:04 +08:00
parent f0ec91ed4c
commit 2059d4fd54
2 changed files with 16 additions and 8 deletions

View File

@ -86,12 +86,14 @@
<el-upload <el-upload
:action="uploadUrl" :action="uploadUrl"
:headers="uploadHeaders" :headers="uploadHeaders"
name="url" name="file"
:accept="'image/*'" :accept="'image/*'"
:on-preview="handlePictureCardPreview" :on-preview="handlePictureCardPreview"
:on-success="(response, file, fileList)=>{handleUploadSuccess(response, file, fileList,item.key)}" :on-success="(response, file, fileList)=>{handleUploadSuccess(response, file, fileList,item.key)}"
:on-error="handleError" :on-error="handleError"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:before-remove="(file, fileList)=>{beforeRemove(file, fileList, item.key)}"
:multiple="item.form_item_type_label!=='img'"
:limit="item.form_item_type_label==='img'?1:5" :limit="item.form_item_type_label==='img'?1:5"
:ref="'imgUpload_'+item.key" :ref="'imgUpload_'+item.key"
:data-keyname="item.key" :data-keyname="item.key"
@ -110,15 +112,16 @@
<el-upload <el-upload
:action="uploadUrl" :action="uploadUrl"
:headers="uploadHeaders" :headers="uploadHeaders"
name="url" name="file"
:on-preview="handlePictureCardPreview" :on-preview="handlePictureCardPreview"
:on-success="(response, file, fileList)=>{handleUploadSuccess(response, file, fileList,item.key)}" :on-success="(response, file, fileList)=>{handleUploadSuccess(response, file, fileList,item.key)}"
:on-error="handleError" :on-error="handleError"
:on-exceed="handleExceed" :on-exceed="handleExceed"
:before-remove="(file, fileList)=>{beforeRemove(file, fileList, item.key)}"
:limit="item.form_item_type_label==='img'?1:5" :limit="item.form_item_type_label==='img'?1:5"
:ref="'fileUpload_'+item.key" :ref="'fileUpload_'+item.key"
:data-keyname="item.key" :data-keyname="item.key"
:file-list="item.value?item.value:[]" :file-list="item.value"
list-type="picture-card" list-type="picture-card"
> >
<i class="el-icon-plus"></i> <i class="el-icon-plus"></i>
@ -301,7 +304,6 @@ export default {
const form = JSON.parse(JSON.stringify(this.form)) const form = JSON.parse(JSON.stringify(this.form))
const keys = Object.keys(form) const keys = Object.keys(form)
const values = Object.values(form) const values = Object.values(form)
console.log(111, form)
for (const index in this.formList) { for (const index in this.formList) {
const item = this.formList[index] const item = this.formList[index]
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
@ -349,7 +351,6 @@ export default {
} }
that.$refs.form.clearValidate() that.$refs.form.clearValidate()
that.$refs.form.validate((valid) => { that.$refs.form.validate((valid) => {
console.log(this.formList)
if (valid) { if (valid) {
api.saveContent(this.options.id, api.saveContent(this.options.id,
this.formList).then(res => { this.formList).then(res => {
@ -408,7 +409,7 @@ export default {
msg msg
} = response } = response
if (code === 2000) { if (code === 2000) {
const { url } = response.data.data const { url } = response.data
const { name } = file const { name } = file
const type = that.isImage(name) const type = that.isImage(name)
if (!type) { if (!type) {
@ -421,7 +422,7 @@ export default {
// console.log(len) // console.log(len)
const dict = { const dict = {
name: name, name: name,
url: url url: util.baseURL() + url
} }
that.form[imgKey].push(dict) that.form[imgKey].push(dict)
} }
@ -436,6 +437,14 @@ export default {
// //
handleExceed () { handleExceed () {
this.$message.error('超过文件上传数量') this.$message.error('超过文件上传数量')
},
//
beforeRemove (file, fileList, key) {
var index = 0
this.form[key].map((value, inx) => {
if (value.uid === file.uid) index = inx
})
this.form[key].splice(index, 1)
} }
}, },
mounted () { mounted () {

View File

@ -77,7 +77,6 @@ export default {
* 获取验证码 * 获取验证码
*/ */
getCaptcha () { getCaptcha () {
console.log(2, this.captchaState, this.captchaState !== undefined)
if (this.captchaState !== undefined && !this.captchaState) return if (this.captchaState !== undefined && !this.captchaState) return
api.getCaptcha().then((ret) => { api.getCaptcha().then((ret) => {
this.formLogin.captcha = null this.formLogin.captcha = null