Skip to content

Commit

Permalink
feat: 编辑额度支持负数
Browse files Browse the repository at this point in the history
  • Loading branch information
Calcium-Ion committed May 12, 2024
1 parent b427f02 commit d8c0060
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions web/src/pages/User/EditUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const EditUser = (props) => {
const userId = props.editingUser.id;
const [loading, setLoading] = useState(true);
const [addQuotaModalOpen, setIsModalOpen] = useState(false);
const [addQuotaLocal, setAddQuotaLocal] = useState(0);
const [addQuotaLocal, setAddQuotaLocal] = useState('');
const [inputs, setInputs] = useState({
username: '',
display_name: '',
Expand Down Expand Up @@ -111,12 +111,12 @@ const EditUser = (props) => {
};

const addLocalQuota = () => {
let newQuota = parseInt(quota) + addQuotaLocal;
let newQuota = parseInt(quota) + parseInt(addQuotaLocal);
setInputs((inputs) => ({ ...inputs, quota: newQuota }));
};

const openAddQuotaModal = () => {
setAddQuotaLocal(0);
setAddQuotaLocal('0');
setIsModalOpen(true);
};

Expand Down Expand Up @@ -272,12 +272,14 @@ const EditUser = (props) => {
closable={null}
>
<div style={{ marginTop: 20 }}>
<Typography.Text>{`新额度${renderQuota(quota)} + ${renderQuota(addQuotaLocal)} = ${renderQuota(quota + addQuotaLocal)}`}</Typography.Text>
<Typography.Text>{`新额度${renderQuota(quota)} + ${renderQuota(addQuotaLocal)} = ${renderQuota(quota + parseInt(addQuotaLocal))}`}</Typography.Text>
</div>
<Input
name='addQuotaLocal'
placeholder={'需要添加的额度'}
onChange={(value) => setAddQuotaLocal(parseInt(value))}
placeholder={'需要添加的额度(支持负数)'}
onChange={(value) => {
setAddQuotaLocal(value);
}}
value={addQuotaLocal}
type={'number'}
autoComplete='new-password'
Expand Down

0 comments on commit d8c0060

Please sign in to comment.