|
@@ -12,41 +12,67 @@ export default class extends Page {
|
|
|
initData() {
|
|
|
System.getIndex().then(result => {
|
|
|
const { form } = this.props;
|
|
|
- form.setFieldsValue(flattenObject(result));
|
|
|
- this.setState({ load: true, data: result });
|
|
|
+ form.setFieldsValue(flattenObject(result, 'index'));
|
|
|
+ this.setState({ load: true, index: result });
|
|
|
+ });
|
|
|
+ System.getBase().then(result => {
|
|
|
+ const { form } = this.props;
|
|
|
+ form.setFieldsValue(flattenObject(result, 'base'));
|
|
|
+ this.setState({ load: true, base: result });
|
|
|
});
|
|
|
}
|
|
|
|
|
|
addLength(field, info) {
|
|
|
- let { data } = this.state;
|
|
|
- data = data || {};
|
|
|
- data[field] = data[field] || [];
|
|
|
- data[field].push(info);
|
|
|
- this.setState({ data });
|
|
|
+ let { index } = this.state;
|
|
|
+ index = index || {};
|
|
|
+ index[field] = index[field] || [];
|
|
|
+ index[field].push(info);
|
|
|
+ this.setState({ index });
|
|
|
}
|
|
|
|
|
|
deleteLength(field, start, length) {
|
|
|
- let { data } = this.state;
|
|
|
- data = data || {};
|
|
|
- data[field] = data[field] || [];
|
|
|
- data[field].splice(start, length);
|
|
|
- this.setState({ data });
|
|
|
+ let { index } = this.state;
|
|
|
+ index = index || {};
|
|
|
+ index[field] = index[field] || [];
|
|
|
+ index[field].splice(start, length);
|
|
|
+ this.setState({ index });
|
|
|
}
|
|
|
|
|
|
submit() {
|
|
|
+ this.submitIndex();
|
|
|
+ this.submitBase();
|
|
|
+ }
|
|
|
+
|
|
|
+ submitIndex() {
|
|
|
+ const { form } = this.props;
|
|
|
+ form.validateFields(['index'], (err) => {
|
|
|
+ if (!err) {
|
|
|
+ const { index } = form.getFieldsValue();
|
|
|
+ index.class = Object.keys(index.class || {}).map((key) => index.class[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 });
|
|
|
+ asyncSMessage('保存成功');
|
|
|
+ }).catch((e) => {
|
|
|
+ form.setFields(formatFormError(index, e.result));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ submitBase() {
|
|
|
const { form } = this.props;
|
|
|
- form.validateFields((err) => {
|
|
|
+ form.validateFields(['base'], (err) => {
|
|
|
if (!err) {
|
|
|
- const data = form.getFieldsValue();
|
|
|
- data.class = Object.keys(data.class || {}).map((key) => data.class[key]);
|
|
|
- data.activity = Object.keys(data.activity || {}).map((key) => data.activity[key]);
|
|
|
- data.evaluation = Object.keys(data.evaluation || {}).map((key) => data.evaluation[key]);
|
|
|
- System.setIndex(data)
|
|
|
+ const { base } = form.getFieldsValue();
|
|
|
+ System.setBase(base)
|
|
|
.then(() => {
|
|
|
- this.setState(data);
|
|
|
+ this.setState({ base });
|
|
|
asyncSMessage('保存成功');
|
|
|
}).catch((e) => {
|
|
|
- form.setFields(formatFormError(data, e.result));
|
|
|
+ form.setFields(formatFormError(base, e.result));
|
|
|
});
|
|
|
}
|
|
|
});
|
|
@@ -58,7 +84,7 @@ export default class extends Page {
|
|
|
<h1>备考攻略</h1>
|
|
|
<Form>
|
|
|
<Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} label='自学-从零开始'>
|
|
|
- {getFieldDecorator('prepare.first', {
|
|
|
+ {getFieldDecorator('index.prepare.first', {
|
|
|
rules: [
|
|
|
{ required: false, message: '请输入跳转地址' },
|
|
|
],
|
|
@@ -67,7 +93,7 @@ export default class extends Page {
|
|
|
)}
|
|
|
</Form.Item>
|
|
|
<Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} label='自学-继续练习'>
|
|
|
- {getFieldDecorator('prepare.continue', {
|
|
|
+ {getFieldDecorator('index.prepare.continue', {
|
|
|
rules: [
|
|
|
{ required: false, message: '请输入跳转地址' },
|
|
|
],
|
|
@@ -76,7 +102,7 @@ export default class extends Page {
|
|
|
)}
|
|
|
</Form.Item>
|
|
|
<Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} label='课程-初学'>
|
|
|
- {getFieldDecorator('prepare.classJunior', {
|
|
|
+ {getFieldDecorator('index.prepare.classJunior', {
|
|
|
rules: [
|
|
|
{ required: false, message: '请输入跳转地址' },
|
|
|
],
|
|
@@ -85,7 +111,7 @@ export default class extends Page {
|
|
|
)}
|
|
|
</Form.Item>
|
|
|
<Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} label='课程-中级'>
|
|
|
- {getFieldDecorator('prepare.classMiddle', {
|
|
|
+ {getFieldDecorator('index.prepare.classMiddle', {
|
|
|
rules: [
|
|
|
{ required: false, message: '请输入跳转地址' },
|
|
|
],
|
|
@@ -94,7 +120,7 @@ export default class extends Page {
|
|
|
)}
|
|
|
</Form.Item>
|
|
|
<Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} label='课程-高级'>
|
|
|
- {getFieldDecorator('prepare.classSenior', {
|
|
|
+ {getFieldDecorator('index.prepare.classSenior', {
|
|
|
rules: [
|
|
|
{ required: false, message: '请输入跳转地址' },
|
|
|
],
|
|
@@ -112,7 +138,7 @@ export default class extends Page {
|
|
|
<h1>用户数据</h1>
|
|
|
<Form>
|
|
|
<Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} label='线下用户量'>
|
|
|
- {getFieldDecorator('user.numberOffline', {
|
|
|
+ {getFieldDecorator('index.user.numberOffline', {
|
|
|
rules: [
|
|
|
{ required: false, message: '' },
|
|
|
],
|
|
@@ -122,7 +148,7 @@ export default class extends Page {
|
|
|
</Form.Item>
|
|
|
|
|
|
<Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} label='700+学员数'>
|
|
|
- {getFieldDecorator('user.number700', {
|
|
|
+ {getFieldDecorator('index.user.number700', {
|
|
|
rules: [
|
|
|
{ required: false, message: '' },
|
|
|
],
|
|
@@ -132,7 +158,7 @@ export default class extends Page {
|
|
|
</Form.Item>
|
|
|
|
|
|
<Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} label='学员平均分'>
|
|
|
- {getFieldDecorator('user.numberScore', {
|
|
|
+ {getFieldDecorator('index.user.numberScore', {
|
|
|
rules: [
|
|
|
{ required: false, message: '' },
|
|
|
],
|
|
@@ -153,7 +179,7 @@ export default class extends Page {
|
|
|
<Form>
|
|
|
<Row>
|
|
|
{course.map((row, index) => {
|
|
|
- const image = getFieldValue(`course.${index}.image`) || null;
|
|
|
+ const image = getFieldValue(`index.course.${index}.image`) || null;
|
|
|
return <Col span={7} offset={index % 3 ? 1 : 0}><Card>
|
|
|
<Button className="delete-button" size="small" onClick={() => {
|
|
|
this.deleteLength('course', index, 1);
|
|
@@ -161,7 +187,7 @@ export default class extends Page {
|
|
|
<Icon type="delete" />
|
|
|
</Button>
|
|
|
<Form.Item labelCol={{ span: 7 }} wrapperCol={{ span: 15 }} label='课程名称'>
|
|
|
- {getFieldDecorator(`course.${index}.title`, {
|
|
|
+ {getFieldDecorator(`index.course.${index}.title`, {
|
|
|
rules: [
|
|
|
{ required: true, message: '输入课程名称' },
|
|
|
],
|
|
@@ -171,7 +197,7 @@ export default class extends Page {
|
|
|
)}
|
|
|
</Form.Item>
|
|
|
<Form.Item labelCol={{ span: 7 }} wrapperCol={{ span: 15 }} label='跳转链接'>
|
|
|
- {getFieldDecorator(`course.${index}.link`, {
|
|
|
+ {getFieldDecorator(`index.course.${index}.link`, {
|
|
|
rules: [
|
|
|
{ required: true, message: '输入跳转链接' },
|
|
|
],
|
|
@@ -181,7 +207,7 @@ export default class extends Page {
|
|
|
)}
|
|
|
</Form.Item>
|
|
|
<Form.Item labelCol={{ span: 7 }} wrapperCol={{ span: 15 }} label='背景图片'>
|
|
|
- {getFieldDecorator(`course.${index}.image`, {
|
|
|
+ {getFieldDecorator(`index.course.${index}.image`, {
|
|
|
rules: [
|
|
|
{ required: true, message: '上传图片' },
|
|
|
],
|
|
@@ -190,7 +216,7 @@ export default class extends Page {
|
|
|
listType="picture-card"
|
|
|
showUploadList={false}
|
|
|
beforeUpload={(file) => System.uploadImage(file).then((result) => {
|
|
|
- setFieldsValue({ [`course.${index}.image`]: result.url });
|
|
|
+ setFieldsValue({ [`index.course.${index}.image`]: result.url });
|
|
|
return Promise.reject();
|
|
|
})}
|
|
|
>
|
|
@@ -224,7 +250,7 @@ export default class extends Page {
|
|
|
<Form>
|
|
|
<Row>
|
|
|
{activity.map((row, index) => {
|
|
|
- const image = getFieldValue(`activity.${index}.image`) || null;
|
|
|
+ const image = getFieldValue(`index.activity.${index}.image`) || null;
|
|
|
return <Col span={7} offset={index % 3 ? 1 : 0}><Card>
|
|
|
<Button className="delete-button" size="small" onClick={() => {
|
|
|
this.deleteLength('activity', index, 1);
|
|
@@ -232,7 +258,7 @@ export default class extends Page {
|
|
|
<Icon type="delete" />
|
|
|
</Button>
|
|
|
<Form.Item labelCol={{ span: 7 }} wrapperCol={{ span: 15 }} label='跳转链接'>
|
|
|
- {getFieldDecorator(`activity.${index}.link`, {
|
|
|
+ {getFieldDecorator(`index.activity.${index}.link`, {
|
|
|
rules: [
|
|
|
{ required: true, message: '输入跳转链接' },
|
|
|
],
|
|
@@ -242,7 +268,7 @@ export default class extends Page {
|
|
|
)}
|
|
|
</Form.Item>
|
|
|
<Form.Item labelCol={{ span: 7 }} wrapperCol={{ span: 15 }} label='活动图片'>
|
|
|
- {getFieldDecorator(`activity.${index}.image`, {
|
|
|
+ {getFieldDecorator(`index.activity.${index}.image`, {
|
|
|
rules: [
|
|
|
{ required: true, message: '上传图片' },
|
|
|
],
|
|
@@ -251,7 +277,7 @@ export default class extends Page {
|
|
|
listType="picture-card"
|
|
|
showUploadList={false}
|
|
|
beforeUpload={(file) => System.uploadImage(file).then((result) => {
|
|
|
- setFieldsValue({ [`claactivityss.${index}.image`]: result.url });
|
|
|
+ setFieldsValue({ [`index.activity.${index}.image`]: result.url });
|
|
|
return Promise.reject();
|
|
|
})}
|
|
|
>
|
|
@@ -285,7 +311,7 @@ export default class extends Page {
|
|
|
<Form>
|
|
|
<Row>
|
|
|
{evaluation.map((row, index) => {
|
|
|
- const avatar = getFieldValue(`evaluation.${index}.avatar`) || null;
|
|
|
+ const avatar = getFieldValue(`index.evaluation.${index}.avatar`) || null;
|
|
|
return <Col span={7} offset={index % 3 ? 1 : 0}><Card>
|
|
|
<Button className="delete-button" size="small" onClick={() => {
|
|
|
this.deleteLength('evaluation', index, 1);
|
|
@@ -293,7 +319,7 @@ export default class extends Page {
|
|
|
<Icon type="delete" />
|
|
|
</Button>
|
|
|
<Form.Item labelCol={{ span: 7 }} wrapperCol={{ span: 15 }} label='学员昵称'>
|
|
|
- {getFieldDecorator(`evaluation.${index}.nickname`, {
|
|
|
+ {getFieldDecorator(`index.evaluation.${index}.nickname`, {
|
|
|
rules: [
|
|
|
{ required: true, message: '输入学员昵称' },
|
|
|
],
|
|
@@ -303,7 +329,7 @@ export default class extends Page {
|
|
|
)}
|
|
|
</Form.Item>
|
|
|
<Form.Item labelCol={{ span: 7 }} wrapperCol={{ span: 15 }} label='学员头像'>
|
|
|
- {getFieldDecorator(`evaluation.${index}.avatar`, {
|
|
|
+ {getFieldDecorator(`index.evaluation.${index}.avatar`, {
|
|
|
rules: [
|
|
|
{ required: true, message: '上传图片' },
|
|
|
],
|
|
@@ -312,7 +338,7 @@ export default class extends Page {
|
|
|
listType="picture-card"
|
|
|
showUploadList={false}
|
|
|
beforeUpload={(file) => System.uploadImage(file).then((result) => {
|
|
|
- setFieldsValue({ [`evaluation.${index}.avatar`]: result.url });
|
|
|
+ setFieldsValue({ [`index.evaluation.${index}.avatar`]: result.url });
|
|
|
return Promise.reject();
|
|
|
})}
|
|
|
>
|
|
@@ -324,7 +350,7 @@ export default class extends Page {
|
|
|
)}
|
|
|
</Form.Item>
|
|
|
<Form.Item labelCol={{ span: 7 }} wrapperCol={{ span: 15 }} label='评价内容'>
|
|
|
- {getFieldDecorator(`evaluation.${index}.content`, {
|
|
|
+ {getFieldDecorator(`index.evaluation.${index}.content`, {
|
|
|
rules: [
|
|
|
{ required: true, message: '输入评价内容' },
|
|
|
],
|
|
@@ -349,13 +375,13 @@ export default class extends Page {
|
|
|
|
|
|
renderContact() {
|
|
|
const { getFieldDecorator, setFieldsValue, getFieldValue } = this.props.form;
|
|
|
- const wechatImage = getFieldValue('contact.wechatImage');
|
|
|
- const weiboImage = getFieldValue('contacct.weiboImage');
|
|
|
+ const wechatImage = getFieldValue('base.contact.wechatImage');
|
|
|
+ const weiboImage = getFieldValue('base.contacct.weiboImage');
|
|
|
return <Block>
|
|
|
<Form>
|
|
|
<h1>联系方式</h1>
|
|
|
<Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} label='电话'>
|
|
|
- {getFieldDecorator('contact.phone', {
|
|
|
+ {getFieldDecorator('base.contact.phone', {
|
|
|
rules: [
|
|
|
{ required: false, message: '请输入电话' },
|
|
|
],
|
|
@@ -364,7 +390,7 @@ export default class extends Page {
|
|
|
)}
|
|
|
</Form.Item>
|
|
|
<Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} label='邮箱'>
|
|
|
- {getFieldDecorator('contact.email', {
|
|
|
+ {getFieldDecorator('base.contact.email', {
|
|
|
rules: [
|
|
|
{ required: false, message: '请输入邮箱' },
|
|
|
],
|
|
@@ -373,7 +399,7 @@ export default class extends Page {
|
|
|
)}
|
|
|
</Form.Item>
|
|
|
<Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} label='微信号'>
|
|
|
- {getFieldDecorator('contact.wechat', {
|
|
|
+ {getFieldDecorator('base.contact.wechat', {
|
|
|
rules: [
|
|
|
{ required: false, message: '请输入微信号' },
|
|
|
],
|
|
@@ -383,13 +409,13 @@ export default class extends Page {
|
|
|
</Form.Item>
|
|
|
|
|
|
<Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} label='公众号二维码'>
|
|
|
- {getFieldDecorator('contact.wechatImage')(
|
|
|
+ {getFieldDecorator('base.contact.wechatImage')(
|
|
|
<Upload
|
|
|
listType="picture-card"
|
|
|
showUploadList={false}
|
|
|
beforeUpload={(file) => {
|
|
|
System.uploadImage(file).then((result) => {
|
|
|
- setFieldsValue({ 'contact.wechatImage': result.url });
|
|
|
+ setFieldsValue({ 'base.contact.wechatImage': result.url });
|
|
|
return Promise.reject();
|
|
|
});
|
|
|
}
|
|
@@ -403,12 +429,12 @@ export default class extends Page {
|
|
|
)}
|
|
|
</Form.Item>
|
|
|
<Form.Item labelCol={{ span: 5 }} wrapperCol={{ span: 16 }} label='微博二维码'>
|
|
|
- {getFieldDecorator('contact.weiboImage')(
|
|
|
+ {getFieldDecorator('base.contact.weiboImage')(
|
|
|
<Upload
|
|
|
listType="picture-card"
|
|
|
showUploadList={false}
|
|
|
beforeUpload={(file) => System.uploadImage(file).then((result) => {
|
|
|
- setFieldsValue({ 'contact.weiboImage': result.url });
|
|
|
+ setFieldsValue({ 'base.contact.weiboImage': result.url });
|
|
|
return Promise.reject();
|
|
|
})}
|
|
|
>
|