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 { 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 (
<div className={style.tenant_wrapper}>
@ -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 = () => {
<Button onClick={() => actions('edit', record)} type="link" className={style.opreate_btn}>
</Button>
<Button onClick={() => actions('edit', record)} type="link" className={style.opreate_btn}>
<Button onClick={() => actions('delete', record)} type="link" className={style.opreate_btn}>
</Button>
</Space>
@ -113,6 +131,7 @@ const Tenant: React.FC = () => {
},
]}
/>
<ItemCreate data={curItem} onClose={handleClose} visible={editVisible} type={type} />
</div>
);
};

@ -6,12 +6,6 @@ const fetchItemList = async (
): Promise<{ total: number; list: Array<any> }> => {
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,

Loading…
Cancel
Save