提交 6f8480dc 编写于 作者: Shine-zwj's avatar Shine-zwj

update:更新

上级 9b9289f2
import { IParam } from "./i-param";
/** /**
* @description 视图状态参数 * @description 行为参数
* @export * @export
* @interface IActionParam * @interface IActionParam
*/ */
......
...@@ -16,13 +16,14 @@ export class FormControl extends MainControl { ...@@ -16,13 +16,14 @@ export class FormControl extends MainControl {
public declare controlState: FormControlState; public declare controlState: FormControlState;
/** /**
* 修改表单的数据对象的某一属性的值。 * @description 表单数据改变
* 可通过模块扩展增加一系列相关后续操作。 * @param {string} name 属性名称
* @param name 属性名称 * @param {*} value 属性值
* @param value 属性值 * @memberof FormControl
*/ */
public async formDataChange(name: string, value: any){ public formDataChange(name: string, value: any){
this.controlState.data[name] = value; this.controlState.data[name] = value;
console.log(name, value, this.controlState.data);
} }
/** /**
...@@ -74,6 +75,22 @@ export class FormControl extends MainControl { ...@@ -74,6 +75,22 @@ export class FormControl extends MainControl {
} }
} }
/**
* @description 处理编辑器事件
* @param {IActionParam} actionParam 行为参数
* @memberof FormControl
*/
public handleEditorEvent(actionParam: IActionParam) {
const { tag, action, data } = actionParam;
switch (action) {
case "valueChange":
this.formDataChange(tag, data);
break;
default:
break;
}
}
/** /**
* @description 安装部件所有功能模块的方法 * @description 安装部件所有功能模块的方法
* @param {FormControlProps} props 传入的Props * @param {FormControlProps} props 传入的Props
...@@ -85,17 +102,16 @@ export class FormControl extends MainControl { ...@@ -85,17 +102,16 @@ export class FormControl extends MainControl {
const superParams = super.moduleInstall(props, emit); const superParams = super.moduleInstall(props, emit);
const { load } = this.useLoad(props) const { load } = this.useLoad(props)
// 扩展表单数值变化的后续逻辑 const handleEditorEvent = this.handleEditorEvent.bind(this);
const superFormDataChange = this.formDataChange.bind(this); this.handleEditorEvent = (actionParam: IActionParam) => {
this.formDataChange = async (name: string , value: any) => { handleEditorEvent(actionParam)
await superFormDataChange(name, value)
} }
return { return {
...superParams, ...superParams,
state: this.controlState, state: this.controlState,
load, load,
formDataChange: this.formDataChange, handleEditorEvent: this.handleEditorEvent,
}; };
} }
} }
...@@ -25,7 +25,7 @@ interface CtrlEmit { ...@@ -25,7 +25,7 @@ interface CtrlEmit {
const emit = defineEmits<CtrlEmit>(); const emit = defineEmits<CtrlEmit>();
// 安装功能模块,提供状态和能力方法 // 安装功能模块,提供状态和能力方法
const { state } = new FormControl(CtrlConfig).moduleInstall(props); const { state, handleEditorEvent } = new FormControl(CtrlConfig).moduleInstall(props);
</script> </script>
<template> <template>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册