issue的开始/结束日期下拉框

This commit is contained in:
caishi 2023-06-08 14:47:00 +08:00
commit c7569e3c08
1 changed files with 11 additions and 2 deletions

View File

@ -17,6 +17,12 @@ function Date({name , today , setDate , editFlag},ref){
const refFa = useRef(null);
const refBox = useRef(null);
useEffect(()=>{
if(!visible){
setDate(time);
}
},[visible])
useEffect(() => {
document.addEventListener('click', clickMe , false);
@ -29,7 +35,8 @@ function Date({name , today , setDate , editFlag},ref){
if (faComponent && boxComponent) {
const isChild = faComponent.contains(target);
const isBox = boxComponent.contains(target);
if(!isChild && !isBox){
let role = target.getAttribute("role");
if(!isChild && !isBox && !(role && role === "option")){
setVisible(false);
}
}
@ -78,7 +85,7 @@ function Date({name , today , setDate , editFlag},ref){
<Row type="flex" justify="space-between">
<Col>
<Group size="small" onChange={e => onTypeChange(e.target.value)} value={type}>
<Group size="small" onChange={e => {console.log("typyCHange:",e);onTypeChange(e.target.value)}} value={type}>
<Button value="month">日期</Button>
<Button value="year">月份</Button>
</Group>
@ -91,6 +98,7 @@ function Date({name , today , setDate , editFlag},ref){
style={{ width: 80 }}
onChange={newYear => {
const now = value.clone().year(newYear);
setTime(moment(now).format('YYYY-MM-DD'));
onChange(now);
}}
value={String(year)}
@ -106,6 +114,7 @@ function Date({name , today , setDate , editFlag},ref){
onChange={selectedMonth => {
const newValue = value.clone();
newValue.month(parseInt(selectedMonth, 10));
setTime(moment(newValue).format('YYYY-MM-DD'));
onChange(newValue);
}}
>