import React from 'react' // import StatActTable from '../table/stat-act-table' import {Button, Col, Form, FormInstance, Modal, Row} from "antd"; import EntryControl from "../controls/entry-control"; import HCserviceV3 from "../tmpl/hcservice-v3"; import withRouter from "../routable/withroute"; import {LocaleContext} from "../locale/LocaleProvider"; import DraggableModal from "../module/draggable-modal"; //以列表为入口的,页面内列表,基本原则是所有交互在页面内完成,不会触发路由。 export interface ContextSetterProps { serverKey?:string, // match:any, }; export interface ContextSetterState { loading?:boolean, config?: object, context?:object, }; class ContextSetter extends React.PureComponent { state = { loading:false, config: null, context:null, } formRef = React.createRef(); static defaultProps = {} static contextType = LocaleContext; context: React.ContextType; async componentDidMount() { let config = await HCserviceV3.getContextSourceConfig(); let context = await HCserviceV3.getContextSourceValue(); if (!config || config.length==0 ) { config = [] window.location.hash = "#/home"; return; } this.setState({ config, context, loading: false }) } async componentDidUpdate(prevProps) { } handleSubmit =async () => { this.setState({ loading: true }) let { config} = this.state await this.formRef.current.validateFields().then(async (values) => { let json = {} config.forEach((c) => { json[c.id] = values[c.id]; }) let res = await HCserviceV3.setContext(json); // if (res.status === 'error') { // await this.getKaptchaToken(); // } } ).catch(errorInfo => { }) this.setState({ loading: false }) } render() { const { translate} = this.context; const {config,loading,context}=this.state; const {serverKey}=this.props; return
{config ? config.map((c) => { let initialValue=null; if(context ){ context.forEach((con)=>{ if(con.moduleName== c.moduleName){ initialValue=con.selectedValues; } }) } return }) : null}
} } export default withRouter(ContextSetter);