修复文件上传后无法点击下载的问题。

This commit is contained in:
vdpAdmin 2022-11-03 11:17:02 +08:00
parent ad40ae6fa8
commit 85efe2bc42
3 changed files with 27 additions and 12 deletions

View File

@ -198,7 +198,7 @@ export default {
}, },
buildFieldRules() { buildFieldRules() {
if (!this.field.formItemFlag) { if (!this.field.formItemFlag && this.field.options.hidden) {
return return
} }

View File

@ -205,22 +205,17 @@
} }
this.updateFieldModelAndEmitDataChangeForUpload(fileList, customResult, res) this.updateFieldModelAndEmitDataChangeForUpload(fileList, customResult, res)
if (!!customResult && !!customResult.name) {
file.name = customResult.name
}
if (!!customResult && !!customResult.url) {
file.url = customResult.url
}
this.fileList = deepClone(fileList) this.fileList = deepClone(fileList)
this.uploadBtnHidden = fileList.length >= this.field.options.limit this.uploadBtnHidden = fileList.length >= this.field.options.limit
} }
}, },
// handleFileRemove(file, fileList) {
// this.fileList = deepClone(fileList) //this.fileList = fileList
// this.updateUploadFieldModelAndEmitDataChange(fileList)
// this.uploadBtnHidden = fileList.length >= this.field.options.limit
//
// if (!!this.field.options.onFileRemove) {
// let customFn = new Function('file', 'fileList', this.field.options.onFileRemove)
// customFn.call(this, file, fileList)
// }
// },
updateFieldModelAndEmitDataChangeForRemove(deletedFileIdx, fileList) { updateFieldModelAndEmitDataChangeForRemove(deletedFileIdx, fileList) {
let oldValue = deepClone(this.fieldModel) let oldValue = deepClone(this.fieldModel)
this.fieldModel.splice(deletedFileIdx, 1) this.fieldModel.splice(deletedFileIdx, 1)

View File

@ -127,6 +127,10 @@ export const loadRemoteScript = function(srcPath, callback) { /*加载远程js
} }
export function traverseFieldWidgets(widgetList, handler, parent = null) { export function traverseFieldWidgets(widgetList, handler, parent = null) {
if (!widgetList) {
return
}
widgetList.map(w => { widgetList.map(w => {
if (w.formItemFlag) { if (w.formItemFlag) {
handler(w, parent) handler(w, parent)
@ -153,6 +157,10 @@ export function traverseFieldWidgets(widgetList, handler, parent = null) {
} }
export function traverseContainerWidgets(widgetList, handler) { export function traverseContainerWidgets(widgetList, handler) {
if (!widgetList) {
return
}
widgetList.map(w => { widgetList.map(w => {
if (w.category === 'container') { if (w.category === 'container') {
handler(w) handler(w)
@ -181,6 +189,10 @@ export function traverseContainerWidgets(widgetList, handler) {
} }
export function traverseAllWidgets(widgetList, handler) { export function traverseAllWidgets(widgetList, handler) {
if (!widgetList) {
return
}
widgetList.map(w => { widgetList.map(w => {
handler(w) handler(w)
@ -259,6 +271,10 @@ export function traverseFieldWidgetsOfContainer(con, handler) {
* @returns {[]} * @returns {[]}
*/ */
export function getAllFieldWidgets(widgetList) { export function getAllFieldWidgets(widgetList) {
if (!widgetList) {
return []
}
let result = [] let result = []
let handlerFn = (w) => { let handlerFn = (w) => {
result.push({ result.push({
@ -278,6 +294,10 @@ export function getAllFieldWidgets(widgetList) {
* @returns {[]} * @returns {[]}
*/ */
export function getAllContainerWidgets(widgetList) { export function getAllContainerWidgets(widgetList) {
if (!widgetList) {
return []
}
let result = [] let result = []
let handlerFn = (w) => { let handlerFn = (w) => {
result.push({ result.push({