Skip to content

Commit

Permalink
save1
Browse files Browse the repository at this point in the history
  • Loading branch information
markliu2013 committed May 2, 2024
1 parent 3d0c868 commit 3a025dd
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "moneynote-pc",
"version": "1.0.88",
"version": "1.0.89",
"private": true,
"scripts": {
"analyze": "cross-env ANALYZE=1 max build",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en-US/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default {
'action.title': '{action} {title}',
'operation': 'Actions',
'add': 'New ',
'update': 'Update ',
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-CN/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default {
'action.title': '{action}{title}',
'operation': '操作',
'add': '新增',
'update': '修改',
Expand Down
8 changes: 8 additions & 0 deletions src/pages/Account/DataTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import TrashButton from '@/components/TrashButton';
import {selectSingleProp, tableProp} from '@/utils/prop';
import { tableSortFormat } from '@/utils/util';
import ActionForm from './ActionForm';
import NotesForm from './NotesForm';
import AdjustForm from './AdjustForm';
import t from '@/utils/i18n';

Expand Down Expand Up @@ -49,6 +50,10 @@ export default ({ type, actionRef }) => {
show(<ActionForm type={type} actionRef={actionRef} />, 2, record);
};

const notesUpdateHandler = (record) => {
show(<NotesForm actionRef={actionRef} />, 2, record);
};

const adjustHandler = (record) => {
show(<AdjustForm actionRef={actionRef} />, 1, record);
};
Expand Down Expand Up @@ -174,6 +179,9 @@ export default ({ type, actionRef }) => {
<Button type="link" onClick={() => adjustHandler(record)}>
{t('adjust.balance')}
</Button>,
<Button type="link" onClick={() => notesUpdateHandler(record)}>
{t('label.notes')}
</Button>,
],
},
{
Expand Down
47 changes: 47 additions & 0 deletions src/pages/Account/NotesForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {useEffect, useState} from "react";
import {useModel} from "@umijs/max";
import { ProFormTextArea } from '@ant-design/pro-components';
import MyModalForm from '@/components/MyModalForm';
import { updateNotes } from '@/services/account';
import t from '@/utils/i18n';

export default ({ actionRef }) => {

const { currentRow } = useModel('modal');

const [initialValues, setInitialValues] = useState({});
useEffect(() => {
setInitialValues({
notes: currentRow.notes
});
}, [currentRow]);

const successHandler = () => {
actionRef.current?.reload();
}

const requestHandler = async (values) => {
await updateNotes(currentRow.id, values.notes)
}

return (
<>
<MyModalForm
title={ t('action.title', {'action': t('update'), 'title': t('label.notes')} ) }
width={700}
labelWidth={85}
request={requestHandler}
onSuccess={successHandler}
initialValues={initialValues}
>
<ProFormTextArea
name="notes"
label={t('label.notes')}
fieldProps={{
autoSize: { minRows: 20 }
}}
/>
</MyModalForm>
</>
);
}
8 changes: 8 additions & 0 deletions src/services/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ export async function overview() {
method: 'GET',
});
}

export async function updateNotes(id, notes) {
return request(`${prefix}/${id}/updateNotes`, {
method: 'PUT',
data: {"notes": notes},
});

}

0 comments on commit 3a025dd

Please sign in to comment.