1. input组件增加onAppendButtonClick交互事件;

2. 增加组件动态添加或移除自定义样式的API方法;
3. 修复部分bug。
master
vdpAdmin 2022-07-06 15:24:48 +08:00
parent dd801e871d
commit daf943e4ab
7 changed files with 80 additions and 6 deletions

View File

@ -353,8 +353,17 @@ export default {
},
emitAppendButtonClick() {
/* 必须调用mixins中的dispatch方法逐级向父组件发送消息 */
this.dispatch('VFormRender', 'appendButtonClick', [this]);
if (!!this.designState) { //设计状态不触发点击事件
return
}
if (!!this.field.options.onAppendButtonClick) {
let customFn = new Function(this.field.options.onAppendButtonClick)
customFn.call(this)
} else {
/* 必须调用mixins中的dispatch方法逐级向父组件发送消息 */
this.dispatch('VFormRender', 'appendButtonClick', [this])
}
},
handleOnChange(val, oldVal) { //自定义onChange事件
@ -564,7 +573,39 @@ export default {
*/
isSubFormItem() {
return !!this.parentWidget ? this.parentWidget.type === 'sub-form' : false
}
},
/**
* 动态增加自定义css样式
* @param className
*/
addCssClass(className) {
if (!this.field.options.customClass) {
this.field.options.customClass = [className]
} else {
this.field.options.customClass.push(className)
}
},
/**
* 动态移除自定义css样式
* @param className
*/
removeCssClass(className) {
if (!this.field.options.customClass) {
return
}
let foundIdx = -1
this.field.options.customClass.map((cc, idx) => {
if (cc === className) {
foundIdx = idx
}
})
if (foundIdx > -1) {
this.field.options.customClass.splice(foundIdx, 1)
}
},
//--------------------- 以上为组件支持外部调用的API方法 end ------------------//

View File

@ -136,7 +136,7 @@
docUrl: 'https://www.vform666.com/document.html',
gitUrl: 'https://github.com/vform666/variant-form',
chatUrl: 'https://www.vform666.com/chat-group.html',
chatUrl: 'https://www.vform666.com/pages/chat-group/',
subScribeUrl: 'https://www.vform666.com/subscribe.html',
scrollerHeight: 0,

View File

@ -121,6 +121,7 @@ const EVENT_PROPERTIES = {
'onUploadError' : 'onUploadError-editor',
'onFileRemove' : 'onFileRemove-editor',
'onValidate' : 'onValidate-editor',
'onAppendButtonClick': 'onAppendButtonClick-editor',
//容器
'onSubFormRowAdd' : 'onSubFormRowAdd-editor',

View File

@ -45,7 +45,7 @@
<el-dialog :title="i18nt('designer.toolbar.preview')" :visible.sync="showPreviewDialogFlag" v-if="showPreviewDialogFlag"
:show-close="true" :close-on-click-modal="false" :close-on-press-escape="false" center v-dialog-drag
:destroy-on-close="true" class="small-padding-dialog" width="75%"
:destroy-on-close="true" :append-to-body="true" class="small-padding-dialog" width="75%"
:fullscreen="(layoutType === 'H5') || (layoutType === 'Pad')">
<div>
<div class="form-render-wrapper" :class="[layoutType === 'H5' ? 'h5-layout' : (layoutType === 'Pad' ? 'pad-layout' : '')]">

View File

@ -142,6 +142,7 @@ export const basicFields = [
onFocus: '',
onBlur: '',
onValidate: '',
onAppendButtonClick: '',
},
},

View File

@ -181,6 +181,38 @@ export default {
// //TODO:
// },
/**
* 动态增加自定义css样式
* @param className
*/
addCssClass(className) {
if (!this.widget.options.customClass) {
this.widget.options.customClass = [className]
} else {
this.widget.options.customClass.push(className)
}
},
/**
* 动态移除自定义css样式
* @param className
*/
removeCssClass(className) {
if (!this.widget.options.customClass) {
return
}
let foundIdx = -1
this.widget.options.customClass.map((cc, idx) => {
if (cc === className) {
foundIdx = idx
}
})
if (foundIdx > -1) {
this.widget.options.customClass.splice(foundIdx, 1)
}
},
//--------------------- 以上为组件支持外部调用的API方法 end ------------------//
},

View File

@ -481,7 +481,6 @@
// SubForm
this.broadcast('ContainerItem', 'setFormData', this.formDataModel)
// FieldWidget
this.broadcast('FieldWidget', 'setFormData', this.formDataModel)
},