import React from 'react';
import { Link } from 'react-router-dom';
import { Button, Modal, Form, InputNumber, Row, Col } from 'antd';
import './index.less';
import Page from '@src/containers/Page';
import Block from '@src/components/Block';
import FilterLayout from '@src/layouts/FilterLayout';
import ActionLayout from '@src/layouts/ActionLayout';
import TableLayout from '@src/layouts/TableLayout';
import { formatDate, formatTreeData, getMap } from '@src/services/Tools';
import { asyncSMessage } from '@src/services/AsyncTools';
import { ExperienceScore, ExperiencePercent } from '../../../../Constant';
import { System } from '../../../stores/system';
import { Course } from '../../../stores/course';
import { Exercise } from '../../../stores/exercise';
export default class extends Page {
init() {
this.filterForm = [
{
key: 'structId',
type: 'input',
allowClear: true,
name: '搜索',
placeholder: '标题或正文',
}, {
key: 'type',
type: 'select',
name: '类型',
allowClear: true,
select: [],
placeholder: '请输入',
},
];
this.actionList = [{
key: 'info',
name: '首页视频',
}, {
key: 'addVideo',
type: 'primary',
name: '创建视频课程',
render: (item) => {
return ;
},
}, {
key: 'addOnline',
type: 'primary',
name: '创建直播课程',
render: (item) => {
return ;
},
}, {
key: 'addVs',
type: 'primary',
name: '创建1vs1课程',
render: (item) => {
return ;
},
}];
this.columns = [{
title: '文章标题',
dataIndex: 'title',
}, {
title: '作者',
dataIndex: 'user',
render: (text) => {
return (text || {}).nickname;
},
}, {
title: '录入时间',
dataIndex: 'createTime',
render: (text) => {
return formatDate(text);
},
}, {
title: '收藏数',
dataIndex: 'collectNumber',
}, {
title: '操作',
dataIndex: 'handler',
render: (text, record) => {
return
{编辑}
;
},
}];
System.getCourseIndex().then(result => {
return this.refreshInfo(result);
}).then(() => {
this.initData();
});
Exercise.courseStruct().then((result) => {
const list = result.map(row => { row.title = `${row.titleZh}/${row.titleEn}`; row.value = row.id; return row; });
this.filterForm[0].tree = formatTreeData(list, 'id', 'title', 'parentId');
this.exerciseMap = getMap(result.map(row => {
row.title = `${row.titleZh}/${row.titleEn}`;
row.value = row.id;
return row;
}), 'id', 'title');
this.setState({ exercise: result });
});
}
initData() {
Course.list(this.state.search).then(result => {
this.setTableData(result.list, result.total);
});
}
refreshInfo(result) {
this.setState({ info: result });
}
infoAction() {
const { info = {} } = this.state;
this.open(info);
}
changeInfo(field, value) {
const { detail } = this.state;
detail[field] = value;
this.setState({ detail });
}
submitInfo() {
const { detail } = this.state;
System.setCourseIndex(detail).then(() => {
asyncSMessage('保存成功');
this.close(false, 'detail');
return this.refreshInfo(detail);
});
}
renderView() {
const { exercise } = this.state;
return
{exercise && {
this.search(data);
}} />}
this.onAction(key)}
/>
this.tableChange(pagination, filters, sorter)}
onSelect={(keys, rows) => this.tableSelect(keys, rows)}
selectedKeys={this.state.selectedKeys}
/>
{this.state.detail && {
this.close(false, 'detail');
}} onOk={() => {
this.submitInfo();
}}>
{ExperienceScore.map((row, index) => {
return
{
this.changeInfoList('score', index, value);
}} />
;
})}
{
this.changeInfo('period', value);
}} />
{ExperiencePercent.map((row, index) => {
return
{
this.changeInfoList('percent', index, value);
}} />
;
})}
}
;
}
}