|
|
@ -99,6 +99,7 @@ const QuestionBank = () => {
|
|
|
|
|
|
|
|
|
|
|
|
const type = history.location.pathname === '/questionbank/attestation' ? 1 : 0 ; // 题库类型
|
|
|
|
const type = history.location.pathname === '/questionbank/attestation' ? 1 : 0 ; // 题库类型
|
|
|
|
const actionRef = useRef<ActionType>();
|
|
|
|
const actionRef = useRef<ActionType>();
|
|
|
|
|
|
|
|
const formRef = useRef();
|
|
|
|
|
|
|
|
|
|
|
|
const [questionType, setQuestionType] = useState([]);
|
|
|
|
const [questionType, setQuestionType] = useState([]);
|
|
|
|
|
|
|
|
|
|
|
@ -114,6 +115,7 @@ const QuestionBank = () => {
|
|
|
|
|
|
|
|
|
|
|
|
const [pageNumber, setPageNumber] = useState(1)
|
|
|
|
const [pageNumber, setPageNumber] = useState(1)
|
|
|
|
//const [answertrueValues, setAnswertrueValues] = useState(); // 编辑试题答案项值
|
|
|
|
//const [answertrueValues, setAnswertrueValues] = useState(); // 编辑试题答案项值
|
|
|
|
|
|
|
|
//const [options, setOptions] = useState([]); // 设置当前选项, 用于删除选项时判断
|
|
|
|
|
|
|
|
|
|
|
|
/** 表单项定义 */
|
|
|
|
/** 表单项定义 */
|
|
|
|
const columns: ProColumns<TableListItem>[] = [
|
|
|
|
const columns: ProColumns<TableListItem>[] = [
|
|
|
@ -233,7 +235,7 @@ const QuestionBank = () => {
|
|
|
|
dependencies:['answers'],
|
|
|
|
dependencies:['answers'],
|
|
|
|
renderFormItem: (item, { defaultRender, ...rest }, form) => {
|
|
|
|
renderFormItem: (item, { defaultRender, ...rest }, form) => {
|
|
|
|
console.log('正确答案...', form.getFieldValue('answers'))
|
|
|
|
console.log('正确答案...', form.getFieldValue('answers'))
|
|
|
|
// 需要处理 关联长度变化及编辑回显
|
|
|
|
// 关联长度变化及编辑回显
|
|
|
|
console.log('edit answertrue11', item)
|
|
|
|
console.log('edit answertrue11', item)
|
|
|
|
console.log('form::::::',form.getFieldValue('answertrue'))
|
|
|
|
console.log('form::::::',form.getFieldValue('answertrue'))
|
|
|
|
console.log('rest', rest)
|
|
|
|
console.log('rest', rest)
|
|
|
@ -251,6 +253,7 @@ const QuestionBank = () => {
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
console.log('====0')
|
|
|
|
console.log('====0')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
console.log('answers??',form.getFieldValue('answers')?.length)
|
|
|
|
console.log('answers??',form.getFieldValue('answers')?.length)
|
|
|
|
console.log('addType?.value', addType?.value)
|
|
|
|
console.log('addType?.value', addType?.value)
|
|
|
|
|
|
|
|
|
|
|
@ -488,7 +491,7 @@ const QuestionBank = () => {
|
|
|
|
title: '题干',
|
|
|
|
title: '题干',
|
|
|
|
search: false,
|
|
|
|
search: false,
|
|
|
|
dataIndex: 'question_stem',
|
|
|
|
dataIndex: 'question_stem',
|
|
|
|
render: (text: React.ReactNode, record: T, index: number) => (<><Text code style={{width:80, fontSize:10, color:'bfbfbf',display:'none'}}>{record?.id}</Text> {text}</>),
|
|
|
|
render: (text: React.ReactNode, record: T, index: number) => (<span style={{fontFamily:'auto'}}><Text code style={{width:80, fontSize:10, color:'bfbfbf',display:'none'}}>{record?.id}</Text> {text}</span>),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
avatar: {
|
|
|
|
avatar: {
|
|
|
|
title: '题型',
|
|
|
|
title: '题型',
|
|
|
@ -729,14 +732,41 @@ const QuestionBank = () => {
|
|
|
|
footer={null}
|
|
|
|
footer={null}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<BetaSchemaForm<DataItem>
|
|
|
|
<BetaSchemaForm<DataItem>
|
|
|
|
|
|
|
|
formRef={formRef}
|
|
|
|
layout="horizontal"
|
|
|
|
layout="horizontal"
|
|
|
|
layoutType="Form"
|
|
|
|
layoutType="Form"
|
|
|
|
labelCol={{ span: 8 }}
|
|
|
|
labelCol={{ span: 8 }}
|
|
|
|
wrapperCol={{ span: 12 }}
|
|
|
|
wrapperCol={{ span: 12 }}
|
|
|
|
|
|
|
|
onValuesChange={()=>{
|
|
|
|
|
|
|
|
//console.log('formRef', formRef.current.getFieldInstance('answertrue'))
|
|
|
|
|
|
|
|
//console.log('formRef.current', formRef.current.getFieldsValue(['answertrue']))
|
|
|
|
|
|
|
|
//console.log('v', value)
|
|
|
|
|
|
|
|
//console.log('answers', formRef?.current?.getFieldValue('answers'))
|
|
|
|
|
|
|
|
const answerTrue = formRef?.current?.getFieldValue('answertrue');
|
|
|
|
|
|
|
|
let fixed_answertrue;
|
|
|
|
|
|
|
|
// 如果正确答案为字符串(单选 / 判断)
|
|
|
|
|
|
|
|
if(typeof answerTrue === 'string'){
|
|
|
|
|
|
|
|
console.log('string.....')
|
|
|
|
|
|
|
|
fixed_answertrue = labels.indexOf(answerTrue) < (formRef?.current?.getFieldValue('answers')?.length || 0) ? answerTrue : undefined;
|
|
|
|
|
|
|
|
}else if(answerTrue?.length > 0){
|
|
|
|
|
|
|
|
fixed_answertrue = answerTrue?.filter((item, key)=>{
|
|
|
|
|
|
|
|
return labels.indexOf(item) < (formRef?.current?.getFieldValue('answers')?.length || 0)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('answerTrue', answerTrue)
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
const */
|
|
|
|
|
|
|
|
//console.log('fixed', fixed_answertrue)
|
|
|
|
|
|
|
|
formRef?.current?.setFieldsValue({answertrue: fixed_answertrue})
|
|
|
|
|
|
|
|
}}
|
|
|
|
onFinish={async (values: any) => {
|
|
|
|
onFinish={async (values: any) => {
|
|
|
|
|
|
|
|
//console.log('formRef.current', formRef.current.getFieldsValue(['answertrue']))
|
|
|
|
|
|
|
|
|
|
|
|
// 表单处理
|
|
|
|
// 表单处理
|
|
|
|
console.log('columns:', columns);
|
|
|
|
console.log('columns:', columns);
|
|
|
|
console.log('values:', values);
|
|
|
|
console.log('values:', values);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false
|
|
|
|
const opts = [];
|
|
|
|
const opts = [];
|
|
|
|
values?.answers?.forEach((item, key)=>{
|
|
|
|
values?.answers?.forEach((item, key)=>{
|
|
|
|
//
|
|
|
|
//
|
|
|
|