-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
651 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import type { FormInstance } from 'antd'; | ||
import { Alert, Button } from 'antd'; | ||
import type { LTableInstance } from 'lighting-design'; | ||
import { LFormItemInput, LTable } from 'lighting-design'; | ||
import type { FC } from 'react'; | ||
import { useRef, useState } from 'react'; | ||
import { apiGetUserList, columns } from './service'; | ||
|
||
const formItems = [ | ||
<LFormItemInput key="0" name="input4" label="输入框" />, | ||
<LFormItemInput key="1" name="input5" label="输入框" />, | ||
<LFormItemInput key="2" name="input6" label="输入框" />, | ||
<LFormItemInput key="3" name="input7" label="输入框" />, | ||
]; | ||
|
||
const Demo3: FC = () => { | ||
const formRef = useRef<FormInstance>(); | ||
const tableRef = useRef<LTableInstance>(); | ||
|
||
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]); | ||
const onSelectChange = (newSelectedRowKeys: React.Key[]) => { | ||
console.log('selectedRowKeys changed: ', newSelectedRowKeys); | ||
setSelectedRowKeys(newSelectedRowKeys); | ||
}; | ||
const rowSelection = { | ||
preserveSelectedRowKeys: true, | ||
selectedRowKeys, | ||
onChange: onSelectChange, | ||
}; | ||
|
||
return ( | ||
<LTable | ||
rowKey="key" | ||
rowSelection={rowSelection} | ||
tableRef={tableRef} | ||
toolbarLeft={<Button type="primary">新增</Button>} | ||
toolbarRight={<Button type="primary">审批</Button>} | ||
formItems={formItems} | ||
// tableExtra='也可以把 Alert 放这' | ||
tableHeaderRender={() => | ||
selectedRowKeys.length ? ( | ||
<Alert | ||
style={{ marginBottom: 10 }} | ||
message={`已选择 ${selectedRowKeys.length} 项,共 ${ | ||
tableRef.current?.pagination.total || 0 | ||
} 项`} | ||
type="info" | ||
action={ | ||
<a | ||
onClick={() => { | ||
onSelectChange([]); | ||
}} | ||
> | ||
取消选择 | ||
</a> | ||
} | ||
/> | ||
) : null | ||
} | ||
formRef={formRef} | ||
columns={columns} | ||
request={async (params, requestType) => { | ||
const res: Record<string, any> = await apiGetUserList(params); | ||
return { | ||
success: true, | ||
data: res.data, | ||
total: res.total, | ||
}; | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default Demo3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import ScrollTableSelect from './components/ScrollTableSelect'; | ||
|
||
export default function Demo8() { | ||
return ( | ||
<div> | ||
<h5>无线滚动</h5> | ||
{/* <LTrigger width="50%" overlayArrow> | ||
<MyTable2></MyTable2> | ||
</LTrigger> */} | ||
<ScrollTableSelect></ScrollTableSelect> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { useMount } from 'ahooks'; | ||
import { Avatar, Checkbox, message } from 'antd'; | ||
import { LList } from 'lighting-design'; | ||
import React, { useState } from 'react'; | ||
|
||
interface UserItem { | ||
email: string; | ||
gender: string; | ||
name: { | ||
first: string; | ||
last: string; | ||
title: string; | ||
}; | ||
nat: string; | ||
picture: { | ||
large: string; | ||
medium: string; | ||
thumbnail: string; | ||
}; | ||
} | ||
|
||
const fakeDataUrl = | ||
'https://randomuser.me/api/?results=10&inc=id,name,gender,email,nat,picture&noinfo'; | ||
const ContainerHeight = 500; | ||
|
||
const Demo1: React.FC = () => { | ||
const [data, setData] = useState<UserItem[]>([]); | ||
|
||
const appendData = () => { | ||
fetch(fakeDataUrl) | ||
.then((res) => res.json()) | ||
.then((body) => { | ||
setData(data.concat(body.results)); | ||
message.destroy('updatable'); | ||
}); | ||
}; | ||
|
||
useMount(() => { | ||
appendData(); | ||
}); | ||
|
||
const onScrollBottom = () => { | ||
console.log('onScrollBottom'); | ||
message.loading({ | ||
key: 'updatable', | ||
duration: 0, | ||
content: '加载中...', | ||
}); | ||
setTimeout(() => { | ||
appendData(); | ||
}, 1000); | ||
}; | ||
|
||
return ( | ||
<Checkbox.Group | ||
style={{ width: '100%', display: 'block' }} | ||
onChange={(vals) => { | ||
console.log('==vals====>', vals); | ||
}} | ||
> | ||
<LList | ||
dataSource={data} | ||
height={ContainerHeight} | ||
itemMinHeight={10} | ||
rowKey="email" | ||
onScrollBottom={onScrollBottom} | ||
renderItem={(item: UserItem, i) => { | ||
return ( | ||
<Checkbox value={i}> | ||
<div style={{ border: '1px solid', marginBottom: 8 }}> | ||
<Avatar src={item.picture.large} size="small" /> | ||
<div>{item.name.last}</div> | ||
<div>{item.email}</div> | ||
</div> | ||
</Checkbox> | ||
); | ||
}} | ||
/> | ||
</Checkbox.Group> | ||
); | ||
}; | ||
|
||
export default Demo1; |
Oops, something went wrong.