import React from 'react';
import { Form, Input, Button, Row, Col } from 'antd';
import './index.less';
import Editor from '@src/components/Editor';
import Page from '@src/containers/Page';
import Block from '@src/components/Block';
// import FileUpload from '@src/components/FileUpload';
import { formatFormError, getMap } from '@src/services/Tools';
import { asyncSMessage } from '@src/services/AsyncTools';
// import { } from '../../../../Constant';
// import { User } from '../../../stores/user';
import { System } from '../../../stores/system';
import { ContractKey } from '../../../../Constant';
const ContractKeyMap = getMap(ContractKey, 'value', 'label');
export default class extends Page {
initData() {
const { key } = this.params;
const { form } = this.props;
let handler;
if (key) {
handler = System.getContract({ key });
} else {
handler = Promise.resolve({});
}
handler
.then(result => {
form.setFieldsValue(result);
this.setState({ data: result });
});
}
submit() {
const { form } = this.props;
form.validateFields((err) => {
if (!err) {
const data = form.getFieldsValue();
System.setContract(data).then(() => {
asyncSMessage('保存成功');
goBack();
}).catch((e) => {
if (e.result) form.setFields(formatFormError(data, e.result));
});
}
});
}
renderBase() {
const { getFieldDecorator } = this.props.form;
const { data } = this.state;
return 协议基本信息