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

master
vdpAdmin 2023-07-05 16:47:35 +08:00
parent 6d66308fbb
commit 949a75ea29
3 changed files with 33 additions and 5 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}"
@ -37,7 +37,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";
import SvgIcon from "@/components/svg-icon/index";
@ -100,6 +100,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}"
@ -56,7 +56,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";
import SvgIcon from "@/components/svg-icon/index";
@ -118,7 +118,19 @@
computed: {
previewList() {
return this.fileList.map(el => el.url);
}
},
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') {