|
@@ -13,7 +13,7 @@ export default class extends Page {
|
|
|
System.getIndex().then(result => {
|
|
|
const { form } = this.props;
|
|
|
form.setFieldsValue(flattenObject(result, 'index'));
|
|
|
- this.setState({ load: true, index: result });
|
|
|
+ this.setState({ load: true, indexInfo: result });
|
|
|
});
|
|
|
System.getBase().then(result => {
|
|
|
const { form } = this.props;
|
|
@@ -23,19 +23,19 @@ export default class extends Page {
|
|
|
}
|
|
|
|
|
|
addLength(field, info) {
|
|
|
- let { index } = this.state;
|
|
|
- index = index || {};
|
|
|
- index[field] = index[field] || [];
|
|
|
- index[field].push(info);
|
|
|
- this.setState({ index });
|
|
|
+ let { indexInfo } = this.state;
|
|
|
+ indexInfo = indexInfo || {};
|
|
|
+ indexInfo[field] = indexInfo[field] || [];
|
|
|
+ indexInfo[field].push(info);
|
|
|
+ this.setState({ indexInfo });
|
|
|
}
|
|
|
|
|
|
deleteLength(field, start, length) {
|
|
|
- let { index } = this.state;
|
|
|
- index = index || {};
|
|
|
- index[field] = index[field] || [];
|
|
|
- index[field].splice(start, length);
|
|
|
- this.setState({ index });
|
|
|
+ let { indexInfo } = this.state;
|
|
|
+ indexInfo = indexInfo || {};
|
|
|
+ indexInfo[field] = indexInfo[field] || [];
|
|
|
+ indexInfo[field].splice(start, length);
|
|
|
+ this.setState({ indexInfo });
|
|
|
}
|
|
|
|
|
|
submit() {
|
|
@@ -47,13 +47,14 @@ export default class extends Page {
|
|
|
const { form } = this.props;
|
|
|
form.validateFields(['index'], (err) => {
|
|
|
if (!err) {
|
|
|
+ // const { indexInfo } = this.state;
|
|
|
const { index } = form.getFieldsValue();
|
|
|
- index.class = Object.keys(index.class || {}).map((key) => index.class[key]);
|
|
|
+ index.course = Object.keys(index.course || {}).map((key) => index.course[key]);
|
|
|
index.activity = Object.keys(index.activity || {}).map((key) => index.activity[key]);
|
|
|
index.evaluation = Object.keys(index.evaluation || {}).map((key) => index.evaluation[key]);
|
|
|
System.setIndex(index)
|
|
|
.then(() => {
|
|
|
- this.setState({ index });
|
|
|
+ this.setState({ indexInfo: index });
|
|
|
asyncSMessage('保存成功');
|
|
|
}).catch((e) => {
|
|
|
form.setFields(formatFormError(index, e.result));
|
|
@@ -170,10 +171,10 @@ export default class extends Page {
|
|
|
</Block>;
|
|
|
}
|
|
|
|
|
|
- renderClass() {
|
|
|
+ renderCourse() {
|
|
|
const { getFieldDecorator, getFieldValue, setFieldsValue } = this.props.form;
|
|
|
- const { data } = this.state;
|
|
|
- const course = data.course || [];
|
|
|
+ const { indexInfo = {} } = this.state;
|
|
|
+ const course = indexInfo.course || [];
|
|
|
return <Block>
|
|
|
<h1>千行课堂</h1>
|
|
|
<Form>
|
|
@@ -243,8 +244,8 @@ export default class extends Page {
|
|
|
|
|
|
renderActivity() {
|
|
|
const { getFieldDecorator, getFieldValue, setFieldsValue } = this.props.form;
|
|
|
- const { data } = this.state;
|
|
|
- const activity = data.activity || [];
|
|
|
+ const { indexInfo = {} } = this.state;
|
|
|
+ const activity = indexInfo.activity || [];
|
|
|
return <Block>
|
|
|
<h1>活动信息</h1>
|
|
|
<Form>
|
|
@@ -304,8 +305,8 @@ export default class extends Page {
|
|
|
|
|
|
renderEvaluation() {
|
|
|
const { getFieldDecorator, getFieldValue, setFieldsValue } = this.props.form;
|
|
|
- const { data } = this.state;
|
|
|
- const evaluation = data.evaluation || [];
|
|
|
+ const { indexInfo = {} } = this.state;
|
|
|
+ const evaluation = indexInfo.evaluation || [];
|
|
|
return <Block>
|
|
|
<h1>学员评价</h1>
|
|
|
<Form>
|
|
@@ -328,6 +329,16 @@ export default class extends Page {
|
|
|
<Input placeholder='请输入学员昵称' />,
|
|
|
)}
|
|
|
</Form.Item>
|
|
|
+ <Form.Item labelCol={{ span: 7 }} wrapperCol={{ span: 15 }} label='发布时间'>
|
|
|
+ {getFieldDecorator(`index.evaluation.${index}.createTime`, {
|
|
|
+ rules: [
|
|
|
+ { required: true, message: '输入发布时间' },
|
|
|
+ ],
|
|
|
+ initialValue: row.createTime,
|
|
|
+ })(
|
|
|
+ <Input placeholder='请输入发布时间' />,
|
|
|
+ )}
|
|
|
+ </Form.Item>
|
|
|
<Form.Item labelCol={{ span: 7 }} wrapperCol={{ span: 15 }} label='学员头像'>
|
|
|
{getFieldDecorator(`index.evaluation.${index}.avatar`, {
|
|
|
rules: [
|
|
@@ -376,7 +387,7 @@ export default class extends Page {
|
|
|
renderContact() {
|
|
|
const { getFieldDecorator, setFieldsValue, getFieldValue } = this.props.form;
|
|
|
const wechatImage = getFieldValue('base.contact.wechatImage');
|
|
|
- const weiboImage = getFieldValue('base.contacct.weiboImage');
|
|
|
+ const weiboImage = getFieldValue('base.contact.weiboImage');
|
|
|
return <Block>
|
|
|
<Form>
|
|
|
<h1>联系方式</h1>
|
|
@@ -453,7 +464,7 @@ export default class extends Page {
|
|
|
return <div >
|
|
|
{this.renderPrepare()}
|
|
|
{this.renderUser()}
|
|
|
- {this.renderClass()}
|
|
|
+ {this.renderCourse()}
|
|
|
{this.renderActivity()}
|
|
|
{this.renderEvaluation()}
|
|
|
{this.renderContact()}
|