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

master
zhengpengju 4 years ago
parent f3a14c0d97
commit 5b6e67ba61

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

@ -4,11 +4,12 @@ import type { RunTimeLayoutConfig } from 'umi';
import { history, Link } from 'umi'; import { history, Link } from 'umi';
import RightContent from '@/components/RightContent'; import RightContent from '@/components/RightContent';
import Footer from '@/components/Footer'; 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 { BookOutlined, LinkOutlined } from '@ant-design/icons';
import { RequestConfig } from 'umi'; import { RequestConfig } from 'umi';
import { ResponseError } from 'umi-request'; import { ResponseError } from 'umi-request';
import { notification } from 'antd'; import { notification } from 'antd';
import cookie from 'react-cookies';
const isDev = process.env.NODE_ENV === 'development'; const isDev = process.env.NODE_ENV === 'development';
const loginPath = '/user/login'; const loginPath = '/user/login';
@ -28,8 +29,20 @@ export async function getInitialState(): Promise<{
}> { }> {
const fetchUserInfo = async () => { const fetchUserInfo = async () => {
try { try {
const msg = await queryCurrentUser(); const msg = await queryCurrentUser({
return msg.data; 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) { } catch (error) {
history.push(loginPath); history.push(loginPath);
} }

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

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

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

Loading…
Cancel
Save