123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- 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 <Button onClick={() => {
- linkTo('/textbook/topic/detail');
- }}>{item.name}</Button>;
- },
- }];
- 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 <div className="table-button">
- {(
- <Link to={`/textbook/topic/detail/${record.id}`}>编辑</Link>
- )}
- {(
- <a onClick={() => {
- this.deleteAction(record);
- }}>删除</a>
- )}
- </div>;
- },
- }];
- 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 <Block flex>
- <FilterLayout
- show
- itemList={this.filterForm}
- data={this.state.search}
- onChange={data => {
- data.page = 1;
- this.search(data);
- }} />
- <ActionLayout
- itemList={this.actionList}
- selectedKeys={this.state.selectedKeys}
- onAction={key => this.onAction(key)}
- />
- <TableLayout
- columns={this.tableSort(this.columns)}
- list={this.state.list}
- pagination={this.state.page}
- loading={this.props.core.loading}
- onChange={(pagination, filters, sorter) => this.tableChange(pagination, filters, sorter)}
- onSelect={(keys, rows) => this.tableSelect(keys, rows)}
- selectedKeys={this.state.selectedKeys}
- />
- </Block>;
- }
- }
|