Skip to content

Commit

Permalink
更新代码
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoubichuan committed Mar 17, 2024
1 parent 314930f commit 3627e93
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 29 deletions.
12 changes: 7 additions & 5 deletions src/pages/list/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ const TableList: React.FC = () => {
setTabs(tabsData.data);
if (dataId) {
const result: any = await requestList({ current: 1, pageSize: 1 }, { id: dataId });
setOptions(result.data);
}
setTabActiveKey(key);
if (actionRef.current) {
actionRef.current.reload();
setCurrentRow(result.data[0]);
setShowDetail(true);
} else {
setTabActiveKey(key);
if (actionRef.current) {
actionRef.current.reload();
}
}
};

Expand Down
5 changes: 3 additions & 2 deletions src/pages/list/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { FC } from 'react';
import { useState, useEffect } from 'react';
import { history } from 'umi';
import { list } from './service';

import styles from './style.less';
type SearchProps = {
match: {
url: string;
Expand Down Expand Up @@ -58,6 +58,7 @@ const Search: FC<SearchProps> = (props) => {

return (
<PageContainer
className={styles.pageContainer}
content={
<div style={{ textAlign: 'center' }}>
<Input.Search
Expand All @@ -76,7 +77,7 @@ const Search: FC<SearchProps> = (props) => {
tabActiveKey={activeKey}
onTabChange={handleTabChange}
>
{props.children}
<div className={styles.content}> {props.children}</div>
</PageContainer>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const TagSelect: FC<TagSelectProps> & { Option: typeof TagSelectOption } = (prop
const [expand, { toggle }] = useBoolean();

const [value, setValue] = useControllableValue<(string | number)[]>(props);

const isTagSelectOption = (node: TagSelectOptionElement) =>
node &&
node.type &&
Expand Down
46 changes: 25 additions & 21 deletions src/pages/list/search/projects/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@ const { Paragraph } = Typography;
const Projects: FC = () => {
const path: string = location.pathname.replace('/antdpro-demo', '');
const [templateData, setTemplateData] = useState<any>([]);
const [type, setType] = useState<any>({});
const [lists, setLists] = useState<any>([]);
const getData = async (params: any) => {
let data: any = [];
const result = await list(
'data/1',
{
current: 1,
},
params,
);
data = result.data;
setLists(data);
};
const getTemplateData = async () => {
const { data } = await list(
'field/1',
Expand All @@ -28,27 +41,18 @@ const Projects: FC = () => {
);
setTemplateData(data);
setLists(data);
setType({ type: [data[0].value] });
};
useEffect(() => {
getTemplateData();
}, [path]);
const getData = async (params: any) => {
let data: any = [];
if (params.category) {
params.type = params.category[0];
delete params.category;
useEffect(() => {
if (type.type) {
type.type = type.type[0];
}
const result = await list(
'data/1',
{
current: 1,
pageSize: 20,
},
params,
);
data = result.data;
setLists(data);
};
getData(type);
}, [JSON.stringify(type)]);

const formItemLayout = {
wrapperCol: {
xs: { span: 24 },
Expand All @@ -61,12 +65,12 @@ const Projects: FC = () => {
<Card bordered={false}>
<Form
layout="inline"
onValuesChange={(_) => {
getData(_);
onValuesChange={(params) => {
setType(params);
}}
>
<StandardFormRow title="所属类目" block style={{ paddingBottom: 11 }}>
<FormItem name="category">
<FormItem name="type">
<TagSelect expandable>
{templateData.map((item: any) => (
<TagSelect.Option value={item.value}>{item.name}</TagSelect.Option>
Expand All @@ -86,7 +90,7 @@ const Projects: FC = () => {
</FormItem>
</Col>
<Col lg={8} md={10} sm={10} xs={24}>
<FormItem {...formItemLayout} label="好评度" name="rate">
<FormItem {...formItemLayout} label="好评度" name="code">
<Select placeholder="不限" style={{ maxWidth: 200, width: '100%' }}>
{lists.map((item: any) => (
<Option value={item.code}>{item.code}</Option>
Expand Down Expand Up @@ -114,7 +118,7 @@ const Projects: FC = () => {
dataSource={lists}
renderItem={(item: any) => (
<List.Item>
<Link to={`/list/data/1?id=${item.id}`} target="_blank">
<Link to={`/list/list?page=data&tab=1&dataId=${item.id}`} target="_blank">
<Card
className={styles.card}
hoverable
Expand Down
2 changes: 2 additions & 0 deletions src/pages/list/search/projects/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
}
}
.cardList {
height: calc(100vh - 410px);
margin-top: 24px;
overflow-y: auto;
.ant-card-cover {
img {
height: 300px;
Expand Down
12 changes: 12 additions & 0 deletions src/pages/list/search/style.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@import '~antd/es/style/themes/default.less';

.pageContainer {
.content {
margin-top: 24px;
}
:global {
.ant-list .ant-list-item-content-single {
max-width: 100%;
}
}
}

0 comments on commit 3627e93

Please sign in to comment.