测试bug修改

master
wangxi 3 years ago
parent 6f4c56577e
commit 1ccad14781

@ -18,8 +18,7 @@ import { getInfo } from 'react-mediainfo';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
const uuid = uuidv4(); let uuid = uuidv4();
/** /**
@ -223,9 +222,10 @@ const CourseList: React.FC = () => {
hideInSearch: true, hideInSearch: true,
hideInDescriptions: true, hideInDescriptions: true,
renderFormItem: (item, { defaultRender, ...rest }, form) => ( renderFormItem: (item, { defaultRender, ...rest }, form) => (
console.log('item.initialValue',item.initialValue), // console.log('item.initialValue',item.initialValue),
console.log('dfeededed',item.initialValue ?item.initialValue.length===undefined? [item.initialValue].map(i=>({...i, url:'/dsideal_yy/html/' + i.url})):item.initialValue.map(i=>({...i, url:'/dsideal_yy/html/' + i.url})) : []), // console.log('dfeededed',item.initialValue ?item.initialValue.length===undefined? [item.initialValue].map(i=>({...i, url:'/dsideal_yy/html/' + i.url})):item.initialValue.map(i=>({...i, url:'/dsideal_yy/html/' + i.url})) : []),
// console.log('uuid0000000000000',uuid),
// console.log('uploadFileExt000000000000',uploadFileExt),
// item.initialValue.length===undefined? // item.initialValue.length===undefined?
<Upload <Upload
accept='.mp4' accept='.mp4'
@ -234,14 +234,12 @@ const CourseList: React.FC = () => {
beforeUpload={async (file) => { beforeUpload={async (file) => {
/** 获取视频文件信息 */ /** 获取视频文件信息 */
const {media: {track:[General, Video, Audio]}} = await getInfo(file) const {media: {track:[General, Video, Audio]}} = await getInfo(file)
console.log('media',General,Video,Audio) // console.log('media',General,Video,Audio)
if(Video.Format !== 'AVC' || Audio.Format !== 'AAC'){ if(Video.Format !== 'AVC' || Audio.Format !== 'AAC'){
message.error('视频编码格式不正确视频采用AVC音频采用AAC') message.error('视频编码格式不正确视频采用AVC音频采用AAC')
return false; return false;
} }
console.log('filename', file?.name)
// 获取文件名 // 获取文件名
SetUploadFileName(file?.name);
// 获取最后一个.的位置 // 获取最后一个.的位置
const index = file?.name.lastIndexOf("."); const index = file?.name.lastIndexOf(".");
// 获取后缀 // 获取后缀
@ -250,9 +248,6 @@ const CourseList: React.FC = () => {
onRemove={()=>{ onRemove={()=>{
//createFormRef?.current?.setFieldsValue({attachment_json: ""}) //createFormRef?.current?.setFieldsValue({attachment_json: ""})
}} }}
// this.setState({ fileList });
// console.log(999,fileList)
// }}
data={{ data={{
name: uploadFileName, name: uploadFileName,
chunk: 0, chunk: 0,
@ -264,11 +259,11 @@ const CourseList: React.FC = () => {
> >
<Button icon={<UploadOutlined />}></Button> <Button icon={<UploadOutlined />}></Button>
</Upload> </Upload>
), ),
formItemProps: { formItemProps: {
// 参照 https://ant.design/components/form-cn/#Rule // 参照 https://ant.design/components/form-cn/#Rule
getValueFromEvent:(e: any)=>{ getValueFromEvent:(e: any)=>{
console.log('Upload event:', e);
if (Array.isArray(e)) { if (Array.isArray(e)) {
return e; return e;
} }
@ -334,6 +329,7 @@ const CourseList: React.FC = () => {
<a <a
key="update" key="update"
onClick={async() => { onClick={async() => {
uuid = uuidv4();
const info= await viewCourse({course_id:record.course_id}); const info= await viewCourse({course_id:record.course_id});
setCurrentRow(info.data); setCurrentRow(info.data);
handleUpdateModalVisible(true); handleUpdateModalVisible(true);
@ -378,7 +374,6 @@ const CourseList: React.FC = () => {
const handleAdd = async (fields: TableListItem) => { const handleAdd = async (fields: TableListItem) => {
const info= await saveCourse({ ...fields }); const info= await saveCourse({ ...fields });
console.log('info---',info);
if(info.code!==2000){ if(info.code!==2000){
message.warning(info.msg); message.warning(info.msg);
return false; return false;
@ -410,7 +405,6 @@ const CourseList: React.FC = () => {
const info= await saveCourse({ const info= await saveCourse({
...fields, ...fields,
}); });
console.log('info---',info)
if(info.code!==2000){ if(info.code!==2000){
message.warning(info.msg); message.warning(info.msg);
return false; return false;
@ -447,6 +441,7 @@ const CourseList: React.FC = () => {
type="primary" type="primary"
key="primary" key="primary"
onClick={() => { onClick={() => {
uuid = uuidv4();
handleCreateModalVisible(true); handleCreateModalVisible(true);
}} }}
> >
@ -520,7 +515,7 @@ const CourseList: React.FC = () => {
footer={null} footer={null}
centered centered
> >
{console.log('currentRow',currentRow)} {/*{console.log('currentRow',currentRow)}*/}
{currentRow?.course_id && ( {currentRow?.course_id && (
<Row> <Row>
<Col span={14}> <Col span={14}>
@ -627,6 +622,7 @@ const CourseList: React.FC = () => {
formRef={createFormRef} formRef={createFormRef}
layout="horizontal" layout="horizontal"
layoutType="Form" layoutType="Form"
preserve={false}
labelCol={{ span: 8 }} labelCol={{ span: 8 }}
wrapperCol={{ span: 12 }} wrapperCol={{ span: 12 }}
onFinish={async (values: any) => { onFinish={async (values: any) => {
@ -680,11 +676,10 @@ const CourseList: React.FC = () => {
formRef={updateFormRef} formRef={updateFormRef}
layout="horizontal" layout="horizontal"
layoutType="Form" layoutType="Form"
preserve={false}
labelCol={{ span: 8 }} labelCol={{ span: 8 }}
wrapperCol={{ span: 12 }} wrapperCol={{ span: 12 }}
onFinish={async (values: any) => { onFinish={async (values: any) => {
console.log('values',values)
console.log('currentRow',currentRow)
await handleUpdate({ await handleUpdate({
...values, ...values,
attachment_json: `[{"img":"", "name": "${values?.attachment_json[0]?.name}", "url": "down/Syzx/${uuid?.substr(0, 2)}/${uuid}.mp4"}]`, attachment_json: `[{"img":"", "name": "${values?.attachment_json[0]?.name}", "url": "down/Syzx/${uuid?.substr(0, 2)}/${uuid}.mp4"}]`,

@ -82,7 +82,7 @@ export default defineConfig({
{ {
name: '资质考试答题', name: '资质考试答题',
icon: 'dashboard', icon: 'dashboard',
path: '/dashboard/qualification/examAnswer/:examination_id/:rule_id/:examination_name/:time', path: '/dashboard/qualification/examAnswer/:examination_id/:rule_id/:examination_name/:time/:paperId',
component: './dashboard/qualification/examAnswer', component: './dashboard/qualification/examAnswer',
hideInMenu: true, hideInMenu: true,
}, },

@ -60,10 +60,11 @@ const formatSeconds = (value) => {
return result return result
} }
const CardList = () => { const CardList = () => {
const params = useParams();
const formRef = useRef<ActionType>(); const formRef = useRef<ActionType>();
console.log('params0000000',params)
// 组卷详情查询 // 组卷详情查询
const [rulesPaperInfo, setRulesPaperInfo] = useState([]); const [rulesPaperInfo, setRulesPaperInfo] = useState(params.paperId);
//规则 //规则
const [ruleId, setRuleId] = useState([]); const [ruleId, setRuleId] = useState([]);
// 试题列表 // 试题列表
@ -102,25 +103,25 @@ const CardList = () => {
}, []) }, [])
const params = useParams();
const { loading, data } = useRequest(() => { // const { loading, data } = useRequest(() => {
return getPersonPaperId({ // return getPersonPaperId({
examination_id: params.examination_id, // examination_id: params.examination_id,
person_id: cookie.load('person_id') // person_id: cookie.load('person_id')
}); // });
}, // },
{ // {
formatResult: (result) => { // formatResult: (result) => {
return result; // return result;
}, // },
onSuccess: (result) => { // onSuccess: (result) => {
if (result.success) { // if (result.success) {
setRulesPaperInfo(result.paper_id) // setRulesPaperInfo(result.paper_id)
run({ paper_id: result.paper_id }) // run({ paper_id: result.paper_id })
// setQuestionTypeList(result.question_list[0].question_type_count) // // setQuestionTypeList(result.question_list[0].question_type_count)
} // }
} // }
}); // });
const personInfo = useRequest(() => { const personInfo = useRequest(() => {
return getExaminationPersonApplyInfo({ return getExaminationPersonApplyInfo({
@ -160,81 +161,160 @@ const CardList = () => {
} }
}); });
const { run } = useRequest(getPaperQuestionList, const getQuestionList=useRequest(()=>{
{ return getPaperQuestionList({
refreshDeps: [rulesPaperInfo], paper_id:params.paperId
manual: true, })
formatResult: (result) => { },{
return result; // manual: true,
}, formatResult: (result) => {
onSuccess: (result, params) => { return result;
// setRulesPaperInfo(result || []) },
if (result.success) { onSuccess: (result, params) => {
// 试题列表 // setRulesPaperInfo(result || [])
if (result.success) {
const paperList = result.question_list; // 试题列表
const arr = [[], [], []];
const question_type_count = [ const paperList = result.question_list;
{ count: 0, question_type: 0, type_name: '单选' }, const arr = [[], [], []];
{ count: 0, question_type: 1, type_name: '多选' }, const question_type_count = [
{ count: 0, question_type: 2, type_name: '判断' }, { count: 0, question_type: 0, type_name: '单选' },
]; { count: 0, question_type: 1, type_name: '多选' },
if (result.question_list.length !== 0) { { count: 0, question_type: 2, type_name: '判断' },
setRuleId(result.question_list[0].rules_id) ];
result.question_list.forEach((item) => { if (result.question_list.length !== 0) {
if (item.question_type === 0) { setRuleId(result.question_list[0].rules_id)
arr[0].push(item) result.question_list.forEach((item) => {
} else if (item.question_type === 1) { if (item.question_type === 0) {
arr[1].push(item) arr[0].push(item)
} else { } else if (item.question_type === 1) {
arr[2].push(item) arr[1].push(item)
} } else {
}) arr[2].push(item)
} }
question_type_count[0].count = arr[0].length; })
question_type_count[1].count = arr[1].length; }
question_type_count[2].count = arr[2].length; question_type_count[0].count = arr[0].length;
setQuestionType(question_type_count); question_type_count[1].count = arr[1].length;
const qList = question_type_count question_type_count[2].count = arr[2].length;
const questionList: any[] = [] setQuestionType(question_type_count);
qList.map((e, i) => { const qList = question_type_count
if (e.count > 0) { const questionList: any[] = []
questionList.push({ qList.map((e, i) => {
children: [], if (e.count > 0) {
...e questionList.push({
}) children: [],
} ...e
}) })
}
})
// 根据分类拆分试题 左侧答题卡 state:0 未答题 1 已答题 // 根据分类拆分试题 左侧答题卡 state:0 未答题 1 已答题
paperList.map((e) => { paperList.map((e) => {
questionList.map((item, index) => { questionList.map((item, index) => {
if (item.question_type == e.question_type) { if (item.question_type == e.question_type) {
questionList[index].children.push({ ...e, question_type: item.question_type, answerSelect: "", state: 0, answerId: "" }) questionList[index].children.push({ ...e, question_type: item.question_type, answerSelect: "", state: 0, answerId: "" })
} }
}) })
}) })
// 根据答题卡生成考试顺序 // 根据答题卡生成考试顺序
const questionInfo = [] const questionInfo = []
for (let i = 0; i < questionList.length; i++) { for (let i = 0; i < questionList.length; i++) {
questionList[i].children.map((e, index) => { questionList[i].children.map((e, index) => {
questionInfo.push({ ...e, index: [i, index] }) questionInfo.push({ ...e, index: [i, index] })
questionList[i].children[index].index = [i, index] questionList[i].children[index].index = [i, index]
}) })
} }
setPaperInfo(questionInfo || []) setPaperInfo(questionInfo || [])
setQuestionNow(questionInfo[0] || []) setQuestionNow(questionInfo[0] || [])
setQuestionTypeList(questionList || []) setQuestionTypeList(questionList || [])
setQuestioNum(questionInfo.length) setQuestioNum(questionInfo.length)
} }
} }
}); }
)
// const { run } = useRequest(getPaperQuestionList,
// {
// refreshDeps: [rulesPaperInfo],
// manual: true,
// formatResult: (result) => {
// return result;
// },
// onSuccess: (result, params) => {
// // setRulesPaperInfo(result || [])
// if (result.success) {
// // 试题列表
//
// const paperList = result.question_list;
// const arr = [[], [], []];
// const question_type_count = [
// { count: 0, question_type: 0, type_name: '单选' },
// { count: 0, question_type: 1, type_name: '多选' },
// { count: 0, question_type: 2, type_name: '判断' },
// ];
// if (result.question_list.length !== 0) {
// setRuleId(result.question_list[0].rules_id)
// result.question_list.forEach((item) => {
// if (item.question_type === 0) {
// arr[0].push(item)
// } else if (item.question_type === 1) {
// arr[1].push(item)
// } else {
// arr[2].push(item)
// }
// })
// }
// question_type_count[0].count = arr[0].length;
// question_type_count[1].count = arr[1].length;
// question_type_count[2].count = arr[2].length;
// setQuestionType(question_type_count);
// const qList = question_type_count
// const questionList: any[] = []
// qList.map((e, i) => {
// if (e.count > 0) {
// questionList.push({
// children: [],
// ...e
// })
// }
// })
//
//
// // 根据分类拆分试题 左侧答题卡 state:0 未答题 1 已答题
// paperList.map((e) => {
// questionList.map((item, index) => {
// if (item.question_type == e.question_type) {
// questionList[index].children.push({ ...e, question_type: item.question_type, answerSelect: "", state: 0, answerId: "" })
// }
// })
// })
//
// // 根据答题卡生成考试顺序
// const questionInfo = []
// for (let i = 0; i < questionList.length; i++) {
// questionList[i].children.map((e, index) => {
// questionInfo.push({ ...e, index: [i, index] })
// questionList[i].children[index].index = [i, index]
//
// })
// }
//
//
// setPaperInfo(questionInfo || [])
// setQuestionNow(questionInfo[0] || [])
// setQuestionTypeList(questionList || [])
//
// setQuestioNum(questionInfo.length)
// }
// }
// });

@ -40,6 +40,7 @@ const Qualification = () => {
}); });
const paperInfo = useRequest(() => { const paperInfo = useRequest(() => {
return getPersonPaperId({ return getPersonPaperId({
examination_id:params.examination_id, examination_id:params.examination_id,
person_id:cookie.load('person_id') person_id:cookie.load('person_id')
@ -102,7 +103,7 @@ const Qualification = () => {
// const time = await getCurrentDate(); // const time = await getCurrentDate();
// getTime(time); // getTime(time);
const time=rule.examination_time*60; const time=rule.examination_time*60;
history.push(`/dashboard/qualification/examAnswer/${params.examination_id}/${examinationInfo.rules_id}/${examinationInfo.examination_name}/${time}`) history.push(`/dashboard/qualification/examAnswer/${params.examination_id}/${examinationInfo.rules_id}/${examinationInfo.examination_name}/${time}/${paperId}`)
}catch (error) { }catch (error) {
if(error.response){ if(error.response){

@ -155,7 +155,6 @@ const Workplace: FC = () => {
dataIndex: 'option', dataIndex: 'option',
key: 'option', key: 'option',
render: (_, record, index, action) => { render: (_, record, index, action) => {
console.log('record',record)
// return record?.status === 0 ? <Button type="primary" onClick={() => { history.push('/registration' + record.examination_id) }}>去报名</Button> : <Button type="primary" onClick={() => { history.push('/examination/paper') }}> 参加考试</Button > // return record?.status === 0 ? <Button type="primary" onClick={() => { history.push('/registration' + record.examination_id) }}>去报名</Button> : <Button type="primary" onClick={() => { history.push('/examination/paper') }}> 参加考试</Button >
switch (record.status_type) { switch (record.status_type) {
case 0://待报名 case 0://待报名
@ -190,7 +189,7 @@ const Workplace: FC = () => {
const time_diff=(endTime-startTime)/1000; const time_diff=(endTime-startTime)/1000;
console.log('time_diff',time_diff) console.log('time_diff',time_diff)
getExamInfo(record.examination_id,time_diff) getExamInfo(record.examination_id,time_diff,info.bean.paper_id)
}else { }else {
getParperId(record.examination_id) getParperId(record.examination_id)
} }
@ -219,13 +218,13 @@ const Workplace: FC = () => {
}, },
}, },
]; ];
const getExamInfo=async (id,time)=>{ const getExamInfo=async (id,time,paper_id)=>{
try { try {
const info=await getExaminationById({examination_id:id}); const info=await getExaminationById({examination_id:id});
console.log('info--------------------',info) console.log('info--------------------',info)
console.log('time',time) console.log('paper_idpaper_idpaper_id',paper_id)
history.push(`/dashboard/qualification/examAnswer/${id}/${info.bean.rules_id}/${info.bean.examination_name}/${time}`) history.push(`/dashboard/qualification/examAnswer/${id}/${info.bean.rules_id}/${info.bean.examination_name}/${time}/${paper_id}`)
}catch (error) { }catch (error) {
if(error.response){ if(error.response){
@ -243,7 +242,9 @@ const Workplace: FC = () => {
if(info.paper_id===''){ if(info.paper_id===''){
message.warning('考试失败!') message.warning('考试失败!')
}else { }else {
history.push('/dashboard/qualification/' + id) history.push('/dashboard/qualification/' + id)
// history.push(`/dashboard/qualification/${id}/${info.paper_id}`)
} }
}catch (error) { }catch (error) {

Loading…
Cancel
Save