import React from 'react' import { Layout, Button, Icon, Input, Menu, Dropdown, Card, Col, Row } from 'antd' import { connect } from 'dva' import { dateFormat } from '../../utils/baseUtils' import Ellipsis from 'ant-design-pro/lib/Ellipsis' import DistributeBox from './distributeBox' import TransferBox from '../common/selectUserBox'; import 'ant-design-pro/dist/ant-design-pro.css' import Thumbnail from './thumbnail' import './list.less' import DeleteBox from '../common/deleteBox' const { Content } = Layout const { Search } = Input const CardGrid = Card.Grid class DashboardList extends React.Component { constructor(props) { super(props); this.state = { selectedRecord: null, visibleChooseDataSourceBox: false, visibleDistributeBox: false, visibleTransferBox: false, visibleGroupMenu: false, // 显示分组菜单 visibleDeleteBox: false } } componentDidMount() { const { dispatch } = this.props; this.setBodyWidth(); dispatch({ type: 'dashboard/fetchList' }); } /** * 设置卡片容器宽度 = 每行最大卡片数量 * 卡片宽度 */ setBodyWidth() { const chartBody = document.getElementsByClassName('dashboard-body')[0]; // 卡片容器 const parent = chartBody.parentNode; // 父级容器 const pWidth = parent.offsetWidth; // 父级容器宽度 const pPadding = 10 + 10; // 父级容器左右padding const cWidth = 512; // 每个卡片宽度 const cMargin = 5 + 5; // 每个卡片左右margin const pTrueWidth = pWidth - pPadding; // 父容器实际可用宽度 const cTrueWidth = cWidth + cMargin; // 卡片实际占用宽度 const count = Math.floor(pTrueWidth/cTrueWidth); // 每行最大卡片数量 chartBody.style.width = count * cTrueWidth + 'px'; } generateCard() { const { dashboard, dispatch } = this.props; const list = dashboard.list; const reg = new RegExp('([+ \\- & | ! ( ) { } \\[ \\] ^ \" ~ * ? : ( ) \/])', 'g'); // 需要转义的字符 let filterLabel = dashboard.filterLabel.replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1'); // 添加转义符号 const operationMenu = (
) let cards = list.filter(l => { let reg = new RegExp('(' + filterLabel + '){1}', 'ig'); return (l.name || '').search(reg) !== -1 || (l.description || '').search(reg) !== -1; }).sort((a, b) => { return new Date(b.createTime) - new Date(a.createTime) }).map( (l, i) => (