import React, { RefObject } from "react"; import "./index.css"; import { ActionConfig, ButtonName, DtmplConfig, TmplBase, } from "../../../aldehyde/tmpl/interface"; import { Affix, Button, Popconfirm, Popover } from "antd"; import { LeftOutlined, SaveOutlined } from "@ant-design/icons"; import Action from "../../controls/action"; import { SubmitButtonProps } from "./submit-button-bar"; import { LocaleContext } from "../../locale/LocaleProvider"; interface FixRightSubmitButtonProps extends SubmitButtonProps {} interface FixRightSubmitButtonState { // stateSerial:number // loading: boolean; } class FixRightSubmitButtonBar extends React.PureComponent< FixRightSubmitButtonProps, FixRightSubmitButtonState > { state = { // loading: false, }; static contextType = LocaleContext; context: React.ContextType; calcOffsetBottom = (buttons: ButtonName[], actions: ActionConfig[]) => { let buttonSize: number = 0; if (actions) { buttonSize = buttonSize + actions.length; } if (buttons && buttons.includes("dtmplSave")) { buttonSize = buttonSize + 1; } if (buttonSize >= 3) { return 120; } else if (buttonSize == 2) { return 86; } else { return 80; } }; // doSubmit=async ()=>{ // // this.setState({loading:true}) // await this.props.doSubmit(); // // this.setState({loading:false}) // } render() { const {} = this.state; const { dtmplConfig, formRef, doSubmit,loading, serial, serverKey, dtmplData, } = this.props; const { buttons, actions } = dtmplConfig; const cardList: TmplBase[] = []; const { translate } = this.context; //console.log(" submit-button-bar serial:",serial); // console.log(" submit-button-bar stateSerial:",stateSerial); if (dtmplConfig.premises && dtmplConfig.premises.length > 0) { cardList.push({ id: "1", title: translate("${默认字段}"), }); } dtmplConfig.groups.forEach((g) => { cardList.push({ title: g.title, id: g.id, }); }); let content; if (actions && actions.length > 1) { content = (
{actions.map((item, index) => { if (index > 1) { // return doSubmit(item.id)} okText="确定" cancelText="取消"> // // return ( ); } })}
); } return ( style={{ position: "absolute", bottom: 60, right: 15 }} offsetBottom={this.calcOffsetBottom(buttons, actions)} >
    {buttons.includes("dtmplSave") ? (
  • ) : ( "" )} {//处理前两个 actions ? actions.map((item, index) => { if (index < 2) { return (
  • {/* doSubmit(item.id)} okText="确定" cancelText="取消">*/} {/**/} {/**/}
  • ); } }) : ""} {//处理后面的 actions && actions.length > 2 ? ( ) : ( "" )}
); } } export default FixRightSubmitButtonBar;