From 9f2af3f23f47fb77d7a973ce8307661929ac4ba3 Mon Sep 17 00:00:00 2001 From: hutanglong Date: Sun, 24 Sep 2023 02:53:16 +0800 Subject: [PATCH] edit tenant --- .../console-new/src/page/item/create.tsx | 33 +++++++++++++ .../console-new/src/page/item/index.tsx | 47 +++++++++++++------ .../console-new/src/page/item/service.ts | 6 --- 3 files changed, 66 insertions(+), 20 deletions(-) create mode 100644 threadpool/console-new/src/page/item/create.tsx diff --git a/threadpool/console-new/src/page/item/create.tsx b/threadpool/console-new/src/page/item/create.tsx new file mode 100644 index 00000000..860aef60 --- /dev/null +++ b/threadpool/console-new/src/page/item/create.tsx @@ -0,0 +1,33 @@ +import { useRequest } from 'ahooks'; +import { Form, Modal, Input, Select } from 'antd'; +import React from 'react'; +import { fetchTenantList } from '../tenant/service'; + +const ItemCreate: React.FC<{ + type: string; + data: any; + visible: boolean; + onClose: () => void; +}> = props => { + const { visible, onClose, data, type } = props; + const { data: tenant } = useRequest(fetchTenantList); + console.log('tenant', tenant); + + return ( + +
+ + {/* */} + + + + + + + +
+
+ ); +}; + +export default ItemCreate; diff --git a/threadpool/console-new/src/page/item/index.tsx b/threadpool/console-new/src/page/item/index.tsx index 8684894a..ea506206 100644 --- a/threadpool/console-new/src/page/item/index.tsx +++ b/threadpool/console-new/src/page/item/index.tsx @@ -1,27 +1,37 @@ import { useAntdTable } from 'ahooks'; -import { Button, Form, Input, Row, Space, Table, Col } from 'antd'; +import { Button, Form, Input, Row, Space, Table, Col, Modal } from 'antd'; import { SearchOutlined, EditOutlined } from '@ant-design/icons'; import React, { useState } from 'react'; import { fetchItemList } from './service'; import { useUrlSet } from '@/hooks/useUrlSet'; import style from './index.module.less'; +import ItemCreate from './create'; const baseColumns = [ { title: '序号', dataIndex: 'index', + with: 200, }, { title: '租户', dataIndex: 'tenantId', + with: 200, + }, + { + title: '项目', + dataIndex: 'itemId', + with: 200, }, { title: '项目名称', dataIndex: 'itemName', + with: 200, }, { title: '负责人', dataIndex: 'owner', + with: 200, }, { title: '修改时间', @@ -32,37 +42,44 @@ const baseColumns = [ const Tenant: React.FC = () => { const [editVisible, setEditVisible] = useState(false); const [type, setType] = useState('add'); + const [curItem, setCurItem] = useState({}); const [form] = Form.useForm(); const { setUrl } = useUrlSet({ form }); const { tableProps, search } = useAntdTable(fetchItemList, { form }); // const {run: delete} = useRequest(fetchDeleteTenant, { manual: true }); + const handleSearch = () => { + setUrl(); + search.submit(); + }; + const handleDelete = (item: any) => { + Modal.confirm({ + title: `此操作将删除${item.itemName}, 是否继续?`, + onOk: () => { + search.submit(); + }, + }); + }; const actions = (type: string, item?: any) => { switch (type) { case 'add': + setType('add'); setEditVisible(true); break; case 'edit': + setType('edit'); + setCurItem(item); setEditVisible(true); break; case 'delete': - // handleDelete(); + handleDelete(item); break; default: break; } }; - const handleSearch = () => { - setUrl(); - search.submit(); + const handleClose = () => { + setEditVisible(false); }; - // const handleDelete = (item: any) => { - // Modal.confirm({ - // title: `此操作将删除${item.tenantName}, 是否继续?`, - // onOk: () => { - // search.submit(); - // }, - // }); - // }; return (
@@ -93,6 +110,7 @@ const Tenant: React.FC = () => { {...tableProps} bordered rowKey="index" + scroll={{ x: 1000 }} columns={[ ...baseColumns, { @@ -104,7 +122,7 @@ const Tenant: React.FC = () => { - @@ -113,6 +131,7 @@ const Tenant: React.FC = () => { }, ]} /> +
); }; diff --git a/threadpool/console-new/src/page/item/service.ts b/threadpool/console-new/src/page/item/service.ts index cd426860..babf4216 100644 --- a/threadpool/console-new/src/page/item/service.ts +++ b/threadpool/console-new/src/page/item/service.ts @@ -6,12 +6,6 @@ const fetchItemList = async ( ): Promise<{ total: number; list: Array }> => { const res: any = await request('/hippo4j/v1/cs/item/query/page', { method: 'POST', - headers: { - Authorization: - 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ', - cookie: - 'Admin-Token=Bearer%20eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ; userName=baoxinyi_admin', - }, body: { ...formData, current: pageProps.current,