标签管理

master
xialiang 4 years ago
parent 6a715ab746
commit 9c165d9435

@ -3,9 +3,8 @@ import { Tag, Input, Tooltip } from 'antd';
import { useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { useRequest } from 'umi'; import { useRequest } from 'umi';
import { queryTagList } from '../service'; import { queryTagList, saveTag } from '../service';
import styles from '../style.less'; import styles from '../style.less';
//const { Paragraph } = Typography; //const { Paragraph } = Typography;
/* /*
const tags = [ const tags = [
@ -16,19 +15,38 @@ const tags = [
const Tags = () => { const Tags = () => {
const [inputVisible, setInputVisible] = useState<boolean>(false); const [inputVisible, setInputVisible] = useState<boolean>(false);
const [items, setItems] = useState([]); const [items, setItems] = useState([]);
const inputRef = useRef<any>();;
/** 显示输入框 */ /** 显示输入框 */
const showInput = () => { const showInput = async () => {
setInputVisible(true) await setInputVisible(true)
console.log('inputRef', inputRef)
inputRef.current.focus({
cursor: 'start',
});
} }
/** 获取标签数据 */ /** 获取标签数据 */
const { data } = useRequest(queryTagList); const { data } = useRequest(queryTagList);
useEffect(() => { useEffect(() => {
setItems(data?.list || []); setItems(data || []);
console.log('tags',data?.list) console.log('tags', data)
}, [data]); }, [data]);
// 添加标签
const handleInputConfirm = async (e: any) => {
console.log(items)
const res = await saveTag({ tag_name: e.target.value })
console.log(res);
// setItems(data?.list || []);
setInputVisible(false)
}
return ( return (
<div className={styles.tags}> <div className={styles.tags}>
{items.map((tag: any, index: number) => { {items.map((tag: any, index: number) => {
@ -37,7 +55,7 @@ const Tags = () => {
className="edit-tag" className="edit-tag"
closable={true} closable={true}
key={tag.tag_id.toString()} key={tag.tag_id.toString()}
//rowKey={index.toString()} //rowKey={index.toString()}
> >
<span key={index.toString()}>{tag.tag_name}</span> <span key={index.toString()}>{tag.tag_name}</span>
</Tag> </Tag>
@ -49,15 +67,16 @@ const Tags = () => {
type="text" type="text"
size="small" size="small"
className="tag-input" className="tag-input"
ref={inputRef}
//value={inputValue} //value={inputValue}
//onChange={handleInputChange} // onChange={handleInputChange}
//onBlur={handleInputConfirm} onBlur={handleInputConfirm}
//onPressEnter={handleInputConfirm} onPressEnter={handleInputConfirm}
/> />
)} )}
<Tag className="site-tag-plus" key={''} onClick={showInput}> {!inputVisible && (<Tag className="site-tag-plus" key={''} onClick={showInput}>
<PlusOutlined /> <PlusOutlined />
</Tag> </Tag>)}
</div> </div>
); );
}; };

@ -13,7 +13,7 @@ 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 { 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';
/** /**
@ -101,7 +101,7 @@ const CourseList: React.FC = () => {
{ {
title: '序号', title: '序号',
key: 'index', key: 'index',
valueType: 'indexBorder', valueType: 'indexBorder',
width: 48, width: 48,
}, },
{ {
@ -116,7 +116,7 @@ const CourseList: React.FC = () => {
{ {
title: '主讲教师', title: '主讲教师',
dataIndex: 'lecture_teacher', dataIndex: 'lecture_teacher',
valueType: 'text', valueType: 'text',
sorter: false, sorter: false,
hideInTable: false, hideInTable: false,
hideInForm: false, hideInForm: false,
@ -126,7 +126,7 @@ const CourseList: React.FC = () => {
{ {
title: '课时', title: '课时',
dataIndex: 'course_minutes', dataIndex: 'course_minutes',
valueType: 'text', valueType: 'text',
sorter: false, sorter: false,
hideInTable: false, hideInTable: false,
hideInForm: false, hideInForm: false,
@ -157,7 +157,7 @@ const CourseList: React.FC = () => {
sorter: false, sorter: false,
hideInForm: false, hideInForm: false,
hideInSearch: true, hideInSearch: true,
renderFormItem:() => ( renderFormItem: () => (
<Upload > <Upload >
<Button icon={<UploadOutlined />}></Button> <Button icon={<UploadOutlined />}></Button>
</Upload>), </Upload>),
@ -199,14 +199,14 @@ const CourseList: React.FC = () => {
</a>, </a>,
<a <a
key="update" key="update"
onClick={() => { onClick={() => {
setCurrentRow(record); setCurrentRow(record);
handleUpdateModalVisible(true); handleUpdateModalVisible(true);
}} }}
> >
</a>, </a>,
<a key="remove" onClick={()=>{}}> <a key="remove" onClick={() => { }}>
</a>, </a>,
], ],
@ -257,7 +257,7 @@ const CourseList: React.FC = () => {
</Button>, </Button>,
]} ]}
request={async (value) => { request={async (value) => {
const _data = await queryCourseList(value); const _data = await queryCourseList(value);
return { return {
current: _data?.page_number, current: _data?.page_number,
data: _data?.data?.list, data: _data?.data?.list,
@ -311,8 +311,8 @@ const CourseList: React.FC = () => {
footer={null} footer={null}
centered centered
> >
{ console.log('currentRow', currentRow)} {console.log('currentRow', currentRow)}
{ console.log('columns', columns.slice(0, columns.length - 1))} {console.log('columns', columns.slice(0, columns.length - 1))}
{currentRow?.course_id && ( {currentRow?.course_id && (
<Row> <Row>
<Col span={14}> <Col span={14}>
@ -341,26 +341,26 @@ const CourseList: React.FC = () => {
durationDisplay: true, durationDisplay: true,
remainingTimeDisplay: true, remainingTimeDisplay: true,
fullscreenToggle: true // 全屏按钮 fullscreenToggle: true // 全屏按钮
} }
}} }}
onReady={(play: any)=>{ onReady={(play: any) => {
console.log('play====', play); console.log('play====', play);
playerRef.current = play playerRef.current = play
play.play(); play.play();
play.on("timeupdate", function(event) { play.on("timeupdate", function (event) {
//const _timeCurrent = Date.parse(new Date().toString()) / 1000; // 当前时间 //const _timeCurrent = Date.parse(new Date().toString()) / 1000; // 当前时间
//setTimeUpdateState(_timeCurrent); //timeUpdateState //setTimeUpdateState(_timeCurrent); //timeUpdateState
console.log('play--',play.currentTime()) console.log('play--', play.currentTime())
console.log('play-%-', parseInt(play.currentTime()) % 15 ) console.log('play-%-', parseInt(play.currentTime()) % 15)
if( parseInt(play.currentTime()) % 15 === 0){ // 每15秒更新进度 if (parseInt(play.currentTime()) % 15 === 0) { // 每15秒更新进度
console.log() console.log()
} }
//var currentTime = parseInt(this.currentTime()); //当前时间 //var currentTime = parseInt(this.currentTime()); //当前时间
//var duration = this.duration(); //视频时常 //var duration = this.duration(); //视频时常
//var percent = (currentTime / duration * 100).toFixed(0) + "%"; //var percent = (currentTime / duration * 100).toFixed(0) + "%";
//console.log('event',event); //console.log('event',event);
//$("#current").text(this.currentTime()); //$("#current").text(this.currentTime());
//$("#duration").text(duration); //$("#duration").text(duration);
}) })
}} }}
/> />
@ -380,18 +380,18 @@ const CourseList: React.FC = () => {
columns={ columns={
columns.slice(0, columns.length - 1) as ProDescriptionsItemProps<TableListItem>[] columns.slice(0, columns.length - 1) as ProDescriptionsItemProps<TableListItem>[]
} }
style={{padding:'0 24px'}} style={{ padding: '0 24px' }}
/> />
</Col> </Col>
</Row> </Row>
)} )}
</Modal> </Modal>
<ModalForm <ModalForm
title="标签管理" title="标签管理"
visible={tagsModalVisible} visible={tagsModalVisible}
// onVisibleChange={handleModalVisible} onVisibleChange={handleTagsModalVisible}
> >
<Tags/> <Tags />
</ModalForm> </ModalForm>
<Modal <Modal

@ -1,5 +1,5 @@
import { request } from 'umi'; import { request } from 'umi';
import { TableListItem } from './data'; import type { TableListItem } from './data';
/** 获取课程列表 GET /dsideal_yy/ypt/careerTraining/course/list */ /** 获取课程列表 GET /dsideal_yy/ypt/careerTraining/course/list */
export async function queryCourseList( export async function queryCourseList(
@ -10,7 +10,7 @@ export async function queryCourseList(
/** 页面的容量 */ /** 页面的容量 */
pageSize?: number; pageSize?: number;
}, },
options?: { [key: string]: any }, options?: Record<string, any>,
) { ) {
return request<{ return request<{
data: TableListItem[]; data: TableListItem[];
@ -29,7 +29,7 @@ export async function queryCourseList(
} }
/** 新建/修改课程 POST /dsideal_yy/ypt/careerTraining/course/save */ /** 新建/修改课程 POST /dsideal_yy/ypt/careerTraining/course/save */
export async function saveCourse(data: { [key: string]: any }, options?: { [key: string]: any }) { export async function saveCourse(data: Record<string, any>, options?: Record<string, any>) {
return request<TableListItem>('/dsideal_yy/ypt/careerTraining/course/save', { return request<TableListItem>('/dsideal_yy/ypt/careerTraining/course/save', {
data, data,
method: 'POST', method: 'POST',
@ -38,7 +38,7 @@ export async function saveCourse(data: { [key: string]: any }, options?: { [key:
} }
/** 删除课程 POST /dsideal_yy/ypt/careerTraining/course/delete */ /** 删除课程 POST /dsideal_yy/ypt/careerTraining/course/delete */
export async function removeCourse(data: { key: number[] }, options?: { [key: string]: any }) { export async function removeCourse(data: { key: number[] }, options?: Record<string, any>) {
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',
@ -47,7 +47,7 @@ export async function removeCourse(data: { key: number[] }, options?: { [key: st
} }
/** 查看课程仅仅获取课程详情不标记浏览量GET /dsideal_yy/ypt/careerTraining/course/view */ /** 查看课程仅仅获取课程详情不标记浏览量GET /dsideal_yy/ypt/careerTraining/course/view */
export async function queryCourseView(data: { [key: string]: any }, options?: { [key: string]: any }) { export async function queryCourseView(data: Record<string, any>, options?: Record<string, any>) {
return request<TableListItem>('/dsideal_yy/ypt/careerTraining/course/view', { return request<TableListItem>('/dsideal_yy/ypt/careerTraining/course/view', {
data, data,
method: 'POST', method: 'POST',
@ -55,6 +55,29 @@ export async function queryCourseView(data: { [key: string]: any }, options?: {
}); });
} }
/** 新建/修改课程 POST /dsideal_yy/ypt/careerTraining/course/save */
export async function saveTag(data: Record<string, any>, options?: Record<string, any>) {
return request<TableListItem>('/dsideal_yy/ypt/careerTraining/tag/save', {
data,
method: 'POST',
requestType: 'form',
...(options || {}),
});
}
/** 获取标签列表 GET /dsideal_yy/ypt/careerTraining/tag/list */ /** 获取标签列表 GET /dsideal_yy/ypt/careerTraining/tag/list */
export async function queryTagList( export async function queryTagList(
params: { params: {
@ -64,7 +87,7 @@ export async function queryTagList(
/** 页面的容量 */ /** 页面的容量 */
pageSize?: number; pageSize?: number;
}, },
options?: { [key: string]: any }, options?: Record<string, any>,
) { ) {
return request<{ return request<{
data: TableListItem[]; data: TableListItem[];

@ -13,7 +13,7 @@ import type { FormValueType } from './components/UpdateForm';
import UpdateForm from './components/UpdateForm'; import UpdateForm from './components/UpdateForm';
import { saveRegistration, removeRegistration, queryRegistrationList } from '../service'; import { saveRegistration, removeRegistration, queryRegistrationList } from '../service';
import type { TableListItem, TableListPagination } from './data'; import type { TableListItem, TableListPagination } from './data';
import { DataItem } from '@antv/data-set/lib/transform/tag-cloud'; import type { DataItem } from '@antv/data-set/lib/transform/tag-cloud';
/** /**
* *
@ -89,7 +89,7 @@ const RegistrationList: React.FC = () => {
const [detailModalVisible, handleDetailModalVisible] = useState<boolean>(false); const [detailModalVisible, handleDetailModalVisible] = useState<boolean>(false);
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false); const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>();
const [currentRow, setCurrentRow] = useState<TableListItem>(); const [currentRow, setCurrentRow] = useState<TableListItem>();
const [selectedRowsState, setSelectedRows] = useState<TableListItem[]>([]); const [selectedRowsState, setSelectedRows] = useState<TableListItem[]>([]);
@ -100,7 +100,7 @@ const RegistrationList: React.FC = () => {
{ {
title: '序号', title: '序号',
key: 'index', key: 'index',
valueType: 'indexBorder', valueType: 'indexBorder',
width: 48, width: 48,
}, },
{ {
@ -114,7 +114,7 @@ const RegistrationList: React.FC = () => {
{ {
title: '市', title: '市',
dataIndex: 'city_name', dataIndex: 'city_name',
valueType: 'text', valueType: 'text',
sorter: false, sorter: false,
hideInTable: false, hideInTable: false,
hideInForm: false, hideInForm: false,
@ -124,7 +124,7 @@ const RegistrationList: React.FC = () => {
{ {
title: '区县', title: '区县',
dataIndex: 'area_name', dataIndex: 'area_name',
valueType: 'text', valueType: 'text',
sorter: false, sorter: false,
hideInTable: false, hideInTable: false,
hideInForm: false, hideInForm: false,
@ -214,7 +214,7 @@ const RegistrationList: React.FC = () => {
</Button>, </Button>,
]} ]}
request={async (value) => { request={async (value) => {
const _data = await queryRegistrationList(value); const _data = await queryRegistrationList(value);
return { return {
current: _data?.page_number, current: _data?.page_number,
data: _data?.data?.list, data: _data?.data?.list,
@ -229,12 +229,12 @@ const RegistrationList: React.FC = () => {
setSelectedRows(selectedRows); setSelectedRows(selectedRows);
}, },
}} }}
/* /*
pagination={{ pagination={{
showTotal: (total) => { showTotal: (total) => {
return `${total}`; return `${total}`;
} }
}}*/ }}*/
/> />
{selectedRowsState?.length > 0 && ( {selectedRowsState?.length > 0 && (
<FooterToolbar <FooterToolbar
@ -274,7 +274,7 @@ const RegistrationList: React.FC = () => {
}} }}
footer={null} footer={null}
centered centered
>{ console.log('currentRow',currentRow)} >{console.log('currentRow', currentRow)}
{currentRow?.name && ( {currentRow?.name && (
<ProDescriptions<TableListItem> <ProDescriptions<TableListItem>
column={2} column={2}

@ -1,5 +1,5 @@
import { request } from 'umi'; import { request } from 'umi';
import { TableListItem } from './data'; import type { TableListItem } from './data';
/** 获取考试列表 GET /dsideal_yy/zygh/training/examination/getExaminationList */ /** 获取考试列表 GET /dsideal_yy/zygh/training/examination/getExaminationList */
export async function queryExaminationList( export async function queryExaminationList(
@ -10,7 +10,7 @@ export async function queryExaminationList(
/** 页面的容量 */ /** 页面的容量 */
pageSize?: number; pageSize?: number;
}, },
options?: { [key: string]: any }, options?: Record<string, any>,
) { ) {
return request<{ return request<{
data: TableListItem[]; data: TableListItem[];
@ -37,7 +37,7 @@ export async function queryCertificateList(
/** 页面的容量 */ /** 页面的容量 */
pageSize?: number; pageSize?: number;
}, },
options?: { [key: string]: any }, options?: Record<string, any>,
) { ) {
return request<{ return request<{
data: TableListItem[]; data: TableListItem[];
@ -56,7 +56,7 @@ export async function queryCertificateList(
} }
/** 新建/修改考试 POST /dsideal_yy/ypt/careerTraining/course/save */ /** 新建/修改考试 POST /dsideal_yy/ypt/careerTraining/course/save */
export async function saveExamination(data: { [key: string]: any }, options?: { [key: string]: any }) { export async function saveExamination(data: Record<string, any>, options?: Record<string, any>) {
return request<TableListItem>('/dsideal_yy/ypt/careerTraining/course/save', { return request<TableListItem>('/dsideal_yy/ypt/careerTraining/course/save', {
data, data,
method: 'POST', method: 'POST',
@ -65,7 +65,23 @@ export async function saveExamination(data: { [key: string]: any }, options?: {
} }
/** 删除考试 POST /dsideal_yy/ypt/careerTraining/course/delete */ /** 删除考试 POST /dsideal_yy/ypt/careerTraining/course/delete */
export async function removeExamination(data: { key: number[] }, options?: { [key: string]: any }) { export async function removeExamination(data: { key: number[] }, options?: Record<string, any>) {
return request<Record<string, any>>('/dsideal_yy/ypt/careerTraining/course/delete', {
data,
method: 'POST',
...(options || {}),
});
}
/** saveRegistration */
export async function saveRegistration(data: { key: number[] }, options?: Record<string, any>) {
return request<Record<string, any>>('/dsideal_yy/ypt/careerTraining/course/delete', {
data,
method: 'POST',
...(options || {}),
});
}
/** removeRegistration */
export async function removeRegistration(data: { key: number[] }, options?: Record<string, any>) {
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',
@ -74,7 +90,7 @@ export async function removeExamination(data: { key: number[] }, options?: { [ke
} }
/** 查看考试仅仅获取考试详情不标记浏览量GET /dsideal_yy/ypt/careerTraining/course/view */ /** 查看考试仅仅获取考试详情不标记浏览量GET /dsideal_yy/ypt/careerTraining/course/view */
export async function queryExaminationView(data: { [key: string]: any }, options?: { [key: string]: any }) { export async function queryExaminationView(data: Record<string, any>, options?: Record<string, any>) {
return request<TableListItem>('/dsideal_yy/ypt/careerTraining/course/view', { return request<TableListItem>('/dsideal_yy/ypt/careerTraining/course/view', {
data, data,
method: 'POST', method: 'POST',
@ -91,7 +107,7 @@ export async function queryRegistrationList(
/** 页面的容量 */ /** 页面的容量 */
pageSize?: number; pageSize?: number;
}, },
options?: { [key: string]: any }, options?: Record<string, any>,
) { ) {
return request<{ return request<{
data: TableListItem[]; data: TableListItem[];

Loading…
Cancel
Save