Commit ff907ca4 authored by Chunchi Che's avatar Chunchi Che

update checkCardModalV2.tsx

parent a05bea12
Pipeline #21012 passed with stages
in 21 minutes and 15 seconds
...@@ -32,10 +32,10 @@ const CheckCardModal = () => { ...@@ -32,10 +32,10 @@ const CheckCardModal = () => {
const cancelResponse = useAppSelector(selectCheckCardModalCacnelResponse); const cancelResponse = useAppSelector(selectCheckCardModalCacnelResponse);
const [response, setResponse] = useState<number[]>([]); const [response, setResponse] = useState<number[]>([]);
const defaultValue: number[] = []; const defaultValue: number[] = [];
// Draggable 相关 // Draggable 相关
const [draggable, setDraggable] = useState(false); const [draggable, setDraggable] = useState(false);
const draggleRef = useRef<HTMLDivElement>(null); const draggleRef = useRef<HTMLDivElement>(null);
const onMouseOver = () => { const onMouseOver = () => {
if (draggable) { if (draggable) {
setDraggable(false); setDraggable(false);
...@@ -44,7 +44,6 @@ const CheckCardModal = () => { ...@@ -44,7 +44,6 @@ const CheckCardModal = () => {
const onMouseOut = () => { const onMouseOut = () => {
setDraggable(true); setDraggable(true);
}; };
// TODO: 这里可以考虑更好地封装 // TODO: 这里可以考虑更好地封装
const sendResponseHandler = ( const sendResponseHandler = (
handlerName: string | undefined, handlerName: string | undefined,
......
import React from "react"; import React, { useRef, useState } from "react";
import { useAppSelector } from "../../hook"; import { useAppSelector } from "../../hook";
import { store } from "../../store"; import { store } from "../../store";
import { Modal, Button, Card, Row, Col } from "antd"; import { Button, Card, Row, Col } from "antd";
import { CheckCard } from "@ant-design/pro-components"; import { CheckCard } from "@ant-design/pro-components";
import { import {
selectCheckCardModalV2CancelAble, selectCheckCardModalV2CancelAble,
...@@ -19,6 +19,7 @@ import { ...@@ -19,6 +19,7 @@ import {
setCheckCardModalV2ResponseAble, setCheckCardModalV2ResponseAble,
} from "../../reducers/duel/mod"; } from "../../reducers/duel/mod";
import NeosConfig from "../../../neos.config.json"; import NeosConfig from "../../../neos.config.json";
import DragModal from "./dragModal";
const CheckCardModalV2 = () => { const CheckCardModalV2 = () => {
const dispatch = store.dispatch; const dispatch = store.dispatch;
...@@ -31,35 +32,59 @@ const CheckCardModalV2 = () => { ...@@ -31,35 +32,59 @@ const CheckCardModalV2 = () => {
); );
const selectedOptions = useAppSelector(selectCheckCardModalV2SelectedOptions); const selectedOptions = useAppSelector(selectCheckCardModalV2SelectedOptions);
const responseable = useAppSelector(selectCheckCardModalV2ResponseAble); const responseable = useAppSelector(selectCheckCardModalV2ResponseAble);
// Draggable 相关
const [draggable, setDraggable] = useState(false);
const draggleRef = useRef<HTMLDivElement>(null);
const onMouseOver = () => {
if (draggable) {
setDraggable(false);
}
};
const onMouseOut = () => {
setDraggable(true);
};
const onFinish = () => { const onFinish = () => {
sendSelectUnselectCardResponse({ cancel_or_finish: true }); sendSelectUnselectCardResponse({ cancel_or_finish: true });
dispatch(setCheckCardModalV2IsOpen(false)); dispatch(setCheckCardModalV2IsOpen(false));
dispatch(resetCheckCardModalV2()); dispatch(resetCheckCardModalV2());
dispatch(setCheckCardModalV2ResponseAble(false)); dispatch(setCheckCardModalV2ResponseAble(false));
}; };
const onCancel = () => { const onCancel = () => {
sendSelectUnselectCardResponse({ cancel_or_finish: true }); sendSelectUnselectCardResponse({ cancel_or_finish: true });
dispatch(setCheckCardModalV2ResponseAble(false)); dispatch(setCheckCardModalV2ResponseAble(false));
}; };
return ( return (
<Modal <DragModal
title={`请选择未选择的卡片,最少${min}张,最多${max}张`} modalProps={{
open={isOpen} title: `请选择未选择的卡片,最少${min}张,最多${max}张`,
closable={false} open: isOpen,
footer={ closable: false,
<> footer: (
<Button disabled={!finishable || !responseable} onClick={onFinish}> <>
finish <Button
</Button> disabled={!finishable || !responseable}
<Button disabled={!cancelable || !responseable} onClick={onCancel}> onClick={onFinish}
cancel onMouseOver={onMouseOver}
</Button> onMouseOut={onMouseOut}
</> >
} finish
width={800} </Button>
<Button
disabled={!cancelable || !responseable}
onClick={onCancel}
onMouseOver={onMouseOver}
onMouseOut={onMouseOut}
>
cancel
</Button>
</>
),
width: 800,
}}
dragRef={draggleRef}
draggable={draggable}
> >
<CheckCard.Group <CheckCard.Group
bordered bordered
...@@ -89,6 +114,8 @@ const CheckCardModalV2 = () => { ...@@ -89,6 +114,8 @@ const CheckCardModalV2 = () => {
/> />
} }
value={option.response} value={option.response}
onMouseEnter={onMouseOver}
onMouseLeave={onMouseOut}
/> />
</Col> </Col>
); );
...@@ -114,7 +141,7 @@ const CheckCardModalV2 = () => { ...@@ -114,7 +141,7 @@ const CheckCardModalV2 = () => {
); );
})} })}
</Row> </Row>
</Modal> </DragModal>
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment