升级到2.2.9版本:

1. 增加global-dsv属性,用于传递外部参数或外部组件;
2. 同步发布2.2.9版npm包。
master
vdpAdmin 2023-02-15 13:33:09 +08:00
parent 05d2b0c408
commit 279105908f
11 changed files with 56 additions and 11 deletions

View File

@ -1,6 +1,6 @@
{
"name": "variant-form",
"version": "2.2.8",
"version": "2.2.9",
"private": false,
"scripts": {
"serve": "vue-cli-service serve --open src/main.js",

View File

@ -1,6 +1,6 @@
<template>
<div id="app">
<VFormDesigner ref="vfDesignerRef" :designer-config="designerConfig">
<VFormDesigner ref="vfDesignerRef" :designer-config="designerConfig" :global-dsv="globalDsv">
<template #customToolButtons>
<el-button type="text" @click="printFormJson"></el-button>
</template>
@ -21,7 +21,13 @@ export default {
designerConfig: {
resetFormJson: false,
toolbarMaxWidth: 490,
}
},
//
globalDsv: {
testApiHost: 'http://www.test.com/api',
testPort: 8080,
},
}
},
methods: {

View File

@ -1,4 +1,5 @@
export default {
inject: ['getGlobalDsv'],
methods: {
appendTableRow(widget) {
this.designer.appendTableRow(widget)

View File

@ -2,7 +2,7 @@ import {deepClone} from "@/utils/util"
import FormValidators from '@/utils/validators'
export default {
inject: ['refList', 'formConfig', 'globalOptionData', 'globalModel', 'getOptionData'],
inject: ['refList', 'formConfig', 'getGlobalDsv', 'globalOptionData', 'globalModel', 'getOptionData'],
computed: {
subFormName() {

View File

@ -49,11 +49,16 @@
type: Object,
default: () => ({})
},
globalDsv: {
type: Object,
default: () => ({})
},
},
provide() {
return {
refList: this.widgetRefList,
formConfig: this.formConfig,
getGlobalDsv: () => this.globalDsv, //
globalOptionData: this.optionData,
getOptionData: () => this.optionData,
globalModel: {

View File

@ -37,7 +37,7 @@
<el-container class="center-layout-container">
<el-header class="toolbar-header">
<toolbar-panel :designer="designer" ref="toolbarRef">
<toolbar-panel :designer="designer" :global-dsv="globalDsv" ref="toolbarRef">
<template v-for="(idx, slotName) in $slots" #[slotName]>
<slot :name="slotName"></slot>
</template>
@ -45,14 +45,15 @@
</el-header>
<el-main class="form-widget-main">
<el-scrollbar class="container-scroll-bar" :style="{height: scrollerHeight}">
<v-form-widget :designer="designer" :form-config="designer.formConfig" ref="formRef">
<v-form-widget :designer="designer" :form-config="designer.formConfig" :global-dsv="globalDsv" ref="formRef">
</v-form-widget>
</el-scrollbar>
</el-main>
</el-container>
<el-aside>
<setting-panel :designer="designer" :selected-widget="designer.selectedWidget" :form-config="designer.formConfig" />
<setting-panel :designer="designer" :selected-widget="designer.selectedWidget"
:form-config="designer.formConfig" :global-dsv="globalDsv" />
</el-aside>
</el-container>
@ -127,6 +128,12 @@
}
},
/* 全局数据源变量 */
globalDsv: {
type: Object,
default: () => ({})
},
},
data() {
return {

View File

@ -114,6 +114,10 @@
designer: Object,
selectedWidget: Object,
formConfig: Object,
globalDsv: {
type: Object,
default: () => ({})
},
},
provide() {
return {

View File

@ -50,7 +50,7 @@
<div>
<div class="form-render-wrapper" :class="[layoutType === 'H5' ? 'h5-layout' : (layoutType === 'Pad' ? 'pad-layout' : '')]">
<VFormRender ref="preForm" :form-json="formJson" :form-data="testFormData" :preview-state="true"
:option-data="testOptionData"
:option-data="testOptionData" :global-dsv="designerDsv"
@appendButtonClick="testOnAppendButtonClick" @buttonClick="testOnButtonClick"
@formChange="handleFormChange">
<!--
@ -191,7 +191,11 @@
SvgIcon,
},
props: {
designer: Object
designer: Object,
globalDsv: {
type: Object,
default: () => ({})
},
},
inject: ['getDesignerConfig'],
data() {
@ -274,6 +278,10 @@
return this.designer.getLayoutType()
},
designerDsv() {
return this.globalDsv
}
},
watch: {
'designer.widgetList': {

View File

@ -1,6 +1,7 @@
import { traverseFieldWidgetsOfContainer } from "@/utils/util";
export default {
inject: ['getGlobalDsv'],
computed: {
customClass() {
return this.widget.options.customClass || ''

View File

@ -74,13 +74,18 @@
previewState: { //
type: Boolean,
default: false
}
},
globalDsv: {
type: Object,
default: () => ({})
},
},
provide() {
return {
refList: this.widgetRefList,
sfRefList: this.subFormRefList, //SubForm
formConfig: this.formConfig,
getGlobalDsv: () => this.globalDsv, //
globalOptionData: this.optionData,
getOptionData: () => this.optionData, /* 该方法用于在异步更新option-data之后重新获取到最新值 */
globalModel: {
@ -695,6 +700,14 @@
return this.externalComponents[componentName]
},
/**
* 获取globalDsv对象
* @returns {*}
*/
getGlobalDsv() {
return this.globalDsv
},
//--------------------- API end ------------------//
},

View File

@ -1,4 +1,4 @@
export const VARIANT_FORM_VERSION = '2.2.8'
export const VARIANT_FORM_VERSION = '2.2.9'
//export const MOCK_CASE_URL = 'https://www.fastmock.site/mock/2de212e0dc4b8e0885fea44ab9f2e1d0/vform/'
export const MOCK_CASE_URL = 'https://ks3-cn-beijing.ksyuncs.com/vform-static/vcase/'