import { Component } from 'react'; import { Dialog, Input, Button } from '@alifd/next'; import { PluginProps } from '@ali/lowcode-types'; import './index.scss'; export default class VariableBindDialog extends Component { private loopVariableList: any[] = [ { name: 'item', }, { name: 'index', }, ]; private stateVaroableList: any[] = [ { name: 'abc', }, { name: 'title', }, { name: 'jdata', }, ]; state = { visiable: false, selectedVariableName: '', variableContext: '', }; openDialog = (bindEventName: String) => { this.setState({ visiable: true, eventName: bindEventName, }); }; closeDialog = () => { this.setState({ visiable: false, }); }; componentDidMount() { const { editor, config } = this.props; editor.on(`${config.pluginKey}.openDialog`, (bindEventName: String) => { this.openDialog(bindEventName); }); } initEventName = () => { const { bindEventName } = this.state; let eventName = bindEventName; this.eventList.map((item) => { if (item.name === eventName) { eventName = `${eventName}_new`; } }); this.setState({ eventName, }); }; onInputChange = (eventName: String) => { this.setState({ eventName, }); }; onSelectItem = (variableName: String) => { this.setState({ selectedVariableName:variableName, variableContext:variableName }); // // 为空是新建事件 // if (variableName === '') { // this.initEventName(); // } else { // this.setState({ // selectedEventName: eventName, // eventName, // }); // } }; onOk = () => { const { editor } = this.props; editor.emit('event-setter.bindEvent', this.state.eventName); this.closeDialog(); }; renderBottom = () => { return (
  
) } render() { const { selectedEventName, eventName, visiable ,variableContext} = this.state; return (
变量选择
当前上下文
{this.loopVariableList.map((item) => (
this.onSelectItem(item.name)}> {item.name}
))}
State属性
{this.stateVaroableList.map((item) => (
this.onSelectItem(item.name)}> {item.name}
))}
绑定
帮助
); } }