edit tenant

pull/1477/head
hutanglong 2 years ago
parent b46f098e29
commit 9f2af3f23f

@ -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 (
<Modal open={visible} onCancel={onClose} footer={null} width={600} title={type === 'edit' ? '编辑' : '创建'}>
<Form>
<Form.Item label="租户" name="">
{/* <Select options={tenant}></Select> */}
</Form.Item>
<Form.Item label="项目" name="">
<Input />
</Form.Item>
<Form.Item label="负责人" name="">
<Input />
</Form.Item>
</Form>
</Modal>
);
};
export default ItemCreate;

@ -1,27 +1,37 @@
import { useAntdTable } from 'ahooks'; 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 { SearchOutlined, EditOutlined } from '@ant-design/icons';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { fetchItemList } from './service'; import { fetchItemList } from './service';
import { useUrlSet } from '@/hooks/useUrlSet'; import { useUrlSet } from '@/hooks/useUrlSet';
import style from './index.module.less'; import style from './index.module.less';
import ItemCreate from './create';
const baseColumns = [ const baseColumns = [
{ {
title: '序号', title: '序号',
dataIndex: 'index', dataIndex: 'index',
with: 200,
}, },
{ {
title: '租户', title: '租户',
dataIndex: 'tenantId', dataIndex: 'tenantId',
with: 200,
},
{
title: '项目',
dataIndex: 'itemId',
with: 200,
}, },
{ {
title: '项目名称', title: '项目名称',
dataIndex: 'itemName', dataIndex: 'itemName',
with: 200,
}, },
{ {
title: '负责人', title: '负责人',
dataIndex: 'owner', dataIndex: 'owner',
with: 200,
}, },
{ {
title: '修改时间', title: '修改时间',
@ -32,37 +42,44 @@ const baseColumns = [
const Tenant: React.FC = () => { const Tenant: React.FC = () => {
const [editVisible, setEditVisible] = useState(false); const [editVisible, setEditVisible] = useState(false);
const [type, setType] = useState('add'); const [type, setType] = useState('add');
const [curItem, setCurItem] = useState({});
const [form] = Form.useForm(); const [form] = Form.useForm();
const { setUrl } = useUrlSet({ form }); const { setUrl } = useUrlSet({ form });
const { tableProps, search } = useAntdTable(fetchItemList, { form }); const { tableProps, search } = useAntdTable(fetchItemList, { form });
// const {run: delete} = useRequest(fetchDeleteTenant, { manual: true }); // 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) => { const actions = (type: string, item?: any) => {
switch (type) { switch (type) {
case 'add': case 'add':
setType('add');
setEditVisible(true); setEditVisible(true);
break; break;
case 'edit': case 'edit':
setType('edit');
setCurItem(item);
setEditVisible(true); setEditVisible(true);
break; break;
case 'delete': case 'delete':
// handleDelete(); handleDelete(item);
break; break;
default: default:
break; break;
} }
}; };
const handleSearch = () => { const handleClose = () => {
setUrl(); setEditVisible(false);
search.submit();
}; };
// const handleDelete = (item: any) => {
// Modal.confirm({
// title: `此操作将删除${item.tenantName}, 是否继续?`,
// onOk: () => {
// search.submit();
// },
// });
// };
return ( return (
<div className={style.tenant_wrapper}> <div className={style.tenant_wrapper}>
@ -93,6 +110,7 @@ const Tenant: React.FC = () => {
{...tableProps} {...tableProps}
bordered bordered
rowKey="index" rowKey="index"
scroll={{ x: 1000 }}
columns={[ columns={[
...baseColumns, ...baseColumns,
{ {
@ -104,7 +122,7 @@ const Tenant: React.FC = () => {
<Button onClick={() => actions('edit', record)} type="link" className={style.opreate_btn}> <Button onClick={() => actions('edit', record)} type="link" className={style.opreate_btn}>
</Button> </Button>
<Button onClick={() => actions('edit', record)} type="link" className={style.opreate_btn}> <Button onClick={() => actions('delete', record)} type="link" className={style.opreate_btn}>
</Button> </Button>
</Space> </Space>
@ -113,6 +131,7 @@ const Tenant: React.FC = () => {
}, },
]} ]}
/> />
<ItemCreate data={curItem} onClose={handleClose} visible={editVisible} type={type} />
</div> </div>
); );
}; };

@ -6,12 +6,6 @@ const fetchItemList = async (
): Promise<{ total: number; list: Array<any> }> => { ): Promise<{ total: number; list: Array<any> }> => {
const res: any = await request('/hippo4j/v1/cs/item/query/page', { const res: any = await request('/hippo4j/v1/cs/item/query/page', {
method: 'POST', method: 'POST',
headers: {
Authorization:
'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ',
cookie:
'Admin-Token=Bearer%20eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI3LGJhb3hpbnlpX2FkbWluIiwiaXNzIjoiYWRtaW4iLCJleHAiOjE2OTUzOTg4NDksImlhdCI6MTY5NDc5NDA0OSwicm9sIjoiUk9MRV9BRE1JTiJ9.syRDshKpd-xETsSdeMPRtk956f4BJkPt4utVsUl4smgH71Woj8SUq4w2RX1YtGTC4aTZRJYdKOfkTqwK0g_dHQ; userName=baoxinyi_admin',
},
body: { body: {
...formData, ...formData,
current: pageProps.current, current: pageProps.current,

Loading…
Cancel
Save