From da9bef00de01b06b1024347acf7a8688bb478ee9 Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Tue, 1 Mar 2022 08:32:23 +0800 Subject: [PATCH] fix --- .../RightContent/AvatarDropdown.tsx | 3 +- admin/src/pages/demo/index.tsx | 19 +- .../attestation/components/AutoSelector.tsx | 35 +- .../attestation/step/index.tsx | 298 ++++++++++-------- .../components/ScoreSetter.tsx | 17 +- .../examinationrules/normal/step/index.tsx | 23 +- admin/src/pages/examinationrules/service.ts | 2 +- 7 files changed, 245 insertions(+), 152 deletions(-) diff --git a/admin/src/components/RightContent/AvatarDropdown.tsx b/admin/src/components/RightContent/AvatarDropdown.tsx index d9e6731..96a6d10 100644 --- a/admin/src/components/RightContent/AvatarDropdown.tsx +++ b/admin/src/components/RightContent/AvatarDropdown.tsx @@ -70,6 +70,7 @@ const AvatarDropdown: React.FC = ({ menu }) => { const menuHeaderDropdown = ( + {/* {menu && ( @@ -83,7 +84,7 @@ const AvatarDropdown: React.FC = ({ menu }) => { )} {menu && } - + */} 退出登录 diff --git a/admin/src/pages/demo/index.tsx b/admin/src/pages/demo/index.tsx index b3eb0f2..e8caa60 100644 --- a/admin/src/pages/demo/index.tsx +++ b/admin/src/pages/demo/index.tsx @@ -1,5 +1,5 @@ import { DingdingOutlined, UploadOutlined } from '@ant-design/icons'; -import { Button, Card, Steps, Result, Descriptions, Modal, Input, Upload, Popconfirm, Menu } from 'antd'; +import { Button, Card, Steps, Result, Descriptions, Modal, Input, Upload, Popconfirm, Menu, Radio } from 'antd'; import { Fragment, useEffect, useRef, useState } from 'react'; import { GridContent } from '@ant-design/pro-layout'; import { Line } from '@ant-design/charts'; @@ -117,6 +117,8 @@ export default () => { const [modalVisible, handleModalVisible] = useState(false); const saveInputRef = useRef(); + const radioRef = useRef(); + //const currentRow = {course_name:'课程0001'}; const currentRow = {course_name1:'课程0001'}; const columns = [ @@ -162,11 +164,6 @@ export default () => { {menuItems} ); - - - - - }, [listData, selectedCourse]); const config = { @@ -254,6 +251,16 @@ export default () => { + + + { + }}> + A + B + C + D + + {}}>rrrrr ) }; diff --git a/admin/src/pages/examinationrules/attestation/components/AutoSelector.tsx b/admin/src/pages/examinationrules/attestation/components/AutoSelector.tsx index 1e68b1b..ced6334 100644 --- a/admin/src/pages/examinationrules/attestation/components/AutoSelector.tsx +++ b/admin/src/pages/examinationrules/attestation/components/AutoSelector.tsx @@ -44,6 +44,9 @@ const AutoSelector = (props: any, ref: any) => { const [questionCount, setQuestionCount] = useState([0,0]) // 题库抽取数量 const [questionTypeCount, setQuestionTypeCount] = useState(questionType.map(()=>(0))) // 题型抽取数量 + const [normalQuestionSum, setNormalQuestionSum] = useState(0) // 常规题库试题数量 + const [attestationQuestionSum, setAttestationQuestionSum] = useState(0) // 资质考试题库试题数量 + const match = useRouteMatch(); console.log('match', match); @@ -52,7 +55,28 @@ const AutoSelector = (props: any, ref: any) => { //const [selectedRowsState, setSelectedRows] = useState([]); //const [addType, setAddType] = useState({name: '', value: 0}); + /** 获取常规题库试题数量 */ + const { data: normalSum } = useRequest(()=>{ + return queryQuestionList({page_number: 1, page_size: 1, type: 0}) + },{ + formatResult: (result) => { + return result.totalRow; + } + }); + + /** 获取资质考试题库试题数量 */ + const { data: attestationSum } = useRequest(()=>{ + return queryQuestionList({page_number: 1, page_size: 1, type: 1}) + },{ + formatResult: (result) => { + return result.totalRow; + } + }); + useEffect(() => { + setNormalQuestionSum(normalSum); + setAttestationQuestionSum(attestationSum); + }, [ normalSum, attestationSum]); // 暴露组件的方法 接受外部获取的ref useImperativeHandle(ref, () => ({ @@ -61,18 +85,19 @@ const AutoSelector = (props: any, ref: any) => { return {questionCount, questionTypeCount}; }, })); + return ( <> 题库选择 - {`常规题库 ( ${0} 道题)`} - 抽取比例: { - setQuestionCount([value,questionCount[1]]) + {`常规题库 ( ${normalQuestionSum} 道题)`} + 抽取比例: { + setQuestionCount([value, questionCount[1]]) }} /> % - {`资质考试题库 ( ${0} 道题)`} - 抽取比例: { + {`资质考试题库 ( ${attestationQuestionSum} 道题)`} + 抽取比例: { setQuestionCount([questionCount[0], value]) }} /> % diff --git a/admin/src/pages/examinationrules/attestation/step/index.tsx b/admin/src/pages/examinationrules/attestation/step/index.tsx index 95baa64..7d7cea5 100644 --- a/admin/src/pages/examinationrules/attestation/step/index.tsx +++ b/admin/src/pages/examinationrules/attestation/step/index.tsx @@ -2,163 +2,159 @@ import React, { useEffect, useRef, useState } from 'react'; import { history, useParams, useRequest } from 'umi'; import { ModalForm, ProFormInstance } from '@ant-design/pro-form'; import { ProFormRadio } from '@ant-design/pro-form'; -import ProForm, { - StepsForm, - ProFormText, - ProFormDatePicker, - ProFormSelect, - ProFormTextArea, - ProFormCheckbox, - ProFormDateRangePicker, -} from '@ant-design/pro-form'; +import ProForm, {StepsForm, ProFormText, ProFormSelect, ProFormDateRangePicker } from '@ant-design/pro-form'; import ProCard from '@ant-design/pro-card'; -import { Button, Checkbox, Col, Divider, Input, List, Menu, message, Radio, Row, Space, Typography } from 'antd'; +import { Button, Checkbox, Col, Divider, Input, List, Menu, message, Radio, Row, Space } from 'antd'; import { PageContainer } from '@ant-design/pro-layout'; import ProDescriptions from '@ant-design/pro-descriptions'; import styles from './index.less' import { saveRules, querySubjectList, queryRulesView, queryRulesList, queryRulesPaper, saveQuestionTypeScore, autoPaperOfficial } from '../../service'; import { queryQuestionType } from '@/pages/questionbank/service'; import ProTable, { ActionType, EditableProTable, ProColumns } from '@ant-design/pro-table'; -import { TableListPagination } from '@/pages/ListTableList2/data'; +//import { TableListPagination } from '@/pages/ListTableList2/data'; import { DiffOutlined, PlusOutlined } from '@ant-design/icons'; -import { TableListItem } from '../../components/QuestionSelector'; +//import { TableListItem } from '../../components/QuestionSelector'; import ScoreSetter from '../../components/ScoreSetter'; import AutoSelector from '../components/AutoSelector'; +import QuestionSelector from '../../components/QuestionSelector'; /** 题型序号 */ const numberType = ['一','二','三','四','五','六','七','八','九','十']; +const questions = [] +export default () => { + const params = useParams(); -const waitTime = (time: number = 100) => { - return new Promise((resolve) => { - setTimeout(() => { - resolve(true); - }, time); - }); -}; -const numbers = []; -for (let i = 0; i < 50; i++) { - numbers.push({ id: `${i}` }) -} + const formRef = useRef(); + const actionRef = useRef(); + const setterRef = useRef(); + const autoRef = useRef(); + + const [questionTypeValues, setQuestionTypeValues] = useState([]); // 题型数据[{count:0, score:0, score_harf:0}] + + /** 自动组卷窗口 */ + const [autoModalVisible, handleAutoModalVisible] = useState(false); + /** 分值窗口 */ + const [scoreModalVisible, handleScoreModalVisible] = useState(false); + /** 试卷详情窗口 */ + const [paperModalVisible, handlePaperModalVisible] = useState(false); -export default () => { /** 列表项定义 */ - const columns: ProColumns[] = [ + const columns: ProColumns[] = [ { - title: '序号', - key: 'index', - valueType: 'indexBorder', - width: 48, + title: '序号', + key: 'index', + valueType: 'indexBorder', + width: 48, }, { - title: '考试名称', - dataIndex: 'rules_name', - valueType: 'text', - hideInTable: false, - hideInForm: false, - hideInSearch: true, + title: '考试名称', + dataIndex: 'rules_name', + valueType: 'text', + hideInTable: false, + hideInForm: false, + hideInSearch: true, }, { - title: '试卷', - dataIndex: 'examination_time', - valueType: 'text', - sorter: false, - hideInTable: true, - hideInForm: true, - hideInSearch: true, - renderText: (val: string) => `${val}`, - }, + title: '试卷', + dataIndex: 'examination_time', + valueType: 'text', + sorter: false, + hideInTable: true, + hideInForm: true, + hideInSearch: true, + renderText: (val: string) => `${val}`, + }, { - title: '关联主题', - dataIndex: 'subject_name', - valueType: 'text', - hideInTable: true, - hideInForm: true, - hideInSearch: true, + title: '关联主题', + dataIndex: 'subject_name', + valueType: 'text', + hideInTable: true, + hideInForm: true, + hideInSearch: true, }, { - title: '题型设置', - dataIndex: 'question_type_count', - valueType: 'text', - hideInTable: true, - hideInForm: false, - hideInSearch: false, - request: async () => { - /* - const { data: Items } = await querySubjectList({}); - // console.log(Items, ')))'); + title: '题型设置', + dataIndex: 'question_type_count', + valueType: 'text', + hideInTable: true, + hideInForm: false, + hideInSearch: false, + request: async () => { + /* + const { data: Items } = await querySubjectList({}); + // console.log(Items, ')))'); - const sinfo = [] - for (let i = 0; i < Items.list.length; i++) { - // console.log(Items.list[i], ">>>") - sinfo.push({ label: Items.list[i].subject_name, value: Items.list[i].subject_id }) - } - console.log(sinfo, 'sinfo'); - */ - return []; + const sinfo = [] + for (let i = 0; i < Items.list.length; i++) { + // console.log(Items.list[i], ">>>") + sinfo.push({ label: Items.list[i].subject_name, value: Items.list[i].subject_id }) + } + console.log(sinfo, 'sinfo'); + */ + return []; }, }, { - title: '总分', - dataIndex: 'sum_score', - sorter: false, - valueType: 'text', - hideInSearch: true, - hideInForm: false, - renderText: (val: string) => `${val || 0} 分`, + title: '总分', + dataIndex: 'sum_score', + sorter: false, + valueType: 'text', + hideInSearch: true, + hideInForm: false, + renderText: (val: string) => `${val || 0} 分`, }, { - title: '通过线', - dataIndex: 'pass_score', - sorter: false, - valueType: 'text', - hideInSearch: true, - hideInForm: false, - renderText: (val: string) => `${val || '-'}`, + title: '通过线', + dataIndex: 'pass_score', + sorter: false, + valueType: 'text', + hideInSearch: true, + hideInForm: false, + renderText: (val: string) => `${val || '-'}`, }, { - title: '操作', - dataIndex: 'option', - valueType: 'option', - width: 200, - render: (_dom: any, record: React.SetStateAction) => { - console.log(record, 'record') - return [ - { - //console.log('entity', entity); - //setCurrentRow(record); - //handleDetailModalVisible(true); - }} - > - 查看 - , - { - //history.push(`/examination/option/registration/${record.examination_id}`); - //setCurrentRow(record); - }} - > - 重新生成 - , - ] - }, + title: '操作', + dataIndex: 'option', + valueType: 'option', + width: 200, + render: (_dom: any, record: React.SetStateAction) => { + console.log(record, 'record') + return [ + { + //console.log('entity', entity); + //setCurrentRow(record); + handlePaperModalVisible(true); // 试卷详情 + }} + > + 查看 + , + { + //history.push(`/examination/option/registration/${record.examination_id}`); + //setCurrentRow(record); + const _type_count: any[] = []; + record?.question_type_count.forEach((item: { count: any; })=>{ + _type_count.push(item?.count || 0) + }) + const { success } = await autoPaperOfficial( + { + paper_id: record?.paper_id, + rules_id: Number(params?.id), + question_count: '50,50', // 当前数据库没保存,只能采用默认 + question_type_count: _type_count?.toString() + } + ) + }} + > + 重新生成 + , + ] + }, }, ]; - - const params = useParams(); - - const formRef = useRef(); - const actionRef = useRef(); - const setterRef = useRef(); - const autoRef = useRef(); - - /** 自动组卷窗口 */ - const [autoModalVisible, handleAutoModalVisible] = useState(false); - /** 分值窗口 */ - const [scoreModalVisible, handleScoreModalVisible] = useState(false); - console.log(params, 'params'); let ruleData = {} if (params?.id) { @@ -198,7 +194,6 @@ export default () => { }> formRef={formRef} onFinish={async () => { - await waitTime(1000); message.success('提交成功'); }} formProps={{ @@ -231,8 +226,6 @@ export default () => { start_time: fileds.dateRange[0], end_time: fileds.dateRange[1] }); - - // await waitTime(2000); return true; }} @@ -305,7 +298,8 @@ export default () => { }} >
- + {`试卷`} + { )} request={async (value) => { console.log('queryRulesPaper::') + /** 获取试卷 */ const _data = await queryRulesPaper( { rules_id: params?.id, @@ -343,6 +338,28 @@ export default () => { page_size: value.pageSize } ); + + + const _questionTypeCountData = []; + _data.question_list[0]?.question_type_count.forEach((item)=>{ + _questionTypeCountData.push(item.count) + }) + console.log('_questionTypeCountData', _questionTypeCountData) + const _questionType = []; + + console.log('_data.question_type_score', _data.question_type_score) + if(_data?.question_type_score.length > 0){ + _data.question_type_score?.forEach((item, index)=>{ + _questionType.push({count: _questionTypeCountData[index], score: item.score, score_harf: item.score_harf}) + }) + }else{ + _questionTypeCountData?.forEach((item, index)=>{ + _questionType.push({count: _questionTypeCountData[index], score:0, score_harf: 0}) + }) + } + + console.log('_questionType', _questionType) + setQuestionTypeValues(_questionType) return { current: _data?.pageNumber, data: _data?.question_list, @@ -437,7 +454,32 @@ export default () => { return true; }} > - + + + { + const values = setterRef.current?.getData() + console.log('试卷详情::::', values); + //const {code, data: paper, msg} = await saveQuestionTypeScore({rules_id:Number(params?.id), type_score: JSON.stringify(values)}) + console.log('paper', paper) + // setUuidPaper(paper?.paper_uuid) + // message.success('提交成功'); + handleScoreModalVisible(false) + return true; + }} + > + {questions && questions?.map((item)=>{ + return <> + + + })} + 试卷详情正在调整布局。。。。。。 diff --git a/admin/src/pages/examinationrules/components/ScoreSetter.tsx b/admin/src/pages/examinationrules/components/ScoreSetter.tsx index 89b2796..573bcb5 100644 --- a/admin/src/pages/examinationrules/components/ScoreSetter.tsx +++ b/admin/src/pages/examinationrules/components/ScoreSetter.tsx @@ -34,6 +34,9 @@ export type TableListItem = { // React.forwardRef 接受渲染函数作为参数。React 将使用 props 和 ref 作为参数来调用此函数。此函数应返回 React 节点。 const ScoreSetter = (props: any, ref: any) => { + + const {questionTypeValues} = props + console.log('questionTypeValues', questionTypeValues) const match = useRouteMatch(); console.log('match', match); @@ -45,11 +48,9 @@ const ScoreSetter = (props: any, ref: any) => { const [sumScore, setSumScore] = useState(0); // 总分 - const formRef = useRef(); - - //const actionRef = useRef(); + //const actionRef = useRef(); /** 列表项定义 */ const columns: any = [ @@ -67,7 +68,7 @@ const ScoreSetter = (props: any, ref: any) => { render: (text, record, index) => 每题 - { + { console.log('row', index) console.log('v1',value) const _data = []; @@ -81,7 +82,7 @@ const ScoreSetter = (props: any, ref: any) => { { (record?.code === 1) && <> 错选、漏选得:: - { + { // const _data = []; console.log('typeScore',typeScore) @@ -99,7 +100,7 @@ const ScoreSetter = (props: any, ref: any) => { title: '题目数量', dataIndex: 'count', width: 80, - //render: text => {text}, + render: (text, _, index) => <>{questionTypeValues[index].count}, /* editable: (text, record, index) => { return true; @@ -160,7 +161,9 @@ const ScoreSetter = (props: any, ref: any) => { ref={formRef} > {return 共计 0 题, 总计 {sumScore} 分 通过分数线 + title={()=>{ + questionTypeValues + return 共计 0 题, 总计 {sumScore} 分 通过分数线 }} //formMapRef={formMapRef} diff --git a/admin/src/pages/examinationrules/normal/step/index.tsx b/admin/src/pages/examinationrules/normal/step/index.tsx index 4139f4f..5b55dc7 100644 --- a/admin/src/pages/examinationrules/normal/step/index.tsx +++ b/admin/src/pages/examinationrules/normal/step/index.tsx @@ -194,7 +194,7 @@ export default () => { b_use: 0, rules_type: 0, }); - run({paper_uuid:1}); // 获取当前选题列表 + //run({paper_uuid:1}); // 获取当前选题列表 // console.log('模拟考试基本信息', fileds) setSubjectId(fileds?.subject_id) // 设置当前关联主题 setRulesName(fileds?.rules_name) // 设置模拟考试规则名称 @@ -278,7 +278,7 @@ export default () => { { > + { questions && questions.map( + <> + + 0. 以下哪些是符合法律规定的 ? + + { return true }} value={0} size="large"> + + A. 单位在试用期辞退员工 + B. 社会中介收取中介费 + C. 单位不缴纳五险一金 + D. 要求员工支付押金 + + + + )} 4. 以下哪些是符合法律规定的 ? @@ -416,14 +431,14 @@ export default () => { visible={selectorModalVisible} onVisibleChange={handleSelectorModalVisible} footer={null} - onFinish={async (values) => { - + onFinish={async (values) => { console.log('v::::', values.name); const rows = selectorRef?.current?.getSelectedRows() console.log('rows::::', rows); const {code, data: paper, msg} = await handleAppend(Number(params?.id), rows) console.log('paper', paper) setUuidPaper(paper?.paper_uuid) + run({paper_uuid: paper?.paper_uuid}); // 获取当前选题列表 // message.success('提交成功'); handleSelectorModalVisible(false) return true; diff --git a/admin/src/pages/examinationrules/service.ts b/admin/src/pages/examinationrules/service.ts index 5e161fb..f485591 100644 --- a/admin/src/pages/examinationrules/service.ts +++ b/admin/src/pages/examinationrules/service.ts @@ -209,4 +209,4 @@ export async function autoPaperOfficial(data: Record, options?: Rec requestType: "form", ...(options || {}), }); -} \ No newline at end of file +}