|
|
@ -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>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|