import React from 'react'; import { Link } from 'react-router-dom'; import { Button, Modal, Form, Icon, Upload } 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 { formatTreeData, getMap } from '@src/services/Tools'; import { asyncSMessage } from '@src/services/AsyncTools'; import { CourseModule, CourseVideoType } from '../../../../Constant'; import { System } from '../../../stores/system'; import { Course } from '../../../stores/course'; import { Exercise } from '../../../stores/exercise'; const CourseModuleMap = getMap(CourseModule, 'value', 'label'); const CourseVideoTypeMap = getMap(CourseVideoType, 'value', 'label'); export default class extends Page { init() { this.exerciseMap = {}; this.filterForm = [ { key: 'structId', type: 'tree', allowClear: true, tree: [], name: '学科', placeholder: '标题或正文', }, { key: 'courseModule', type: 'select', name: '课程种类', allowClear: true, select: CourseModule, 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: 'courseModule', render: (text) => { return CourseModuleMap[text] || text; }, }, { title: '学科', dataIndex: 'structId', render: (text, record) => { return `${record.parentStructId ? `${this.exerciseMap[record.parentStructId]}-` : ''}${this.exerciseMap[record.structId]}`; }, }, { title: '类型', dataIndex: 'videoType', render: (text) => { return CourseVideoTypeMap[text] || text; }, }, { title: '课程名称', dataIndex: 'title', }, { title: '售价', dataIndex: 'price', }, { title: '试听人数', dataIndex: 'trailNumber', }, { title: '购买数量(含套餐)', dataIndex: 'saleNumber', render: (text, record) => { return text + record.packageSaleNumber; }, }, { title: '操作', dataIndex: 'handler', render: (text, record) => { return
{编辑} {(record.courseModule === 'online') && 查看学员}
; }, }]; 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.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.value = row.id; return row; }), 'id', 'title'); this.setState({ exercise: result }); }); } initData() { Course.list(Object.assign({ excludeVs: true }, 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 && { data.page = 1; 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={() => { if (this.props.core.loading) return; this.submitInfo(); }}>
{this.state.uploadErr} System.uploadVideo(file).then((result) => { this.changeInfo('onlineVideo', result.url); }).catch(err => { this.setState({ onlineErr: err.message }); })} > {this.state.detail.onlineVideo ?
已上传
:
Upload
}
{this.state.detail.onlineVideo && 访问}
System.uploadVideo(file).then((result) => { this.changeInfo('vsVideo', result.url); }).catch(err => { this.setState({ vsErr: err.message }); })} > {this.state.detail.vsVideo ?
已上传
:
Upload
}
{this.state.detail.vsVideo && 访问}
}
; } }