diff --git a/src/components/form-designer/form-widget/field-widget/file-upload-widget.vue b/src/components/form-designer/form-widget/field-widget/file-upload-widget.vue index f77804b..8c89216 100644 --- a/src/components/form-designer/form-widget/field-widget/file-upload-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/file-upload-widget.vue @@ -5,7 +5,7 @@ -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() { diff --git a/src/components/form-designer/form-widget/field-widget/picture-upload-widget.vue b/src/components/form-designer/form-widget/field-widget/picture-upload-widget.vue index 650fd15..4ec8e7c 100644 --- a/src/components/form-designer/form-widget/field-widget/picture-upload-widget.vue +++ b/src/components/form-designer/form-widget/field-widget/picture-upload-widget.vue @@ -4,7 +4,7 @@ :sub-form-row-index="subFormRowIndex" :sub-form-col-index="subFormColIndex" :sub-form-row-id="subFormRowId"> 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() { /* 这里不能访问方法和属性!! */ diff --git a/src/utils/util.js b/src/utils/util.js index ad4ff38..b3166a2 100644 --- a/src/utils/util.js +++ b/src/utils/util.js @@ -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') {