Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoubichuan committed Oct 29, 2023
1 parent ba8018d commit 0d442c4
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 84 deletions.
16 changes: 8 additions & 8 deletions config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@
component: './list/list',
},
{
name: 'list6',
name: 'list8',
icon: 'smile',
path: '/list/data',
redirect: '/list/data/1',
path: '/list/type',
redirect: '/list/type/1',
},
{
name: '',
icon: 'smile',
path: '/list/data/:id',
path: '/list/type/:id',
menuRender: false, // 不渲染菜单
component: './list/list',
},
Expand All @@ -173,15 +173,15 @@
component: './list/list',
},
{
name: 'list8',
name: 'list6',
icon: 'smile',
path: '/list/type',
redirect: '/list/type/1',
path: '/list/data',
redirect: '/list/data/1',
},
{
name: '',
icon: 'smile',
path: '/list/type/:id',
path: '/list/data/:id',
menuRender: false, // 不渲染菜单
component: './list/list',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const TagSelect: FC<TagSelectProps> & { Option: typeof TagSelectOption } = (prop
} else if (!checked && index > -1) {
checkedTags.splice(index, 1);
}
setValue(checkedTags);
setValue([tag]);
};

const checkedAll = getAllTags().length === value?.length;
Expand Down
112 changes: 59 additions & 53 deletions src/pages/list/search/projects/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Card, Col, Form, List, Row, Select, Typography } from 'antd';
import moment from 'moment';
import type { FC } from 'react';
import { useRequest } from 'umi';
import { useRequest, Link } from 'umi';
import AvatarList from './components/AvatarList';
import StandardFormRow from './components/StandardFormRow';
import TagSelect from './components/TagSelect';
Expand Down Expand Up @@ -33,6 +33,7 @@ const Projects: FC = () => {
);
template = result.data;
setTemplateData(template);
setLists(template);
};
useEffect(() => {
getTemplateData();
Expand All @@ -53,54 +54,6 @@ const Projects: FC = () => {
useEffect(() => {
getData('');
}, []);
const cardList = lists && (
<List<ListItemDataType>
rowKey="id"
grid={{
gutter: 16,
xs: 1,
sm: 2,
md: 3,
lg: 3,
xl: 4,
xxl: 4,
}}
dataSource={lists}
renderItem={(item) => (
<List.Item>
<Card
className={styles.card}
hoverable
cover={<img alt={item.name} src={item.images[0].thumbUrl} />}
>
<Card.Meta
title={<a>{item.name}</a>}
description={
<Paragraph className={styles.item} ellipsis={{ rows: 2 }}>
{item.descript}
</Paragraph>
}
/>
<div className={styles.cardItemContent}>
<span>{moment(item.updatedAt).fromNow()}</span>
<div className={styles.avatarList}>
<AvatarList size="small">
{item.members?.map((member, i) => (
<AvatarList.Item
key={getKey(item.id, i)}
src={member.avatar}
tips={member.name}
/>
))}
</AvatarList>
</div>
</div>
</Card>
</List.Item>
)}
/>
);

const formItemLayout = {
wrapperCol: {
xs: { span: 24 },
Expand Down Expand Up @@ -131,23 +84,76 @@ const Projects: FC = () => {
<Col lg={8} md={10} sm={10} xs={24}>
<FormItem {...formItemLayout} label="作者" name="author">
<Select placeholder="不限" style={{ maxWidth: 200, width: '100%' }}>
<Option value="lisa">王昭君</Option>
{lists.map((item: any) => (
<Option value={item.value}>{item.name}</Option>
))}
</Select>
</FormItem>
</Col>
<Col lg={8} md={10} sm={10} xs={24}>
<FormItem {...formItemLayout} label="好评度" name="rate">
<Select placeholder="不限" style={{ maxWidth: 200, width: '100%' }}>
<Option value="good">优秀</Option>
<Option value="normal">普通</Option>
{lists.map((item: any) => (
<Option value={item.value2}>{item.name2}</Option>
))}
</Select>
</FormItem>
</Col>
</Row>
</StandardFormRow>
</Form>
</Card>
<div className={styles.cardList}>{cardList}</div>
<div className={styles.cardList}>
{lists && (
<List<ListItemDataType>
rowKey="id"
grid={{
gutter: 16,
xs: 1,
sm: 2,
md: 3,
lg: 3,
xl: 4,
xxl: 4,
}}
dataSource={lists}
renderItem={(item: any) => (
<List.Item>
<Link to={`/list/data/1?type=${item.type}`} target="_blank">
<Card
className={styles.card}
hoverable
cover={<img alt={item.name} src={item.images[0].thumbUrl} />}
>
<Card.Meta
title={<a>{item.name}</a>}
description={
<Paragraph className={styles.item} ellipsis={{ rows: 2 }}>
{item.descript}
</Paragraph>
}
/>
<div className={styles.cardItemContent}>
<span>{moment(item.updatedAt).fromNow()}</span>
<div className={styles.avatarList}>
<AvatarList size="small">
{item.members?.map((member, i) => (
<AvatarList.Item
key={getKey(item.id, i)}
src={member.avatar}
tips={member.name}
/>
))}
</AvatarList>
</div>
</div>
</Card>
</Link>
</List.Item>
)}
/>
)}
</div>
</div>
);
};
Expand Down
82 changes: 60 additions & 22 deletions src/pages/list/template/1.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
"dataIndex": "type",
"hideInSearch": false,
"hideInTable": false,
"table": {
"type": "select",
"data": [
{ "value": "type", "name": "类型" },
{ "value": "field", "name": "字段" },
{ "value": "data", "name": "数据" }
],
"width": 60
},
"create": {
"rules": [
{
Expand All @@ -25,10 +34,14 @@
"view": true
},
{
"title": "名称",
"title": "字段名称",
"dataIndex": "title",
"hideInSearch": false,
"hideInTable": false,
"table": {
"type": "text",
"width": 60
},
"create": {
"rules": [
{
Expand All @@ -50,10 +63,14 @@
"view": true
},
{
"title": "字段",
"title": "字段值",
"dataIndex": "dataIndex",
"hideInSearch": false,
"hideInTable": false,
"table": {
"type": "text",
"width": 60
},
"create": {
"rules": [
{
Expand All @@ -77,14 +94,15 @@
{
"title": "搜索显示",
"dataIndex": "hideInSearch",
"hideInSearch": false,
"hideInSearch": true,
"hideInTable": false,
"table": {
"type": "select",
"data": [
{ "value": true, "name": "" },
{ "value": false, "name": "" }
]
],
"width": 80
},
"create": {
"rules": [
Expand All @@ -109,14 +127,15 @@
{
"title": "表格显示",
"dataIndex": "hideInTable",
"hideInSearch": false,
"hideInSearch": true,
"hideInTable": false,
"table": {
"type": "select",
"data": [
{ "value": true, "name": "" },
{ "value": false, "name": "" }
]
],
"width": 80
},
"create": {
"rules": [
Expand All @@ -139,16 +158,13 @@
"view": true
},
{
"title": "列表显示",
"dataIndex": "hideInForm",
"hideInSearch": false,
"title": "表格属性",
"dataIndex": "table",
"hideInSearch": true,
"hideInTable": false,
"table": {
"type": "select",
"data": [
{ "value": true, "name": "" },
{ "value": false, "name": "" }
]
"type": "text",
"width": 160
},
"create": {
"rules": [
Expand All @@ -171,10 +187,18 @@
"view": true
},
{
"title": "表格属性",
"dataIndex": "table",
"hideInSearch": false,
"title": "列表显示",
"dataIndex": "hideInForm",
"hideInSearch": true,
"hideInTable": false,
"table": {
"type": "select",
"data": [
{ "value": true, "name": "" },
{ "value": false, "name": "" }
],
"width": 80
},
"create": {
"rules": [
{
Expand All @@ -198,8 +222,12 @@
{
"title": "创建属性",
"dataIndex": "create",
"hideInSearch": false,
"hideInSearch": true,
"hideInTable": false,
"table": {
"type": "text",
"width": 160
},
"create": {
"rules": [
{
Expand All @@ -223,8 +251,12 @@
{
"title": "编辑属性",
"dataIndex": "edit",
"hideInSearch": false,
"hideInSearch": true,
"hideInTable": false,
"table": {
"type": "text",
"width": 160
},
"create": {
"rules": [
{
Expand All @@ -248,8 +280,12 @@
{
"title": "展示属性",
"dataIndex": "view",
"hideInSearch": false,
"hideInSearch": true,
"hideInTable": false,
"table": {
"type": "text",
"width": 160
},
"create": {
"rules": [
{
Expand All @@ -276,7 +312,8 @@
"hideInSearch": true,
"hideInTable": true,
"table": {
"type": "time"
"type": "time",
"width": 60
},
"create": false,
"edit": false,
Expand All @@ -288,7 +325,8 @@
"hideInSearch": true,
"hideInTable": true,
"table": {
"type": "time"
"type": "time",
"width": 60
},
"create": false,
"edit": false,
Expand Down

0 comments on commit 0d442c4

Please sign in to comment.