feat: 消息中心-站内信管理
This commit is contained in:
@@ -1,25 +1,24 @@
|
||||
import EnhancedProTable from "@/components/EnhancedProTable";
|
||||
import { PlusOutlined } from '@ant-design/icons';
|
||||
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
||||
import { Modal, Popconfirm } from 'antd';
|
||||
import dayjs from 'dayjs';
|
||||
import { ref } from 'process';
|
||||
import React, { createContext, useCallback, useRef, useState } from 'react';
|
||||
import ConfigurableDrawerForm, {
|
||||
type ConfigurableDrawerFormRef,
|
||||
} from '@/components/DrawerForm';
|
||||
import EnhancedProTable from '@/components/EnhancedProTable';
|
||||
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
|
||||
import { formStatusType } from '@/constants';
|
||||
import {
|
||||
getTenantPage,
|
||||
createTenant,
|
||||
deleteTenant,
|
||||
getTenantPage,
|
||||
type TenantPageReqVO,
|
||||
type TenantVO,
|
||||
deleteTenant,
|
||||
updateTenant,
|
||||
} from "@/services/system/tenant/list";
|
||||
import React, { createContext, useCallback } from "react";
|
||||
import ConfigurableDrawerForm, {
|
||||
ConfigurableDrawerFormRef,
|
||||
} from "@/components/DrawerForm";
|
||||
import { useRef, useState } from "react";
|
||||
import { formColumns, baseTenantColumns } from "./config";
|
||||
import { PlusOutlined } from "@ant-design/icons";
|
||||
import { ref } from "process";
|
||||
import { ActionType, ProColumns } from "@ant-design/pro-components";
|
||||
import { ToolbarAction } from "@/components/EnhancedProTable/types";
|
||||
import { Modal, Popconfirm } from "antd";
|
||||
import { formStatusType } from "@/constants";
|
||||
import dayjs from "dayjs";
|
||||
} from '@/services/system/tenant/list';
|
||||
import { baseTenantColumns, formColumns } from './config';
|
||||
export const waitTimePromise = async (time: number = 90) => {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
@@ -30,13 +29,13 @@ export const waitTimePromise = async (time: number = 90) => {
|
||||
const TenantList = () => {
|
||||
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null);
|
||||
const tableRef = useRef<ActionType>(null);
|
||||
const [type, setType] = useState<"create" | "update">("create");
|
||||
const [type, setType] = useState<'create' | 'update'>('create');
|
||||
const [id, setId] = useState<number>(0);
|
||||
const onFetch = async (
|
||||
params: TenantPageReqVO & {
|
||||
pageSize?: number;
|
||||
current?: number;
|
||||
}
|
||||
},
|
||||
) => {
|
||||
await waitTimePromise();
|
||||
const data = await getTenantPage({
|
||||
@@ -53,7 +52,7 @@ const TenantList = () => {
|
||||
|
||||
const handleSubmit = useCallback(
|
||||
async (values: TenantVO) => {
|
||||
if (type === "create") {
|
||||
if (type === 'create') {
|
||||
await createTenant(values);
|
||||
} else {
|
||||
await updateTenant({
|
||||
@@ -65,34 +64,34 @@ const TenantList = () => {
|
||||
tableRef.current?.reload();
|
||||
return true;
|
||||
},
|
||||
[type]
|
||||
[type, id],
|
||||
);
|
||||
|
||||
const handleAdd = () => {
|
||||
setType("create");
|
||||
setType('create');
|
||||
configurableDrawerRef.current?.open({});
|
||||
};
|
||||
const handleEdit = (record: TenantVO) => {
|
||||
setType("update");
|
||||
setType('update');
|
||||
setId(record.id);
|
||||
|
||||
configurableDrawerRef.current?.open(record);
|
||||
};
|
||||
const toolbarActions: ToolbarAction[] = [
|
||||
{
|
||||
key: "add",
|
||||
label: "新建",
|
||||
type: "primary",
|
||||
key: 'add',
|
||||
label: '新建',
|
||||
type: 'primary',
|
||||
icon: <PlusOutlined />,
|
||||
onClick: handleAdd,
|
||||
},
|
||||
];
|
||||
|
||||
const actionColumns: ProColumns<TenantVO> = {
|
||||
title: "操作",
|
||||
dataIndex: "option",
|
||||
valueType: "option",
|
||||
fixed: "right",
|
||||
title: '操作',
|
||||
dataIndex: 'option',
|
||||
valueType: 'option',
|
||||
fixed: 'right',
|
||||
width: 120,
|
||||
render: (text: React.ReactNode, record: TenantVO, _: any, action: any) => [
|
||||
<a key="editable" onClick={() => handleEdit(record)}>
|
||||
|
||||
Reference in New Issue
Block a user