mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-04-20 04:18:05 +00:00
feat: 新增事件入参功能
This commit is contained in:
parent
252310ef8e
commit
0614fa7960
@ -60,11 +60,14 @@ export default class EventsSetter extends Component<{
|
|||||||
private bindEventName:String;
|
private bindEventName:String;
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
|
||||||
|
console.log(this.state.eventDataList);
|
||||||
|
|
||||||
const {editor} = this.props.field;
|
const {editor} = this.props.field;
|
||||||
this.initEventBtns();
|
this.initEventBtns();
|
||||||
this.initEventList();
|
this.initEventList();
|
||||||
editor.on(`${SETTER_NAME}.bindEvent`,(relatedEventName)=>{
|
editor.on(`${SETTER_NAME}.bindEvent`,(relatedEventName,paramStr)=>{
|
||||||
this.bindEvent(relatedEventName);
|
this.bindEvent(relatedEventName,paramStr);
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -329,16 +332,26 @@ export default class EventsSetter extends Component<{
|
|||||||
|
|
||||||
openDialog = (bindEventName: String) => {
|
openDialog = (bindEventName: String) => {
|
||||||
const {editor} = this.props.field;
|
const {editor} = this.props.field;
|
||||||
|
const {eventDataList} = this.state;
|
||||||
|
let paramStr;
|
||||||
|
eventDataList.map((item)=>{
|
||||||
|
if (item.name == bindEventName){
|
||||||
|
paramStr = item.paramStr;
|
||||||
|
}
|
||||||
|
})
|
||||||
this.bindEventName = bindEventName;
|
this.bindEventName = bindEventName;
|
||||||
editor.emit('eventBindDialog.openDialog',bindEventName,SETTER_NAME);
|
editor.emit('eventBindDialog.openDialog',bindEventName,SETTER_NAME,paramStr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bindEvent = (relatedEventName: String) => {
|
bindEvent = (relatedEventName: String,paramStr:String) => {
|
||||||
const {eventDataList,eventList} = this.state;
|
const {eventDataList,eventList} = this.state;
|
||||||
eventDataList.map(item => {
|
eventDataList.map(item => {
|
||||||
if (item.name === this.bindEventName) {
|
if (item.name === this.bindEventName) {
|
||||||
item.relatedEventName = relatedEventName;
|
item.relatedEventName = relatedEventName;
|
||||||
|
if (paramStr){
|
||||||
|
item.paramStr = paramStr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -207,6 +207,7 @@ export default function(metadata: TransformedComponentMetadata): TransformedComp
|
|||||||
},
|
},
|
||||||
|
|
||||||
setValue(field: SettingTarget, eventData) {
|
setValue(field: SettingTarget, eventData) {
|
||||||
|
debugger;
|
||||||
const { eventDataList, eventList } = eventData;
|
const { eventDataList, eventList } = eventData;
|
||||||
eventList.map((item) => {
|
eventList.map((item) => {
|
||||||
field.parent.clearPropValue(item.name);
|
field.parent.clearPropValue(item.name);
|
||||||
@ -215,7 +216,7 @@ export default function(metadata: TransformedComponentMetadata): TransformedComp
|
|||||||
eventDataList.map((item) => {
|
eventDataList.map((item) => {
|
||||||
field.parent.setPropValue(item.name, {
|
field.parent.setPropValue(item.name, {
|
||||||
type: 'JSFunction',
|
type: 'JSFunction',
|
||||||
value: `function(){ this.${item.relatedEventName}() }`,
|
value: `function(){ this.${item.relatedEventName}(${item.paramStr?item.paramStr:''}) }`,
|
||||||
});
|
});
|
||||||
return item;
|
return item;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,6 +9,10 @@
|
|||||||
color: rgb(0, 0, 0);
|
color: rgb(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.editor-container{
|
||||||
|
border: 1px solid rgba(31, 56, 88, 0.3);
|
||||||
|
}
|
||||||
|
|
||||||
.dialog-left-container {
|
.dialog-left-container {
|
||||||
float: left;
|
float: left;
|
||||||
|
|
||||||
|
|||||||
@ -53,6 +53,7 @@ export default class EventBindDialog extends Component<PluginProps> {
|
|||||||
setterName:'event-setter',
|
setterName:'event-setter',
|
||||||
selectedEventName: '',
|
selectedEventName: '',
|
||||||
eventName: '',
|
eventName: '',
|
||||||
|
paramStr:''
|
||||||
};
|
};
|
||||||
|
|
||||||
openDialog = (bindEventName: String) => {
|
openDialog = (bindEventName: String) => {
|
||||||
@ -73,10 +74,12 @@ export default class EventBindDialog extends Component<PluginProps> {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { editor, config } = this.props;
|
const { editor, config } = this.props;
|
||||||
editor.on(`${config.pluginKey}.openDialog`, (bindEventName: String,setterName:String) => {
|
editor.on(`${config.pluginKey}.openDialog`, (bindEventName: String,setterName:String,paramStr:String) => {
|
||||||
|
console.log('paramStr:'+paramStr);
|
||||||
this.openDialog(bindEventName);
|
this.openDialog(bindEventName);
|
||||||
this.setState({
|
this.setState({
|
||||||
setterName
|
setterName,
|
||||||
|
paramStr
|
||||||
})
|
})
|
||||||
|
|
||||||
let schema = editor.get('designer').project.getSchema();
|
let schema = editor.get('designer').project.getSchema();
|
||||||
@ -131,10 +134,10 @@ export default class EventBindDialog extends Component<PluginProps> {
|
|||||||
onSearchEvent = (searchEventName: String) => {};
|
onSearchEvent = (searchEventName: String) => {};
|
||||||
|
|
||||||
onOk = () => {
|
onOk = () => {
|
||||||
|
console.log(this);
|
||||||
const { editor } = this.props;
|
const { editor } = this.props;
|
||||||
const {setterName,eventName} = this.state;
|
const {setterName,eventName,paramStr} = this.state;
|
||||||
|
editor.emit(`${setterName}.bindEvent`, eventName,paramStr);
|
||||||
editor.emit(`${setterName}.bindEvent`, eventName);
|
|
||||||
|
|
||||||
// 选中的是新建事件
|
// 选中的是新建事件
|
||||||
if (this.state.selectedEventName == '') {
|
if (this.state.selectedEventName == '') {
|
||||||
@ -153,15 +156,23 @@ export default class EventBindDialog extends Component<PluginProps> {
|
|||||||
this.closeDialog();
|
this.closeDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onChangeEditor = (paramStr) =>{
|
||||||
|
this.setState({
|
||||||
|
paramStr
|
||||||
|
})
|
||||||
|
// console.log(newCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { selectedEventName, eventName, visiable } = this.state;
|
const { selectedEventName, eventName, visiable,paramStr } = this.state;
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
visible={visiable}
|
visible={visiable}
|
||||||
title="事件绑定"
|
title="事件绑定"
|
||||||
onClose={this.closeDialog}
|
onClose={this.closeDialog}
|
||||||
onCancel={this.closeDialog}
|
onCancel={this.closeDialog}
|
||||||
onOk={this.onOk}
|
onOk={()=>this.onOk()}
|
||||||
>
|
>
|
||||||
<div className="event-dialog-body">
|
<div className="event-dialog-body">
|
||||||
<div className="dialog-left-container">
|
<div className="dialog-left-container">
|
||||||
@ -206,12 +217,16 @@ export default class EventBindDialog extends Component<PluginProps> {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="dialog-small-title">参数设置</div>
|
<div className="dialog-small-title">参数设置</div>
|
||||||
<MonacoEditor
|
<div className="editor-container">
|
||||||
{...defaultEditorOption}
|
<MonacoEditor
|
||||||
{...{ language: 'javascript' }}
|
value = {paramStr}
|
||||||
// onChange={(newCode) => this.updateCode(newCode)}
|
{...defaultEditorOption}
|
||||||
// editorDidMount={(editor, monaco) => this.editorDidMount.call(this, editor, monaco, TAB_KEY.JS_TAB)}
|
{...{ language: 'javascript' }}
|
||||||
/>
|
onChange={(newCode) => this.onChangeEditor(newCode)}
|
||||||
|
// editorDidMount={(editor, monaco) => this.editorDidMount.call(this, editor, monaco, TAB_KEY.JS_TAB)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user