master
zhengpengju 4 years ago
parent 1f80c7b827
commit f3a14c0d97

@ -5,6 +5,9 @@ import defaultSettings from './defaultSettings';
import proxy from './proxy'; import proxy from './proxy';
const { REACT_APP_ENV } = process.env; const { REACT_APP_ENV } = process.env;
export default defineConfig({ export default defineConfig({
history:{
type: 'hash'
},
hash: true, hash: true,
antd: {}, antd: {},
dva: { dva: {

@ -6,6 +6,9 @@ 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 } 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 { ResponseError } from 'umi-request';
import { notification } from 'antd';
const isDev = process.env.NODE_ENV === 'development'; const isDev = process.env.NODE_ENV === 'development';
const loginPath = '/user/login'; const loginPath = '/user/login';
@ -70,3 +73,14 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => {
...initialState?.settings, ...initialState?.settings,
}; };
}; };
/** request 用于配置全局的网络请求,你可以在这里做拦截器,全局错误处理,鉴权的配置。*/
export const request: RequestConfig = {
errorHandler: (error: ResponseError) => {
notification.error({
description: '您的网络发生异常,无法连接服务器',
message: '网络异常',
});
throw error;
},
};

@ -12,3 +12,14 @@ export async function queryFakeList(params: {
params, params,
}); });
} }
/** 查询用户信息 */
export async function queryUserInfo(params: {
person_id: number;
identity_id: number;
u_type: number;
}): Promise<{ data: any }> {
return request('/dsideal_yy/ypt/userinfo/getUserInfo', {
params,
});
}

@ -1,20 +1,22 @@
import React, { useState, useRef } from 'react'; import React, { useState, useRef } from 'react';
import { useRequest } from 'umi';
import { PlusOutlined, TagsOutlined, UploadOutlined } from '@ant-design/icons'; import { PlusOutlined, TagsOutlined, UploadOutlined } from '@ant-design/icons';
import { Button, message, Input, Drawer, Modal, Col, Row, Space, Upload } from 'antd'; import { Button, message, Modal, Col, Row, Space, Upload } from 'antd';
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import type { ProColumns, ActionType } from '@ant-design/pro-table'; import type { ProColumns, ActionType } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table';
import { BetaSchemaForm, ModalForm, ProFormText, ProFormTextArea } from '@ant-design/pro-form'; import { BetaSchemaForm, ModalForm } from '@ant-design/pro-form';
import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions'; import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions';
import ProDescriptions from '@ant-design/pro-descriptions'; import ProDescriptions from '@ant-design/pro-descriptions';
import type { FormValueType } from './components/UpdateForm'; import type { FormValueType } from './components/UpdateForm';
import UpdateForm from './components/UpdateForm';
import { queryTagList, saveCourse, removeCourse, queryCourseList } from './service'; import { queryTagList, saveCourse, removeCourse, queryCourseList } from './service';
import type { TableListItem, TableListPagination } from './data'; import type { TableListItem, TableListPagination } from './data';
import Tags from './components/Tags'; import Tags from './components/Tags';
import type { DataItem } from '@antv/data-set/lib/transform/tag-cloud'; import type { DataItem } from '@antv/data-set/lib/transform/tag-cloud';
import { VideoJS } from './components/VideoJS'; import { VideoJS } from './components/VideoJS';
import { v4 as uuidv4 } from 'uuid';
const uuid = uuidv4();
/** /**
* *
@ -25,7 +27,7 @@ const handleAdd = async (fields: TableListItem) => {
const hide = message.loading('正在添加'); const hide = message.loading('正在添加');
try { try {
await saveCourse({ ...fields }); await saveCourse({ ...fields, attachment_filesize:0, attachment_json: `{"img":"", "url": "down/M3u8/${uuid?.substr(0,2)}/${uuid}.m3u8"}` });
hide(); hide();
message.success('添加成功'); message.success('添加成功');
return true; return true;
@ -82,6 +84,7 @@ const handleRemove = async (selectedRows: TableListItem[]) => {
} }
}; };
const CourseList: React.FC = () => { const CourseList: React.FC = () => {
/** 新建窗口的弹窗 */ /** 新建窗口的弹窗 */
@ -96,6 +99,10 @@ const CourseList: React.FC = () => {
const [currentRow, setCurrentRow] = useState<TableListItem>(); const [currentRow, setCurrentRow] = useState<TableListItem>();
const [selectedRowsState, setSelectedRows] = useState<TableListItem[]>([]); const [selectedRowsState, setSelectedRows] = useState<TableListItem[]>([]);
const [uploadFileName, SetUploadFileName] = useState<string>();
const [uploadFileExt, SetUploadFileExt] = useState<string>();
/** 列表项定义 */ /** 列表项定义 */
const columns: ProColumns<TableListItem>[] = [ const columns: ProColumns<TableListItem>[] = [
{ {
@ -112,6 +119,19 @@ const CourseList: React.FC = () => {
hideInDescriptions: false, hideInDescriptions: false,
hideInForm: false, hideInForm: false,
hideInSearch: true, hideInSearch: true,
formItemProps: {
// 参照 https://ant.design/components/form-cn/#Rule
rules: [
{
required: true,
message: '此项为必填项',
},
{
max: 50,
message: '最大长度为50字符',
}
],
}, // 传递给 Form.Item 的配置
}, },
{ {
title: '主讲教师', title: '主讲教师',
@ -122,6 +142,19 @@ const CourseList: React.FC = () => {
hideInForm: false, hideInForm: false,
hideInSearch: true, hideInSearch: true,
renderText: (val: string) => `${val}`, renderText: (val: string) => `${val}`,
formItemProps: {
// 参照 https://ant.design/components/form-cn/#Rule
rules: [
{
required: true,
message: '此项为必填项',
},
{
max: 20,
message: '最大长度为20字符',
}
],
}, // 传递给 Form.Item 的配置
}, },
{ {
title: '课时', title: '课时',
@ -132,6 +165,19 @@ const CourseList: React.FC = () => {
hideInForm: false, hideInForm: false,
hideInSearch: true, hideInSearch: true,
renderText: (val: string) => `${val}`, renderText: (val: string) => `${val}`,
formItemProps: {
// 参照 https://ant.design/components/form-cn/#Rule
rules: [
{
required: true,
message: '此项为必填项',
},
{
max: 4,
message: '最大长度为4字符',
}
],
}, // 传递给 Form.Item 的配置
}, },
{ {
title: '课程描述', title: '课程描述',
@ -142,14 +188,52 @@ const CourseList: React.FC = () => {
hideInForm: false, hideInForm: false,
hideInSearch: true, hideInSearch: true,
renderText: (val: string) => `${val}`, renderText: (val: string) => `${val}`,
formItemProps: {
// 参照 https://ant.design/components/form-cn/#Rule
rules: [
{
required: true,
message: '此项为必填项',
},
{
max: 150,
message: '最大长度为150字符',
}
],
}, // 传递给 Form.Item 的配置
}, },
{ {
title: '标签', title: '标签',
dataIndex: 'tag_name', dataIndex: 'tag_name',
sorter: false, sorter: false,
valueType: 'select', valueType: 'select',
hideInForm: false, hideInForm: true,
renderText: (val: string) => `${val}`, renderText: (val: string) => `${val}`,
},
{
title: '标签',
dataIndex: 'tag_id',
sorter: false,
valueType: 'select',
hideInForm: false,
request: async () => {
const {data: Items} = await queryTagList({});
const tags = []
for(let i=0; i<Items.length; i++){
tags.push({label:Items[i].tag_name, value: Items[i].tag_id})
}
return tags;
},
formItemProps: {
// 参照 https://ant.design/components/form-cn/#Rule
rules: [
{
required: true,
message: '此项为必填项',
},
],
}, // 传递给 Form.Item 的配置
}, },
{ {
title: '视频', title: '视频',
@ -158,10 +242,40 @@ const CourseList: React.FC = () => {
hideInForm: false, hideInForm: false,
hideInSearch: true, hideInSearch: true,
renderFormItem: () => ( renderFormItem: () => (
<Upload > <Upload
action='/dsideal_yy/res/plupload/'
beforeUpload={(file)=>{
console.log('file', file)
// 获取文件名
SetUploadFileName(file?.name) ;
// 获取最后一个.的位置
const index = file?.name.lastIndexOf(".");
// 获取后缀
SetUploadFileExt(file?.name.substr(index+1));
}}
data={{
name: uploadFileName,
chunk: 0,
chunks: 1,
key: `down/Syzx/${uuid?.substr(0,2)}/${uuid}.${uploadFileExt}`
}}
maxCount={1}
multiple={false}
>
<Button icon={<UploadOutlined />}></Button> <Button icon={<UploadOutlined />}></Button>
</Upload>), </Upload>
renderText: (val: string) => `${val}M`, ),
formItemProps: {
// 参照 https://ant.design/components/form-cn/#Rule
rules: [
{
required: true,
message: '此项为必填项',
},
],
}, // 传递给 Form.Item 的配置
//renderText: (val: string) => `${val}M`,
}, },
{ {
title: '视频大小', title: '视频大小',
@ -170,6 +284,15 @@ const CourseList: React.FC = () => {
hideInForm: true, hideInForm: true,
hideInSearch: true, hideInSearch: true,
renderText: (val: string) => `${val}M`, renderText: (val: string) => `${val}M`,
formItemProps: {
// 参照 https://ant.design/components/form-cn/#Rule
rules: [
{
required: true,
message: '此项为必填项',
},
],
}, // 传递给 Form.Item 的配置
}, },
{ {
title: '创建时间', title: '创建时间',
@ -179,7 +302,6 @@ const CourseList: React.FC = () => {
hideInTable: true, hideInTable: true,
hideInForm: true, hideInForm: true,
hideInSearch: false, hideInSearch: false,
//renderText: (val: string) => `${val}`, //renderText: (val: string) => `${val}`,
}, },
{ {
@ -190,7 +312,6 @@ const CourseList: React.FC = () => {
<a <a
key="detail" key="detail"
onClick={() => { onClick={() => {
//console.log('entity', entity);
setCurrentRow(record); setCurrentRow(record);
handleDetailModalVisible(true); handleDetailModalVisible(true);
}} }}
@ -206,7 +327,11 @@ const CourseList: React.FC = () => {
> >
</a>, </a>,
<a key="remove" onClick={() => { }}> <a
key="remove"
onClick={() => {
handleRemove(record);
}}>
</a>, </a>,
], ],
@ -294,9 +419,9 @@ const CourseList: React.FC = () => {
> >
</Button> </Button>
<Button type="primary"></Button>
</FooterToolbar> </FooterToolbar>
)} )}
<Modal <Modal
title={currentRow?.course_name || '课程详细'} title={currentRow?.course_name || '课程详细'}
width="50%" width="50%"
@ -329,7 +454,7 @@ const CourseList: React.FC = () => {
fluid: true, // 当true时Video.js player将拥有流体大小。换句话说它将按比例缩放以适应其容器。 fluid: true, // 当true时Video.js player将拥有流体大小。换句话说它将按比例缩放以适应其容器。
sources: [ sources: [
{ {
src: (currentRow?.attachment_json?.url) || 'http://10.10.14.199/dsideal_yy/html/down/M3u8/2D/2D99BF1D-2F37-47FB-8A24-45112A236B8F.m3u8', // 测试地址后续请删除 src: (currentRow?.attachment_json?.url) || '/dsideal_yy/html/down/M3u8/2D/2D99BF1D-2F37-47FB-8A24-45112A236B8F.m3u8', // 测试地址后续请删除
type: 'application/x-mpegURL' type: 'application/x-mpegURL'
} }
], ],
@ -412,9 +537,9 @@ const CourseList: React.FC = () => {
wrapperCol={{ span: 12 }} wrapperCol={{ span: 12 }}
onFinish={async (values: any) => { onFinish={async (values: any) => {
// 表单处理 // 表单处理
console.log('columns:', columns); //console.log('columns:', columns);
console.log('values:', values); //console.log('values:', values);
handleAdd(values);
}} }}
submitter={{ submitter={{
render: (props, doms) => ( render: (props, doms) => (
@ -427,7 +552,7 @@ const CourseList: React.FC = () => {
}} }}
// action = '' // action = ''
title="新建" title="新建"
columns={columns} columns={columns||[]}
/> />
</Modal> </Modal>
@ -441,7 +566,7 @@ const CourseList: React.FC = () => {
}} }}
footer={null} footer={null}
> >
{currentRow?.name && ( {currentRow?.course_id && (
<BetaSchemaForm<DataItem> <BetaSchemaForm<DataItem>
layout="horizontal" layout="horizontal"
layoutType="Form" layoutType="Form"

@ -33,6 +33,7 @@ export async function saveCourse(data: Record<string, any>, options?: Record<str
return request<TableListItem>('/dsideal_yy/ypt/careerTraining/course/save', { return request<TableListItem>('/dsideal_yy/ypt/careerTraining/course/save', {
data, data,
method: 'POST', method: 'POST',
requestType: 'form',
...(options || {}), ...(options || {}),
}); });
} }
@ -42,6 +43,7 @@ export async function removeCourse(data: { key: number[] }, options?: Record<str
return request<Record<string, any>>('/dsideal_yy/ypt/careerTraining/course/delete', { return request<Record<string, any>>('/dsideal_yy/ypt/careerTraining/course/delete', {
data, data,
method: 'POST', method: 'POST',
requestType: 'form',
...(options || {}), ...(options || {}),
}); });
} }
@ -51,6 +53,7 @@ export async function queryCourseView(data: Record<string, any>, options?: Recor
return request<TableListItem>('/dsideal_yy/ypt/careerTraining/course/view', { return request<TableListItem>('/dsideal_yy/ypt/careerTraining/course/view', {
data, data,
method: 'POST', method: 'POST',
requestType: 'form',
...(options || {}), ...(options || {}),
}); });
} }

Loading…
Cancel
Save