fix score setter

master
zhengpengju 3 years ago
parent 40767fb46b
commit b1ebe5ded9

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

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

@ -642,7 +642,8 @@ export default () => {
//const questionTypeScore = await queryQuestionTypeScore(params?.id || rulesId) //const questionTypeScore = await queryQuestionTypeScore(params?.id || rulesId)
//console.log('q::', questionTypeScore) //console.log('q::', questionTypeScore)
console.log('typeQuestionCount', typeQuestionCount); console.log('typeQuestionCount---------------', typeQuestionCount);
setPassScore(ruleData?.pass_score) setPassScore(ruleData?.pass_score)
handleScoreModalVisible(true) handleScoreModalVisible(true)
}}></Button> }}></Button>
@ -798,8 +799,8 @@ export default () => {
handleScoreModalVisible(false) handleScoreModalVisible(false)
return true; 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> </ModalForm>
</PageContainer> </PageContainer>

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

Loading…
Cancel
Save