edit Item Management

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

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

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

@ -1,10 +1,10 @@
import request from '@/utils';
const fetchTenantList = async (
const fetchItemList = async (
pageProps: { current: number; pageSize: number },
formData: { tencent: string | number }
): 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',
headers: {
Authorization:
@ -22,16 +22,24 @@ const fetchTenantList = async (
if (res && res.success) {
return {
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 || '服务器开小差啦~');
};
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', {
method: 'POST',
params: { id },
body: { ...params },
});
if (res && res.success) {
@ -40,22 +48,10 @@ const fetchAddTenant = async (id: string) => {
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchDeleteTenant = async (id: string) => {
const res = await request('/tenants', {
method: 'POST',
params: { id },
});
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 },
const fetchDeleteItem = async (id: string) => {
const url = 'hippo4j/v1/cs/item/delete/prescription/' + id;
const res = await request(url, {
method: 'DELETE',
});
if (res && res.success) {
@ -64,8 +60,8 @@ const fetchUpdateTenant = async (id: string) => {
throw new Error(res.msg || '服务器开小差啦~');
};
const fetchTenantDetail = async (id: string) => {
const res = await request('/tenants', {
const fetchUpdateItem = async (id: string) => {
const res = await request('/hippo4j/v1/cs/item/update', {
method: 'POST',
params: { id },
});
@ -76,4 +72,4 @@ const fetchTenantDetail = async (id: string) => {
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 { 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 React, { useState } from 'react';
import { fetchTenantList } from './service';
import { fetchUserList } from './service';
import { useUrlSet } from '@/hooks/useUrlSet';
import style from './index.module.less';
const baseColumns = [
{
title: '序号',
dataIndex: 'id',
dataIndex: 'index',
},
{
title: '租户',
dataIndex: 'tenantId',
title: '用户名',
dataIndex: 'userName',
},
{
title: '租户名称',
dataIndex: 'tenantName',
title: '角色',
dataIndex: 'role',
},
{
title: '负责人',
dataIndex: 'owner',
title: '创建时间',
dataIndex: 'gmtCreate',
},
{
title: '修改时间',
@ -34,7 +34,7 @@ const Tenant: React.FC = () => {
const [type, setType] = useState('add');
const [form] = Form.useForm();
const { setUrl } = useUrlSet({ form });
const { tableProps, search } = useAntdTable(fetchTenantList, { form });
const { tableProps, search } = useAntdTable(fetchUserList, { form });
// const {run: delete} = useRequest(fetchDeleteTenant, { manual: true });
const actions = (type: string, item?: any) => {
switch (type) {
@ -70,7 +70,7 @@ const Tenant: React.FC = () => {
<Row>
<Col span={6}>
<Form.Item name="note">
<Input placeholder="租户" />
<Input placeholder="用户名" />
</Form.Item>
</Col>
<Col span={18}>
@ -92,7 +92,7 @@ const Tenant: React.FC = () => {
<Table
{...tableProps}
bordered
rowKey="id"
rowKey="index"
columns={[
...baseColumns,
{

@ -1,10 +1,10 @@
import request from '@/utils';
const fetchTenantList = async (
const fetchUserList = async (
pageProps: { current: number; pageSize: number },
formData: { tencent: string | number }
): 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',
headers: {
Authorization:
@ -16,13 +16,12 @@ const fetchTenantList = async (
...formData,
current: pageProps.current,
size: pageProps.pageSize,
desc: true,
},
});
if (res && res.success) {
return {
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 || '服务器开小差啦~');
@ -76,4 +75,4 @@ const fetchTenantDetail = async (id: string) => {
throw new Error(res.msg || '服务器开小差啦~');
};
export { fetchTenantList, fetchAddTenant, fetchDeleteTenant, fetchUpdateTenant, fetchTenantDetail };
export { fetchUserList, fetchAddTenant, fetchDeleteTenant, fetchUpdateTenant, fetchTenantDetail };

Loading…
Cancel
Save