标签管理

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) => {
@ -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';
/** /**
@ -389,7 +389,7 @@ const CourseList: React.FC = () => {
<ModalForm <ModalForm
title="标签管理" title="标签管理"
visible={tagsModalVisible} visible={tagsModalVisible}
// onVisibleChange={handleModalVisible} onVisibleChange={handleTagsModalVisible}
> >
<Tags /> <Tags />
</ModalForm> </ModalForm>

@ -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';
/** /**
* *

@ -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