import React from 'react'; import { Button, Icon, message } from 'antd'; import { WeaTools, WeaDialog, WeaFormItem, WeaInput, WeaUpload } from 'ecCom'; import LicenseMessage from './LicenseMessage'; class LicenseSubmit extends React.Component { state = { visible: false, isShowMsg: false, isChangeCode: false }; constructor(props) { super(props); this.getButtons = this.getButtons.bind(this); this.getLicenseCode = this.getLicenseCode.bind(this); this.onChange = this.onChange.bind(this); this.onSubmit = this.onSubmit.bind(this); this.onSubmitCode = this.onSubmitCode.bind(this); this.onBack = this.onBack.bind(this); this.onCancel = this.onCancel.bind(this); } render() { const { code = '', code_old = '', code_new = '', code_rep = '' } = this.state; let displayComp = (
this.setState({ code: value })} /> this.setState({ isChangeCode: true })}>更改验证码
提示:将公司名称及识别码提交给软件供应商,以获取License。
); if (this.state.isShowMsg) { displayComp = ; } if (this.state.isChangeCode) { displayComp = (
this.setState({ code_old: value })} /> this.setState({ code_new: value })} /> this.setState({ code_rep: value })} />
); } return ( {displayComp} ); } getButtons() { const { isShowMsg, isChangeCode } = this.state; let buttons = []; if (isChangeCode) { buttons.push(); buttons.push(); } else { if (isShowMsg) { buttons.push(); } else { buttons.push(); } buttons.push(); } return buttons; } getLicenseCode() { WeaTools.callApi('/api/system/license/InLicense', 'POST', {}).then((data) => { this.setState({ ...data }); }); } onChange(ids, list, args) { const _message = args[0].message; this.setState({ isShowMsg: true, message: _message }); } onSubmit() { const { code = '' } = this.state; if (code.trim() != '') { this.refs.WeaUpload.doUpload(); } else { message.warning('必要信息不完整!'); } } onSubmitCode() { const { code_old = '', code_new = '', code_rep = '' } = this.state; if (code_old.trim() != '' && code_new.trim() != '' && code_rep.trim() != '') { if (code_new === code_rep) { WeaTools.callApi('/api/system/license/CodeOperation', 'POST', { passwordold: code_old, passwordnew: code_new, }).then((data) => { const _message = data.message; if (_message == '1') { message.error('旧的验证码不正确!'); } else { message.success(_message); this.onBack(); } }); } else { message.warning('两次输入的新验证码不同!'); } } else { message.warning('必要信息不完整!'); } } onBack() { this.setState({ isShowMsg: false, isChangeCode: false, message: '', code: '', code_old: '', code_new: '', code_rep: '' }); } onCancel() { this.setState({ visible: false, isShowMsg: false, isChangeCode: false, message: '', code: '', code_old: '', code_new: '', code_rep: '' }); } onShow() { this.setState({ visible: true }); this.getLicenseCode(); } } export default LicenseSubmit;