diff --git b/api.ts a/api.ts new file mode 100644 index 0000000..76fdf78 --- /dev/null +++ a/api.ts @@ -0,0 +1,30 @@ +import type { http } from "@/typing/http"; +import { ARCHIVES_HOST } from "@/utils/host"; +import request from "@/utils/request"; + +/** + * @description: 分页获取替换name + * @param {替换name.QueryParams} params + * @return {http.PromisePageResp<替换name.ListVO>} + */ +export function get替换nameListApi(params: 替换name.QueryParams): http.PromisePageResp<替换name.ListVO> { + return request.get(`API url`, { params }); +} + +/** + * @description: 保存替换name + * @param {替换name.ListVO} params + * @return {http.PromiseResp} + */ +export function save替换nameApi(params: 替换name.ListVO): http.PromiseResp { + return request.post(`API url`, params); +} + +/** + * @description: 删除替换name + * @param {number} id + * @return {http.PromiseResp} + */ +export function delete替换nameApi(id: number): http.PromiseResp { + return request.get(`API url`, { params: { id } }); +} diff --git b/components/Filter.tsx a/components/Filter.tsx new file mode 100644 index 0000000..b678ebe --- /dev/null +++ a/components/Filter.tsx @@ -0,0 +1,43 @@ +import React from "react"; +import { Button, Row, Input } from "antd"; +import { PlusOutlined } from "@ant-design/icons"; +import { useStore } from "../index"; +import FeeweeFilterOption from "@/pages/notice/components/FeeweeFilterOption"; + +export default function Filter() { + const { pagination, setOpen } = useStore(); + + return ( + +
+ + pagination.setParams({ keyWords: e.target.value })} + onSearch={() => pagination.setParams({ current: 1 }, true)} + /> + +
+ +
+ ); +} diff --git b/components/List.tsx a/components/List.tsx new file mode 100644 index 0000000..f1e7ae1 --- /dev/null +++ a/components/List.tsx @@ -0,0 +1,46 @@ +import React from "react"; +import { Divider, message, Popconfirm, Popover, Table } from "antd"; +import { delete替换nameApi } from "../api"; +import { useStore } from "../index"; + +export default function List() { + const { pagination, setCurrent, setOpen } = useStore(); + + function editItem(item: 替换name.ListVO) { + setCurrent(item); + setOpen(true); + } + + function deleteItem(id: number) { + const hide = message.loading('删除中,请稍后...', 0); + delete替换nameApi(id) + .then((res) => { + hide(); + message.success(res.result); + pagination.setLoading(true); + }) + .catch((error) => { + hide(); + message.error(error.message); + }); + } + + return ( + + + 替换name.ListVO) => ( + <> + 编辑 + + 确定删除?} onConfirm={() => deleteItem(record.id || -1)}> + 删除 + + + )} + /> +
+ ); +} diff --git b/components/Modal.tsx a/components/Modal.tsx new file mode 100644 index 0000000..62e9113 --- /dev/null +++ a/components/Modal.tsx @@ -0,0 +1,64 @@ +import React, { useEffect, useState } from "react"; +import { Form, Input, message, Modal as AntdModal, Spin } from "antd"; +import { save替换nameApi } from "../api"; +import { useStore } from "../index"; + +export default function Modal() { + const { pagination, current, setCurrent, open, setOpen } = useStore(); + const [form] = Form.useForm(); + const [confirmLoading, setConfirmLoading] = useState(false); + + useEffect(() => { + if (open && current) { + form.setFieldsValue(current); + } else { + form.resetFields(); + } + }, [open, current]); + + function onOk(val: any) { + const hide = message.loading('提交中,请稍后...', 0); + setConfirmLoading(true); + const params: 替换name.ListVO = { + ...val, + id: current?.id, + }; + save替换nameApi(params) + .then((res) => { + hide(); + setConfirmLoading(false); + message.success(res.result); + onCancel(); + pagination.setLoading(true); + }) + .catch((error) => { + hide(); + setConfirmLoading(false); + message.error(error.message); + }); + } + + function onCancel() { + setCurrent(undefined); + setOpen(false); + } + + return ( + 替换name`} + open={open} + maskClosable={false} + onOk={form.submit} + confirmLoading={confirmLoading} + onCancel={onCancel} + > + +
+ + + +
+
+
+ ); +} diff --git b/index.tsx a/index.tsx new file mode 100644 index 0000000..24f1519 --- /dev/null +++ a/index.tsx @@ -0,0 +1,27 @@ +import React from "react"; +import { ConfigProvider } from "antd"; +import zhCN from "antd/lib/locale-provider/zh_CN"; +import { PageHeaderWrapper } from "@ant-design/pro-layout"; +import { createStore } from "@/hooks/moz"; +import store from './store'; +import Filter from './components/Filter'; +import List from './components/List'; +import Modal from './components/Modal'; + +export const { Provider, useStore } = createStore(store); + +export default () => <替换name />; + +function 替换name() { + return ( + + + + + + + + + + ); +} diff --git b/interface.d.ts a/interface.d.ts new file mode 100644 index 0000000..5ab3f23 --- /dev/null +++ a/interface.d.ts @@ -0,0 +1,5 @@ +declare namespace 替换name { + interface QueryParams {} + + interface ListVO {} +} diff --git b/store.ts a/store.ts new file mode 100644 index 0000000..22d6f90 --- /dev/null +++ a/store.ts @@ -0,0 +1,17 @@ +import { useState } from 'react'; +import usePagination from "@/hooks/usePagination"; +import { get替换nameListApi } from "./api"; + +export default function useStore() { + const pagination = usePagination(get替换nameListApi); + const [open, setOpen] = useState(false); + const [current, setCurrent] = useState<替换name.ListVO>(); + + return { + pagination, + open, + setOpen, + current, + setCurrent, + }; +}