图片、文件上传地址增加DSV变量支持。

master
vdpAdmin 2023-07-05 16:48:40 +08:00
parent f104313c1b
commit 325cc6b573
3 changed files with 30 additions and 4 deletions

View File

@ -5,7 +5,7 @@
<!-- el-upload增加:name="field.options.name"会导致又拍云上传失败故删除之 -->
<el-upload ref="fieldEditor" :disabled="field.options.disabled"
:style="styleVariables" class="dynamicPseudoAfter"
:action="field.options.uploadURL" :headers="uploadHeaders" :data="uploadData"
:action="realUploadURL" :headers="uploadHeaders" :data="uploadData"
:with-credentials="field.options.withCredentials"
:multiple="field.options.multipleSelect" :file-list="fileList"
:show-file-list="field.options.showFileList" :class="{'hideUploadDiv': uploadBtnHidden}"
@ -31,7 +31,7 @@
import FormItemWrapper from './form-item-wrapper'
import emitter from '@/utils/emitter'
import i18n, {translate} from "@/utils/i18n";
import {deepClone} from "@/utils/util";
import {deepClone, evalFn} from "@/utils/util";
import fieldMixin from "@/components/form-designer/form-widget/field-widget/fieldMixin";
let selectFileText = "'" + translate('render.hint.selectFile') + "'"
@ -93,6 +93,16 @@
}
},
computed: {
realUploadURL() {
let uploadURL = this.field.options.uploadURL
if (!!uploadURL && ((uploadURL.indexOf('DSV.') > -1) || (uploadURL.indexOf('DSV[') > -1))) {
let DSV = this.getGlobalDsv()
console.log('test DSV: ', DSV) //DSV
return evalFn(this.field.options.uploadURL, DSV)
}
return this.field.options.uploadURL
},
},
beforeCreate() {

View File

@ -4,7 +4,7 @@
:sub-form-row-index="subFormRowIndex" :sub-form-col-index="subFormColIndex" :sub-form-row-id="subFormRowId">
<!-- el-upload增加:name="field.options.name"会导致又拍云上传失败故删除之 -->
<el-upload ref="fieldEditor" :disabled="field.options.disabled"
:action="field.options.uploadURL" :headers="uploadHeaders" :data="uploadData"
:action="realUploadURL" :headers="uploadHeaders" :data="uploadData"
:with-credentials="field.options.withCredentials"
:multiple="field.options.multipleSelect" :file-list="fileList" :show-file-list="field.options.showFileList"
list-type="picture-card" :class="{'hideUploadDiv': uploadBtnHidden}"
@ -29,7 +29,7 @@
import FormItemWrapper from './form-item-wrapper'
import emitter from '@/utils/emitter'
import i18n, {translate} from "@/utils/i18n";
import {deepClone} from "@/utils/util";
import {deepClone, evalFn} from "@/utils/util";
import fieldMixin from "@/components/form-designer/form-widget/field-widget/fieldMixin";
export default {
@ -88,6 +88,16 @@
}
},
computed: {
realUploadURL() {
let uploadURL = this.field.options.uploadURL
if (!!uploadURL && ((uploadURL.indexOf('DSV.') > -1) || (uploadURL.indexOf('DSV[') > -1))) {
let DSV = this.getGlobalDsv()
console.log('test DSV: ', DSV) //DSV
return evalFn(this.field.options.uploadURL, DSV)
}
return this.field.options.uploadURL
},
},
beforeCreate() {

View File

@ -37,6 +37,12 @@ export const overwriteObj = function(obj1, obj2) { /* 浅拷贝对象属性o
})
}
/* 用Function对象实现eval函数功能 */
export const evalFn = function (fn, DSV = null, VFR = null) {
let f = new Function('DSV', 'VFR', 'return ' + fn);
return f(DSV, VFR);
};
export const addWindowResizeHandler = function (handler) {
let oldHandler = window.onresize
if (typeof window.onresize != 'function') {