修复部分bug。

master
vdpAdmin 2021-11-14 16:03:42 +08:00
parent 1414bce040
commit 85aaca2dd0
17 changed files with 113 additions and 31 deletions

View File

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

View File

@ -5,24 +5,15 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<!-- 禁止浏览器缓存index.html begin -->
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
<!-- 禁止浏览器缓存index.html end -->
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
</body>
</html>

View File

@ -3,7 +3,7 @@
: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-slider ref="fieldEditor" v-model="fieldModel"
:disabled="field.options.disabled"
:disabled="field.options.disabled" :show-stops="field.options.showStops"
:min="field.options.min" :max="field.options.max" :step="field.options.step"
:range="field.options.range" :vertical="field.options.vertical"
@change="handleChangeEvent">

View File

@ -13,7 +13,7 @@
<el-header class="main-header">
<div class="float-left main-title">
<img src="../../assets/vform-logo.png" @click="openHome">
<span class="bold">VariantForm</span> {{i18nt('application.productTitle')}} <span class="version-span">Ver {{vFormVersion}}</span></div>
<span class="bold">VForm</span> {{i18nt('application.productTitle')}} <span class="version-span">Ver {{vFormVersion}}</span></div>
<div class="float-right external-link">
<el-dropdown @command="handleLanguageChanged">
<span class="el-dropdown-link">{{curLangName}}<i class="el-icon-arrow-down el-icon--right"></i></span>

View File

@ -0,0 +1,23 @@
<template>
<el-form-item :label="i18nt('designer.setting.showStops')">
<el-checkbox v-model="optionModel.showStops"></el-checkbox>
</el-form-item>
</template>
<script>
import i18n from "@/utils/i18n"
export default {
name: "showStops-editor",
mixins: [i18n],
props: {
designer: Object,
selectedWidget: Object,
optionModel: Object,
},
}
</script>
<style scoped>
</style>

View File

@ -15,6 +15,7 @@ const COMMON_PROPERTIES = {
'endPlaceholder' : 'endPlaceholder-editor',
'columnWidth' : 'columnWidth-editor',
'size' : 'size-editor',
'showStops' : 'showStops-editor',
'displayStyle' : 'displayStyle-editor',
'buttonStyle' : 'buttonStyle-editor',
'border' : 'border-editor',

View File

@ -2,6 +2,10 @@
<el-scrollbar class="side-scroll-bar" :style="{height: scrollerHeight}">
<div class="panel-container">
<el-tabs v-model="firstTab" class="no-bottom-margin indent-left-margin">
<el-tab-pane name="componentLib">
<span slot="label"><i class="el-icon-set-up"></i> {{i18nt('designer.componentLib')}}</span>
<el-collapse v-model="activeNames" class="widget-collapse">
<el-collapse-item name="1" :title="i18nt('designer.containerTitle')">
<draggable tag="ul" :list="containers" :group="{name: 'dragGroup', pull: 'clone', put: false}"
@ -49,6 +53,15 @@
</el-collapse>
</el-tab-pane>
<el-tab-pane name="formLib" v-if="false">
<span slot="label"><i class="el-icon-c-scale-to-original"></i> {{i18nt('designer.formLib')}}</span>
</el-tab-pane>
</el-tabs>
</div>
</el-scrollbar>
</template>
@ -70,6 +83,8 @@
},
data() {
return {
firstTab: 'componentLib',
scrollerHeight: 0,
activeNames: ['1', '2', '3', '4'],
@ -179,11 +194,23 @@
padding-bottom: 10px;
}
.no-bottom-margin ::v-deep .el-tabs__header {
margin-bottom: 0;
}
.indent-left-margin {
::v-deep .el-tabs__nav {
margin-left: 20px;
}
}
.el-collapse-item ::v-deep ul > li {
list-style: none;
}
.widget-collapse {
border-top-width: 0;
::v-deep .el-collapse-item__header {
margin-left: 8px;
font-style: italic;

View File

@ -102,7 +102,7 @@ export const containers = [
}
},
/*
/*
{
type: 'data-table',
category: 'container',
@ -662,6 +662,7 @@ export const basicFields = [
label: '',
labelAlign: '',
columnWidth: '200px',
showStops: true,
size: '',
labelWidth: null,
labelHidden: false,
@ -677,7 +678,7 @@ export const basicFields = [
labelTooltip: null,
min: 0,
max: 100,
step: 1,
step: 10,
range: false,
//vertical: false,
height: null,

View File

@ -118,6 +118,7 @@
//
},
created() {
this.buildFormModel(!this.formJsonObj ? null : this.formJsonObj.widgetList)
this.initFormObject()
},
mounted() {
@ -127,7 +128,7 @@
methods: {
initFormObject() {
this.insertCustomStyleAndScriptNode()
this.buildFormModel()
//this.buildFormModel()
this.addFieldChangeEventHandler()
this.registerFormToRefList()
this.handleOnCreated()
@ -156,14 +157,20 @@
}
},
buildFormModel() {
if (!this.formJsonObj || !this.widgetList) {
return
buildFormModel(widgetList) {
if (!!widgetList && (widgetList.length > 0)) {
widgetList.forEach((wItem) => {
this.buildDataFromWidget(wItem)
})
}
this.widgetList.forEach((wItem) => {
this.buildDataFromWidget(wItem, null)
})
// if (!this.formJsonObj || !this.widgetList) {
// return
// }
//
// this.widgetList.forEach((wItem) => {
// this.buildDataFromWidget(wItem)
// })
},
buildDataFromWidget(wItem) {
@ -171,7 +178,7 @@
if (wItem.type === 'grid') {
if (!!wItem.cols && (wItem.cols.length > 0)) {
wItem.cols.forEach((childItem) => {
this.buildDataFromWidget(childItem, wItem)
this.buildDataFromWidget(childItem)
})
}
} else if (wItem.type === 'table') {
@ -179,7 +186,7 @@
wItem.rows.forEach((rowItem) => {
if (!!rowItem.cols && (rowItem.cols.length > 0)) {
rowItem.cols.forEach((colItem) => {
this.buildDataFromWidget(colItem, wItem)
this.buildDataFromWidget(colItem)
})
}
})
@ -189,7 +196,7 @@
wItem.tabs.forEach((tabItem) => {
if (!!tabItem.widgetList && (tabItem.widgetList.length > 0)) {
tabItem.widgetList.forEach((childItem) => {
this.buildDataFromWidget(childItem, wItem)
this.buildDataFromWidget(childItem)
})
}
})
@ -216,13 +223,13 @@
} else if ((wItem.type === 'grid-col') || (wItem.type === 'table-cell')) {
if (!!wItem.widgetList && (wItem.widgetList.length > 0)) {
wItem.widgetList.forEach((childItem) => {
this.buildDataFromWidget(childItem, wItem)
this.buildDataFromWidget(childItem)
})
}
} else { //
if (!!wItem.widgetList && (wItem.widgetList.length > 0)) {
wItem.widgetList.forEach((childItem) => {
this.buildDataFromWidget(childItem, wItem)
this.buildDataFromWidget(childItem)
})
}
}
@ -305,6 +312,12 @@
return foundRef
},
clearFormDataModel() {
for (let pkey in this.formDataModel) {
delete this.formDataModel[pkey]
}
},
/**
* 动态加载表单JSON
* @param newFormJson
@ -312,7 +325,7 @@
setFormJson(newFormJson) {
if (!!newFormJson) {
if ((typeof newFormJson === 'string') || (newFormJson.constructor === Object)) {
let newFormJsonObj = null
let newFormJsonObj = null
if (typeof newFormJson === 'string') {
newFormJsonObj = JSON.parse(newFormJson)
} else {
@ -320,10 +333,15 @@
}
if (!newFormJsonObj.formConfig || !newFormJsonObj.widgetList) {
this.$message.error('Set form json failed.')
this.$message.error('Invalid format of form json.')
return
}
/* formDataModel必须在widgetList赋值完成初始化因为widgetList赋值意味着子组件开始创建 */
//this.formDataModel = {} //bug
this.clearFormDataModel() //
this.buildFormModel(newFormJsonObj.widgetList)
this.$set(this.formJsonObj, 'formConfig', newFormJsonObj.formConfig)
this._provided.formConfig = newFormJsonObj.formConfig //provideformConfig
this.$set(this.formJsonObj, 'widgetList', newFormJsonObj.widgetList)

View File

@ -36,6 +36,9 @@ export const loadExtension = function () {
PERegister.registerCPEditor('folded', 'card-folded-editor',
PEFactory.createBooleanEditor('folded', 'extension.setting.cardFolded'))
PERegister.registerCPEditor('showFold', 'card-showFold-editor',
PEFactory.createBooleanEditor('showFold', 'extension.setting.cardShowFold'))
PERegister.registerCPEditor('cardWidth', 'card-cardWidth-editor',
PEFactory.createInputTextEditor('cardWidth', 'extension.setting.cardWidth'))

View File

@ -6,7 +6,8 @@
:class="[selected ? 'selected' : '', !!widget.options.folded ? 'folded' : '', customClass]">
<div slot="header" class="clear-fix">
<span>{{widget.options.label}}</span>
<i class="float-right" :class="[!widget.options.folded ? 'el-icon-arrow-down' : 'el-icon-arrow-up']"
<i v-if="widget.options.showFold" class="float-right"
:class="[!widget.options.folded ? 'el-icon-arrow-down' : 'el-icon-arrow-up']"
@click="toggleCard"></i>
</div>
<draggable :list="widget.widgetList" v-bind="{group:'dragGroup', ghostClass: 'ghost',animation: 200}"
@ -77,6 +78,14 @@
this.widget.options.folded = !this.widget.options.folded
},
/**
* 设置折叠/打开状态
* @param folded
*/
setFolded(folded) {
this.widget.options.folded = !!folded
}
}
}
</script>

View File

@ -8,6 +8,7 @@ export const cardSchema = {
label: 'card',
hidden: false,
folded: false,
showFold: true,
cardWidth: '100%',
shadow: 'never',
customClass: '',

View File

@ -11,6 +11,8 @@ export default {
},
designer: {
componentLib: 'Components',
formLib: 'Templates',
containerTitle: 'Container',
dragHandlerHint: 'drag container or field to layout center',
dragAction: 'drag',
@ -164,6 +166,7 @@ export default {
endPlaceholder: 'End Placeholder',
widgetColumnWidth: 'Width',
widgetSize: 'Size',
showStops: 'Show Stops',
displayStyle: 'Display Style',
inlineLayout: 'inline',
blockLayout: 'block',

View File

@ -7,6 +7,7 @@ export default {
setting: {
cardFolded: 'Folded',
cardShowFold: 'Show Fold',
cardWidth: 'Width Of Card',
cardShadow: 'Shadow',

View File

@ -11,6 +11,8 @@ export default {
},
designer: {
componentLib: '组件库',
formLib: '表单模板',
containerTitle: '容器',
dragHandlerHint: '鼠标拖拽容器组件或字段组件并放置于表单中',
dragAction: '拖动',
@ -164,6 +166,7 @@ export default {
endPlaceholder: '截止占位内容',
widgetColumnWidth: '组件列宽',
widgetSize: '组件大小',
showStops: '显示间断点',
displayStyle: '显示样式',
inlineLayout: '行内',
blockLayout: '块',

View File

@ -7,6 +7,7 @@ export default {
setting: {
cardFolded: '是否收起',
cardShowFold: '显示折叠按钮',
cardWidth: '卡片宽度',
cardShadow: '显示阴影',

View File

@ -8,7 +8,7 @@ export const DESIGNER_OPTIONS = {
}
export const VARIANT_FORM_VERSION = '2.1.5'
export const VARIANT_FORM_VERSION = '2.1.6'
export const MOCK_CASE_URL = 'https://www.fastmock.site/mock/2de212e0dc4b8e0885fea44ab9f2e1d0/vform/'