From 949a75ea29f52fc3d5c069a9efff01c49559de8c Mon Sep 17 00:00:00 2001 From: vdpAdmin Date: Wed, 5 Jul 2023 16:47:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E3=80=81=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=9C=B0=E5=9D=80=E5=A2=9E=E5=8A=A0DSV?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E6=94=AF=E6=8C=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../field-widget/file-upload-widget.vue | 14 ++++++++++++-- .../field-widget/picture-upload-widget.vue | 18 +++++++++++++++--- src/utils/util.js | 6 ++++++ 3 files changed, 33 insertions(+), 5 deletions(-) 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') {