Skip to content

Commit 90e7c8d

Browse files
authored
新增抽屉组件;CTable 和 InputNumber 组件问题修复 (#712)
1 parent bec81bd commit 90e7c8d

26 files changed

Lines changed: 1037 additions & 365 deletions

src/components/c-table/css/basic.less

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@
249249
&-body {
250250
flex: 1;
251251
overflow: auto auto !important;
252-
overflow: overlay overlay !important;
252+
//overflow: overlay overlay !important;
253253
//&::-webkit-scrollbar-thumb {
254254
// background-color: var(--dw-scroll-color, rgba(0, 0, 0, 0)) !important;
255255
//}
@@ -536,6 +536,46 @@
536536
}
537537
}
538538
}
539+
540+
&-sticky {
541+
&-holder {
542+
position: sticky;
543+
z-index: 2;
544+
}
545+
&-scroll {
546+
position: sticky;
547+
bottom: 0;
548+
z-index: 2;
549+
display: flex;
550+
align-items: center;
551+
border-top: 1px solid #f3f3f3;
552+
opacity: 0.6;
553+
transition: transform 0.1s ease-in 0s;
554+
&:hover {
555+
transform: scaleY(1.2);
556+
transform-origin: center bottom;
557+
}
558+
&-bar {
559+
height: 8px;
560+
background-color: #bbb;
561+
border-radius: 4px;
562+
&:hover {
563+
background-color: #999;
564+
}
565+
&-active {
566+
background-color: #999;
567+
}
568+
}
569+
}
570+
}
571+
572+
&-sticky-footer {
573+
position: sticky;
574+
bottom: 0;
575+
background: white;
576+
z-index: 100;
577+
border-top: 1px solid #e8e8e8;
578+
}
539579
}
540580

541581
// 筛选
@@ -612,7 +652,7 @@
612652
//noinspection CssInvalidPropertyValue
613653
.@{prefix}-popover-desc {
614654
max-height: 250px;
615-
overflow-y: overlay;
655+
//overflow-y: overlay;
616656

617657
&::-webkit-scrollbar {
618658
width: 8px !important;

src/components/c-table/css/business.less

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -320,15 +320,15 @@
320320

321321
//解决表头滚动问题(rcTable bug)
322322
&.@{tablePrefixCls}-use-custom-scroll {
323-
.@{tablePrefixCls}-thead {
324-
// 表头最右侧元素 td,在有自定义滚动条时,会导致表头错位,由 css 和 js(setFixedStyle setFooterHeight) 共同控制
325-
td {
326-
&.@{tablePrefixCls}-cell-fix-right,
327-
&.@{tablePrefixCls}-cell-scrollbar {
328-
display: none !important;
329-
}
330-
}
331-
}
323+
//.@{tablePrefixCls}-thead {
324+
// // 表头最右侧元素 td,在有自定义滚动条时,会导致表头错位,由 css 和 js(setFixedStyle setFooterHeight) 共同控制
325+
// td {
326+
// &.@{tablePrefixCls}-cell-fix-right,
327+
// &.@{tablePrefixCls}-cell-scrollbar {
328+
// display: none !important;
329+
// }
330+
// }
331+
//}
332332

333333
// 带边框表格
334334
&.@{tablePrefixCls}-bordered {

src/components/c-table/demos/checkbox.md

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/components/c-table/demos/custom-column-tag.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const columns = [
2222
{ title: '创建时间', dataIndex: 'createTime' },
2323
{
2424
title: '活动分类',
25+
width: 200,
2526
dataIndex: 'category',
2627
render: (category) => {
2728
const styleConfig = {

src/components/c-table/demos/disabled0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const columns = [
3434
function CTableDemo(props) {
3535
return (
3636
<CTable
37-
style={{ width: '100%', height: 360 }}
37+
style={{ width: '100%', height: 400 }}
3838
supportCheckbox
3939
supportPage
4040
rowKey="id"

src/components/c-table/demos/disabled1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const columns = [
4545
export default function CTableDemo() {
4646
return (
4747
<CTable
48-
style={{ width: '100%', height: 360 }}
48+
style={{ width: '100%', height: 400 }}
4949
supportCheckbox
5050
supportPage
5151
rowKey="id" // rowKey 设置为 "",disabledData 可以传递整行数据,例如:rowKey="" disabledData={[data[0], data[8]]}

src/components/c-table/demos/disabled2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const columns = [
4343
export default function CTableDemo() {
4444
return (
4545
<CTable
46-
style={{ width: '100%', height: 360 }}
46+
style={{ width: '100%', height: 400 }}
4747
supportCheckbox
4848
supportPage
4949
rowKey="id"
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
```jsx
2+
3+
/**
4+
* title: 纯前端表格带操作
5+
* desc: 此例子用来解决:纯前端表格,对表格进行增删操作时,表格数据源异常的问题(利用对象的引用特性解决)
6+
*/
7+
import React, { useState, useEffect } from 'react';
8+
import { CTable, Button } from 'cloud-react';
9+
10+
export default function CTableDemo() {
11+
const [data, setData] = useState([
12+
{ id: '121410327', name: '手机号优先继续发送1', createTime: '2021/12/14 10:19:02', creator: 'liyuan.meng', num: '12,222' },
13+
{ id: '121410328', name: 'ouid疲劳度3', createTime: '2021/12/13 15:47:33 ', creator: 'jiaojiao.diao', num: '198' },
14+
{ id: '121410329', name: '继续发送手机1', createTime: '2021/12/13 15:36:42', creator: 'nan.run', num: '1,232' },
15+
{ id: '121408294', name: '继续发送手机2', createTime: '2021/12/13 11:14:40', creator: 'xiaotong.fan', num: '12,122,112' },
16+
{ id: '121407191', name: '继续发送手机3', createTime: '2021/12/13 11:03:05', creator: 'zhenxiao.guo', num: '1000,000' },
17+
]);
18+
19+
// (1)定义一个 buffer 对象,将 data 赋值给 buffer.bufferData,并监听 data 变化更新 buffer
20+
const [buffer] = useState({ bufferData: data });
21+
useEffect(() => {
22+
buffer.bufferData = data;
23+
}, [data]);
24+
25+
// (2)删除操作使用 buffer.bufferData 处理
26+
const onDelete = row => {
27+
const targetIndex = buffer.bufferData.findIndex(item => item.id === row.id);
28+
if (targetIndex > -1) {
29+
buffer.bufferData.splice(targetIndex, 1);
30+
}
31+
setData([...buffer.bufferData]);
32+
}
33+
34+
// (3)新增操作使用 buffer.bufferData 处理
35+
const onAdd = () => {
36+
setData([...buffer.bufferData, { id: new Date().getTime(), name: '手机号优先继续发送1', createTime: '2021/12/14 10:19:02', creator: 'liyuan.meng', num: '12,222' }])
37+
};
38+
39+
const columns = [
40+
{ title: '活动ID', dataIndex: 'id', width: 130 },
41+
{ title: '活动名称', dataIndex: 'name', width: 140 },
42+
{ title: '创建时间', dataIndex: 'createTime', width: 140 },
43+
{ title: '人数', dataIndex: 'num', align: 'right', width: 120 },
44+
{ title: '创建人', dataIndex: 'creator', width: 130 },
45+
{
46+
title: '操作',
47+
dataIndex: 'creator',
48+
width: 100,
49+
render: (_, row) => {
50+
return (
51+
<Button type="text" onClick={() => onDelete(row)}>删除</Button>
52+
)
53+
}
54+
}
55+
];
56+
57+
return (
58+
<div>
59+
<Button style={{ marginBottom: 20 }} onClick={onAdd}>新增数据</Button>
60+
<CTable
61+
maxHeight={260}
62+
columnData={columns}
63+
ajaxData={{ totals: data.length, data }}
64+
/>
65+
</div>
66+
);
67+
}
68+
```

src/components/c-table/demos/goods-table.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
---
2-
order: 1
3-
title: CTable
4-
desc: 默认表格
5-
---
6-
71
```jsx
2+
3+
/**
4+
* title: 商品选择器表格
5+
* desc: 商品选择器表格交互样例
6+
*/
87
import React, { useState, createRef, useEffect, Component } from 'react';
98
import { CTable, Button, Checkbox } from 'cloud-react';
109
import './style/goods.less';

src/components/c-table/demos/page.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export default function CTableDemo() {
4343
const [isEmpty, setIsEmpty] = useState(false);
4444
const [hideEmptyFooter, setHideEmptyFooter] = useState(false);
4545
const [isLoading, setIsLoading] = useState(false);
46+
const [disabled, setDisabled] = useState(false);
4647
const tableRef = useRef();
4748

4849
useEffect(() => {
@@ -52,7 +53,7 @@ export default function CTableDemo() {
5253
return (
5354
<div>
5455
<div style={{ marginBottom: 20, display: 'flex', flexDirection: 'column', gap: 15 }}>
55-
<div style={{ display: 'flex', alignItems: 'center', gap: 15 }}>
56+
<div style={{ display: 'flex', alignItems: 'center', gap: 15, flexWrap: 'wrap' }}>
5657
<Checkbox checked={lightCheckedRow} onChange={checked => {
5758
setLightCheckedRow(checked);
5859
}}>选中行高亮</Checkbox>
@@ -68,6 +69,9 @@ export default function CTableDemo() {
6869
<Checkbox checked={isLoading} onChange={checked => {
6970
setIsLoading(checked);
7071
}}>展示loading</Checkbox>
72+
<Checkbox checked={disabled} onChange={disabled => {
73+
setDisabled(disabled);
74+
}}>禁用选择</Checkbox>
7175
</div>
7276
<div style={{ display: 'flex', alignItems: 'center', gap: 15 }}>
7377
<Button onClick={() => {
@@ -87,6 +91,7 @@ export default function CTableDemo() {
8791
</div>
8892
</div>
8993
<CTable
94+
key={String(disabled)}
9095
style={{ width: '100%', height: 400 }}
9196
ref={tableRef}
9297
supportExpend
@@ -102,6 +107,7 @@ export default function CTableDemo() {
102107
showRefresh={showRefresh}
103108
showTotal={showTotal}
104109
hideEmptyFooter={hideEmptyFooter}
110+
disabled={disabled}
105111
checkedData={checkedData}
106112
columnData={columns}
107113
ajaxData={(params) => {

0 commit comments

Comments
 (0)