fix score setter

master
zhengpengju 3 years ago
parent 40767fb46b
commit b1ebe5ded9

@ -275,6 +275,7 @@ const CourseList: React.FC = () => {
message.error('视频编码格式不正确视频采用AVC音频采用AAC')
return false;
}
console.log('filename', file?.name)
// 获取文件名
SetUploadFileName(file?.name);
// 获取最后一个.的位置
@ -609,9 +610,12 @@ const CourseList: React.FC = () => {
//return false;
await handleAdd({
...values,
//course_id: currentRow?.course_id,
attachment_json: `{"img":"", "name": "${values?.attachment_json?.file?.name}", "url": "down/Syzx/${uuid?.substr(0, 2)}/${uuid}.mp4"}`,
attachment_filesize: values?.attachment_json?.file?.size, // 字节
////course_id: currentRow?.course_id,
//attachment_json: `{"img":"", "name": "${values?.attachment_json?.file?.name}", "url": "down/Syzx/${uuid?.substr(0, 2)}/${uuid}.mp4"}`,
//attachment_filesize: values?.attachment_json?.file?.size, // 字节
attachment_json: `{"img":"", "name": "${values?.attachment_json[0]?.name}", "url": "down/Syzx/${uuid?.substr(0, 2)}/${uuid}.mp4"}`,
attachment_filesize: values?.attachment_json[0]?.size, // 字节
});
handleCreateModalVisible(false); // 隐藏创建窗口
actionRef.current?.reloadAndRest?.();

@ -61,7 +61,7 @@ const ScoreSetter = (props: any, ref: any) => {
e.currentTarget.value = val.slice(0,3)
}
}}
defaultValue={questionTypeValues ? questionTypeValues[index]?.score : 0}
defaultValue={questionTypeValues ? questionTypeValues[index]?.score || 0 : 0}
placeholder="请输入"
size="small"
onChange={(e)=>{
@ -87,7 +87,7 @@ const ScoreSetter = (props: any, ref: any) => {
message: '请输入分值!',
},*/
]}
><InputNumber min={0} max={99} maxLength={2} type="number" defaultValue={questionTypeValues ? questionTypeValues[index]?.score_harf : 0} placeholder="请输入" size="small" name='score_harf' onChange={(value)=>{
><InputNumber min={0} max={99} maxLength={2} type="number" defaultValue={questionTypeValues ? questionTypeValues[index]?.score_harf || 0 : 0} placeholder="请输入" size="small" name='score_harf' onChange={(value)=>{
const harf = typeScore?.map((item: { score_harf: any; }, key: number)=>{
return {...item, score_harf: ((index === key) ? value : item?.score_harf)}
})
@ -102,7 +102,7 @@ const ScoreSetter = (props: any, ref: any) => {
title: '题目数量',
dataIndex: 'count',
width: 80,
render: (_text: any, _: any, index: number) => <>{questionTypeValues ? questionTypeValues[index]?.count : '0'}</>,
render: (_text: any, _: any, index: number) => <>{questionTypeValues ? questionTypeValues[index]?.count || 0 : '0'}</>,
},
{
title: '总分值',
@ -112,8 +112,8 @@ const ScoreSetter = (props: any, ref: any) => {
render: (_text: any, _: any, index: number) => {
return <>
{flag?.indexOf(index) === -1 ?
questionTypeValues[index]?.score * questionTypeValues[index].count :
(typeScore && questionTypeValues) ? ((typeScore[index]?.score > 0 ? typeScore[index]?.score : 0) * questionTypeValues[index]?.count).toFixed(1) : '0'
(questionTypeValues[index]?.score || 0) * (questionTypeValues[index]?.count || 0) :
(typeScore && questionTypeValues) ? ((typeScore[index]?.score > 0 ? typeScore[index]?.score : 0) * (questionTypeValues[index]?.count || 0)).toFixed(1) : '0'
}
</>
},
@ -154,20 +154,23 @@ const ScoreSetter = (props: any, ref: any) => {
>
<ProTable
title={()=>{
return <Space size="large"><span> {sumQuestion} ,</span><span> {
return <Space size="large"><span> {sumQuestion || 0} ,</span><span> {
typeScore?.length > 0 &&
typeScore?.map((item: any, key: number)=>{return item?.score * questionTypeValues[key].count})?.reduce((total: number, item: number)=>(total + item)) || 0
} </span> 线
<Form.Item style={{margin:0}} name='pass_socre' initialValue={passScore}><InputNumber min={0} onChange={(value)=>{
<Form.Item style={{margin:0}} name='pass_socre' initialValue={passScore || 0}><InputNumber min={0} onChange={(value)=>{
setPassScore(value)
}} /></Form.Item>
</Space>}}
//formMapRef={formMapRef}
rowKey={'code'}
request={async ()=>{
console.log('questionTypeValues1111', questionTypeValues)
const result = await queryQuestionType() // 从字典获取题型数据 [{code: 0, name:"单选题"},]
setTypeScore(questionTypeValues?.map((item: { score: any; score_harf: any; }, key: number)=>{
return {question_type: result.list[key]?.code, score: item?.score, score_harf: (item?.score_harf || 0)}
}))
return {data:questionTypeValues?.map((item: any, key: number)=>({
...item,
code: result.list[key]?.code,
@ -175,6 +178,17 @@ const ScoreSetter = (props: any, ref: any) => {
name: result.list[key]?.name,
count: result.list[key]?.count
}))}
/*
return {data:result?.list?.map((item: any)=>({
...item,
code: item?.code,
question_type: item?.code,
name: item?.name,
count: item?.count || 0
}))}
*/
}}
bordered
cardProps={{bodyStyle:{padding:0}}}

@ -642,7 +642,8 @@ export default () => {
//const questionTypeScore = await queryQuestionTypeScore(params?.id || rulesId)
//console.log('q::', questionTypeScore)
console.log('typeQuestionCount', typeQuestionCount);
console.log('typeQuestionCount---------------', typeQuestionCount);
setPassScore(ruleData?.pass_score)
handleScoreModalVisible(true)
}}></Button>
@ -798,8 +799,8 @@ export default () => {
handleScoreModalVisible(false)
return true;
}}
>{console.log('q1',questionTypeValues)}{console.log('q2',scoreData)}
<ScoreSetter ref={setterRef} questionTypeValues={questionTypeValues || false} passScore={passScore} />
>
<ScoreSetter ref={setterRef} questionTypeValues={questionTypeValues.length > 0 ? questionTypeValues : questionType?.map((item,key)=>({...item, count: typeQuestionCount[key]}))} passScore={passScore} />
</ModalForm>
</PageContainer>

@ -34,6 +34,7 @@ console.log('first');
* @param fields
*/
const handleAdd = async (fields: TableListItem) => {
console.log('handleadd...')
const hide = message.loading('正在添加');
try {
await saveQuestion({ ...fields });
@ -292,7 +293,7 @@ const QuestionBank = () => {
hideInForm: false,
hideInSearch: true,
formItemProps: {
rules: [
rules: [
{
required: true,
message: '请填写试题解析',
@ -784,8 +785,6 @@ const QuestionBank = () => {
onFinish={async (values: any) => {
//console.log('formRef.current', formRef.current.getFieldsValue(['answertrue']))
console.log(values);
return
// 表单处理
console.log('columns:', columns);
console.log('values:', values);

Loading…
Cancel
Save