Commit e2ade0f6 authored by Chunchi Che's avatar Chunchi Che

fix checkCounterModal

parent 3d7dd366
Pipeline #23475 passed with stages
in 14 minutes and 47 seconds
// 指示器选择弹窗 // 指示器选择弹窗
import { Omit } from "@react-spring/web"; import { Omit } from "@react-spring/web";
import { Button, Card, Col, InputNumber, Row } from "antd"; import { Button, Card, Col, InputNumber, Row } from "antd";
import React, { useState } from "react"; import React, { useEffect, useState } from "react";
import { proxy, useSnapshot } from "valtio"; import { proxy, useSnapshot } from "valtio";
import { fetchStrings, Region, sendSelectCounterResponse } from "@/api"; import { fetchStrings, Region, sendSelectCounterResponse } from "@/api";
...@@ -41,6 +41,10 @@ export const CheckCounterModal = () => { ...@@ -41,6 +41,10 @@ export const CheckCounterModal = () => {
const sum = selected.reduce((sum, current) => sum + current, 0); const sum = selected.reduce((sum, current) => sum + current, 0);
const finishable = sum === min; const finishable = sum === min;
useEffect(() => {
setSelected(new Array(options.length));
}, [options]);
const onFinish = () => { const onFinish = () => {
sendSelectCounterResponse(selected); sendSelectCounterResponse(selected);
rs(); rs();
...@@ -75,10 +79,11 @@ export const CheckCounterModal = () => { ...@@ -75,10 +79,11 @@ export const CheckCounterModal = () => {
max={option.max} max={option.max}
defaultValue={0} defaultValue={0}
onChange={(value) => { onChange={(value) => {
let newSelected = [...selected]; setSelected((prevSelected) => {
newSelected[idx] = value || 0; let newSelected = [...prevSelected];
newSelected[idx] = value ?? 0;
setSelected(newSelected); return newSelected;
});
}} }}
/> />
</Card> </Card>
......
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