为v-form-render的form-json属性增加默认值。

This commit is contained in:
vdpAdmin 2022-04-26 11:25:51 +08:00
parent 696b744da1
commit 9028208e1a
7 changed files with 49 additions and 28 deletions

View File

@ -6,30 +6,13 @@
* remark: 如果要分发VForm源码需在本文件顶部保留此文件头信息
*/
import {deepClone, generateId, overwriteObj} from "@/utils/util"
import {deepClone, generateId, getDefaultFormConfig, overwriteObj} from "@/utils/util"
import {containers, advancedFields, basicFields, customFields} from "@/components/form-designer/widget-panel/widgetsConfig.js"
import {VARIANT_FORM_VERSION} from "@/utils/config"
import eventBus from "@/utils/event-bus"
export function createDesigner(vueInstance) {
let defaultFormConfig = {
modelName: 'formData',
refName: 'vForm',
rulesName: 'rules',
labelWidth: 80,
labelPosition: 'left',
size: '',
labelAlign: 'label-left-align',
cssCode: '',
customClass: '',
functions: '', //全局函数
layoutType: 'PC',
jsonVersion: 3,
onFormCreated: '',
onFormMounted: '',
onFormDataChange: '',
}
let defaultFormConfig = deepClone( getDefaultFormConfig() )
return {
widgetList: [],

View File

@ -1,5 +1,5 @@
<template>
<static-content-wrapper :designer="designer" :field="field" :design-state="designState"
<static-content-wrapper :designer="designer" :field="field" :design-state="designState" :display-style="field.options.displayStyle"
:parent-widget="parentWidget" :parent-list="parentList" :index-of-parent-list="indexOfParentList"
:sub-form-row-index="subFormRowIndex" :sub-form-col-index="subFormColIndex" :sub-form-row-id="subFormRowId">
<el-button ref="fieldEditor" :type="field.options.type" :size="widgetSize"

View File

@ -1,6 +1,6 @@
<template>
<div class="field-wrapper" :class="{'design-time-bottom-margin': !!this.designer}">
<div class="static-content-item" v-show="!field.options.hidden || (designState === true)"
<div class="field-wrapper" :class="{'design-time-bottom-margin': !!this.designer}" :style="{display: displayStyle}">
<div class="static-content-item" v-show="!field.options.hidden || (designState === true)" :style="{display: displayStyle}"
:class="[selected ? 'selected' : '', customClass]" @click.stop="selectField(field)">
<slot></slot>
</div>
@ -46,6 +46,11 @@
default: false
},
displayStyle: {
type: String,
default: 'block'
},
subFormRowIndex: { /* 子表单组件行索引从0开始计数 */
type: Number,
default: -1

View File

@ -31,7 +31,8 @@
data() {
return {
uploadPictureTypes: [
{value: 'jpeg', label: 'jpg'}, /* label如用大写字母选择两个文件类型就会导致设置面板快速抖动、闪烁非常奇怪 */
{value: 'jpg', label: 'jpg'}, /* label如用大写字母选择两个文件类型就会导致设置面板快速抖动、闪烁非常奇怪 */
{value: 'jpeg', label: 'jpeg'},
{value: 'png', label: 'png'},
{value: 'gif', label: 'gif'},
],

View File

@ -702,6 +702,7 @@ export const basicFields = [
label: '',
columnWidth: '200px',
size: '',
displayStyle: 'block',
disabled: false,
hidden: false,
type: '',
@ -765,7 +766,7 @@ export const advancedFields = [
showFileList: true,
limit: 3,
fileMaxSize: 5, //MB
fileTypes: ['jpeg', 'png'],
fileTypes: ['jpg', 'jpeg', 'png'],
//headers: [],
//-------------------
customClass: '', //自定义css类名

View File

@ -43,9 +43,9 @@
import FieldComponents from '@/components/form-designer/form-widget/field-widget/index'
import {
generateId, deepClone, insertCustomCssToHead, insertGlobalFunctionsToHtml, getAllContainerWidgets,
getAllFieldWidgets, traverseFieldWidgets} from "@/utils/util"
getAllFieldWidgets, traverseFieldWidgets, buildDefaultFormJson
} from "@/utils/util"
import i18n, { changeLocale } from "@/utils/i18n"
import eventBus from "@/utils/event-bus"
export default {
name: "VFormRender",
@ -57,9 +57,12 @@
...FieldComponents,
},
props: {
formJson: Object, //propJSON
formJson: { //propJSON
type: Object,
default: () => buildDefaultFormJson()
},
formData: { //prop
Object,
type: Object,
default: () => {}
},
optionData: { //prop

View File

@ -321,3 +321,31 @@ export function getQueryParam(variable) {
return undefined;
}
export function getDefaultFormConfig() {
return {
modelName: 'formData',
refName: 'vForm',
rulesName: 'rules',
labelWidth: 80,
labelPosition: 'left',
size: '',
labelAlign: 'label-left-align',
cssCode: '',
customClass: '',
functions: '', //全局函数
layoutType: 'PC',
jsonVersion: 3,
onFormCreated: '',
onFormMounted: '',
onFormDataChange: '',
}
}
export function buildDefaultFormJson() {
return {
widgetList: [],
formConfig: deepClone( getDefaultFormConfig() )
}
}