Commit dd4107f0 authored by Chunchi Che's avatar Chunchi Che

update checkCardModalV3.tsx

parent ff907ca4
Pipeline #21013 failed with stages
in 1 minute and 40 seconds
import React, { useState } 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 { sendSelectCardResponse } from "../../api/ocgcore/ocgHelper"; import { sendSelectCardResponse } from "../../api/ocgcore/ocgHelper";
import { import {
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
} from "../../reducers/duel/mod"; } from "../../reducers/duel/mod";
import NeosConfig from "../../../neos.config.json"; import NeosConfig from "../../../neos.config.json";
import { selectCheckCardModalV3 } from "../../reducers/duel/modal/checkCardModalV3Slice"; import { selectCheckCardModalV3 } from "../../reducers/duel/modal/checkCardModalV3Slice";
import DragModal from "./dragModal";
const CheckCardModalV3 = () => { const CheckCardModalV3 = () => {
const dispatch = store.dispatch; const dispatch = store.dispatch;
...@@ -31,14 +32,24 @@ const CheckCardModalV3 = () => { ...@@ -31,14 +32,24 @@ const CheckCardModalV3 = () => {
.concat(selectedOptions) .concat(selectedOptions)
.map((option) => option.level2) .map((option) => option.level2)
.reduce((sum, current) => sum + current, 0); .reduce((sum, current) => sum + current, 0);
// Draggable 相关
const [draggable, setDraggable] = useState(false);
const draggleRef = useRef<HTMLDivElement>(null);
const onMouseOver = () => {
if (draggable) {
setDraggable(false);
}
};
const onMouseOut = () => {
setDraggable(true);
};
const responseable = const responseable =
(overflow (overflow
? Level1Sum >= LevelSum || Level2Sum >= LevelSum ? Level1Sum >= LevelSum || Level2Sum >= LevelSum
: Level1Sum == LevelSum || Level2Sum == LevelSum) && : Level1Sum == LevelSum || Level2Sum == LevelSum) &&
selectedOptions.length <= max && selectedOptions.length <= max &&
selectedOptions.length >= min; selectedOptions.length >= min;
const onFinish = () => { const onFinish = () => {
sendSelectCardResponse( sendSelectCardResponse(
mustSelectOptions.concat(selectedOptions).map((option) => option.response) mustSelectOptions.concat(selectedOptions).map((option) => option.response)
...@@ -49,18 +60,27 @@ const CheckCardModalV3 = () => { ...@@ -49,18 +60,27 @@ const CheckCardModalV3 = () => {
}; };
return ( return (
<Modal <DragModal
title={`请选择卡片,最少${min}张,最多${max}张`} modalProps={{
open={isOpen} title: `请选择卡片,最少${min}张,最多${max}张`,
closable={false} open: isOpen,
footer={ closable: false,
<> footer: (
<Button disabled={!responseable} onClick={onFinish}> <>
finish <Button
</Button> disabled={!responseable}
</> onClick={onFinish}
} onMouseOver={onMouseOver}
width={800} onMouseOut={onMouseOut}
>
finish
</Button>
</>
),
width: 800,
}}
dragRef={draggleRef}
draggable={draggable}
> >
<CheckCard.Group <CheckCard.Group
bordered bordered
...@@ -87,6 +107,8 @@ const CheckCardModalV3 = () => { ...@@ -87,6 +107,8 @@ const CheckCardModalV3 = () => {
/> />
} }
value={option} value={option}
onMouseEnter={onMouseOver}
onMouseLeave={onMouseOut}
/> />
</Col> </Col>
); );
...@@ -112,7 +134,7 @@ const CheckCardModalV3 = () => { ...@@ -112,7 +134,7 @@ const CheckCardModalV3 = () => {
); );
})} })}
</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