|
|
@@ -1,12 +1,13 @@
|
|
|
import {CheckCard} from '@ant-design/pro-components';
|
|
|
-import { Dropdown, Flex, Input, Pagination, theme, Tooltip} from 'antd';
|
|
|
+import { Dropdown, Flex, Input, Pagination, theme, Tooltip,Button, Empty, Typography} from 'antd';
|
|
|
import {memo, useCallback, useState} from 'react'
|
|
|
const { Search } = Input;
|
|
|
import { Avatar ,Card,Checkbox ,Tag,Col,Divider} from 'antd';
|
|
|
const CheckboxGroup = Checkbox.Group;
|
|
|
import {styled} from 'styled-components';
|
|
|
import {EllipsisOutlined} from "@ant-design/icons";
|
|
|
-
|
|
|
+import useI18NPrefix from "../hooks/useI18NPrefix";
|
|
|
+import EMPTY from '../assets/empty.svg'
|
|
|
/**
|
|
|
* @style: 样式
|
|
|
*
|
|
|
@@ -41,8 +42,10 @@ export const CheckCardList=memo(({
|
|
|
actions,
|
|
|
onDoubleClick,
|
|
|
onChecked,
|
|
|
- pagination
|
|
|
+ pagination,
|
|
|
+ onCreate
|
|
|
})=>{
|
|
|
+ const t = useI18NPrefix('global');
|
|
|
const isArray = Object.prototype.toString.call(options) === '[object Array]';
|
|
|
const {token} = theme.useToken();
|
|
|
const [check,setCheck]=useState([]);
|
|
|
@@ -85,91 +88,111 @@ export const CheckCardList=memo(({
|
|
|
}
|
|
|
return (
|
|
|
<>
|
|
|
- {onSearch && <Search allowClear onSearch={onSearch} style={{marginBottom:8}} placeholder="输入关键字进行搜索"/>}
|
|
|
+ {onSearch && <Search allowClear onSearch={onSearch} style={{marginBottom:8}} placeholder={t("placeholder.filter")}/>}
|
|
|
{extra}
|
|
|
- <Container style={{height:pagination?'65vh':'67.5vh'}}>
|
|
|
- {
|
|
|
- type==="card" &&
|
|
|
- <CheckCard.Group style={style?style:{width:"100%"}} onChange={onSelect&&onSelect}>
|
|
|
- {
|
|
|
- isArray&&options.map(item=>
|
|
|
- <CheckCard
|
|
|
- style={{width:"100%",marginBlockEnd:3,cursor:'pointer'}}
|
|
|
- key={item?.value?.id||item?.value}
|
|
|
- title={item?.title}
|
|
|
- value={item?.value}
|
|
|
- extra={cardExtra(item)}
|
|
|
- onDoubleClick={()=>{
|
|
|
- onDoubleClick && onDoubleClick(item)
|
|
|
- }}
|
|
|
- avatar={
|
|
|
- item?.avatar&&
|
|
|
- <Avatar
|
|
|
- size={item?.avatar?.size}
|
|
|
- shape={item?.avatar?.shape}
|
|
|
- src={item?.avatar?.src}
|
|
|
- />
|
|
|
- }
|
|
|
- />
|
|
|
- )
|
|
|
+ {
|
|
|
+ options.length === 0 &&
|
|
|
+ <Empty
|
|
|
+ style={{height:pagination?'65vh':'67.5vh',paddingTop:'15%'}}
|
|
|
+ image={EMPTY}
|
|
|
+ imageStyle={{
|
|
|
+ height: 60,
|
|
|
+ }}
|
|
|
+ description={
|
|
|
+ <Typography.Text>
|
|
|
+ {t("placeholder.emptyAdd")}
|
|
|
+ </Typography.Text>
|
|
|
}
|
|
|
- </CheckCard.Group>
|
|
|
- }
|
|
|
- {
|
|
|
- type==="checkBox" &&
|
|
|
- <CheckboxGroup onChange={onCardCheck} style={{width:'100%'}}>
|
|
|
- {
|
|
|
- isArray&&options.map(item=>
|
|
|
- <Col span={24} key={item?.value}>
|
|
|
- <CustomCard
|
|
|
- size="small"
|
|
|
- style={styleFun(item?.value)}
|
|
|
+ >
|
|
|
+ {onCreate && <Button type="primary" onClick={onCreate}>{t("button.createNow")}</Button>}
|
|
|
+ </Empty>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ options.length > 0 &&
|
|
|
+ <Container style={{height:pagination?'65vh':'67.5vh'}}>
|
|
|
+ {
|
|
|
+ type==="card" &&
|
|
|
+ <CheckCard.Group style={style?style:{width:"100%"}} onChange={onSelect&&onSelect}>
|
|
|
+ {
|
|
|
+ isArray&&options.map(item=>
|
|
|
+ <CheckCard
|
|
|
+ style={{width:"100%",marginBlockEnd:3,cursor:'pointer'}}
|
|
|
+ key={item?.value?.id||item?.value}
|
|
|
+ title={item?.title}
|
|
|
+ value={item?.value}
|
|
|
+ extra={cardExtra(item)}
|
|
|
onDoubleClick={()=>{
|
|
|
onDoubleClick && onDoubleClick(item)
|
|
|
}}
|
|
|
- >
|
|
|
- <Tooltip placement="top" title={tooltip} mouseEnterDelay={0.5}>
|
|
|
- <Flex>
|
|
|
- {/*卡片头信息 以及 内容*/}
|
|
|
- <Col flex="auto" >
|
|
|
- <Checkbox value={item}>
|
|
|
- <Span>
|
|
|
- {item?.title}
|
|
|
- {
|
|
|
- item?.tag &&
|
|
|
- <Tag color={item?.tag?.color?item?.tag?.color:'#2db7f5'} style={{marginLeft:10}}>{item?.tag?.label}</Tag>
|
|
|
- }
|
|
|
- </Span>
|
|
|
- </Checkbox>
|
|
|
-
|
|
|
- <Contant>
|
|
|
- {item?.content}
|
|
|
- </Contant>
|
|
|
- </Col>
|
|
|
-
|
|
|
- {/*卡片头Extra按钮*/}
|
|
|
- {
|
|
|
- item?.extra && Object.prototype.toString.call(item?.extra) === '[object Array]' &&
|
|
|
- (
|
|
|
- <>
|
|
|
- <CustomDivider type="vertical" />
|
|
|
- <Col flex="auto" style={{paddingBlockStart:40,paddingBlockEnd:40}}>
|
|
|
+ avatar={
|
|
|
+ item?.avatar&&
|
|
|
+ <Avatar
|
|
|
+ size={item?.avatar?.size}
|
|
|
+ shape={item?.avatar?.shape}
|
|
|
+ src={item?.avatar?.src}
|
|
|
+ />
|
|
|
+ }
|
|
|
+ />
|
|
|
+ )
|
|
|
+ }
|
|
|
+ </CheckCard.Group>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ type==="checkBox" &&
|
|
|
+ <CheckboxGroup onChange={onCardCheck} style={{width:'100%'}}>
|
|
|
+ {
|
|
|
+ isArray&&options.map(item=>
|
|
|
+ <Col span={24} key={item?.value}>
|
|
|
+ <CustomCard
|
|
|
+ size="small"
|
|
|
+ style={styleFun(item?.value)}
|
|
|
+ onDoubleClick={()=>{
|
|
|
+ onDoubleClick && onDoubleClick(item)
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <Tooltip placement="top" title={tooltip} mouseEnterDelay={0.5}>
|
|
|
+ <Flex>
|
|
|
+ {/*卡片头信息 以及 内容*/}
|
|
|
+ <Col flex="auto" >
|
|
|
+ <Checkbox value={item}>
|
|
|
+ <Span>
|
|
|
+ {item?.title}
|
|
|
{
|
|
|
- item.extra.map(item=>item)
|
|
|
+ item?.tag &&
|
|
|
+ <Tag color={item?.tag?.color?item?.tag?.color:'#2db7f5'} style={{marginLeft:10}}>{item?.tag?.label}</Tag>
|
|
|
}
|
|
|
- </Col>
|
|
|
- </>
|
|
|
- )
|
|
|
- }
|
|
|
- </Flex>
|
|
|
- </Tooltip>
|
|
|
- </CustomCard>
|
|
|
- </Col>
|
|
|
- )
|
|
|
- }
|
|
|
- </CheckboxGroup>
|
|
|
- }
|
|
|
- </Container>
|
|
|
+ </Span>
|
|
|
+ </Checkbox>
|
|
|
+
|
|
|
+ <Contant>
|
|
|
+ {item?.content}
|
|
|
+ </Contant>
|
|
|
+ </Col>
|
|
|
+
|
|
|
+ {/*卡片头Extra按钮*/}
|
|
|
+ {
|
|
|
+ item?.extra && Object.prototype.toString.call(item?.extra) === '[object Array]' &&
|
|
|
+ (
|
|
|
+ <>
|
|
|
+ <CustomDivider type="vertical" />
|
|
|
+ <Col flex="auto" style={{paddingBlockStart:40,paddingBlockEnd:40}}>
|
|
|
+ {
|
|
|
+ item.extra.map(item=>item)
|
|
|
+ }
|
|
|
+ </Col>
|
|
|
+ </>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ </Flex>
|
|
|
+ </Tooltip>
|
|
|
+ </CustomCard>
|
|
|
+ </Col>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ </CheckboxGroup>
|
|
|
+ }
|
|
|
+ </Container>
|
|
|
+ }
|
|
|
{ type==="checkBox" && pagination && <Pagination align="end" showSizeChanger {...pagination}/>}
|
|
|
</>
|
|
|
)
|