From 3a025dd920dc450a20a532a75b52232400c14de1 Mon Sep 17 00:00:00 2001 From: markliu2013 Date: Thu, 2 May 2024 18:16:28 +0800 Subject: [PATCH] save1 --- package.json | 2 +- src/locales/en-US/common.ts | 1 + src/locales/zh-CN/common.ts | 1 + src/pages/Account/DataTable.jsx | 8 ++++++ src/pages/Account/NotesForm.jsx | 47 +++++++++++++++++++++++++++++++++ src/services/account.js | 8 ++++++ 6 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/pages/Account/NotesForm.jsx diff --git a/package.json b/package.json index a70c445..ff6c640 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/locales/en-US/common.ts b/src/locales/en-US/common.ts index 0f8620b..1e40f67 100644 --- a/src/locales/en-US/common.ts +++ b/src/locales/en-US/common.ts @@ -1,4 +1,5 @@ export default { + 'action.title': '{action} {title}', 'operation': 'Actions', 'add': 'New ', 'update': 'Update ', diff --git a/src/locales/zh-CN/common.ts b/src/locales/zh-CN/common.ts index 4d09eb1..c5b938b 100644 --- a/src/locales/zh-CN/common.ts +++ b/src/locales/zh-CN/common.ts @@ -1,4 +1,5 @@ export default { + 'action.title': '{action}{title}', 'operation': '操作', 'add': '新增', 'update': '修改', diff --git a/src/pages/Account/DataTable.jsx b/src/pages/Account/DataTable.jsx index 2a52173..b36cf7e 100644 --- a/src/pages/Account/DataTable.jsx +++ b/src/pages/Account/DataTable.jsx @@ -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'; @@ -49,6 +50,10 @@ export default ({ type, actionRef }) => { show(, 2, record); }; + const notesUpdateHandler = (record) => { + show(, 2, record); + }; + const adjustHandler = (record) => { show(, 1, record); }; @@ -174,6 +179,9 @@ export default ({ type, actionRef }) => { , + , ], }, { diff --git a/src/pages/Account/NotesForm.jsx b/src/pages/Account/NotesForm.jsx new file mode 100644 index 0000000..97a1fe0 --- /dev/null +++ b/src/pages/Account/NotesForm.jsx @@ -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 ( + <> + + + + + ); +} diff --git a/src/services/account.js b/src/services/account.js index 50ab8ff..0487648 100644 --- a/src/services/account.js +++ b/src/services/account.js @@ -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}, + }); + +}