import React from 'react'; import { Button } from 'antd'; import { Link } from 'react-router-dom'; 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 { getMap, bindSearch, formatDate } from '@src/services/Tools'; import { asyncDelConfirm, asyncSMessage } from '@src/services/AsyncTools'; // import { TextbookType } from '../../../../Constant'; import { Textbook } from '../../../stores/textbook'; import { TextbookSubject, TextbookQuality } from '../../../../Constant'; // import { Slient } from '../../../stores/slient'; const TextbookSubjectMap = getMap(TextbookSubject, 'value', 'label'); const TextbookQualityMap = getMap(TextbookQuality, 'value', 'label'); export default class extends Page { constructor(props) { super(props); this.actionList = [{ key: 'add', name: '新建', render: (item) => { return ; }, }]; this.filterForm = [{ key: 'textbookSubject', type: 'select', name: '单项', select: TextbookSubject, allowClear: true, }, { key: 'libraryId', type: 'select', name: '换库表', select: [], number: true, allowClear: true, }, { key: 'quality', type: 'select', name: '机经质量', select: TextbookQuality, allowClear: true, }]; this.columns = [{ title: '单项', dataIndex: 'textbookSubject', render: (text) => { return TextbookSubjectMap[text] || ''; }, }, { title: '所属库', dataIndex: 'library', render: (text) => { return `${formatDate(text.startDate, 'YYYY-MM-DD')}-${text.endDate ? `${formatDate(text.endDate, 'YYYY-MM-DD')}` : '至今'}`; }, }, { title: '题目序号', dataIndex: 'no', }, { title: '关键词', dataIndex: 'keyword', }, { title: '机经质量', dataIndex: 'quality', render: (text) => { return TextbookQualityMap[text] || ''; }, }, { title: '操作', dataIndex: 'handler', render: (text, record) => { return
{( 编辑 )} {( { this.deleteAction(record); }}>删除 )}
; }, }]; bindSearch(this.filterForm, 'libraryId', this, (search) => { return Textbook.listLibrary(search); }, (row) => { return { title: `${formatDate(row.startDate, 'YYYY-MM-DD')}-${row.endDate ? `${formatDate(row.endDate, 'YYYY-MM-DD')}` : '至今'}`, value: row.id, }; }, this.state.search.libraryId ? Number(this.state.search.libraryId) : null, null); } initData() { const { search } = this.state; const data = Object.assign({}, search); Textbook.listTopic(data).then(result => { this.setTableData(result.list, result.total || 1); }); } loadHistory(record) { Textbook.listHistory({ libraryId: record.id }).then(result => { this.setState({ history: result.list }); }); } deleteAction(row) { asyncDelConfirm('删除确认', '是否删除选中记录?', () => { return Textbook.delTopic({ id: row.id }).then(() => { asyncSMessage('操作成功!'); this.refresh(); }); }); } 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} /> ; } }