diff --git a/admin/src/pages/course/option/components/Tags.tsx b/admin/src/pages/course/option/components/Tags.tsx index a9352da..1e277e5 100644 --- a/admin/src/pages/course/option/components/Tags.tsx +++ b/admin/src/pages/course/option/components/Tags.tsx @@ -3,9 +3,8 @@ import { Tag, Input, Tooltip } from 'antd'; import { useEffect, useRef, useState } from 'react'; import { useRequest } from 'umi'; -import { queryTagList } from '../service'; +import { queryTagList, saveTag } from '../service'; import styles from '../style.less'; - //const { Paragraph } = Typography; /* const tags = [ @@ -16,19 +15,38 @@ const tags = [ const Tags = () => { const [inputVisible, setInputVisible] = useState(false); const [items, setItems] = useState([]); + const inputRef = useRef();; + /** 显示输入框 */ - const showInput = () => { - setInputVisible(true) + const showInput = async () => { + await setInputVisible(true) + console.log('inputRef', inputRef) + inputRef.current.focus({ + cursor: 'start', + }); } /** 获取标签数据 */ const { data } = useRequest(queryTagList); useEffect(() => { - setItems(data?.list || []); - console.log('tags',data?.list) + setItems(data || []); + console.log('tags', 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 (
{items.map((tag: any, index: number) => { @@ -37,7 +55,7 @@ const Tags = () => { className="edit-tag" closable={true} key={tag.tag_id.toString()} - //rowKey={index.toString()} + //rowKey={index.toString()} > {tag.tag_name} @@ -49,15 +67,16 @@ const Tags = () => { type="text" size="small" className="tag-input" + ref={inputRef} //value={inputValue} - //onChange={handleInputChange} - //onBlur={handleInputConfirm} - //onPressEnter={handleInputConfirm} + // onChange={handleInputChange} + onBlur={handleInputConfirm} + onPressEnter={handleInputConfirm} /> )} - + {!inputVisible && ( 新建标签 - + )}
); }; diff --git a/admin/src/pages/course/option/index.tsx b/admin/src/pages/course/option/index.tsx index 9b9f8d0..2c709d0 100644 --- a/admin/src/pages/course/option/index.tsx +++ b/admin/src/pages/course/option/index.tsx @@ -13,7 +13,7 @@ import UpdateForm from './components/UpdateForm'; import { queryTagList, saveCourse, removeCourse, queryCourseList } from './service'; import type { TableListItem, TableListPagination } from './data'; 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'; /** @@ -101,7 +101,7 @@ const CourseList: React.FC = () => { { title: '序号', key: 'index', - valueType: 'indexBorder', + valueType: 'indexBorder', width: 48, }, { @@ -116,7 +116,7 @@ const CourseList: React.FC = () => { { title: '主讲教师', dataIndex: 'lecture_teacher', - valueType: 'text', + valueType: 'text', sorter: false, hideInTable: false, hideInForm: false, @@ -126,7 +126,7 @@ const CourseList: React.FC = () => { { title: '课时', dataIndex: 'course_minutes', - valueType: 'text', + valueType: 'text', sorter: false, hideInTable: false, hideInForm: false, @@ -157,7 +157,7 @@ const CourseList: React.FC = () => { sorter: false, hideInForm: false, hideInSearch: true, - renderFormItem:() => ( + renderFormItem: () => ( ), @@ -199,14 +199,14 @@ const CourseList: React.FC = () => { , { + onClick={() => { setCurrentRow(record); handleUpdateModalVisible(true); }} > 编辑 , - {}}> + { }}> 删除 , ], @@ -257,7 +257,7 @@ const CourseList: React.FC = () => { , ]} request={async (value) => { - const _data = await queryCourseList(value); + const _data = await queryCourseList(value); return { current: _data?.page_number, data: _data?.data?.list, @@ -311,8 +311,8 @@ const CourseList: React.FC = () => { footer={null} centered > - { console.log('currentRow', currentRow)} - { console.log('columns', columns.slice(0, columns.length - 1))} + {console.log('currentRow', currentRow)} + {console.log('columns', columns.slice(0, columns.length - 1))} {currentRow?.course_id && ( @@ -341,26 +341,26 @@ const CourseList: React.FC = () => { durationDisplay: true, remainingTimeDisplay: true, fullscreenToggle: true // 全屏按钮 - } + } }} - onReady={(play: any)=>{ + onReady={(play: any) => { console.log('play====', play); playerRef.current = play play.play(); - play.on("timeupdate", function(event) { + play.on("timeupdate", function (event) { //const _timeCurrent = Date.parse(new Date().toString()) / 1000; // 当前时间 //setTimeUpdateState(_timeCurrent); //timeUpdateState - console.log('play--',play.currentTime()) - console.log('play-%-', parseInt(play.currentTime()) % 15 ) - if( parseInt(play.currentTime()) % 15 === 0){ // 每15秒更新进度 + console.log('play--', play.currentTime()) + console.log('play-%-', parseInt(play.currentTime()) % 15) + if (parseInt(play.currentTime()) % 15 === 0) { // 每15秒更新进度 console.log() } //var currentTime = parseInt(this.currentTime()); //当前时间 //var duration = this.duration(); //视频时常 //var percent = (currentTime / duration * 100).toFixed(0) + "%"; - //console.log('event',event); - //$("#current").text(this.currentTime()); - //$("#duration").text(duration); + //console.log('event',event); + //$("#current").text(this.currentTime()); + //$("#duration").text(duration); }) }} /> @@ -380,18 +380,18 @@ const CourseList: React.FC = () => { columns={ columns.slice(0, columns.length - 1) as ProDescriptionsItemProps[] } - style={{padding:'0 24px'}} + style={{ padding: '0 24px' }} /> - + )} - + , ) { return request<{ data: TableListItem[]; @@ -29,7 +29,7 @@ export async function queryCourseList( } /** 新建/修改课程 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, options?: Record) { return request('/dsideal_yy/ypt/careerTraining/course/save', { data, method: 'POST', @@ -38,7 +38,7 @@ export async function saveCourse(data: { [key: string]: any }, options?: { [key: } /** 删除课程 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) { return request>('/dsideal_yy/ypt/careerTraining/course/delete', { data, method: 'POST', @@ -47,7 +47,7 @@ export async function removeCourse(data: { key: number[] }, options?: { [key: st } /** 查看课程(仅仅获取课程详情,不标记浏览量)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, options?: Record) { return request('/dsideal_yy/ypt/careerTraining/course/view', { data, 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, options?: Record) { + return request('/dsideal_yy/ypt/careerTraining/tag/save', { + data, + method: 'POST', + requestType: 'form', + ...(options || {}), + }); +} + /** 获取标签列表 GET /dsideal_yy/ypt/careerTraining/tag/list */ export async function queryTagList( params: { @@ -64,7 +87,7 @@ export async function queryTagList( /** 页面的容量 */ pageSize?: number; }, - options?: { [key: string]: any }, + options?: Record, ) { return request<{ data: TableListItem[]; diff --git a/admin/src/pages/examination/registration/index.tsx b/admin/src/pages/examination/registration/index.tsx index b823dca..eb5a3e8 100644 --- a/admin/src/pages/examination/registration/index.tsx +++ b/admin/src/pages/examination/registration/index.tsx @@ -13,7 +13,7 @@ import type { FormValueType } from './components/UpdateForm'; import UpdateForm from './components/UpdateForm'; import { saveRegistration, removeRegistration, queryRegistrationList } from '../service'; 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(false); const [updateModalVisible, handleUpdateModalVisible] = useState(false); - + const actionRef = useRef(); const [currentRow, setCurrentRow] = useState(); const [selectedRowsState, setSelectedRows] = useState([]); @@ -100,7 +100,7 @@ const RegistrationList: React.FC = () => { { title: '序号', key: 'index', - valueType: 'indexBorder', + valueType: 'indexBorder', width: 48, }, { @@ -114,7 +114,7 @@ const RegistrationList: React.FC = () => { { title: '市', dataIndex: 'city_name', - valueType: 'text', + valueType: 'text', sorter: false, hideInTable: false, hideInForm: false, @@ -124,7 +124,7 @@ const RegistrationList: React.FC = () => { { title: '区县', dataIndex: 'area_name', - valueType: 'text', + valueType: 'text', sorter: false, hideInTable: false, hideInForm: false, @@ -214,7 +214,7 @@ const RegistrationList: React.FC = () => { , ]} request={async (value) => { - const _data = await queryRegistrationList(value); + const _data = await queryRegistrationList(value); return { current: _data?.page_number, data: _data?.data?.list, @@ -229,12 +229,12 @@ const RegistrationList: React.FC = () => { setSelectedRows(selectedRows); }, }} - /* - pagination={{ - showTotal: (total) => { - return `共 ${total} 条`; - } - }}*/ + /* + pagination={{ + showTotal: (total) => { + return `共 ${total} 条`; + } + }}*/ /> {selectedRowsState?.length > 0 && ( { }} footer={null} centered - >{ console.log('currentRow',currentRow)} + >{console.log('currentRow', currentRow)} {currentRow?.name && ( column={2} diff --git a/admin/src/pages/examination/service.ts b/admin/src/pages/examination/service.ts index b6738be..b5f0a6e 100644 --- a/admin/src/pages/examination/service.ts +++ b/admin/src/pages/examination/service.ts @@ -1,5 +1,5 @@ import { request } from 'umi'; -import { TableListItem } from './data'; +import type { TableListItem } from './data'; /** 获取考试列表 GET /dsideal_yy/zygh/training/examination/getExaminationList */ export async function queryExaminationList( @@ -10,7 +10,7 @@ export async function queryExaminationList( /** 页面的容量 */ pageSize?: number; }, - options?: { [key: string]: any }, + options?: Record, ) { return request<{ data: TableListItem[]; @@ -37,7 +37,7 @@ export async function queryCertificateList( /** 页面的容量 */ pageSize?: number; }, - options?: { [key: string]: any }, + options?: Record, ) { return request<{ data: TableListItem[]; @@ -56,7 +56,7 @@ export async function queryCertificateList( } /** 新建/修改考试 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, options?: Record) { return request('/dsideal_yy/ypt/careerTraining/course/save', { data, method: 'POST', @@ -65,7 +65,23 @@ export async function saveExamination(data: { [key: string]: any }, options?: { } /** 删除考试 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) { + return request>('/dsideal_yy/ypt/careerTraining/course/delete', { + data, + method: 'POST', + ...(options || {}), + }); +} +/** saveRegistration */ +export async function saveRegistration(data: { key: number[] }, options?: Record) { + return request>('/dsideal_yy/ypt/careerTraining/course/delete', { + data, + method: 'POST', + ...(options || {}), + }); +} +/** removeRegistration */ +export async function removeRegistration(data: { key: number[] }, options?: Record) { return request>('/dsideal_yy/ypt/careerTraining/course/delete', { data, method: 'POST', @@ -74,7 +90,7 @@ export async function removeExamination(data: { key: number[] }, options?: { [ke } /** 查看考试(仅仅获取考试详情,不标记浏览量)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, options?: Record) { return request('/dsideal_yy/ypt/careerTraining/course/view', { data, method: 'POST', @@ -91,7 +107,7 @@ export async function queryRegistrationList( /** 页面的容量 */ pageSize?: number; }, - options?: { [key: string]: any }, + options?: Record, ) { return request<{ data: TableListItem[];