调优化供应商用户列表的请求接口和加载状态处理。
This commit is contained in:
@ -23,12 +23,18 @@ const Index: React.FC<{}> = () => {
|
|||||||
{
|
{
|
||||||
title: '组织名称',
|
title: '组织名称',
|
||||||
dataIndex: 'orgName',
|
dataIndex: 'orgName',
|
||||||
width: '45%',
|
width: '35%',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '组织全称',
|
title: '组织全称',
|
||||||
dataIndex: 'orgFullName',
|
dataIndex: 'orgFullName',
|
||||||
width: '40%',
|
width: '30%',
|
||||||
|
hideInSearch: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '公司级别',
|
||||||
|
dataIndex: 'companyLevelText',
|
||||||
|
width: '25%',
|
||||||
hideInSearch: true,
|
hideInSearch: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -132,6 +138,12 @@ const Index: React.FC<{}> = () => {
|
|||||||
<Form.Item label="组织编码" name="orgNum" rules={[{ required: true }]}>
|
<Form.Item label="组织编码" name="orgNum" rules={[{ required: true }]}>
|
||||||
<Input />
|
<Input />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item label="公司级别代码" name="companyLevelCode">
|
||||||
|
<Input placeholder="请输入公司级别代码" />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item label="公司级别名称" name="companyLevelText">
|
||||||
|
<Input placeholder="请输入公司级别名称" />
|
||||||
|
</Form.Item>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
@ -103,6 +103,7 @@ const LoginLog: React.FC = () => {
|
|||||||
title: '登录IP',
|
title: '登录IP',
|
||||||
dataIndex: 'loginIp',
|
dataIndex: 'loginIp',
|
||||||
width: 140,
|
width: 140,
|
||||||
|
search: false,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
render: (text) => (
|
render: (text) => (
|
||||||
<Tooltip title={text}>
|
<Tooltip title={text}>
|
||||||
@ -114,6 +115,7 @@ const LoginLog: React.FC = () => {
|
|||||||
title: '登录状态',
|
title: '登录状态',
|
||||||
dataIndex: 'loginStatus',
|
dataIndex: 'loginStatus',
|
||||||
width: 100,
|
width: 100,
|
||||||
|
search: false,
|
||||||
valueType: 'select',
|
valueType: 'select',
|
||||||
valueEnum: {
|
valueEnum: {
|
||||||
1: { text: '成功' },
|
1: { text: '成功' },
|
||||||
@ -129,6 +131,7 @@ const LoginLog: React.FC = () => {
|
|||||||
title: '登录方式',
|
title: '登录方式',
|
||||||
dataIndex: 'loginType',
|
dataIndex: 'loginType',
|
||||||
width: 100,
|
width: 100,
|
||||||
|
search: false,
|
||||||
valueType: 'select',
|
valueType: 'select',
|
||||||
valueEnum: {
|
valueEnum: {
|
||||||
'PASSWORD': { text: '密码登录' },
|
'PASSWORD': { text: '密码登录' },
|
||||||
@ -271,8 +274,8 @@ const LoginLog: React.FC = () => {
|
|||||||
// 构建查询参数
|
// 构建查询参数
|
||||||
const buildQueryParams = (params: any): LoginLogQueryParams => {
|
const buildQueryParams = (params: any): LoginLogQueryParams => {
|
||||||
const basePageRequest: BasePageRequest = {
|
const basePageRequest: BasePageRequest = {
|
||||||
current: params.current || 1,
|
pageNo: params.current || 1,
|
||||||
size: params.pageSize || 10,
|
pageSize: params.pageSize || 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
const queryParams: LoginLogQueryParams = {
|
const queryParams: LoginLogQueryParams = {
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
// 基础分页请求
|
// 基础分页请求
|
||||||
export interface BasePageRequest {
|
export interface BasePageRequest {
|
||||||
current: number; // 当前页码
|
pageNo: number; // 当前页码
|
||||||
size: number; // 每页大小
|
pageSize: number; // 每页大小
|
||||||
}
|
}
|
||||||
|
|
||||||
// 登录日志查询参数
|
// 登录日志查询参数
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { PlusOutlined } from '@ant-design/icons';
|
import { PlusOutlined } from '@ant-design/icons';
|
||||||
import { Button, message, Popconfirm } from 'antd';
|
import { Button, message, Popconfirm, Spin } from 'antd';
|
||||||
import React, { useState, useRef, useEffect } from 'react';
|
import React, { useState, useRef, useEffect } from 'react';
|
||||||
import { PageContainer } from '@ant-design/pro-layout';
|
import { PageContainer } from '@ant-design/pro-layout';
|
||||||
import type { ProColumns, ActionType } from '@ant-design/pro-table';
|
import type { ProColumns, ActionType } from '@ant-design/pro-table';
|
||||||
@ -7,11 +7,19 @@ import ProTable from '@ant-design/pro-table';
|
|||||||
import type { SupplierUserListItem } from './data.d';
|
import type { SupplierUserListItem } from './data.d';
|
||||||
import { getSupplierUserList, updateSupplierUser, resetPassword } from './service';
|
import { getSupplierUserList, updateSupplierUser, resetPassword } from './service';
|
||||||
import UpdateForm from './components/UpdateForm';
|
import UpdateForm from './components/UpdateForm';
|
||||||
|
import tableProps from '@/utils/tableProps';
|
||||||
|
import '@/assets/xsy_style.less';
|
||||||
|
|
||||||
const SupplierUser: React.FC = () => {
|
const SupplierUser: React.FC = () => {
|
||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
|
||||||
const [formValues, setFormValues] = useState({});
|
const [formValues, setFormValues] = useState({});
|
||||||
|
const [spin, spinSet] = useState<boolean>(false);
|
||||||
|
//查询分页数据
|
||||||
|
const [pageData, pageDataSet] = useState<any>({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10
|
||||||
|
});
|
||||||
|
|
||||||
// 从URL查询参数获取并保存必要的参数
|
// 从URL查询参数获取并保存必要的参数
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -77,28 +85,33 @@ const SupplierUser: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const columns: ProColumns<SupplierUserListItem>[] = [
|
const columns: ProColumns<SupplierUserListItem>[] = [
|
||||||
|
{ title: '序号', valueType: 'index', width: 50, },
|
||||||
{
|
{
|
||||||
title: '用户名',
|
title: '用户名',
|
||||||
dataIndex: 'username',
|
dataIndex: 'username',
|
||||||
sorter: true,
|
sorter: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '姓名',
|
title: '名称',
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
sorter: true,
|
sorter: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '供应商名称',
|
title: '供应商名称',
|
||||||
dataIndex: 'supplierName',
|
dataIndex: 'supplierName',
|
||||||
|
search: false,
|
||||||
|
hideInTable: true,
|
||||||
sorter: true,
|
sorter: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '统一信用代码',
|
title: '统一信用代码',
|
||||||
dataIndex: 'creditCode',
|
dataIndex: 'creditCode',
|
||||||
|
search: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '手机号',
|
title: '手机号',
|
||||||
dataIndex: 'mobile',
|
dataIndex: 'mobile',
|
||||||
|
search: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '状态',
|
title: '状态',
|
||||||
@ -112,66 +125,78 @@ const SupplierUser: React.FC = () => {
|
|||||||
title: '操作',
|
title: '操作',
|
||||||
dataIndex: 'option',
|
dataIndex: 'option',
|
||||||
valueType: 'option',
|
valueType: 'option',
|
||||||
|
width: '15%',
|
||||||
render: (_, record) => [
|
render: (_, record) => [
|
||||||
<a
|
<Button type='text' key="config" onClick={() => {
|
||||||
key="config"
|
handleUpdateModalVisible(true);
|
||||||
onClick={() => {
|
setFormValues(record);
|
||||||
handleUpdateModalVisible(true);
|
}}>
|
||||||
setFormValues(record);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
修改
|
修改
|
||||||
</a>,
|
</Button>,
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
title="确认重置该用户的密码?"
|
title="确认重置该用户的密码?"
|
||||||
onConfirm={() => handleResetPassword(record.username)}
|
onConfirm={() => handleResetPassword(record.username)}
|
||||||
key="reset"
|
key="reset"
|
||||||
>
|
>
|
||||||
<a>重置密码</a>
|
<Button type='text'>重置密码</Button>
|
||||||
</Popconfirm>,
|
</Popconfirm>,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer>
|
<Spin spinning={spin}>
|
||||||
<ProTable<SupplierUserListItem>
|
<div style={{ maxHeight: innerHeight - 130, height: innerHeight - 130 }} className='xsy-entrust bgCWhite'>
|
||||||
headerTitle="供应商用户列表"
|
<ProTable<SupplierUserListItem>
|
||||||
actionRef={actionRef}
|
actionRef={actionRef}
|
||||||
rowKey="userId"
|
rowKey="userId"
|
||||||
search={{
|
columns={columns}
|
||||||
labelWidth: 120,
|
options={false}
|
||||||
}}
|
bordered={false}
|
||||||
request={(params) =>
|
className='tableSearch'
|
||||||
getSupplierUserList(params).then((res) => {
|
size='small'
|
||||||
return {
|
search={{ labelWidth: 'auto', span: 6 }}
|
||||||
data: res.data.records,
|
request={(params) =>
|
||||||
success: true,
|
getSupplierUserList({
|
||||||
total: res.data.total,
|
...params,
|
||||||
};
|
}).then((res) => {
|
||||||
})
|
const result = {
|
||||||
}
|
data: res.data.records,
|
||||||
columns={columns}
|
total: res.data.total,
|
||||||
/>
|
success: res.success,
|
||||||
<UpdateForm
|
pageSize: res.data.size,
|
||||||
onSubmit={async (value) => {
|
current: res.data.current
|
||||||
const success = await handleUpdate(value);
|
}
|
||||||
if (success) {
|
return result;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
pagination={{
|
||||||
|
...tableProps.pagination,
|
||||||
|
onChange: (page, pageSize) => pageDataSet({ pageNo: page, pageSize: pageSize }),
|
||||||
|
onShowSizeChange: (current, size) => pageDataSet({ pageNo: current, pageSize: size }),
|
||||||
|
}}
|
||||||
|
onReset={() => { pageDataSet({ pageNo: 1, pageSize: 10 }) }}
|
||||||
|
/>
|
||||||
|
<UpdateForm
|
||||||
|
onSubmit={async (value) => {
|
||||||
|
const success = await handleUpdate(value);
|
||||||
|
if (success) {
|
||||||
|
handleUpdateModalVisible(false);
|
||||||
|
setFormValues({});
|
||||||
|
if (actionRef.current) {
|
||||||
|
actionRef.current.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onCancel={() => {
|
||||||
handleUpdateModalVisible(false);
|
handleUpdateModalVisible(false);
|
||||||
setFormValues({});
|
setFormValues({});
|
||||||
if (actionRef.current) {
|
}}
|
||||||
actionRef.current.reload();
|
updateModalVisible={updateModalVisible}
|
||||||
}
|
values={formValues}
|
||||||
}
|
/>
|
||||||
}}
|
</div>
|
||||||
onCancel={() => {
|
</Spin>
|
||||||
handleUpdateModalVisible(false);
|
|
||||||
setFormValues({});
|
|
||||||
}}
|
|
||||||
updateModalVisible={updateModalVisible}
|
|
||||||
values={formValues}
|
|
||||||
/>
|
|
||||||
</PageContainer>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,22 +2,28 @@ import request from '@/utils/request';
|
|||||||
import type { SupplierUserListItem, TableListParams } from './data.d';
|
import type { SupplierUserListItem, TableListParams } from './data.d';
|
||||||
|
|
||||||
export async function getSupplierUserList(params: TableListParams) {
|
export async function getSupplierUserList(params: TableListParams) {
|
||||||
return request('/sys/supplier/user/list', {
|
return request('/api/sys-manager-ebtp-project/v1/supplieruser/getPage', {
|
||||||
method: 'GET',
|
method: 'POST',
|
||||||
params,
|
data: {
|
||||||
|
...params,
|
||||||
|
basePageRequest: {
|
||||||
|
pageNo: params.current || 1,
|
||||||
|
pageSize: params.pageSize || 10,
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateSupplierUser(params: SupplierUserListItem) {
|
export async function updateSupplierUser(params: SupplierUserListItem) {
|
||||||
return request('/sys/supplier/user/update', {
|
return request('/api/sys-manager-ebtp-project/v1/supplieruser/update', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: params,
|
data: params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function resetPassword(username: string) {
|
export async function resetPassword(username: string) {
|
||||||
return request('/sys/supplier/user/reset-password', {
|
return request('/api/sys-manager-ebtp-project/v1/supplieruser/resetPassword', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { username },
|
params: { username },
|
||||||
});
|
});
|
||||||
}
|
}
|
Reference in New Issue
Block a user