wangxi 3 years ago
commit c52a2fa343

@ -64,4 +64,7 @@ ol {
} }
.ant-pro-field-index-column-border{ .ant-pro-field-index-column-border{
background-color: #999 !important; background-color: #999 !important;
}
main{
min-width: 1024px;
} }

@ -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?.();

@ -92,8 +92,9 @@ console.log('props---', props)
return ( return (
<> <>
<Row><Col style={{padding: '10px 0 10px 10px', lineHeight:'32px'}}></Col><Col style={{padding:10}}><Input name='paper_count' defaultValue={1} onChange={(value)=>{ <Row><Col style={{padding: '10px 0 10px 10px', lineHeight:'32px'}}></Col><Col style={{padding:10}}><Input name='paper_count' defaultValue={1} onChange={(e)=>{
setPaperCount(value) const value = e.currentTarget.value;
setPaperCount(value || 0)
}} /></Col><Col style={{color:'#cccccc'}}><span style={{display: 'block', margin: '15px 0 0 10px'}}></span></Col></Row> }} /></Col><Col style={{color:'#cccccc'}}><span style={{display: 'block', margin: '15px 0 0 10px'}}></span></Col></Row>
<Row><Col style={{padding:10}}></Col></Row> <Row><Col style={{padding:10}}></Col></Row>
<Row style={{padding:5}}> <Row style={{padding:5}}>

@ -43,6 +43,7 @@ export default () => {
const [questionTypeValues, setQuestionTypeValues] = useState([]); // 题型数据[{count:0, score:0, score_harf:0}] const [questionTypeValues, setQuestionTypeValues] = useState([]); // 题型数据[{count:0, score:0, score_harf:0}]
const [questionType, setQuestionType] = useState([]); // 题型 const [questionType, setQuestionType] = useState([]); // 题型
const [passScore, setPassScore] = useState(0)
const [rulesId, setRulesId] = useState(0); // 规则id, 保存新建的rules_id const [rulesId, setRulesId] = useState(0); // 规则id, 保存新建的rules_id
const [subjectId, setSubjectId] = useState<number>(0); // 关联主题id const [subjectId, setSubjectId] = useState<number>(0); // 关联主题id
@ -398,7 +399,7 @@ export default () => {
<Row style={{ marginBottom: 24, marginTop: -7 }}> <Row style={{ marginBottom: 24, marginTop: -7 }}>
<Col offset={8} style={{ color: '#bfbfbf' }}></Col> <Col offset={8} style={{ color: '#bfbfbf' }}></Col>
</Row> </Row>
{/*
<ProFormText name="paper_count" label="试卷数量" <ProFormText name="paper_count" label="试卷数量"
width='lg' width='lg'
initialValue={ruleData.paper_count} initialValue={ruleData.paper_count}
@ -427,6 +428,7 @@ export default () => {
<Row style={{ marginBottom: 24, marginTop: -7 }}> <Row style={{ marginBottom: 24, marginTop: -7 }}>
<Col offset={8} style={{ color: '#bfbfbf' }}></Col> <Col offset={8} style={{ color: '#bfbfbf' }}></Col>
</Row> </Row>
*/}
{console.log('###', ruleData)} {console.log('###', ruleData)}
<ProFormDateRangePicker width='lg' name="dateRange" label="试卷有效期" initialValue={(ruleData?.start_time && ruleData?.end_time) ? [ruleData?.start_time, ruleData?.end_time] : []} rules={[{ required: true, message: '请输试卷有效期' }]} /> <ProFormDateRangePicker width='lg' name="dateRange" label="试卷有效期" initialValue={(ruleData?.start_time && ruleData?.end_time) ? [ruleData?.start_time, ruleData?.end_time] : []} rules={[{ required: true, message: '请输试卷有效期' }]} />
<Row style={{ marginBottom: 24, marginTop: -7 }}> <Row style={{ marginBottom: 24, marginTop: -7 }}>
@ -477,7 +479,19 @@ export default () => {
<Button <Button
type="primary" type="primary"
key="primary" key="primary"
onClick={() => { onClick={async () => {
/** 获取试卷 */
const {question_type_score, question_list} = await queryRulesPaper(
{
rules_id: params?.id || rulesId,
page_number: 1,
page_size: 10
}
);
console.log('_data:', question_type_score)
setPassScore(question_list[0]?.pass_score)
//questionTypeValues?.map((item,idx)=>{return {...item, score:values[idx]?.score, score_harf:values[idx]?.score_harf}})
//setQuestionTypeValues() // 更新分值成功后设置组件分值
handleScoreModalVisible(true) handleScoreModalVisible(true)
}} }}
> >
@ -495,9 +509,7 @@ export default () => {
page_size: value.pageSize page_size: value.pageSize
} }
); );
const _questionType = []; const _questionType = [];
const _questionTypeCountData = []; const _questionTypeCountData = [];
_data.question_list[0]?.question_type_count.forEach((item) => { _data.question_list[0]?.question_type_count.forEach((item) => {
_questionTypeCountData.push(item.count) _questionTypeCountData.push(item.count)
@ -515,21 +527,9 @@ export default () => {
_questionType[index] = { ..._questionType[index], count: _questionTypeCountData[index], score: 0, score_harf: 0 } _questionType[index] = { ..._questionType[index], count: _questionTypeCountData[index], score: 0, score_harf: 0 }
}) })
} }
// question_type_count // question_type_count
console.log('_questionType 1', _questionType) console.log('_questionType 1', _questionType)
setQuestionTypeValues(_questionType) setQuestionTypeValues(_questionType)
return { return {
current: _data?.pageNumber, current: _data?.pageNumber,
data: _data?.question_list, data: _data?.question_list,
@ -630,13 +630,19 @@ export default () => {
onFinish={async () => { onFinish={async () => {
const values = setterRef.current?.getData() // 获取题型分值数据 const values = setterRef.current?.getData() // 获取题型分值数据
const passSocre = setterRef.current?.getValue() // 获取通过分数线 const passSocre = setterRef.current?.getValue() // 获取通过分数线
const sumCore = setterRef.current?.getSum() // 获取总分数
console.log('getSum()',sumCore)
if(passSocre > sumCore){ if(passSocre > sumCore){
message.error('通过分数线不能大于总分,请修改通过分数线'); message.error('通过分数线不能大于总分,请修改通过分数线');
return false; return false;
} }
console.log('批量设置分值v::::', values); console.log('批量设置分值v::::', values);
const { code, data: paper, msg } = await saveQuestionTypeScore({ rules_id: Number(params?.id || rulesId), type_score: JSON.stringify(values) }) const { code, data: paper, msg } = await saveQuestionTypeScore({ rules_id: Number(params?.id || rulesId), type_score: JSON.stringify(values) })
console.log('paper', paper) console.log('paper', paper)
// 总分及通过分 // 总分及通过分
let _sumScore = 0; let _sumScore = 0;
values?.forEach((item: { score: number; }) => { values?.forEach((item: { score: number; }) => {
@ -644,7 +650,7 @@ export default () => {
_sumScore += item?.score _sumScore += item?.score
}) })
console.log('_sumScore', _sumScore) console.log('_sumScore', _sumScore)
// 需要处理 //return false;
console.log('passSocre', passSocre) console.log('passSocre', passSocre)
//console.log('sumScore',sumScore) //console.log('sumScore',sumScore)
const { success } = await updateScore({ rules_id: Number(params?.id || rulesId), pass_socre: passSocre, sum_score: _sumScore }) const { success } = await updateScore({ rules_id: Number(params?.id || rulesId), pass_socre: passSocre, sum_score: _sumScore })
@ -656,12 +662,11 @@ export default () => {
return true; return true;
}} }}
> >
<ScoreSetter ref={setterRef} questionTypeValues={questionTypeValues || false} /> <ScoreSetter ref={setterRef} questionTypeValues={questionTypeValues || false} passScore={passScore} />
</ModalForm> </ModalForm>
<ModalForm <ModalForm
// title={`试卷详情`} // title={`试卷详情`}
title={ruleData?.rules_name} title={ruleData?.rules_name}
//
width="80%" width="80%"
visible={paperModalVisible} visible={paperModalVisible}
onVisibleChange={handlePaperModalVisible} onVisibleChange={handlePaperModalVisible}

@ -1,24 +1,14 @@
/** 模拟考试 | 资质考试选题 */ /** 模拟考试 | 资质考试选题 */
//import { AlignLeftOutlined, PlusOutlined } from '@ant-design/icons'; import { InputNumber, Space, Form, Input} from 'antd';
import { Button, InputNumber, message, Space, Form, Input} from 'antd'; //import styles from '../style.less';
//import { FooterToolbar, PageContainer } from '@ant-design/pro-layout'; import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
//import { useRequest } from 'umi'; //import { useParams, useRequest, history, useRouteMatch } from 'umi';
//import { queryFakeList } from './service'; //import { queryCourseView } from '@/pages/course/option/service';
//import type { CardListItemDataType } from './data'; import { queryQuestionType } from '@/pages/questionbank/service';
import styles from '../style.less';
//import SubMenu from 'antd/lib/menu/SubMenu';
//import ProCard from '@ant-design/pro-card';
//import ProList from '@ant-design/pro-list';
import { forwardRef, ReactText, useEffect, useImperativeHandle, useRef, useState } from 'react';
//import { PlusOutlined, DeleteOutlined, DownloadOutlined, UploadOutlined, EditOutlined, EyeOutlined, EyeInvisibleOutlined, DownOutlined } from '@ant-design/icons';
import { useParams, useRequest, history, useRouteMatch } from 'umi';
import { queryCourseView } from '@/pages/course/option/service';
import { queryQuestionList, queryQuestionType } from '@/pages/questionbank/service';
//import ProForm, { ProFormSelect } from '@ant-design/pro-form'; //import ProForm, { ProFormSelect } from '@ant-design/pro-form';
import { ActionType, EditableProTable, ProColumns } from '@ant-design/pro-table'; //import { ActionType, EditableProTable, ProColumns } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table';
import ProForm from '@ant-design/pro-form'; //import ProForm from '@ant-design/pro-form';
export type TableListItem = { export type TableListItem = {
id: string; id: string;
@ -33,31 +23,16 @@ export type TableListItem = {
}; };
// React.forwardRef 接受渲染函数作为参数。React 将使用 props 和 ref 作为参数来调用此函数。此函数应返回 React 节点。 // React.forwardRef 接受渲染函数作为参数。React 将使用 props 和 ref 作为参数来调用此函数。此函数应返回 React 节点。
const ScoreSetter = (props: any, ref: any) => { const ScoreSetter = (props: any, ref: any) => {
const {questionTypeValues, passScore: passScoreValue } = props
const {questionTypeValues } = props
console.log('questionTypeValues:::', questionTypeValues)
//console.log('passScoreValue:::', passScoreValue)
const match = useRouteMatch();
console.log('match', match);
const [typeScore, setTypeScore] = useState([]) ; // 题型分数数组 [{"question_type": "0","score": "3","score_harf": "0"},] const [flag, setFlag] = useState<any>([]) // 分数变更标记
const [typeScore, setTypeScore] = useState(questionTypeValues.map((item: { code: number; score: number; score_harf: number; })=>({question_type:item.code, score: item.score, score_harf: item.score_harf}))) ; // 题型分数数组 [{"question_type": "0","score": "3","score_harf": "0"},]
//const type = history.location.pathname === '/questionbank/attestation' ? 1 : 0 ; // 题库类型 //const type = history.location.pathname === '/questionbank/attestation' ? 1 : 0 ; // 题库类型
const [dataSource, setDataSource] = useState([]); //const [sumScore, setSumScore] = useState();
//const [selectedRowsState, setSelectedRows] = useState<API.RuleListItem[]>([]); const [passScore, setPassScore] = useState(passScoreValue); // 设置通过分数线
//const [addType, setAddType] = useState({name: '', value: 0});
const [sumScore, setSumScore] = useState(0);
const [passScore, setPassScore] = useState(0); // 设置通过分数线
//let sumScore = 0 // 总分
const formRef = useRef();
//const actionRef = useRef<ActionType>(); const formRef = useRef<any>();
/** 列表项定义 */ /** 列表项定义 */
const columns: any = [ const columns: any = [
@ -72,7 +47,7 @@ const ScoreSetter = (props: any, ref: any) => {
dataIndex: 'score', dataIndex: 'score',
key: 'code', key: 'code',
width: 400, width: 400,
render: (text, record, index) => render: (_text: any, record: { code: number; }, index: string | number) =>
<Space direction='horizontal'> <Space direction='horizontal'>
<span></span> <span></span>
<Form.Item style={{margin:0}} name={`score[${index}]`}><Input <Form.Item style={{margin:0}} name={`score[${index}]`}><Input
@ -86,39 +61,39 @@ 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)=>{
const value = e.currentTarget.value const value = e.currentTarget.value;
console.log('row', index) const scoreData = typeScore?.map((item: { score: any; }, key: string | number)=>{
console.log('v1',value) return {...item, score: ((index === key) ? Number(value) : Number(item?.score))} // 题型分数
const _data = [];
console.log('typeScore1',typeScore)
//const _sumItems = [];
typeScore?.forEach((item, key)=>{
_data.push({...item, score: ((index === key) ? Number(value) : Number(item?.score))}) // 题型分数
//_sumItems.push((index === key) ? (value * questionTypeValues[index].count) : sumScoreItems[index]) // 题型总分
}) })
setTypeScore(_data) // 标记重新设置项(序号)
if(flag.indexOf(index) === -1){
//setSumScoreItems(_sumItems) setFlag([...flag, index])
//console.log('setSumScoreItems', sumScoreItems) }
setTypeScore(scoreData)
}}/></Form.Item> }}/></Form.Item>
<span></span> <span></span>
{ (record?.code === 1) && { (record?.code === 1) &&
<> <>
<span>:</span> <span>:</span>
<Form.Item style={{margin:0}} name={`score_harf`}><InputNumber min={0} max={99} maxLength={2} type="number" defaultValue={questionTypeValues ? questionTypeValues[index]?.score_harf : 0} placeholder="请输入" size="small" name='score_harf' onChange={(value)=>{ <Form.Item style={{margin:0}} name={`score_harf`}
// rules={[
const _data = []; /*
console.log('typeScore',typeScore) {
typeScore?.forEach((item, key)=>{ required: true,
_data.push({...item, score_harf: ((index === key) ? value : item?.score_harf)}) message: '请输入分值!',
}) },*/
setTypeScore(_data) ]}
}} /></Form.Item> ><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)=>{
<span></span> const harf = typeScore?.map((item: { score_harf: any; }, key: number)=>{
return {...item, score_harf: ((index === key) ? value : item?.score_harf)}
})
setTypeScore(harf)
}} /></Form.Item>
<span></span>
</> </>
} }
</Space>, </Space>,
@ -127,117 +102,103 @@ const ScoreSetter = (props: any, ref: any) => {
title: '题目数量', title: '题目数量',
dataIndex: 'count', dataIndex: 'count',
width: 80, width: 80,
render: (text, _, index) => <>{questionTypeValues ? questionTypeValues[index]?.count : '0'}</>, render: (_text: any, _: any, index: number) => <>{questionTypeValues ? questionTypeValues[index]?.count || 0 : '0'}</>,
/*
editable: (text, record, index) => {
return true;
},*/
}, },
{ {
title: '总分值', title: '总分值',
dataIndex: 'score_sum', dataIndex: 'score_sum',
//key: 'age', //key: 'age',
width: 80, width: 80,
render: (text, _, index) => { render: (_text: any, _: any, index: number) => {
{console.log('typeScore---', typeScore)}
return <> return <>
{(typeScore && questionTypeValues) ? ((typeScore[index]?.score > 0 ? typeScore[index]?.score : 0) * questionTypeValues[index]?.count).toFixed(1) : '0'} {flag?.indexOf(index) === -1 ?
(questionTypeValues[index]?.score || 0) * (questionTypeValues[index]?.count || 0) :
(typeScore && questionTypeValues) ? ((typeScore[index]?.score > 0 ? typeScore[index]?.score : 0) * (questionTypeValues[index]?.count || 0)).toFixed(1) : '0'
}
</> </>
}, },
} }
]; ];
//const labels = ['A','B','C','D','E']
/** 获取总题数 */ /** 获取总题数 */
let sumQuestion = 0; let sumQuestion = 0;
questionTypeValues?.forEach((item) => { questionTypeValues?.forEach((item: any) => {
sumQuestion += item.count; sumQuestion += item.count;
}); });
// 获取题型
const { data } = useRequest(() => {
return queryQuestionType();
},{
formatResult: (result) => {
const _data = [];
if(result.list){
result.list.forEach((item)=>{
_data.push({
name: item?.name,
code: item?.code,
count: 0,
score_sum: 0,
harf: 0
})
})
}
console.log('_data',_data)
return _data;
}
});
useEffect(() => {
setDataSource(data);
console.log('data', data)
const _typeScore = [];
data?.forEach((item)=>{
_typeScore.push({question_type: item?.code, score: item?.count, score_harf: 0})
})
setTypeScore(_typeScore) // 初始值
//return ()=>{}
}, [data]);
/** 计算总分 */
useEffect(() => {
console.log('typeScore', typeScore)
let _sum = 0;
typeScore?.forEach((item, index)=>{
_sum += (item.score > 0 ? item.score : 0 ) * questionTypeValues[index]?.count;
})
setSumScore(_sum)
//return ()=>{}
}, [typeScore]);
// 暴露组件的方法 接受外部获取的ref // 暴露组件的方法 接受外部获取的ref
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
// 构造ref的获取数据方法 // 构造ref的获取数据方法
getData: () => { getData: () => {
return typeScore; return typeScore?.map((item: any, idx: number)=>{
return {
...item,
count: questionTypeValues[idx]?.count,
sum: item?.score * questionTypeValues[idx]?.count,
}
})
}, },
getValue: () => { getValue: () => {
return passScore; return passScore
}, },
getSum: () => { getSum: () => {
return sumScore; return typeScore?.map((item: any, key: number)=>{return item?.score * questionTypeValues[key].count})?.reduce((total: number, item: number)=>(total + item)) || 0 ;
}, },
})); }));
return ( return (
<Form <>
ref={formRef} <Form
> ref={formRef}
<EditableProTable >
title={()=>{ <ProTable
return <Space size="large"><span> {sumQuestion} ,</span><span> {sumScore} </span> 线 title={()=>{
<Form.Item style={{margin:0}} name='pass_socre' initialValue={0}><InputNumber min={0} onChange={(value)=>{ return <Space size="large"><span> {sumQuestion || 0} ,</span><span> {
setPassScore(value) typeScore?.length > 0 &&
}} /></Form.Item> typeScore?.map((item: any, key: number)=>{return item?.score * questionTypeValues[key].count})?.reduce((total: number, item: number)=>(total + item)) || 0
</Space>}} } </span> 线
//formMapRef={formMapRef} <Form.Item style={{margin:0}} name='pass_socre' initialValue={passScore || 0}><InputNumber min={0} onChange={(value)=>{
//rowKey={'code'} setPassScore(value)
bordered }} /></Form.Item>
cardProps={{bodyStyle:{padding:0}}} </Space>}}
recordCreatorProps={false} //formMapRef={formMapRef}
search={false} rowKey={'code'}
options={false} request={async ()=>{
value={dataSource} console.log('questionTypeValues1111', questionTypeValues)
columns={columns} const result = await queryQuestionType() // 从字典获取题型数据 [{code: 0, name:"单选题"},]
/> setTypeScore(questionTypeValues?.map((item: { score: any; score_harf: any; }, key: number)=>{
</Form> return {question_type: result.list[key]?.code, score: item?.score, score_harf: (item?.score_harf || 0)}
}))
return {data:questionTypeValues?.map((item: any, key: number)=>({
...item,
code: result.list[key]?.code,
question_type: result.list[key]?.code,
name: result.list[key]?.name,
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
cardProps={{bodyStyle:{padding:0}}}
search={false}
options={false}
columns={columns}
pagination={false}
/>
</Form>
</>
); );
}; };
// forwardRef这个组件能够将其接受的 ref 属性转发到其组件树下 // forwardRef这个组件能够将其接受的 ref 属性转发到其组件树下

@ -195,7 +195,7 @@ export default () => {
/** 组卷,查询试题临时表(当前选题列表) */ /** 组卷,查询试题临时表(当前选题列表) */
const { data: questions, run } = useRequest(async (params) => { const { data: questions, run } = useRequest(async (params) => {
console.log('questions', questions) console.log('questions::::', questions)
const _data = await queryTempQuestionList(params); const _data = await queryTempQuestionList(params);
return _data; return _data;
}, { }, {
@ -209,7 +209,7 @@ export default () => {
useEffect(() => { useEffect(() => {
const _data = [0, 0, 0]; // 当前仅支持 单选 / 多选 / 判断 的顺序 const _data = [0, 0, 0]; // 当前仅支持 单选 / 多选 / 判断 的顺序
console.log('questions-info', questions) console.log('questions-info', questions)
questions?.forEach((item) => { questions?.forEach((item: { question_type: any; }) => {
_data[Number(item?.question_type)] += 1 _data[Number(item?.question_type)] += 1
}) })
@ -236,7 +236,7 @@ export default () => {
} }
}); });
// // 获取组卷详情
const { data: paperData, run: runPaper } = useRequest(async (params) => { const { data: paperData, run: runPaper } = useRequest(async (params) => {
console.log('paperData', paperData) console.log('paperData', paperData)
/** /**
@ -276,7 +276,7 @@ export default () => {
}); });
ruleData = data ruleData = data
} }
console.log(ruleData, 'ruleData'); console.log('ruleData', ruleData);
return ( return (
<PageContainer content={''} extraContent={''}> <PageContainer content={''} extraContent={''}>
@ -315,6 +315,11 @@ export default () => {
rules_type: 0, rules_type: 0,
}); });
// 获取 paper_uuid
const pager = await queryRulesPaper({ rules_id: params?.id || rulesId });
setUuidPaper(pager?.question_list[0]?.paper_uuid)
console.log('###paper_uuid==', pager?.question_list[0]?.paper_uuid)
setRulesId(data?.rules_id) // 保存规则id setRulesId(data?.rules_id) // 保存规则id
//run({paper_uuid:1}); // 获取当前选题列表 //run({paper_uuid:1}); // 获取当前选题列表
// console.log('模拟考试基本信息', fileds) // console.log('模拟考试基本信息', fileds)
@ -322,11 +327,27 @@ export default () => {
setRulesName(fileds?.rules_name) // 设置模拟考试规则名称 setRulesName(fileds?.rules_name) // 设置模拟考试规则名称
console.log('fileds', fileds) console.log('fileds', fileds)
console.log('formRef', formRef.current?.getFieldValue('')) console.log('formRef', formRef.current?.getFieldValue(''))
// await waitTime(2000);
setCurrentStep(1) // 设置步骤号 setCurrentStep(1) // 设置步骤号
runScore({rules_id: data?.rules_id}) // runScore({rules_id: data?.rules_id}) //
return true;
// 如果有保存的试卷,显示当前选题列表数据
if(pager?.question_list[0]?.paper_uuid){
console.log('has......')
// 获取数据
run({
paper_uuid: pager?.question_list[0]?.paper_uuid,
page_size: 1000,
page_number: 1
});
}else{
console.log('no has ....')
}
//runPaper({ rules_id: params?.id || rulesId }) // 获取组卷详情
console.log('###')
console.log('uuidPaper', uuidPaper)
return true;
}} }}
> >
<Row gutter={24}> <Row gutter={24}>
@ -445,15 +466,13 @@ export default () => {
message.error(msg); message.error(msg);
return false; return false;
} }
// question 请选择试题 请选择试题 //
runPaper({ rules_id: params?.id || rulesId }) runPaper({ rules_id: params?.id || rulesId })
return true; return true;
}} }}
> >
<div style={{ margin: '0' }}> <div style={{ margin: '0' }}>
{/*uuidPaper*/}
<Typography style={{ padding: 24, fontSize: 24, textAlign: 'center' }}>{rulesName}</Typography> <Typography style={{ padding: 24, fontSize: 24, textAlign: 'center' }}>{rulesName}</Typography>
{/** 一旦录入另一项将禁用,清空组卷后可选另一项 */} {/** 一旦录入另一项将禁用,清空组卷后可选另一项 */}
<Row> <Row>
@ -532,12 +551,14 @@ export default () => {
<div style={{ height: 'auto', backgroundColor: '#f0f0f0', textAlign: 'right', padding: 5, opacity: 1 }}> <div style={{ height: 'auto', backgroundColor: '#f0f0f0', textAlign: 'right', padding: 5, opacity: 1 }}>
<Button disabled={idx === 0} onClick={async ()=>{ <Button disabled={idx === 0} onClick={async ()=>{
const success = await handleExchangeSortNum(uuidPaper,[questions[idx-1]?.id, item?.id].toString(), rulesId) const success = await handleExchangeSortNum(uuidPaper,[questions[idx-1]?.id, item?.id].toString(), rulesId)
// 刷新试题列表
if (success) { if (success) {
// 当前选题列表数据
run({ run({
paper_uuid: uuidPaper, paper_uuid: uuidPaper,
page_size: 1000, page_size: 1000,
page_number: 1 page_number: 1
}); // 获取当前选题列表 });
} }
}}><ArrowUpOutlined /></Button> }}><ArrowUpOutlined /></Button>
<Button disabled={idx+1 === questions?.length} onClick={async ()=>{ <Button disabled={idx+1 === questions?.length} onClick={async ()=>{
@ -579,27 +600,51 @@ export default () => {
<div style={{ background: '#ffffff', padding: 24 }}> <div style={{ background: '#ffffff', padding: 24 }}>
<Space direction="vertical" style={{ width: '100%' }}> <Space direction="vertical" style={{ width: '100%' }}>
<strong></strong> <strong></strong>
<Typography> {questions?.length} {paperInfo?.sum_score || '-'}{ console.log('scoreData', scoreData)} </Typography> <Typography> {questions?.length} {/*paperInfo?.sum_score || 0*/} {
questionType?.length > 0 ?
questionType?.map((item) => {
return typeQuestionCount[Number(item.code)] * scoreData?.filter(val=>(val.question_type === Number(item?.code)))[0]?.score || 0;
}).reduce((total, item)=>(total + item)) : 0
} </Typography>
<Divider style={{ margin: '6px 0', opacity: 0.5 }} /> <Divider style={{ margin: '6px 0', opacity: 0.5 }} />
<Space direction="vertical"> <Space direction="vertical">
{questionType.map((item) => { {questionType.map((item) => {
return <Typography>{item?.name} {typeQuestionCount[Number(item.code)]} {typeQuestionCount[Number(item.code)] * scoreData?.filter(val=>(val.question_type === Number(item?.code)))[0]?.score} </Typography> const type_sum = typeQuestionCount[Number(item.code)] * scoreData?.filter(val=>(val.question_type === Number(item?.code)))[0]?.score || 0;
return <Typography>{item?.name} {typeQuestionCount[Number(item.code)]} {type_sum} </Typography>
} }
)} )}
</Space> </Space>
<Divider style={{ margin: '6px 0', opacity: 0.5 }} /> <Divider style={{ margin: '6px 0', opacity: 0.5 }} />
<Button size="large" block onClick={() => { <Button size="large" block onClick={async () => {
const {question_type_score} = await queryQuestionTypeScore({rules_id: (params?.id || rulesId)})
console.log('q:::',question_type_score)
console.log('w:::',question_type_score?.map((item,key)=>({count: typeQuestionCount[key], ...item})))
setQuestionTypeValues(question_type_score?.map((item,key)=>({count: typeQuestionCount[key], ...item})))
/** /**
* *
* [{count: 0, score: 0, score_harf: 0},{count: 0, score: 0, score_harf: 0},{count: 0, score: 0, score_harf: 0}] * [{count: 0, score: 0, score_harf: 0},{count: 0, score: 0, score_harf: 0},{count: 0, score: 0, score_harf: 0}]
*/ */
// //
// 初始值
/*
const _data = [] const _data = []
typeQuestionCount?.forEach((item) => { typeQuestionCount?.forEach((item) => {
_data.push({ count: item, score: 0, score_harf: 0 }) _data.push({ count: item, score: 0, score_harf: 0 })
}) })
setQuestionTypeValues(_data) setQuestionTypeValues(_data)
console.log('typeQuestionCount', typeQuestionCount); */
/** */
//const questionTypeScore = await queryQuestionTypeScore(params?.id || rulesId)
//console.log('q::', questionTypeScore)
console.log('typeQuestionCount---------------', typeQuestionCount);
setPassScore(ruleData?.pass_score)
handleScoreModalVisible(true) handleScoreModalVisible(true)
}}></Button> }}></Button>
<Tooltip defaultVisible={false} zIndex={1} title={<span style={{display:'block', width:152}}></span>} placement="bottom" color='#108ee9'> <Tooltip defaultVisible={false} zIndex={1} title={<span style={{display:'block', width:152}}></span>} placement="bottom" color='#108ee9'>
@ -733,9 +778,15 @@ export default () => {
const passSocre = setterRef.current?.getValue() // 获取通过分数线 const passSocre = setterRef.current?.getValue() // 获取通过分数线
const sumCore = setterRef.current?.getSum() // 获取总分 const sumCore = setterRef.current?.getSum() // 获取总分
if(passSocre > sumCore){ if(passSocre > sumCore){
message.error('通过分数线不能大于总分,请修改通过分数线'); message.error('通过分数线不能大于总分,请修改通过分数线');
return false; return false;
} }
if(values.filter(item=>(item?.score_harf > item?.score)).length > 0){
message.error('“错选漏选分数”不能大于该题型分,请修改“通错选漏选得分”');
return false;
}
console.log('批量设置分值v::::2', values); console.log('批量设置分值v::::2', values);
// 题型分数 // 题型分数
const { code, data: paper, msg } = await saveQuestionTypeScore({ rules_id: Number(params?.id || rulesId), type_score: JSON.stringify(values) }) const { code, data: paper, msg } = await saveQuestionTypeScore({ rules_id: Number(params?.id || rulesId), type_score: JSON.stringify(values) })
@ -749,7 +800,7 @@ export default () => {
return true; return true;
}} }}
> >
<ScoreSetter ref={setterRef} questionTypeValues={questionTypeValues || false} /> <ScoreSetter ref={setterRef} questionTypeValues={questionTypeValues.length > 0 ? questionTypeValues : questionType?.map((item,key)=>({...item, count: typeQuestionCount[key]}))} passScore={passScore} />
</ModalForm> </ModalForm>
</PageContainer> </PageContainer>

@ -62,7 +62,6 @@ const IntroduceRow = ({ loading, visitData }: { loading: boolean; visitData: Dat
} }
}); });
const {data: examinationData, run } = useRequest(() => { const {data: examinationData, run } = useRequest(() => {
return getExaminationStatistics({ return getExaminationStatistics({
bureau_id:typeof (school)===number?school:0, bureau_id:typeof (school)===number?school:0,

@ -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);

@ -1,6 +1,6 @@
import { PlusOutlined } from '@ant-design/icons'; import { PlusOutlined } from '@ant-design/icons';
import { Button, message, Input, Drawer, Row, Col, Space, Modal, Popconfirm } from 'antd'; import { Button, message, Input, Drawer, Row, Col, Space, Modal, Popconfirm } from 'antd';
import React, { useState, useRef } from 'react'; import React, { useState, useRef, Children } from 'react';
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import type { ProColumns, ActionType } from '@ant-design/pro-table'; import type { ProColumns, ActionType } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table';
@ -8,11 +8,12 @@ import { BetaSchemaForm, ModalForm, ProFormText, ProFormTextArea } from '@ant-de
import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions'; import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions';
import ProDescriptions from '@ant-design/pro-descriptions'; import ProDescriptions from '@ant-design/pro-descriptions';
import type { FormValueType } from './components/UpdateForm'; import type { FormValueType } from './components/UpdateForm';
import UpdateForm from './components/UpdateForm'; //import UpdateForm from './components/UpdateForm';
import { queryTrainList, saveTrain, removeTrain, queryOrgTree, queryValueByKey, querySubjectList, querySubjectView } from './service'; import { queryTrainList, saveTrain, removeTrain, queryOrgTree, queryValueByKey, querySubjectList, querySubjectView, getAsyncOrgTree, getEduUnitList } from './service';
import type { TableListItem, TableListPagination } from './data'; import type { TableListItem, TableListPagination } from './data';
import { useRequest } from 'umi'; import { useRequest } from 'umi';
import cookie from 'react-cookies';
import Item from 'antd/lib/list/Item';
/** /**
* *
* *
@ -106,11 +107,12 @@ const getJsonTree = (data: [], pId: number) => {
//console.log('f') //console.log('f')
//console.log('node?.pId',node?.pId) //console.log('node?.pId',node?.pId)
//console.log('pId',pId) //console.log('pId',pId)
if (node?.pId === Number(pId)) { if (Number(node?.pId) === Number(pId)) {
console.log('if') console.log('if')
const treeNode: children = {}; const treeNode: children = {};
treeNode.value = node?.id; treeNode.value = node?.id;
treeNode.label = node?.name; treeNode.name = node?.name;
treeNode.children = node?.children;
//treeNode.url = node.url; //treeNode.url = node.url;
//treeNode.icon = node.icon; //treeNode.icon = node.icon;
@ -124,6 +126,8 @@ const getJsonTree = (data: [], pId: number) => {
const TableList: React.FC = () => { const TableList: React.FC = () => {
const provinceId = cookie.load('background_province_id') // 获取省份id
const { data, loading } = useRequest(() => { const { data, loading } = useRequest(() => {
return queryValueByKey({}); return queryValueByKey({});
}); });
@ -170,10 +174,18 @@ const TableList: React.FC = () => {
}, },
{ {
title: '培训对象', title: '培训对象',
valueType: 'select', valueType: 'treeSelect',
hideInSearch: true, hideInSearch: true,
fieldProps: { fieldProps: {
mode: "multiple" //mode: "multiple",
multiple: true,
treeNodeFilterProp: 'name',
labelInValue: true,
fieldNames: {
label: 'name',
key: 'id',
value: 'id'
},
}, },
formItemProps: { formItemProps: {
rules: [ rules: [
@ -185,6 +197,7 @@ const TableList: React.FC = () => {
}, },
dataIndex: 'org_names', dataIndex: 'org_names',
request: async () => { request: async () => {
/*
const Value = await queryValueByKey({}); const Value = await queryValueByKey({});
const orgId = Value['common.org.id'] ? Value['common.org.id'] : 0; // 平台全局设置 const orgId = Value['common.org.id'] ? Value['common.org.id'] : 0; // 平台全局设置
const tree = await queryOrgTree({ const tree = await queryOrgTree({
@ -192,10 +205,52 @@ const TableList: React.FC = () => {
org_type: 2, org_type: 2,
//school_type: 1, //school_type: 1,
}) })
setOrgTree(tree.table_List) //setOrgTree(tree.table_List)
console.log('orgId', orgId) console.log('orgId', orgId)
console.log('tree.table_List', tree.table_List) console.log('tree.table_List', tree.table_List)
return getJsonTree(tree.table_List, orgId) return getJsonTree(tree.table_List, orgId)
*/
let treeData = []
// 获取省级以下的全部机构单位
const {table_List} = await getEduUnitList({
area_id: provinceId,
edu_type: -1,
org_type: 2,
pageNumber: 1,
pageSize: 10000,
school_type: -1,
})
// 格式化机构单位数据
const unitData = table_List?.map(item=>{
return {pId: item?.AREA_ID, name:item?.ORG_NAME, id: item?.ORG_ID}
})
console.log('unit:', unitData)
// 获取市
const cityData = await getAsyncOrgTree({
org_id: provinceId,
org_type: 1,
get_next: 1
});
const areaData = []
//const areaIds = []; // 区域Id数组用于过滤接口返回的非区下单位的垃圾数据
for(let i=0; i< cityData?.length; i++){
const _areaData = await getAsyncOrgTree({
org_id: cityData[i]?.id,
org_type: 2,
get_next: 1
});
treeData.push({name:cityData[i]?.name, id:cityData[i]?.id,
children: _areaData?.map(item=>({
pId: Number(item?.pId),
name: item?.name,
id: Number(item?.id),
children: unitData?.filter(unit=>(Number(unit?.pId) === Number(item?.id)))
}))
})
}
console.log('tree',treeData)
return treeData
}, },
sorter: false, sorter: false,
hideInForm: false, hideInForm: false,
@ -278,7 +333,6 @@ const TableList: React.FC = () => {
dataIndex: 'option', dataIndex: 'option',
valueType: 'option', valueType: 'option',
render: (_, record) => [ render: (_, record) => [
<a <a
key="update" key="update"
onClick={() => { onClick={() => {
@ -288,9 +342,6 @@ const TableList: React.FC = () => {
> >
</a>, </a>,
<Popconfirm key="popconfirm" title={`确认删除当前项吗?`} okText="是" cancelText="否" <Popconfirm key="popconfirm" title={`确认删除当前项吗?`} okText="是" cancelText="否"
onConfirm={async () => { onConfirm={async () => {
handleRemove([{ key: record?.train_id }]); // 调用批量删除函数如果接口不支持批量需要在service中处理 handleRemove([{ key: record?.train_id }]); // 调用批量删除函数如果接口不支持批量需要在service中处理
@ -300,8 +351,6 @@ const TableList: React.FC = () => {
> >
<a key="remove"></a> <a key="remove"></a>
</Popconfirm> </Popconfirm>
], ],
}, },
]; ];
@ -347,10 +396,7 @@ const TableList: React.FC = () => {
} }
// delete value.date_time // delete value.date_time
console.log('search', value); console.log('search', value);
const _data = await queryTrainList(value); const _data = await queryTrainList(value);
return { return {
current: _data?.page_number, current: _data?.page_number,
data: _data?.data?.list, data: _data?.data?.list,
@ -414,20 +460,14 @@ const TableList: React.FC = () => {
// 表单处理 // 表单处理
//console.log('columns:', columns); //console.log('columns:', columns);
console.log('values1:', values, orgTree); console.log('values1:', values, orgTree);
const tree = []
const tree = orgTree.filter((item, idx, self) => { values.org_names.map((e) => {
return (values.org_names.indexOf(item.id) !== -1) tree.push({
}); org_type: 2,
org_id: e.value,
tree.map((e, i) => { org_name: e.label
tree[i].org_id = e.id })
tree[i].org_name = e.name
delete tree[i].id
delete tree[i].name
delete tree[i].pId
}) })
console.log(321);
console.log(tree, 'tree');
const _data = { const _data = {
...values, ...values,
end_time: values.date_time[1], end_time: values.date_time[1],
@ -482,10 +522,7 @@ const TableList: React.FC = () => {
labelCol={{ span: 8 }} labelCol={{ span: 8 }}
wrapperCol={{ span: 12 }} wrapperCol={{ span: 12 }}
request={async () => { request={async () => {
const { data } = await querySubjectView({ train_id: currentRow?.train_id }); const { data } = await querySubjectView({ train_id: currentRow?.train_id });
data.date_time = [currentRow.start_time, currentRow.end_time] data.date_time = [currentRow.start_time, currentRow.end_time]
data.org_names = [] data.org_names = []
data.target_list.map((e) => { data.target_list.map((e) => {
@ -497,57 +534,24 @@ const TableList: React.FC = () => {
}) })
console.log("edit", data); console.log("edit", data);
return data return data
}} }}
onFinish={async (values: any) => { onFinish={async (values: any) => {
// 表单处理 // 表单处理
//console.log('columns:', columns);
console.log('values1:', values, values.org_names.value); console.log('values1:', values, values.org_names.value);
//return false;
// values.attachment_json.response.file.response.url
// 处理机构数据。直接编辑与回显结构不够 // 处理机构数据。直接编辑与回显结构不够
let tree = [] const tree = []
if (typeof values.org_names[0] === 'number') { values.org_names.map((e) => {
// tree = values.org_names tree.push({
console.log('true values.org_names', tree, values) org_type: 2,
tree = orgTree?.filter((item, idx, self) => { org_id: e.value,
return (values?.org_names?.indexOf(item?.id) !== -1) org_name: e.label
});
console.log("tree,1111", tree);
tree.map((e, i) => {
tree[i].org_id = e.id
tree[i].org_name = e.name
delete tree[i].id
delete tree[i].name
delete tree[i].pId
})
} else {
values.org_names.map((e) => {
tree.push({
org_type: 2,
org_id: e.value,
org_name: e.label
})
}) })
})
}
console.log(321);
console.log(tree, 'tree');
const _data = { const _data = {
...values, ...values,
end_time: values.date_time[1], end_time: values.date_time[1],
start_time: values.date_time[0], start_time: values.date_time[0],
target_list_json: JSON.stringify(tree), target_list_json: JSON.stringify(tree),
@ -555,20 +559,16 @@ const TableList: React.FC = () => {
} }
delete _data.date_time delete _data.date_time
delete _data.org_names delete _data.org_names
// delete params.course_time
// delete params.examination_time
console.log('_data', _data); console.log('_data', _data);
const res = await saveTrain(_data); const res = await saveTrain(_data);
// console.log(res, 'ressss');
if (res.code === 2000) { if (res.code === 2000) {
handleUpdateModalVisible(false); handleUpdateModalVisible(false);
actionRef.current?.reloadAndRest?.(); actionRef.current?.reloadAndRest?.();
} else { } else {
message.error(res.msg); message.error(res.msg);
} }
}} }}
submitter={{ submitter={{
render: (props, doms) => ( render: (props, doms) => (

@ -109,3 +109,48 @@ export async function querySubjectView(params: {
}); });
} }
/**
*
* http://10.10.14.252:8080/workspace/myWorkspace.do?projectId=382#6426
* @param params
* @returns
*/
export async function getAsyncOrgTree(params: {
page_size: number;
//count: number;
}): Promise<{ data: { list: CardListItemDataType[] } }> {
return request('/dsideal_yy/org/getAsyncOrgTree', {
params,
});
}
/**
*
* http://10.10.14.252:8080/workspace/myWorkspace.do?projectId=382#6426
* @param params
* @returns
*/
export async function getOrgList(params: {
org_id: number;
org_type: number;
//count: number;
}): Promise<{ data: { list: CardListItemDataType[] } }> {
return request('/dsideal_yy/intellioa/thirdlib/get_org_list', {
params,
});
}
/**
*
* /dsideal_yy/ypt/sys/org/getEduUnitList
* @param params
* @returns
*/
export async function getEduUnitList(params: {
page_size: number;
//count: number;
}): Promise<{ data: { list: CardListItemDataType[] } }> {
return request('/dsideal_yy/ypt/sys/org/getEduUnitList', {
params,
});
}
Loading…
Cancel
Save