import React from 'react'; import { Link } from 'react-router-dom'; import { Button } 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, getMap } from '@src/services/Tools'; import { asyncSMessage, asyncDelConfirm } from '@src/services/AsyncTools'; // import { ArticleChannel } from '../../../../Constant'; import { Ready } from '../../../stores/ready'; // const ArticleChannelMap = getMap(ArticleChannel, 'value', 'label'); export default class extends Page { init() { this.categoryMap = {}; this.categoryList = []; this.filterForm = [{ key: 'parentCategoryId', type: 'select', allowClear: true, name: '一级标题', placeholder: '请选择', select: [], number: true, onChange: (value) => { this.changeSearch(this.filterForm, this, value); }, }, { key: 'categoryId', type: 'select', allowClear: true, name: '二级标题', select: [], number: true, placeholder: '请选择', }]; this.actionList = [{ key: 'add', type: 'primary', name: '创建', render: (item) => { return ; }, }]; this.columns = [{ title: '一级标题', dataIndex: 'parentCategoryId', render: (text) => { return this.categoryMap[text]; }, }, { title: '二级标题', dataIndex: 'categoryId', render: (text) => { return this.categoryMap[text]; }, }, { title: '文章标题', dataIndex: 'title', }, { title: '更新时间', dataIndex: 'updateTime', render: (text) => { return formatDate(text); }, }, { title: '操作', dataIndex: 'handler', render: (text, record) => { return
; }, }]; Ready.allCategory().then(result => { this.categoryList = result.map(row => { row.value = row.id; return row; }); this.categoryMap = getMap(result, 'id', 'title'); this.filterForm[0].select = this.categoryList.filter(row => row.parentId === 0); this.onChangeSearch(this.filterForm, this, this.state.search.parentCategoryId); this.initData(); }); } changeSearch(list, component, value) { if (value) { list[1].disabled = false; list[1].select = this.categoryList.filter(row => row.parentId === value); } else { list[1].disabled = true; list[1].select = []; } component.setState({ load: false }); } initData() { Ready.listArticle(this.state.search).then(result => { this.setTableData(result.list, result.total); }); } deleteAction(row) { asyncDelConfirm('删除确认', '是否删除选中?', () => { const handler = Ready.delArticle({ id: row.id }); return handler.then(() => { asyncSMessage('删除成功!'); this.refresh(); }); }); } renderView() { return