-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
106 additions
and
13 deletions.
There are no files selected for viewing
7 changes: 0 additions & 7 deletions
7
src/pages/Clipboard/Panel/components/List/components/Item/components/Text/index.module.scss
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/pages/Clipboard/Panel/components/List/components/RemarkModel/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { ClipboardPanelContext } from "@/pages/Clipboard/Panel"; | ||
import type { ClipboardItem } from "@/types/database"; | ||
import { Form, Input, Modal } from "antd"; | ||
import { find } from "lodash-es"; | ||
|
||
export interface RemarkModalRef { | ||
open: () => void; | ||
} | ||
|
||
interface FormFields { | ||
remark: string; | ||
} | ||
|
||
const RemarkModal = forwardRef<RemarkModalRef>((_, ref) => { | ||
const { state } = useContext(ClipboardPanelContext); | ||
const [open, { toggle }] = useBoolean(); | ||
const [item, setItem] = useState<ClipboardItem>(); | ||
const [form] = Form.useForm<FormFields>(); | ||
|
||
useImperativeHandle(ref, () => ({ | ||
open: () => { | ||
const findItem = find(state.list, { id: state.activeId }); | ||
|
||
form.setFieldsValue({ | ||
remark: findItem?.remark, | ||
}); | ||
|
||
setItem(findItem); | ||
|
||
toggle(); | ||
}, | ||
})); | ||
|
||
const handleOk = () => { | ||
const { remark } = form.getFieldsValue(); | ||
|
||
if (item) { | ||
item.remark = remark; | ||
|
||
updateSQL("history", { id: item.id, remark }); | ||
} | ||
|
||
toggle(); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
forceRender | ||
centered | ||
title="备注" | ||
open={open} | ||
onOk={handleOk} | ||
onCancel={toggle} | ||
> | ||
<Form | ||
form={form} | ||
initialValues={{ remark: item?.remark }} | ||
onFinish={handleOk} | ||
> | ||
<Form.Item name="remark" className="mb-0!"> | ||
<Input placeholder="请输入备注" /> | ||
</Form.Item> | ||
</Form> | ||
</Modal> | ||
); | ||
}); | ||
|
||
export default RemarkModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters