master
zhengpengju 3 years ago
parent a27729121c
commit 6d87171e0b

@ -1,4 +1,4 @@
import React from "react";
import React, { useEffect } from "react";
import videojs from "video.js";
import "video.js/dist/video-js.css";
import "videojs-contrib-hls";
@ -6,9 +6,9 @@ export const VideoJS = ( props: any ) => {
const videoRef = React.useRef(null);
const playerRef = React.useRef<any>(null);
const { options, onReady } = props;
React.useEffect(() => {
const { options, onReady, width, height } = props;
console.log('props', props)
useEffect(() => {
// make sure Video.js player is only initialized once
if (!playerRef.current) {
@ -32,8 +32,8 @@ export const VideoJS = ( props: any ) => {
return (
<div data-vjs-player>
<video style={{
width:'100%',
height:'auto'
width: width || '100%',
height: height || 'auto'
}} ref={videoRef} className="video-js vjs-big-play-centered" />
</div>
);

@ -465,7 +465,7 @@ const CourseList: React.FC = () => {
<Modal
title={currentRow?.course_name || '课程详细'}
width="50%"
width="70%"
destroyOnClose={true}
visible={detailModalVisible}
onCancel={() => {
@ -483,6 +483,9 @@ const CourseList: React.FC = () => {
<Row>
<Col span={14}>
<VideoJS
style={{width:640,height:480}}
width='100%'
height='480px'
options={{
controls: true,
playbackRates: [0.7, 1.0, 1.5, 2.0], // 播放速度

@ -375,7 +375,7 @@ export default () => {
console.log('val.charAt(0)', val.charAt(0))
if(val.charAt(0) === ''){
console.log('vvv', val)
e.currentTarget.value = ''
e.currentTarget.value = '0'
}
if(val.length > 3) {
e.currentTarget.value = val.slice(0,3)

@ -75,21 +75,36 @@ const ScoreSetter = (props: any, ref: any) => {
render: (text, record, index) =>
<Space direction='horizontal'>
<span></span>
<Form.Item style={{margin:0}} name={`score[${index}]`}><InputNumber min={0} type="number" defaultValue={questionTypeValues ? questionTypeValues[index]?.score : 0} placeholder="请输入" size="small" onChange={(value)=>{
console.log('row', index)
console.log('v1',value)
const _data = [];
console.log('typeScore1',typeScore)
//const _sumItems = [];
typeScore?.forEach((item, key)=>{
_data.push({...item, score: ((index === key) ? value : item?.score)}) // 题型分数
//_sumItems.push((index === key) ? (value * questionTypeValues[index].count) : sumScoreItems[index]) // 题型总分
})
setTypeScore(_data)
//setSumScoreItems(_sumItems)
//console.log('setSumScoreItems', sumScoreItems)
}}/></Form.Item>
<Form.Item style={{margin:0}} name={`score[${index}]`}><Input
style={{width:100}}
min={0}
type="number"
onInput={(e)=>{
const val = `${e.currentTarget?.value}`;
e.currentTarget.value = val.replace(/[^\d]/,'0')
if(val.length > 2) {
e.currentTarget.value = val.slice(0,2)
}
}}
defaultValue={questionTypeValues ? questionTypeValues[index]?.score : 0}
placeholder="请输入"
size="small"
onChange={(e)=>{
const value = e.currentTarget.value
console.log('row', index)
console.log('v1',value)
const _data = [];
console.log('typeScore1',typeScore)
//const _sumItems = [];
typeScore?.forEach((item, key)=>{
_data.push({...item, score: ((index === key) ? Number(value) : Number(item?.score))}) // 题型分数
//_sumItems.push((index === key) ? (value * questionTypeValues[index].count) : sumScoreItems[index]) // 题型总分
})
setTypeScore(_data)
//setSumScoreItems(_sumItems)
//console.log('setSumScoreItems', sumScoreItems)
}}/></Form.Item>
<span></span>
{ (record?.code === 1) &&
<>
@ -124,8 +139,9 @@ const ScoreSetter = (props: any, ref: any) => {
//key: 'age',
width: 80,
render: (text, _, index) => {
{console.log('typeScore---', typeScore)}
return <>
{(typeScore && questionTypeValues) ? (typeScore[index]?.score * questionTypeValues[index]?.count).toFixed(2) : '0'}
{(typeScore && questionTypeValues) ? ((typeScore[index]?.score > 0 ? typeScore[index]?.score : 0) * questionTypeValues[index]?.count).toFixed(1) : '0'}
</>
},
@ -178,7 +194,7 @@ const ScoreSetter = (props: any, ref: any) => {
console.log('typeScore', typeScore)
let _sum = 0;
typeScore?.forEach((item, index)=>{
_sum += item.score * questionTypeValues[index]?.count;
_sum += (item.score > 0 ? item.score : 0 ) * questionTypeValues[index]?.count;
})
setSumScore(_sum)

@ -337,10 +337,9 @@ export default () => {
message: '禁止输入空格'
}
]}
// value="锦书"
// disabled
/>
{console.log(1111)}
<ProFormSelect
width="lg"
initialValue={ruleData?.subject_id}
@ -371,13 +370,17 @@ export default () => {
width="lg"
addonAfter={`分钟`}
name="examination_time"
label="考试时长"
label="考试时长"
fieldProps={{
type: 'number',
min:1,
max:999,
allowClear: false,
width: 'large',
onInput:(e)=>{
const val = `${e.currentTarget?.value}`;
e.currentTarget.value = val.replace(/[^\d]|[0]/,'')
if(val.length > 3) {
e.currentTarget.value = val.slice(0,3)
}
@ -399,7 +402,7 @@ export default () => {
)}
</Col>
</Row>
{console.log(2222)}
</StepsForm.StepForm>
<StepsForm.StepForm<{

@ -5,11 +5,10 @@ import "videojs-contrib-hls";
// React.forwardRef 接受渲染函数作为参数。React 将使用 props 和 ref 作为参数来调用此函数。此函数应返回 React 节点。
const VideoJS = ( props: any, ref: any) => {
//const [count,setCount]=useState(0);
//const countRef=React.useRef(count);
const videoRef = React.useRef(null);
const playerRef = React.useRef<any>(null);
const { options, onReady, } = props;
const { options, onReady, width, height } = props;
useEffect(() => {
if (!playerRef.current) {
@ -38,24 +37,6 @@ const VideoJS = ( props: any, ref: any) => {
}
}, [options]);
// useEffect(()=>{
// videoRef.current.addEventListener()
// },[]);
/*
useEffect(()=>{
countRef.current=count;
},[count])
*/
/*
if(count!==0){
if(countRef.current.toFixed(2)!==count.toFixed(2)){
// console.log('countRef.current前一次',countRef.current.toFixed(2));
// console.log('count这一次',count.toFixed(2))
getTime(count.toFixed(2));
saveLearning(count);
}
}
*/
// 暴露组件的方法 接受外部获取的ref
useImperativeHandle(ref, () => ({
// 构造ref的获取数据方法
@ -70,7 +51,7 @@ const VideoJS = ( props: any, ref: any) => {
return (
<div data-vjs-player>
<video style={{
width:'100%',
width: width ||'100%',
height:'auto'
}} ref={videoRef} className="video-js vjs-big-play-centered" />
</div>

Loading…
Cancel
Save