Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
前端-吴智勇
jinfa-platform
Commits
16cbb684
Commit
16cbb684
authored
May 12, 2021
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 添加 ButtonSwitch 按钮切换组件
parent
fc0a216f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
108 additions
and
29 deletions
+108
-29
index.less
src/components/ButtonSwitch/index.less
+19
-0
index.tsx
src/components/ButtonSwitch/index.tsx
+86
-0
index.less
src/pages/afterService/components/FlowRecords/index.less
+0
-19
index.tsx
src/pages/afterService/components/FlowRecords/index.tsx
+3
-10
No files found.
src/components/ButtonSwitch/index.less
0 → 100644
View file @
16cbb684
.button-switch {
:global {
.ant-radio-button-wrapper:hover {
color: #6B778C;
}
.ant-radio-group-solid {
.ant-radio-button-wrapper-checked {
background: #6B778C;
border-color: #6B778C;
&:hover {
background: #6B778C;
border-color: #6B778C;
}
}
}
}
}
\ No newline at end of file
src/components/ButtonSwitch/index.tsx
0 → 100644
View file @
16cbb684
/*
* @Author: XieZhiXiong
* @Date: 2021-05-12 11:04:26
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-05-12 11:21:04
* @Description: 按钮切换器
*/
import
React
,
{
useState
,
useEffect
}
from
'react'
;
import
{
Radio
}
from
'antd'
;
import
{
RadioChangeEvent
}
from
'antd/lib/radio'
;
import
styles
from
'./index.less'
;
export
interface
OptionItem
{
/**
* 名称
*/
label
:
string
,
/**
* 值
*/
value
:
any
,
}
interface
IProps
{
/**
* 数据
*/
options
:
OptionItem
[],
/**
* 按钮切换触发事件
*/
onChange
?:
(
value
:
any
)
=>
void
,
/**
* 值
*/
value
?:
any
,
}
const
ButtonSwitch
:
React
.
FC
<
IProps
>
=
(
props
:
IProps
)
=>
{
const
{
options
,
onChange
,
value
,
}
=
props
;
const
first
=
options
.
length
?
options
[
0
].
value
:
''
;
const
[
radioValue
,
setRadioValue
]
=
useState
(
first
);
useEffect
(()
=>
{
if
(
'value'
in
props
)
{
setRadioValue
(
value
);
}
},
[
value
]);
const
triggerChange
=
(
next
:
any
)
=>
{
if
(
onChange
)
{
onChange
(
next
);
}
};
const
handleRadioChange
=
(
e
:
RadioChangeEvent
)
=>
{
if
(
!
(
'value'
in
props
))
{
setRadioValue
(
e
.
target
.
value
);
return
;
}
triggerChange
(
e
.
target
.
value
);
};
return
(
<
div
className=
{
styles
[
'button-switch'
]
}
>
<
Radio
.
Group
options=
{
options
}
onChange=
{
handleRadioChange
}
value=
{
radioValue
}
optionType=
"button"
buttonStyle=
"solid"
size=
"small"
/>
</
div
>
);
};
ButtonSwitch
.
defaultProps
=
{
onChange
:
undefined
,
};
export
default
ButtonSwitch
;
src/pages/afterService/components/FlowRecords/index.less
View file @
16cbb684
.flow-records {
:global {
.ant-radio-button-wrapper:hover {
color: #6B778C;
}
.ant-radio-group-solid {
.ant-radio-button-wrapper-checked {
background: #6B778C;
border-color: #6B778C;
&:hover {
background: #6B778C;
border-color: #6B778C;
}
}
}
}
}
\ No newline at end of file
src/pages/afterService/components/FlowRecords/index.tsx
View file @
16cbb684
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Tabs
,
Badge
,
Radio
,
}
from
'antd'
;
import
{
RadioChangeEvent
}
from
'antd/lib/radio'
;
import
PolymericTable
from
'@/components/PolymericTable'
;
import
{
EditableColumns
}
from
'@/components/PolymericTable/interface'
;
import
MellowCard
,
{
MellowCardProps
}
from
'@/components/MellowCard'
;
import
StatusTag
from
'@/components/StatusTag'
;
import
ButtonSwitch
from
'@/components/ButtonSwitch'
;
import
styles
from
'./index.less'
;
export
interface
InnerHistoryItem
{
...
...
@@ -219,8 +217,7 @@ const FlowRecords: React.FC<FlowRecordsProps> = ({
});
};
const
handleRadioChange
=
(
e
:
RadioChangeEvent
)
=>
{
const
{
value
}
=
e
.
target
;
const
handleRadioChange
=
(
value
:
(
'inner'
|
'outer'
))
=>
{
setRadioValue
(
value
);
};
...
...
@@ -245,16 +242,12 @@ const FlowRecords: React.FC<FlowRecordsProps> = ({
<
MellowCard
title=
"流转记录"
extra=
{
(
<
Radio
.
Group
<
ButtonSwitch
options=
{
options
}
onChange=
{
handleRadioChange
}
value=
{
radioValue
}
optionType=
"button"
buttonStyle=
"solid"
size=
"small"
/>
)
}
className=
{
styles
[
'flow-records'
]
}
{
...
rest
}
>
{
outerData
.
data
&&
outerData
.
data
.
length
>
0
?
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment