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, bindSearch, getMap } from '@src/services/Tools'; import { asyncSMessage } from '@src/services/AsyncTools'; import { ExperienceScore, ExperiencePercent, PrepareStatus, ExperienceDay } from '../../../../Constant'; import { System } from '../../../stores/system'; import { Course } from '../../../stores/course'; import { User } from '../../../stores/user'; const PrepareStatusMap = getMap(PrepareStatus, 'value', 'short'); const ExperiencePercentMap = getMap(ExperiencePercent, 'value', 'label'); export default class extends Page { init() { this.filterForm = [{ key: 'keyword', type: 'input', allowClear: true, name: '搜索', placeholder: '标题或正文', }, { key: 'userId', type: 'select', name: '用户', allowClear: true, select: [], number: true, placeholder: '请输入', }, { key: 'prepareStatus', type: 'select', allowClear: true, name: '身份', select: PrepareStatus, placeholder: '请选择', }, { key: 'experienceDay', type: 'select', allowClear: true, name: '备考周期', select: ExperienceDay, placeholder: '请选择', }, { key: 'experienceScore', type: 'select', allowClear: true, name: '分手成绩', select: ExperienceScore, placeholder: '请选择', }, { key: 'experiencePercent', type: 'select', allowClear: true, name: '提分比例', select: ExperiencePercent, placeholder: '请选择', }]; this.actionList = [{ key: 'info', name: '数据管理', }, { key: 'add', type: 'primary', name: '创建', render: (item) => { return ; }, }]; this.columns = [{ title: '文章标题', dataIndex: 'title', }, { title: '作者', dataIndex: 'user', render: (text, record) => { return text ? text.nickname : record.nickname; }, }, { title: '更新时间', dataIndex: 'updateTime', render: (text) => { return formatDate(text, 'YYYY-MM-DD HH:mm:ss'); }, }, { title: '身份', dataIndex: 'prepareStatus', render: (text) => { return PrepareStatusMap[text] || text; }, }, { title: '备考周期', dataIndex: 'experienceDay', }, { title: '分手成绩', dataIndex: 'experienceScore', }, { title: '提分比例', dataIndex: 'experiencePercent', render: (text) => { return ExperiencePercentMap[text] || text; }, }, { title: '阅读数', dataIndex: 'viewNumber', }, { title: '收藏数', dataIndex: 'collectNumber', }, { title: '操作', dataIndex: 'handler', render: (text, record) => { return
{编辑}
; }, }]; System.getExperienceInfo().then(result => { return this.refreshInfo(result); }).then(() => { this.initData(); }); bindSearch(this.filterForm, 'userId', this, (search) => { return User.list(search); }, (row) => { return { title: `${row.nickname}(${row.mobile})`, value: row.id, }; }, this.state.search.userId ? Number(this.state.search.userId) : null, null); } initData() { Course.listExperience(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); } changeInfoList(field, index, value) { const { detail } = this.state; if (!detail[field]) detail[field] = []; detail[field][index] = value; this.setState({ detail }); } changeInfo(field, value) { const { detail } = this.state; detail[field] = value; this.setState({ detail }); } submitInfo() { const { detail } = this.state; System.setExperienceInfo(detail).then(() => { asyncSMessage('保存成功'); this.close(false, 'detail'); return this.refreshInfo(detail); }); } renderView() { return { 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={() => { this.submitInfo(); }}>
{ this.changeInfo('number', value); }} /> {ExperienceScore.map((row, index) => { return { this.changeInfoList('score', index, value); }} /> ; })} { this.changeInfo('period', value); }} /> {ExperiencePercent.map((row, index) => { return { this.changeInfoList('percent', index, value); }} /> ; })}
}
; } }