zhengpengju 3 years ago
parent fe2ab589a1
commit fe9c6d3690

@ -111,6 +111,7 @@ const AutoSelector = (props: any, ref: any) => {
headerTitle={false}
columns={columns}
rowKey="id"
key="id"
// value={dataSource}
request={async (value) => {
const { data } = await queryListChapterBySubject({

@ -5,11 +5,11 @@ import { ModalForm } 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 ProCard from '@ant-design/pro-card';
import { Button, Checkbox, Col, Divider, Dropdown, Form, Input, List, Menu, message, Modal, Radio, Row, Space, Table, Typography, Upload, Empty, Tooltip } from 'antd';
import { Button, Checkbox, Col, Divider, Dropdown, Form, Input, List, Menu, message, Modal, Radio, Row, Space, Table, Typography, Upload, Empty, Tooltip, Popconfirm } 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, queryTempQuestionList, saveQuestionTypeScore, queryRulesPaper, updateScore } from '../../service';
import { saveRules, querySubjectList, queryRulesView, queryTempQuestionList, saveQuestionTypeScore, queryRulesPaper, updateScore, delTempQuestion, exchangeSortNum } from '../../service';
import { queryCourseView } from '@/pages/course/option/service';
import { queryQuestionList, queryQuestionById, queryQuestionType } from '@/pages/questionbank/service';
import { PlusOutlined, DownOutlined, DeleteOutlined, DownloadOutlined, UploadOutlined, EyeInvisibleOutlined, EyeOutlined, EditOutlined, ArrowDownOutlined, ArrowUpOutlined } from '@ant-design/icons';
@ -79,6 +79,62 @@ const handleUpdatePaper = async (rules_id: number, paper_uuid: number, paper_id:
}
};
/**
* ()
*
* @param ids
*/
const handleRemoveTempQuestion = async (paper_uuid: number, question_ids: [{question_id: number}]) => {
const hide = message.loading('正在删除');
console.log('uuidPaper', paper_uuid)
if (!question_ids || !paper_uuid) return true;
try {
const {code, msg} = await delTempQuestion({
paper_uuid: paper_uuid,
question_ids: JSON.stringify(question_ids)
});
hide();
if(code === 2000 ){
message.success('删除成功,即将刷新');
}else{
message.warning(msg);
}
return true;
} catch (error) {
hide();
message.error('删除失败,请重试');
return false;
}
};
/**
*
* @param paper_uuid
* @param question_ids
* @param rules_id
* @returns bool
*/
const handleExchangeSortNum = async (paper_uuid: number, question_ids: string, rules_id: number) => {
const hide = message.loading('正在保存修改');
try {
const data = {
rules_id: Number(rules_id),
paper_uuid: paper_uuid,
question_ids: question_ids
}
const success = await exchangeSortNum(data);
hide();
if(success){
message.success('修改成功');
}
return true;
} catch (error) {
hide();
message.error('修改失败请重试!');
return false;
}
};
const labels = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K']
// 模拟考试规则维护
export default () => {
@ -284,10 +340,11 @@ export default () => {
// value="锦书"
// disabled
/>
{console.log(1111)}
<ProFormSelect
width="lg"
initialValue={ruleData?.subject_id}
key='value'
request={async () => {
return querySubjectList().then(({ data }) => {
console.log(data, 'querySubjectList')
@ -342,7 +399,7 @@ export default () => {
)}
</Col>
</Row>
{console.log(2222)}
</StepsForm.StepForm>
<StepsForm.StepForm<{
@ -430,8 +487,41 @@ export default () => {
))}
</div>
}
<div style={{ height: 'auto', backgroundColor: '#f0f0f0', textAlign: 'right', padding: 5, opacity: 0.5 }}>
<Button><ArrowUpOutlined /></Button> <Button><ArrowDownOutlined /></Button> <Button><DeleteOutlined /></Button>
<div style={{ height: 'auto', backgroundColor: '#f0f0f0', textAlign: 'right', padding: 5, opacity: 1 }}>
<Button disabled={idx === 0} onClick={async ()=>{
const success = await handleExchangeSortNum(uuidPaper,[questions[idx-1]?.id, item?.id].toString(), rulesId)
if (success) {
run({
paper_uuid: uuidPaper,
page_size: 1000,
page_number: 1
}); // 获取当前选题列表
}
}}><ArrowUpOutlined /></Button>
<Button disabled={idx+1 === questions?.length} onClick={async ()=>{
const success = await handleExchangeSortNum(uuidPaper, [ item?.id, questions[idx+1]?.id].toString(), rulesId)
if (success) {
run({
paper_uuid: uuidPaper,
page_size: 1000,
page_number: 1
}); // 获取当前选题列表
}
}}><ArrowDownOutlined /></Button>
<Popconfirm key="popconfirm" title={`确认删除当前项吗?`} okText="是" cancelText="否"
onConfirm={async () => {
const success = await handleRemoveTempQuestion(uuidPaper, [{ question_id: item?.id }]); // 调用批量删除函数如果接口不支持批量需要在service中处理
if (success) {
run({
paper_uuid: uuidPaper,
page_size: 1000,
page_number: 1
}); // 获取当前选题列表
}
}}
>
<Button><DeleteOutlined /></Button>
</Popconfirm>
</div>
</div>
))}
@ -470,7 +560,7 @@ export default () => {
console.log('typeQuestionCount', typeQuestionCount);
handleScoreModalVisible(true)
}}></Button>
<Tooltip zIndex={1} title={<span style={{display:'block', width:152}}></span>} placement="bottom" visible={questions ? false : true} color='#108ee9'>
<Tooltip defaultVisible={false} zIndex={1} title={<span style={{display:'block', width:152}}></span>} placement="bottom" color='#108ee9'>
<Button size="large" disabled={questions ? false : true} type="primary" block onClick={async () => {
console.log('uuidPaper::', uuidPaper)
console.log('rules_id::', params?.id)
@ -565,17 +655,16 @@ export default () => {
</ModalForm>
<ModalForm
title={`系统组卷`}
//
width="60%"
visible={autoModalVisible}
onVisibleChange={handleAutoModalVisible}
onFinish={async () => {
// 需要处理
//console.log('111')
//const values = autoRef?.current?.getData()
//console.log('2222')
const values = [{"question_type":0,"chapter_list": [{ "chapter_id":76, "count":1 },{ "chapter_id":77, "count":1 }]}]
const {code, data: paper, msg} = await autoPaper({rules_id: Number(params?.id), auto_param: JSON.stringify(values)})
const values = autoRef?.current?.getData()
console.log('values ', values )
//const values = [{"question_type":0,"chapter_list": [{ "chapter_id":76, "count":1 },{ "chapter_id":77, "count":1 }]}]
//const {code, data: paper, msg} = await autoPaper({rules_id: Number(params?.id), auto_param: JSON.stringify(values)})
//console.log('paper', paper)
//setUuidPaper(paper?.paper_uuid)
// message.success('提交成功');

@ -195,7 +195,10 @@ const QuestionBank = () => {
hideInDescriptions: false,
hideInForm: false,
hideInSearch: true,
formItemProps: {
fieldProps: {
maxLength: 50
},
formItemProps: {
rules: [
{
required: true,

Loading…
Cancel
Save