edit Item Management

pull/1471/head
hutanglong 2 years ago
parent 1727caca44
commit 89fa0b53b4

@ -5,6 +5,7 @@
"dependencies": { "dependencies": {
"@ahooksjs/use-url-state": "^3.5.1", "@ahooksjs/use-url-state": "^3.5.1",
"@ant-design/icons": "^5.2.6", "@ant-design/icons": "^5.2.6",
"@tanem/react-nprogress": "^5.0.51",
"@testing-library/jest-dom": "^5.16.5", "@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0", "@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",

@ -1,23 +1,23 @@
import { useAntdTable } from 'ahooks'; import { useAntdTable } from 'ahooks';
import { Button, Form, Input, Row, Space, Table, Col, Modal } from 'antd'; import { Button, Form, Input, Row, Space, Table, Col } 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 { fetchTenantList } 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';
const baseColumns = [ const baseColumns = [
{ {
title: '序号', title: '序号',
dataIndex: 'id', dataIndex: 'index',
}, },
{ {
title: '租户', title: '租户',
dataIndex: 'tenantId', dataIndex: 'tenantId',
}, },
{ {
title: '租户名称', title: '项目名称',
dataIndex: 'tenantName', dataIndex: 'itemName',
}, },
{ {
title: '负责人', title: '负责人',
@ -34,7 +34,7 @@ const Tenant: React.FC = () => {
const [type, setType] = useState('add'); const [type, setType] = useState('add');
const [form] = Form.useForm(); const [form] = Form.useForm();
const { setUrl } = useUrlSet({ form }); const { setUrl } = useUrlSet({ form });
const { tableProps, search } = useAntdTable(fetchTenantList, { form }); const { tableProps, search } = useAntdTable(fetchItemList, { form });
// const {run: delete} = useRequest(fetchDeleteTenant, { manual: true }); // const {run: delete} = useRequest(fetchDeleteTenant, { manual: true });
const actions = (type: string, item?: any) => { const actions = (type: string, item?: any) => {
switch (type) { switch (type) {
@ -70,7 +70,7 @@ const Tenant: React.FC = () => {
<Row> <Row>
<Col span={6}> <Col span={6}>
<Form.Item name="note"> <Form.Item name="note">
<Input placeholder="租户" /> <Input placeholder="项目" />
</Form.Item> </Form.Item>
</Col> </Col>
<Col span={18}> <Col span={18}>
@ -92,7 +92,7 @@ const Tenant: React.FC = () => {
<Table <Table
{...tableProps} {...tableProps}
bordered bordered
rowKey="id" rowKey="index"
columns={[ columns={[
...baseColumns, ...baseColumns,
{ {

@ -1,10 +1,10 @@
import request from '@/utils'; import request from '@/utils';
const fetchTenantList = async ( const fetchItemList = async (
pageProps: { current: number; pageSize: number }, pageProps: { current: number; pageSize: number },
formData: { tencent: string | number } formData: { tencent: string | number }
): Promise<{ total: number; list: Array<any> }> => { ): Promise<{ total: number; list: Array<any> }> => {
const res: any = await request('/hippo4j/v1/cs/tenant/query/page', { const res: any = await request('/hippo4j/v1/cs/item/query/page', {
method: 'POST', method: 'POST',
headers: { headers: {
Authorization: Authorization:
@ -22,16 +22,24 @@ const fetchTenantList = async (
if (res && res.success) { if (res && res.success) {
return { return {
total: res.data.total, total: res.data.total,
list: res.data.records, list: res.data.records.map((item: any, index: number) => ({ index: index + 1, ...item })),
}; };
} }
throw new Error(res.msg || '服务器开小差啦~'); throw new Error(res.msg || '服务器开小差啦~');
}; };
const fetchAddTenant = async (id: string) => { const fetchAddTenant = async (params: {
itemDesc: string; // 项目简介
itemId: string; // 项目
itemName: string; // 项目名称
owner: string; // 负责人
tenantId: string; // 租户
tenantDesc?: string;
tenantName?: string;
}) => {
const res = await request('/hippo4j/v1/cs/tenant/save', { const res = await request('/hippo4j/v1/cs/tenant/save', {
method: 'POST', method: 'POST',
params: { id }, body: { ...params },
}); });
if (res && res.success) { if (res && res.success) {
@ -40,22 +48,10 @@ const fetchAddTenant = async (id: string) => {
throw new Error(res.msg || '服务器开小差啦~'); throw new Error(res.msg || '服务器开小差啦~');
}; };
const fetchDeleteTenant = async (id: string) => { const fetchDeleteItem = async (id: string) => {
const res = await request('/tenants', { const url = 'hippo4j/v1/cs/item/delete/prescription/' + id;
method: 'POST', const res = await request(url, {
params: { id }, method: 'DELETE',
});
if (res && res.success) {
return res;
}
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchUpdateTenant = async (id: string) => {
const res = await request('hippo4j/v1/cs/tenant/update', {
method: 'POST',
params: { id },
}); });
if (res && res.success) { if (res && res.success) {
@ -64,8 +60,8 @@ const fetchUpdateTenant = async (id: string) => {
throw new Error(res.msg || '服务器开小差啦~'); throw new Error(res.msg || '服务器开小差啦~');
}; };
const fetchTenantDetail = async (id: string) => { const fetchUpdateItem = async (id: string) => {
const res = await request('/tenants', { const res = await request('/hippo4j/v1/cs/item/update', {
method: 'POST', method: 'POST',
params: { id }, params: { id },
}); });
@ -76,4 +72,4 @@ const fetchTenantDetail = async (id: string) => {
throw new Error(res.msg || '服务器开小差啦~'); throw new Error(res.msg || '服务器开小差啦~');
}; };
export { fetchTenantList, fetchAddTenant, fetchDeleteTenant, fetchUpdateTenant, fetchTenantDetail }; export { fetchItemList, fetchAddTenant, fetchDeleteItem, fetchUpdateItem };

@ -1,27 +1,27 @@
import { useAntdTable } from 'ahooks'; import { useAntdTable } from 'ahooks';
import { Button, Form, Input, Row, Space, Table, Col, Modal } from 'antd'; import { Button, Form, Input, Row, Space, Table, Col } 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 { fetchTenantList } from './service'; import { fetchUserList } from './service';
import { useUrlSet } from '@/hooks/useUrlSet'; import { useUrlSet } from '@/hooks/useUrlSet';
import style from './index.module.less'; import style from './index.module.less';
const baseColumns = [ const baseColumns = [
{ {
title: '序号', title: '序号',
dataIndex: 'id', dataIndex: 'index',
}, },
{ {
title: '租户', title: '用户名',
dataIndex: 'tenantId', dataIndex: 'userName',
}, },
{ {
title: '租户名称', title: '角色',
dataIndex: 'tenantName', dataIndex: 'role',
}, },
{ {
title: '负责人', title: '创建时间',
dataIndex: 'owner', dataIndex: 'gmtCreate',
}, },
{ {
title: '修改时间', title: '修改时间',
@ -34,7 +34,7 @@ const Tenant: React.FC = () => {
const [type, setType] = useState('add'); const [type, setType] = useState('add');
const [form] = Form.useForm(); const [form] = Form.useForm();
const { setUrl } = useUrlSet({ form }); const { setUrl } = useUrlSet({ form });
const { tableProps, search } = useAntdTable(fetchTenantList, { form }); const { tableProps, search } = useAntdTable(fetchUserList, { form });
// const {run: delete} = useRequest(fetchDeleteTenant, { manual: true }); // const {run: delete} = useRequest(fetchDeleteTenant, { manual: true });
const actions = (type: string, item?: any) => { const actions = (type: string, item?: any) => {
switch (type) { switch (type) {
@ -70,7 +70,7 @@ const Tenant: React.FC = () => {
<Row> <Row>
<Col span={6}> <Col span={6}>
<Form.Item name="note"> <Form.Item name="note">
<Input placeholder="租户" /> <Input placeholder="用户名" />
</Form.Item> </Form.Item>
</Col> </Col>
<Col span={18}> <Col span={18}>
@ -92,7 +92,7 @@ const Tenant: React.FC = () => {
<Table <Table
{...tableProps} {...tableProps}
bordered bordered
rowKey="id" rowKey="index"
columns={[ columns={[
...baseColumns, ...baseColumns,
{ {

@ -1,10 +1,10 @@
import request from '@/utils'; import request from '@/utils';
const fetchTenantList = async ( const fetchUserList = async (
pageProps: { current: number; pageSize: number }, pageProps: { current: number; pageSize: number },
formData: { tencent: string | number } formData: { tencent: string | number }
): Promise<{ total: number; list: Array<any> }> => { ): Promise<{ total: number; list: Array<any> }> => {
const res: any = await request('/hippo4j/v1/cs/tenant/query/page', { const res: any = await request('/hippo4j/v1/cs/auth/users/page', {
method: 'POST', method: 'POST',
headers: { headers: {
Authorization: Authorization:
@ -16,13 +16,12 @@ const fetchTenantList = async (
...formData, ...formData,
current: pageProps.current, current: pageProps.current,
size: pageProps.pageSize, size: pageProps.pageSize,
desc: true,
}, },
}); });
if (res && res.success) { if (res && res.success) {
return { return {
total: res.data.total, total: res.data.total,
list: res.data.records, list: res.data.records.map((item: any, index: number) => ({ index: index + 1, ...item })),
}; };
} }
throw new Error(res.msg || '服务器开小差啦~'); throw new Error(res.msg || '服务器开小差啦~');
@ -76,4 +75,4 @@ const fetchTenantDetail = async (id: string) => {
throw new Error(res.msg || '服务器开小差啦~'); throw new Error(res.msg || '服务器开小差啦~');
}; };
export { fetchTenantList, fetchAddTenant, fetchDeleteTenant, fetchUpdateTenant, fetchTenantDetail }; export { fetchUserList, fetchAddTenant, fetchDeleteTenant, fetchUpdateTenant, fetchTenantDetail };

Loading…
Cancel
Save