123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- 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 { asyncSMessage } from '@src/services/AsyncTools';
- import { TextbookType } from '../../../../Constant';
- // import { System } from '../../../stores/system';
- import { Textbook } from '../../../stores/textbook';
- // import { Slient } from '../../../stores/slient';
- const TextbookTypeMap = getMap(TextbookType, 'value', 'label');
- const filterForm = [
- {
- key: 'questionType',
- type: 'select',
- allowClear: true,
- name: '题型',
- select: TextbookType,
- placeholder: '请选择',
- },
- {
- key: 'paperId',
- type: 'select',
- allowClear: true,
- name: '练习册',
- select: [],
- placeholder: '请选择',
- number: true,
- },
- {
- key: 'id',
- type: 'select',
- allowClear: true,
- name: '题目ID',
- select: [],
- number: true,
- placeholder: '请输入',
- },
- ];
- export default class extends Page {
- constructor(props) {
- super(props);
- this.actionList = [{
- key: 'add',
- name: '新建',
- render: (item) => {
- return <Button onClick={() => {
- linkTo('/subject/textbook/question');
- }}>{item.name}</Button>;
- },
- }];
- this.categoryMap = {};
- this.columns = [{
- title: '题型',
- dataIndex: 'questionType',
- render: (text, record) => {
- return TextbookTypeMap[record.question.questionType] || text;
- },
- }, {
- title: '题目ID',
- dataIndex: 'title',
- }, {
- title: '修改时间',
- dataIndex: 'updateTime',
- render: (text, record) => {
- return formatDate(record.question.updateTime, 'YYYY-MM-DD HH:mm:ss');
- },
- }, {
- title: '操作',
- dataIndex: 'handler',
- render: (text, record) => {
- return <div className="table-button">
- {(
- <Link to={`/subject/textbook/question/${record.id}`}>编辑</Link>
- )}
- </div>;
- },
- }];
- }
- init() {
- bindSearch(filterForm, 'paperId', this, (search) => {
- return Textbook.listPaper(search);
- }, (row) => {
- return {
- title: row.title,
- value: row.id,
- };
- }, this.state.search.paperId ? Number(this.state.search.paperId) : null, null);
- bindSearch(filterForm, 'id', this, (search) => {
- return Textbook.searchQuestion(search);
- }, (row) => {
- return {
- title: row.title,
- value: row.id,
- };
- }, this.state.search.id ? Number(this.state.search.id) : null, null);
- }
- initData() {
- const { search } = this.state;
- const data = Object.assign({}, search);
- Textbook.listQuestion(data).then(result => {
- this.setTableData(result.list, result.total || 1);
- });
- }
- renderView() {
- return <Block flex>
- <FilterLayout
- show
- itemList={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>;
- }
- }
|