From 6d87171e0b6e34ac2719ac0b0879ba92e675f185 Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Fri, 18 Mar 2022 21:07:07 +0800 Subject: [PATCH] fix bug --- .../option/components/VideoJS/index.tsx | 12 ++--- admin/src/pages/course/option/index.tsx | 5 +- .../attestation/step/index.tsx | 2 +- .../components/ScoreSetter.tsx | 50 ++++++++++++------- .../examinationrules/normal/step/index.tsx | 13 +++-- web/src/pages/course/components/VideoJS.tsx | 25 ++-------- 6 files changed, 55 insertions(+), 52 deletions(-) diff --git a/admin/src/pages/course/option/components/VideoJS/index.tsx b/admin/src/pages/course/option/components/VideoJS/index.tsx index 5eb1915..a5f9eed 100644 --- a/admin/src/pages/course/option/components/VideoJS/index.tsx +++ b/admin/src/pages/course/option/components/VideoJS/index.tsx @@ -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(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 (
); diff --git a/admin/src/pages/course/option/index.tsx b/admin/src/pages/course/option/index.tsx index af0137b..271bcc7 100644 --- a/admin/src/pages/course/option/index.tsx +++ b/admin/src/pages/course/option/index.tsx @@ -465,7 +465,7 @@ const CourseList: React.FC = () => { { @@ -483,6 +483,9 @@ const CourseList: React.FC = () => { { 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) diff --git a/admin/src/pages/examinationrules/components/ScoreSetter.tsx b/admin/src/pages/examinationrules/components/ScoreSetter.tsx index 109d479..2f511b5 100644 --- a/admin/src/pages/examinationrules/components/ScoreSetter.tsx +++ b/admin/src/pages/examinationrules/components/ScoreSetter.tsx @@ -75,21 +75,36 @@ const ScoreSetter = (props: any, ref: any) => { render: (text, record, index) => 每题 - { - 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) - }}/> + { + 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) + }}/> { (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) diff --git a/admin/src/pages/examinationrules/normal/step/index.tsx b/admin/src/pages/examinationrules/normal/step/index.tsx index 16657db..d4ce38e 100644 --- a/admin/src/pages/examinationrules/normal/step/index.tsx +++ b/admin/src/pages/examinationrules/normal/step/index.tsx @@ -337,10 +337,9 @@ export default () => { message: '禁止输入空格' } ]} - // value="锦书" - // disabled + /> -{console.log(1111)} + { 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 () => { )} -{console.log(2222)} + { - //const [count,setCount]=useState(0); - //const countRef=React.useRef(count); + const videoRef = React.useRef(null); const playerRef = React.useRef(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 (