修复部分问题,分页,刷新,搜索等

master
zhengpengju 4 years ago
parent f3a14c0d97
commit 5b6e67ba61

@ -78,6 +78,7 @@
"nzh": "^1.0.3",
"omit.js": "^2.0.2",
"react": "^17.0.0",
"react-cookies": "^0.1.1",
"react-dev-inspector": "^1.1.1",
"react-dom": "^17.0.0",
"react-fittext": "^1.0.0",

@ -4,11 +4,12 @@ import type { RunTimeLayoutConfig } from 'umi';
import { history, Link } from 'umi';
import RightContent from '@/components/RightContent';
import Footer from '@/components/Footer';
import { currentUser as queryCurrentUser } from './services/ant-design-pro/api';
import { currentUser as queryCurrentUser, queryPersonTxByYw } from './services/ant-design-pro/api';
import { BookOutlined, LinkOutlined } from '@ant-design/icons';
import { RequestConfig } from 'umi';
import { ResponseError } from 'umi-request';
import { notification } from 'antd';
import cookie from 'react-cookies';
const isDev = process.env.NODE_ENV === 'development';
const loginPath = '/user/login';
@ -28,8 +29,20 @@ export async function getInitialState(): Promise<{
}> {
const fetchUserInfo = async () => {
try {
const msg = await queryCurrentUser();
return msg.data;
const msg = await queryCurrentUser({
person_id: cookie.load('person_id'),
identity_id: cookie.load('identity_id'),
u_type: 1, // 用户类型
random_num: new Date().getTime(),
});
const tx = await queryPersonTxByYw({
person_id: cookie.load('person_id'),
identity_id: cookie.load('identity_id'),
u_type: 1, // 用户类型
random_num: new Date().getTime(),
});
console.log('avatar: ',`/dsideal_yy/html/thumb/Material/${tx?.file_id?.substr(0,2)}/${tx?.file_id}.${tx?.extension}`)
return {name: msg?.person_name, userid: msg?.person_id, avatar: `/dsideal_yy/html/thumb/Material/${tx?.file_id?.substr(0,2)}/${tx?.file_id}.${tx?.extension}`};
} catch (error) {
history.push(loginPath);
}

@ -25,7 +25,6 @@ const uuid = uuidv4();
*/
const handleAdd = async (fields: TableListItem) => {
const hide = message.loading('正在添加');
try {
await saveCourse({ ...fields, attachment_filesize:0, attachment_json: `{"img":"", "url": "down/M3u8/${uuid?.substr(0,2)}/${uuid}.m3u8"}` });
hide();
@ -109,6 +108,15 @@ const CourseList: React.FC = () => {
title: '序号',
key: 'index',
valueType: 'indexBorder',
render: (text: React.ReactNode, _: any, index: number) => {
if (actionRef && actionRef?.current && actionRef?.current?.pageInfo) {
return `${
(actionRef?.current?.pageInfo?.current - 1) * actionRef.current.pageInfo?.pageSize + (index + 1)
}`;
} else {
return '';
}
},
width: 48,
},
{
@ -161,7 +169,7 @@ const CourseList: React.FC = () => {
dataIndex: 'course_minutes',
valueType: 'text',
sorter: false,
hideInTable: false,
hideInTable: true,
hideInForm: false,
hideInSearch: true,
renderText: (val: string) => `${val}`,
@ -202,15 +210,6 @@ const CourseList: React.FC = () => {
],
}, // 传递给 Form.Item 的配置
},
{
title: '标签',
dataIndex: 'tag_name',
sorter: false,
valueType: 'select',
hideInForm: true,
renderText: (val: string) => `${val}`,
},
{
title: '标签',
dataIndex: 'tag_id',
@ -239,6 +238,7 @@ const CourseList: React.FC = () => {
title: '视频',
dataIndex: 'attachment_filesize',
sorter: false,
hideInTable: true,
hideInForm: false,
hideInSearch: true,
renderFormItem: () => (
@ -252,7 +252,6 @@ const CourseList: React.FC = () => {
const index = file?.name.lastIndexOf(".");
// 获取后缀
SetUploadFileExt(file?.name.substr(index+1));
}}
data={{
name: uploadFileName,
@ -382,12 +381,23 @@ const CourseList: React.FC = () => {
</Button>,
]}
request={async (value) => {
const _data = await queryCourseList(value);
console.log('value', value)
const { create_time } = value;
if(create_time){
value['begin_time'] = create_time[0]
value['end_time'] = create_time[1]
}
const {data} = await queryCourseList({
...value,
page_number: value?.current || 1,
page_size: value?.pageSize,
});
return {
current: _data?.page_number,
data: _data?.data?.list,
pageSize: _data?.page_size,
total: _data?.total_row || 0,
current: data?.page_number,
data: data?.list,
pageSize: data?.page_size,
success: true,
total: data?.total_row || 0,
};
}}
// dataSource={list}
@ -539,7 +549,9 @@ const CourseList: React.FC = () => {
// 表单处理
//console.log('columns:', columns);
//console.log('values:', values);
handleAdd(values);
await handleAdd(values);
handleCreateModalVisible(false);
actionRef.current?.reloadAndRest?.();
}}
submitter={{
render: (props, doms) => (

@ -43,7 +43,7 @@ const Login: React.FC = () => {
try {
// 登录
const msg = await login({ ...values, type });
if (msg.status === 'ok') {
if (msg.success === true) {
const defaultLoginSuccessMessage = '登录成功!';
message.success(defaultLoginSuccessMessage);
await fetchUserInfo();
@ -79,7 +79,7 @@ const Login: React.FC = () => {
}}
actions={[]}
onFinish={async (values) => {
await handleSubmit(values as API.LoginParams);
await handleSubmit({user: values.username, pwd: values.password} as API.LoginParams);
}}
>
{status === 'error' && loginType === 'account' && (
@ -89,12 +89,12 @@ const Login: React.FC = () => {
<>
<ProFormText
name="username"
initialValue="admin"
initialValue="feiliming"
fieldProps={{
size: 'large',
prefix: <UserOutlined className={styles.prefixIcon} />,
}}
placeholder="用户名: admin or user"
placeholder="用户名: feiliming or user"
rules={[
{
required: true,
@ -109,12 +109,12 @@ const Login: React.FC = () => {
/>
<ProFormText.Password
name="password"
initialValue="ant.design"
initialValue="220250"
fieldProps={{
size: 'large',
prefix: <LockOutlined className={styles.prefixIcon} />,
}}
placeholder="密码: ant.design"
placeholder="密码: 220250"
rules={[
{
required: true,
@ -212,22 +212,6 @@ const Login: React.FC = () => {
/>
</>
)}
<div
style={{
marginBottom: 24,
}}
>
<ProFormCheckbox noStyle name="autoLogin">
<></>
</ProFormCheckbox>
<a
style={{
float: 'right',
}}
>
<></>
</a>
</div>
</LoginForm>
</div>
<Footer />

@ -2,13 +2,29 @@
/* eslint-disable */
import { request } from 'umi';
/** 获取当前的用户 GET /api/currentUser */
export async function currentUser(options?: { [key: string]: any }) {
return request<{
data: API.CurrentUser;
}>('/api/currentUser', {
/** 获取当前的用户 GET */
export async function currentUser(params: {
person_id: number;
identity_id: number;
u_type: number;
random_num?: number;
}) {
return request('/dsideal_yy/ypt/userinfo/getUserInfo', {
method: 'GET',
...(options || {}),
params,
});
}
/** 获取用户头像 GET */
export async function queryPersonTxByYw(params: {
person_id: number;
identity_id: number;
u_type?: number;
random_num?: number;
}) {
return request('/dsideal_yy/person/getPersonTxByYw', {
method: 'GET',
params,
});
}
@ -22,11 +38,9 @@ export async function outLogin(options?: { [key: string]: any }) {
/** 登录接口 POST /api/login/account */
export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
return request<API.LoginResult>('/api/login/account', {
return request<API.LoginResult>('/dsideal_yy/login/doLogin?login_type=1', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
requestType: 'form',
data: body,
...(options || {}),
});

Loading…
Cancel
Save