@ -26,24 +26,12 @@
< / e l - f o r m >
< div class = "score-table-wrap" >
< table class = "score-table" >
< thead > < tr > < th > 题型 < / th > < th > 题库题目数量 < / th > < th > 选题数量 < / th > < th > 每题分值< / th > < th > 小计< / th > < / tr > < / thead >
< thead > < tr > < th > 题型 < / th > < th > 题库题目数量 < / th > < th > 选题数量 < / th > < th > 小计< / th > < / tr > < / thead >
< tbody >
< tr v-for ="item in typeOptions" :key="item.value" >
< td > { { item . label } } < / td >
< td > { { questionCount ( item . value ) } } < / td >
< td > { { selectedByType ( item . value ) } } < / td >
< td >
< el -input -number
class = "type-score-input"
: model - value = "scorePerQuestion(item.value)"
: min = "0.5"
: precision = "1"
: step = "0.5"
controls - position = "right"
size = "small"
@ change = "setTypeScore(item.value, $event)"
/ >
< / td >
< td > { { scoreByType ( item . value ) } } < / td >
< / tr >
< / tbody >
@ -130,10 +118,6 @@
< div class = "q-card-head" >
< span class = "q-card-no" > { { idx + 1 } } < / span >
< span class = "q-card-type" > { { typeOptions . find ( t => t . value === question . type ) ? . label || question . type } } < / span >
< span v -if = " isSelected ( question.id ) " class = "q-score-chip" @ click.stop >
< el -input -number :model-value ="selectedScore(question.id)" :min ="0.5" :precision ="1" :step ="0.5" controls -position = " right " size = "small" @ change = "setScore(question.id, $event)" / >
< span > 分 < / span >
< / span >
< / div >
< h3 class = "q-card-stem" > { { question . stem } } < / h3 >
< div v-if ="question.options?.length" class="q-options" >
@ -240,12 +224,11 @@ function isSelected(questionId) { return form.questions.some((item) => item.ques
function selectedScore ( questionId ) { return form . questions . find ( ( item ) => item . questionId === questionId ) ? . score || 1 ; }
function toggleQuestion ( question , checked ) { if ( checked ) form . questions . push ( { questionId : question . id , score : typeScores [ question . type ] || 1 } ) ; else form . questions = form . questions . filter ( ( item ) => item . questionId !== question . id ) ; }
function removeQuestionFromPreview ( question ) { toggleQuestion ( question , false ) ; }
function setScore ( questionId , score ) { const item = form . questions . find ( ( row ) => row . questionId === questionId ) ; if ( item ) item . score = Number ( score ) ; }
function selectedByType ( type ) { const ids = new Set ( bank . value . filter ( ( item ) => item . type === type ) . map ( ( item ) => item . id ) ) ; return form . questions . filter ( ( item ) => ids . has ( item . questionId ) ) . length ; }
function questionCount ( type ) { return bank . value . filter ( ( item ) => item . type === type ) . length ; }
function scoreByType ( type ) { return selectedQuestions ( type ) . reduce ( ( sum , item ) => sum + Number ( selectedScore ( item . id ) ) , 0 ) ; }
function scorePerQuestion ( type ) { return Number ( typeScores [ type ] || 1 ) ; }
function setTypeScore ( type , score ) { const value = Number ( score ) ; if ( ! Number . isFinite ( value ) || value < 0.5 ) return ; typeScores [ type ] = value ; const ids = new Set ( bank . value . filter ( ( item ) => item . type === type ) . map ( ( item ) => item . id ) ) ; for ( const item of form . questions ) if ( ids . has ( item . questionId ) ) item . score = value ; }
function selectedQuestions ( type ) { const selected = new Set ( form . questions . map ( ( item ) => item . questionId ) ) ; return bank . value . filter ( ( item ) => item . type === type && selected . has ( item . id ) ) ; }
async function nextStep ( ) { if ( activeStep . value === 0 ) { try { await formRef . value . validate ( ) ; const start = new Date ( form . startTime . replace ( " " , "T" ) ) ; const end = new Date ( form . endTime . replace ( " " , "T" ) ) ; if ( end <= start ) return ElMessage . warning ( "结束时间必须晚于开始时间" ) ; duration . value = Math . round ( ( end - start ) / 60000 ) ; } catch { return ; } } if ( activeStep . value === 1 && ! form . questions . length ) return ElMessage . warning ( "至少选择一道试题" ) ; activeStep . value ++ ; }
async function save ( publish ) { if ( inProgress . value ) { await examApi . updateExam ( id . value , form ) ; ElMessage . success ( "结束时间已更新" ) ; return router . push ( "/exam/index" ) ; } try { await formRef . value ? . validate ( ) ; } catch { activeStep . value = 0 ; return ; } if ( ! form . questions . length ) { activeStep . value = 1 ; return ElMessage . warning ( "至少选择一道试题" ) ; } const result = isNew . value ? await examApi . createExam ( form ) : await examApi . updateExam ( id . value , form ) ; const examId = result . data . id ; if ( publish ) await examApi . publishExam ( examId ) ; ElMessage . success ( publish ? "考试已保存并发布" : "考试已保存" ) ; router . push ( "/exam/index" ) ; }
@ -397,8 +380,6 @@ function toBoolean(value, fallback) { if (value === undefined || value === null
tbody tr : hover td { background : # fafcff ; }
}
. type - score - input { width : 112 px ; }
. fixed - step - actions {
display : flex ;
align - items : center ;
@ -690,32 +671,6 @@ function toBoolean(value, fallback) { if (value === undefined || value === null
font - weight : 500 ;
}
. q - score - chip {
display : inline - flex ;
align - items : center ;
gap : var ( -- sp - 1 ) ;
margin - left : auto ;
padding : 2 px var ( -- sp - 3 ) ;
border - radius : var ( -- r - control ) ;
background : # ffffff ;
border : 1 px solid var ( -- edu - primary ) ;
font - size : var ( -- fs - tag ) ;
color : var ( -- edu - primary - deep ) ;
span { color : var ( -- edu - primary - deep ) ; font - weight : 500 ; }
: deep ( . el - input - number ) { width : 88 px ; }
: deep ( . el - input - number . el - input _ _wrapper ) {
padding : 2 px 6 px ;
box - shadow : none ! important ;
background : transparent ;
}
: deep ( . el - input - number _ _decrease ) ,
: deep ( . el - input - number _ _increase ) {
display : none ;
}
}
. q - card - stem {
margin : 0 0 var ( -- sp - 2 ) ;
color : var ( -- text - strong ) ;