升级到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", "name": "variant-form",
"version": "2.2.8", "version": "2.2.9",
"private": false, "private": false,
"scripts": { "scripts": {
"serve": "vue-cli-service serve --open src/main.js", "serve": "vue-cli-service serve --open src/main.js",

View File

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

View File

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

View File

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

View File

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

View File

@ -37,7 +37,7 @@
<el-container class="center-layout-container"> <el-container class="center-layout-container">
<el-header class="toolbar-header"> <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]> <template v-for="(idx, slotName) in $slots" #[slotName]>
<slot :name="slotName"></slot> <slot :name="slotName"></slot>
</template> </template>
@ -45,14 +45,15 @@
</el-header> </el-header>
<el-main class="form-widget-main"> <el-main class="form-widget-main">
<el-scrollbar class="container-scroll-bar" :style="{height: scrollerHeight}"> <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> </v-form-widget>
</el-scrollbar> </el-scrollbar>
</el-main> </el-main>
</el-container> </el-container>
<el-aside> <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-aside>
</el-container> </el-container>
@ -127,6 +128,12 @@
} }
}, },
/* 全局数据源变量 */
globalDsv: {
type: Object,
default: () => ({})
},
}, },
data() { data() {
return { return {

View File

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

View File

@ -50,7 +50,7 @@
<div> <div>
<div class="form-render-wrapper" :class="[layoutType === 'H5' ? 'h5-layout' : (layoutType === 'Pad' ? 'pad-layout' : '')]"> <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" <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" @appendButtonClick="testOnAppendButtonClick" @buttonClick="testOnButtonClick"
@formChange="handleFormChange"> @formChange="handleFormChange">
<!-- <!--
@ -191,7 +191,11 @@
SvgIcon, SvgIcon,
}, },
props: { props: {
designer: Object designer: Object,
globalDsv: {
type: Object,
default: () => ({})
},
}, },
inject: ['getDesignerConfig'], inject: ['getDesignerConfig'],
data() { data() {
@ -274,6 +278,10 @@
return this.designer.getLayoutType() return this.designer.getLayoutType()
}, },
designerDsv() {
return this.globalDsv
}
}, },
watch: { watch: {
'designer.widgetList': { 'designer.widgetList': {

View File

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

View File

@ -74,13 +74,18 @@
previewState: { // previewState: { //
type: Boolean, type: Boolean,
default: false default: false
} },
globalDsv: {
type: Object,
default: () => ({})
},
}, },
provide() { provide() {
return { return {
refList: this.widgetRefList, refList: this.widgetRefList,
sfRefList: this.subFormRefList, //SubForm sfRefList: this.subFormRefList, //SubForm
formConfig: this.formConfig, formConfig: this.formConfig,
getGlobalDsv: () => this.globalDsv, //
globalOptionData: this.optionData, globalOptionData: this.optionData,
getOptionData: () => this.optionData, /* 该方法用于在异步更新option-data之后重新获取到最新值 */ getOptionData: () => this.optionData, /* 该方法用于在异步更新option-data之后重新获取到最新值 */
globalModel: { globalModel: {
@ -695,6 +700,14 @@
return this.externalComponents[componentName] return this.externalComponents[componentName]
}, },
/**
* 获取globalDsv对象
* @returns {*}
*/
getGlobalDsv() {
return this.globalDsv
},
//--------------------- API end ------------------// //--------------------- 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://www.fastmock.site/mock/2de212e0dc4b8e0885fea44ab9f2e1d0/vform/'
export const MOCK_CASE_URL = 'https://ks3-cn-beijing.ksyuncs.com/vform-static/vcase/' export const MOCK_CASE_URL = 'https://ks3-cn-beijing.ksyuncs.com/vform-static/vcase/'