Administrator 3 years ago
commit 7890ee9dd0

@ -1,4 +1,4 @@
import React, { useRef } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import { history, useParams, useRequest } from 'umi';
import type { ProFormInstance } from '@ant-design/pro-form';
import { ProFormRadio } from '@ant-design/pro-form';
@ -16,8 +16,15 @@ import { Button, Checkbox, Col, Divider, List, Menu, message, Radio, Row, Space,
import { PageContainer } from '@ant-design/pro-layout';
import ProDescriptions from '@ant-design/pro-descriptions';
import styles from './index.less'
import { saveRules, querySubjectList, queryRulesView } from '../../service';
import { saveRules, querySubjectList, queryRulesView, queryRulesList, queryRulesPaper } from '../../service';
import { queryQuestionType } from '@/pages/questionbank/service';
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
import { TableListPagination } from '@/pages/ListTableList2/data';
import { PlusOutlined } from '@ant-design/icons';
import { TableListItem } from '../../components/QuestionSelector';
/** 题型序号 */
const numberType = ['一','二','三','四','五','六','七','八','九','十'];
const waitTime = (time: number = 100) => {
return new Promise((resolve) => {
@ -30,12 +37,119 @@ const numbers = [];
for (let i = 0; i < 50; i++) {
numbers.push({ id: `${i}` })
}
export default () => {
/** 列表项定义 */
const columns: ProColumns<TableListItem>[] = [
{
title: '序号',
key: 'index',
valueType: 'indexBorder',
width: 48,
},
{
title: '考试名称',
dataIndex: 'rules_name',
valueType: 'text',
hideInTable: false,
hideInForm: false,
hideInSearch: true,
},
{
title: '试卷',
dataIndex: 'examination_time',
valueType: 'text',
sorter: false,
hideInTable: false,
hideInForm: false,
hideInSearch: true,
renderText: (val: string) => `${val}`,
},
{
title: '关联主题',
dataIndex: 'subject_name',
valueType: 'text',
hideInTable: false,
hideInForm: false,
hideInSearch: true,
},
{
title: '题型设置',
dataIndex: 'subject_id',
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 [];
},
},
{
title: '总分',
dataIndex: 'sum_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',
render: (_dom: any, record: React.SetStateAction<TableListItem | undefined>) => {
console.log(record, 'record')
return [
<a
key="detail"
onClick={() => {
//console.log('entity', entity);
//setCurrentRow(record);
//handleDetailModalVisible(true);
}}
>
</a>,
<a
key="create"
onClick={() => {
//history.push(`/examination/option/registration/${record.examination_id}`);
//setCurrentRow(record);
}}
>
</a>,
]
},
},
];
const formRef = useRef<ProFormInstance>();
const params = useParams();
const actionRef = useRef<ActionType>();
console.log(params, 'params');
let ruleData = {}
if (params.id) {
if (params?.id) {
console.log(JSON.stringify(params), "878");
const { data } = useRequest(async () => {
@ -46,7 +160,24 @@ export default () => {
}
console.log(ruleData, 'ruleData');
const [questionType, setQuestionType] = useState([]); // 题型
/** 获取题型 */
const { data: questionTypeData } = useRequest(() => {
return queryQuestionType();
},{
formatResult: (result) => {
return result.list;
}
});
useEffect(() => {
setQuestionType(questionTypeData || []);
return ()=>{
/** 退出当前页面清空Map */
//parsingMap.clear();
}
}, [questionTypeData]);
return (
<PageContainer content={''} extraContent={''}>
<ProCard className={styles.examinationrules}>
@ -162,78 +293,51 @@ export default () => {
}}
>
<div style={{ margin: '0' }}>
<Typography style={{ padding: 24, fontSize: 24, textAlign: 'center' }}></Typography>
{/** 一旦录入另一项将禁用,清空组卷后可选另一项 */}
<Radio.Group value={1} onChange={() => { }} style={{ marginBottom: 16 }}>
<Radio.Button value={1}></Radio.Button>
<Radio.Button value={2}></Radio.Button>
</Radio.Group>
<Divider style={{ margin: '6px 0', opacity: 0.5 }} />
<Row>
<Col span={18} style={{ background: '#ffffff', padding: 0 }}>
<ProCard
title="一. 单选题 共50分每题1分"
extra={false}
split='vertical'
bordered
headerBordered
>
<Space direction="vertical" style={{ width: '100%', padding: '24px 48px' }}>
<Typography style={{ marginBottom: 16, fontSize: 18 }}>
4.
</Typography>
<Radio.Group onChange={() => { return true }} value={0} size="large">
<Space direction="vertical" style={{ fontSize: 16 }}>
<Radio value={1} style={{ padding: 5, fontSize: 16 }}>A. 退</Radio>
<Radio value={2} style={{ padding: 5, fontSize: 16 }}>B. </Radio>
<Radio value={3} style={{ padding: 5, fontSize: 16 }}>C. </Radio>
<Radio value={4} style={{ padding: 5, fontSize: 16 }}>D. </Radio>
</Space>
</Radio.Group>
<Typography style={{ marginBottom: 16, fontSize: 18 }}>
5. ()
</Typography>
<Checkbox.Group onChange={() => { return true }}>
<Space direction="vertical" style={{}}>
<Checkbox value={1} style={{ padding: 5, fontSize: 16 }}>A. 退</Checkbox>
<Checkbox value={2} style={{ padding: 5, fontSize: 16 }}>B. </Checkbox>
<Checkbox value={3} style={{ padding: 5, fontSize: 16 }}>C. </Checkbox>
<Checkbox value={4} style={{ padding: 5, fontSize: 16 }}>D. </Checkbox>
</Space>
</Checkbox.Group>
<Typography style={{ marginBottom: 16, fontSize: 18 }}>
6. 退
</Typography>
<Radio.Group onChange={() => { return true }} value={0} size="large">
<Space direction="vertical" style={{ fontSize: 16 }}>
<Radio value={1} style={{ padding: 5, fontSize: 16 }}></Radio>
<Radio value={2} style={{ padding: 5, fontSize: 16 }}></Radio>
</Space>
</Radio.Group>
</Space>
</ProCard>
</Col>
<Col span={6} style={{ paddingLeft: 24 }}>
<div style={{ background: '#ffffff', padding: 24 }}>
<Space direction="vertical" style={{ width: '100%' }}>
<strong></strong>
<Typography> { } { } </Typography>
<Divider style={{ margin: '6px 0', opacity: 0.5 }} />
<Space direction="vertical">
<Typography> { } { } </Typography>
<Typography> { } { } </Typography>
<Typography> { } { } </Typography>
</Space>
<Divider style={{ margin: '6px 0', opacity: 0.5 }} />
<Button size="large" block></Button>
<Button size="large" type="primary" block></Button>
</Space>
</div>
</Col>
</Row>
<ProTable<TableListItem, TableListPagination>
headerTitle={false}
actionRef={actionRef}
rowKey="examination_id"
options={false}
search={false}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
//history.push('/examinationrules/attestation/step')
}}
>
<PlusOutlined />
</Button>,
<Button
type="primary"
key="primary"
onClick={() => {
//history.push('/examinationrules/attestation/step')
}}
>
<PlusOutlined />
</Button>
]}
request={async (value) => {
const _data = await queryRulesPaper(
{
rules_id: params?.id,
page_number: value.current,
page_size: value.pageSize
}
);
return {
current: _data?.pageNumber,
data: _data?.table_List,
pageSize: _data?.pageSize,
total: _data?.totalRow || 0,
};
}}
// dataSource={list}
columns={columns}
rowSelection={false}
/>
</div>
</StepsForm.StepForm>

@ -1,21 +1,22 @@
/** 资质考试 */
/** 模拟考试 | 资质考试选题 */
//import { AlignLeftOutlined, PlusOutlined } from '@ant-design/icons';
import { Switch, Button, Card, Col, List, Menu, Progress, Row, Typography, Space, Divider, Radio, Checkbox, Tag, Dropdown, Upload, Modal, Form } from 'antd';
import { PageContainer } from '@ant-design/pro-layout';
import { Button, message } from 'antd';
//import { FooterToolbar, PageContainer } from '@ant-design/pro-layout';
//import { useRequest } from 'umi';
//import { queryFakeList } from './service';
//import type { CardListItemDataType } from './data';
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 { ReactText, useEffect, useRef, useState } from 'react';
import { PlusOutlined, DeleteOutlined, DownloadOutlined, UploadOutlined, EditOutlined, EyeOutlined, EyeInvisibleOutlined, DownOutlined } from '@ant-design/icons';
//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 { queryQuestionById, queryQuestionList, queryQuestionType } from '@/pages/questionbank/service';
import ProForm, { ProFormSelect } from '@ant-design/pro-form';
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
import { queryQuestionList, queryQuestionType } from '@/pages/questionbank/service';
//import ProForm, { ProFormSelect } from '@ant-design/pro-form';
import type { ActionType, ProColumns } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table';
export type TableListItem = {
id: string;
@ -29,10 +30,9 @@ export type TableListItem = {
memo: string;
};
//const { Paragraph } = Typography;
// React.forwardRef 接受渲染函数作为参数。React 将使用 props 和 ref 作为参数来调用此函数。此函数应返回 React 节点。
const QuestionSelector = (props: any, ref: any) => {
console.log('first');
const QuestionSelector = () => {
const actionRef = useRef<ActionType>();
/** 列表项定义 */
const columns: ProColumns<TableListItem>[] | ProColumns<TableListItem>[] = [
@ -57,6 +57,19 @@ const QuestionSelector = () => {
hideInTable: false,
hideInForm: true,
hideInSearch: false,
width: 100,
request: async () => {
const { list: Items } = await queryQuestionType();
const types = []
for (let i = 0; i < Items.length; i++) {
types.push({text: Items[i]?.name, label: Items[i]?.name, value: Items[i]?.code })
}
return types;
},
render: (text: React.ReactNode, _: any, index: number) => {
return text;
},
},
{
title: '题干',
@ -71,13 +84,8 @@ const QuestionSelector = () => {
console.log('match', match);
const type = history.location.pathname === '/questionbank/attestation' ? 1 : 0 ; // 题库类型
const [questionType, setQuestionType] = useState([]);
const [createModalVisible, handleCreateModalVisible] = useState<boolean>(false);
const [selectedRowsState, setSelectedRows] = useState<API.RuleListItem[]>([]);
const [expandedDescRowKeys, setExpandedDescRowKeys] = useState<readonly ReactText[]>([]); // 展开解析设置
const [addType, setAddType] = useState({name: '', value: 0});
const labels = ['A','B','C','D','E']
@ -90,20 +98,22 @@ const QuestionSelector = () => {
return result.list;
}
});
/*
const { data: template } = useRequest(() => {
return exportQuestionTemplate();
});
*/
useEffect(() => {
setQuestionType(data || []);
return ()=>{
/** 退出当前页面清空Map */
//parsingMap.clear();
}
}, [data]);
// 暴露组件的方法 接受外部获取的ref
useImperativeHandle(ref, () => ({
// 构造ref的获取数据方法
getSelectedRows: () => {
return selectedRowsState;
},
}));
return (
<>
<ProTable
pagination={{
defaultPageSize: 10,
@ -152,7 +162,6 @@ const QuestionSelector = () => {
}}
columns={columns}
// grid={{ gutter: 16, column: 1 }}
metas={{
title: {
dataIndex: 'question_stem',
@ -161,20 +170,19 @@ const QuestionSelector = () => {
avatar: {
dataIndex: 'question_type',
valueType: 'text',
render: (text: React.ReactNode, record: T, index: number) => {
const type = questionType?.filter((item, idx, self)=>{
render: (text: React.ReactNode, record: T, _: number) => {
const _type = questionType?.filter((item, idx, self)=>{
return item?.code === record.question_type
});
return `[${type[0]?.name}]`
return `[${_type[0]?.name}]`
},
},
description: {
},
}}
/>
/>
</>
);
};
export default QuestionSelector;
// forwardRef这个组件能够将其接受的 ref 属性转发到其组件树下
export default forwardRef( QuestionSelector );

@ -0,0 +1,105 @@
import type { FC } from 'react';
import {
ModalForm,
ProFormSelect,
ProFormDateTimePicker,
ProFormText,
ProFormTextArea,
} from '@ant-design/pro-form';
import type { BasicListItemDataType } from '../data';
import styles from '../style.less';
import { Button, Result } from 'antd';
type OperationModalProps = {
done: boolean;
visible: boolean;
current: Partial<BasicListItemDataType> | undefined;
onDone: () => void;
onSubmit: (values: BasicListItemDataType) => void;
};
const OperationModal: FC<OperationModalProps> = (props) => {
const { done, visible, current, onDone, onSubmit, children } = props;
if (!visible) {
return null;
}
return (
<ModalForm<BasicListItemDataType>
visible={visible}
title={done ? null : `任务${current ? '编辑' : '添加'}`}
className={styles.standardListForm}
width={640}
onFinish={async (values) => {
onSubmit(values);
}}
initialValues={current}
submitter={{
render: (_, dom) => (done ? null : dom),
}}
trigger={<>{children}</>}
modalProps={{
onCancel: () => onDone(),
destroyOnClose: true,
bodyStyle: done ? { padding: '72px 0' } : {},
}}
>
{!done ? (
<>
<ProFormText
name="title"
label="任务名称"
rules={[{ required: true, message: '请输入任务名称' }]}
placeholder="请输入"
/>
<ProFormDateTimePicker
name="createdAt"
label="开始时间"
rules={[{ required: true, message: '请选择开始时间' }]}
fieldProps={{
style: {
width: '100%',
},
}}
placeholder="请选择"
/>
<ProFormSelect
name="owner"
label="任务负责人"
rules={[{ required: true, message: '请选择任务负责人' }]}
options={[
{
label: '付晓晓',
value: 'xiao',
},
{
label: '周毛毛',
value: 'mao',
},
]}
placeholder="请选择管理员"
/>
<ProFormTextArea
name="subDescription"
label="产品描述"
rules={[{ message: '请输入至少五个字符的产品描述!', min: 5 }]}
placeholder="请输入至少五个字符"
/>
</>
) : (
<Result
status="success"
title="操作成功"
subTitle="一系列的信息描述,很短同样也可以带标点。"
extra={
<Button type="primary" onClick={onDone}>
</Button>
}
className={styles.formResult}
/>
)}
</ModalForm>
);
};
export default OperationModal;

@ -0,0 +1,189 @@
/** 模拟考试 */
//import { AlignLeftOutlined, PlusOutlined } from '@ant-design/icons';
import { Button, message } from 'antd';
//import { FooterToolbar, PageContainer } from '@ant-design/pro-layout';
//import { useRequest } from 'umi';
//import { queryFakeList } from './service';
//import type { CardListItemDataType } from './data';
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 type { ActionType, ProColumns } from '@ant-design/pro-table';
import ProTable from '@ant-design/pro-table';
import { manualPaper } from '../service';
export type TableListItem = {
id: string;
code: number;
name: string;
creator: string;
status: string;
createdAt: number;
progress: number;
money: number;
memo: string;
};
// React.forwardRef 接受渲染函数作为参数。React 将使用 props 和 ref 作为参数来调用此函数。此函数应返回 React 节点。
const QuestionSelector = (props: any, ref: any) => {
const actionRef = useRef<ActionType>();
/** 列表项定义 */
const columns: ProColumns<TableListItem>[] | ProColumns<TableListItem>[] = [
{
title: '序号',
key: 'index',
valueType: 'indexBorder',
render: (text: React.ReactNode, _: any, index: number) => {
if (actionRef && actionRef?.current && actionRef?.current?.pageInfo) {
return `${(actionRef?.current?.pageInfo?.current - 1) * actionRef.current.pageInfo?.pageSize + (index + 1)
}`;
} else {
return '';
}
},
width: 48,
},
{
title: '类型',
dataIndex: 'question_type',
valueType: 'select',
hideInTable: false,
hideInForm: true,
hideInSearch: false,
width: 100,
request: async () => {
const { list: Items } = await queryQuestionType();
const types = []
for (let i = 0; i < Items.length; i++) {
types.push({text: Items[i]?.name, label: Items[i]?.name, value: Items[i]?.code })
}
return types;
},
render: (text: React.ReactNode, _: any, index: number) => {
return text;
},
},
{
title: '题干',
dataIndex: 'question_stem',
valueType: 'text',
hideInTable: false,
hideInForm: true,
hideInSearch: false,
},
];
const match = useRouteMatch();
console.log('match', match);
const type = history.location.pathname === '/questionbank/attestation' ? 1 : 0 ; // 题库类型
const [questionType, setQuestionType] = useState([]);
const [selectedRowsState, setSelectedRows] = useState<API.RuleListItem[]>([]);
const [addType, setAddType] = useState({name: '', value: 0});
const labels = ['A','B','C','D','E']
/** 获取题型 */
const { data } = useRequest(() => {
return queryQuestionType();
},{
formatResult: (result) => {
return result.list;
}
});
useEffect(() => {
setQuestionType(data || []);
return ()=>{
}
}, [data]);
// 暴露组件的方法 接受外部获取的ref
useImperativeHandle(ref, () => ({
// 构造ref的获取数据方法
getSelectedRows: () => {
return selectedRowsState;
},
}));
return (
<>
<ProTable
pagination={{
defaultPageSize: 10,
showSizeChanger: false,
}}
actionRef={actionRef}
toolBarRender={false}
rowKey="id"
headerTitle={false}
tooltip={false}
request={async (value) => {
console.log('value', value)
/*
const { create_time } = value;
if (create_time) {
value.begin_time = create_time[0]
value.end_time = create_time[1]
}*/
const questions = await queryQuestionList({
...value,
type: type,
page_number: value?.current || 1,
page_size: value?.pageSize,
});
// 课程名称及课程标签
const data = []
for(let i=0; i<questions?.table_List.length; i++){
const { data: course } = await queryCourseView({
course_id: questions?.table_List[i]?.course_id
});
data[i] = {...questions?.table_List[i], course_name:course?.course_name, tag_name:course?.tag_name, };
}
return {
current: questions?.pageNumber,
data: data,
pageSize: questions?.pageSize,
success: true,
total: questions?.totalRow || 0,
};
}}
//dataSource={dataSource}
rowSelection={{
onChange: (_, selectedRows) => {
setSelectedRows(selectedRows);
},
}}
columns={columns}
// grid={{ gutter: 16, column: 1 }}
metas={{
title: {
dataIndex: 'question_stem',
render: (text: React.ReactNode, record: T, index: number) => `1. ${text}`,
},
avatar: {
dataIndex: 'question_type',
valueType: 'text',
render: (text: React.ReactNode, record: T, _: number) => {
const _type = questionType?.filter((item, idx, self)=>{
return item?.code === record.question_type
});
return `[${_type[0]?.name}]`
},
},
description: {
},
}}
/>
</>
);
};
// forwardRef这个组件能够将其接受的 ref 属性转发到其组件树下
export default forwardRef( QuestionSelector );

@ -9,11 +9,12 @@ import ProTable from '@ant-design/pro-table';
import { BetaSchemaForm, ModalForm, ProFormText, ProFormTextArea } from '@ant-design/pro-form';
import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions';
import ProDescriptions from '@ant-design/pro-descriptions';
import type { FormValueType } from './components/UpdateForm';
import UpdateForm from './components/UpdateForm';
import type { FormValueType } from './_components/UpdateForm';
import UpdateForm from './_components/UpdateForm';
import { querySubjectList, queryRulesList, removeRules } from '../service';
import type { TableListItem, TableListPagination } from './data';
import type { DataItem } from '@antv/data-set/lib/transform/tag-cloud';
import { updateRules } from './service';
/**
*
@ -38,6 +39,29 @@ const handleRemove = async (selectedRows: TableListItem[], currentRow) => {
}
};
/**
*
*
* @param fields
*/
const handleUpdate = async (fields: FormValueType, currentRow?: TableListItem) => {
const hide = message.loading('正在配置');
console.log('fields',fields)
try {
await updateRules({
...currentRow,
...fields,
});
hide();
message.success('配置成功');
return true;
} catch (error) {
hide();
message.error('配置失败请重试!');
return false;
}
};
const ExaminationRules: React.FC = () => {
//const [registrationModalVisible, handleRegistrationModalVisible] = useState<boolean>(false);
const actionRef = useRef<ActionType>();
@ -173,10 +197,13 @@ const ExaminationRules: React.FC = () => {
</a>,
<a
key="registration"
onClick={() => {
history.push(`/examination/option/registration/${record.examination_id}`);
key="b_use"
onClick={async () => {
//history.push(`/examination/option/registration/${record.examination_id}`);
//setCurrentRow(record);
console.log('record', {...record, b_use: !record.b_use})
await handleUpdate({b_use: record?.b_use === 0 ? 1 : 0}, record);
actionRef.current?.reloadAndRest?.();
}}
>
{record.b_use == 0 ? "未发布" : "已发布"}

@ -5,6 +5,7 @@ type ParamsType = {
count?: number;
} & Partial<BasicListItemDataType>;
export async function queryFakeList(
params: ParamsType,
): Promise<{ data: { list: BasicListItemDataType[] } }> {
@ -13,6 +14,7 @@ export async function queryFakeList(
});
}
/**
*
* http://10.10.14.252:8080/workspace/myWorkspace.do?projectId=382#6426
@ -28,10 +30,6 @@ export async function querySubjectList(params: {
});
}
/dsideal_yy/zygh/training/rules/delRules
export async function removeFakeList(
params: ParamsType,
): Promise<{ data: { list: BasicListItemDataType[] } }> {
@ -44,6 +42,7 @@ export async function removeFakeList(
});
}
export async function addFakeList(
params: ParamsType,
): Promise<{ data: { list: BasicListItemDataType[] } }> {
@ -77,4 +76,66 @@ export async function removeRules(data: { key: number[] }, options?: Record<stri
requestType: 'form',
...(options || {}),
});
}
}
/** 更新考试规则 */
export async function updateRules(
params: ParamsType,
): Promise<{ data: { info: string, success: boolean } }> {
return request('/dsideal_yy/zygh/training/rules/updateRules', {
method: 'POST',
requestType: 'form',
data: {
...params,
},
});
}
/**
*
* http://10.10.14.252:8080/workspace/myWorkspace.do?projectId=382#6426
* @param params
* @returns
*/
export async function queryTempQuestionList(params: {
page_size: number;
//count: number;
}): Promise<{ data: { list: CardListItemDataType[] } }> {
return request('/dsideal_yy/zygh/training/rules/getTempQuestionList', {
params,
});
}
/**
* 15
* @param params
* @returns
*/
export async function manualPaper(
params: ParamsType,
): Promise<{ data: { list: BasicListItemDataType[] } }> {
return request('/dsideal_yy/zygh/training/rules/manualPaper', {
method: 'POST',
requestType: 'form',
data: {
...params,
},
});
}
/**
* 20
* @param params
* @returns
*/
export async function updatePaper(
params: ParamsType,
): Promise<{ data: { list: BasicListItemDataType[] } }> {
return request('/dsideal_yy/zygh/training/rules/updatePaper', {
method: 'POST',
requestType: 'form',
data: {
...params,
},
});
}

@ -1,6 +1,6 @@
import React, { useRef, useState } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import { history, useParams, useRequest } from 'umi';
import type { ProFormInstance } from '@ant-design/pro-form';
import { ModalForm, ProFormInstance } from '@ant-design/pro-form';
import { ProFormRadio } from '@ant-design/pro-form';
import ProForm, {
StepsForm,
@ -16,13 +16,67 @@ import { Button, Checkbox, Col, Divider, Dropdown, List, Menu, message, Modal, R
import { PageContainer } from '@ant-design/pro-layout';
import ProDescriptions from '@ant-design/pro-descriptions';
import styles from './index.less'
import { saveRules, querySubjectList, queryRulesView } from '../../service';
import { saveRules, querySubjectList, queryRulesView, queryTempQuestionList } from '../../service';
import { queryCourseView } from '@/pages/course/option/service';
import { queryQuestionList, queryQuestionById } from '@/pages/questionbank/service';
import { queryQuestionList, queryQuestionById, queryQuestionType } from '@/pages/questionbank/service';
import { PlusOutlined, DownOutlined, DeleteOutlined, DownloadOutlined, UploadOutlined, EyeInvisibleOutlined, EyeOutlined, EditOutlined } from '@ant-design/icons';
import ProList from '@ant-design/pro-list';
import QuestionSelector from '../components/QuestionSelector';
import QuestionSelector from '../../components/QuestionSelector';
import { manualPaper, updatePaper } from '../service';
/**
*
*
* @param values
*/
const handleAppend = async (rules_id: number, rows: any[]) => {
const hide = message.loading('正在添加');
try {
const questions: { question_id: any; }[] = [];
rows?.forEach((item)=>{
questions.push({question_id: item?.id})
})
const _data = await manualPaper({
question_count: questions?.length || 0,
questions: JSON.stringify(questions),
rules_id: Number(rules_id)
});
hide();
message.success('添加成功');
return _data;
} catch (error) {
hide();
message.error('添加失败请重试!');
return false;
}
};
/**
*
*
* @param values
*/
const handleUpdatePaper = async ( rules_id: number, paper_uuid: number, paper_id: number) => {
const hide = message.loading('正在保存');
try {
const _data = {
rules_id: Number(rules_id),
paper_uuid: paper_uuid,
paper_id: paper_id
}
if(paper_id === 0){
delete _data.paper_id;
}
await updatePaper(_data);
hide();
message.success('保存成功');
return true;
} catch (error) {
hide();
message.error('保存失败请重试!');
return false;
}
};
const waitTime = (time: number = 100) => {
return new Promise((resolve) => {
@ -31,25 +85,56 @@ const waitTime = (time: number = 100) => {
}, time);
});
};
const numbers = [];
for (let i = 0; i < 50; i++) {
numbers.push({ id: `${i}` })
}
export default () => {
const [selectorModalVisible, handleSelectorModalVisible] = useState<boolean>(false);
const [uuidPaper, setUuidPaper] = useState<number>(0);
const formRef = useRef<ProFormInstance>();
const childRef = useRef();
const params = useParams();
const [questionType, setQuestionType] = useState([]); // 题型
/** 获取题型 */
const { data: questionTypeData } = useRequest(() => {
return queryQuestionType();
},{
formatResult: (result) => {
return result.list;
}
});
useEffect(() => {
setQuestionType(questionTypeData || []);
return ()=>{
/** 退出当前页面清空Map */
//parsingMap.clear();
}
}, [questionTypeData]);
/** 组卷,查询试题临时表(当前选题列表) */
const { data: questions, run } = useRequest(async () => {
return queryTempQuestionList(params);
},{
manual: true,
formatResult: (result) => {
return result?.bean;
}});
console.log(params, 'params');
let ruleData = {}
if (params?.id) {
console.log(JSON.stringify(params), "878");
//console.log(JSON.stringify(params), "878");
const { data } = useRequest(async () => {
const { bean } = await queryRulesView(params);
return { data: bean }
});
return queryRulesView(params);
},{
formatResult: (result) => {
return result?.bean;
}});
ruleData = data
}
console.log(ruleData, 'ruleData');
@ -99,7 +184,7 @@ export default () => {
b_use: 0,
rules_type: 0,
});
run({paper_uuid:1}); // 获取当前选题列表
// await waitTime(2000);
return true;
@ -141,7 +226,8 @@ export default () => {
label="关联主题"
/>
<ProFormText name="examination_time" label="考试时长"
initialValue={ruleData.examination_time}
width="md"
initialValue={ruleData?.examination_time}
rules={[{ required: true, message: '请输入考试时长' }]}
tooltip="限制考试时长的情况下,用户考试中离开,倒计时不会停止。" />
</>
@ -234,7 +320,12 @@ export default () => {
<Button size="large" block onClick={()=>{
handleSelectorModalVisible(true)
}}></Button>
<Button size="large" type="primary" block></Button>
<Button size="large" type="primary" block onClick={async ()=>{
console.log('uuidPaper::', uuidPaper)
console.log('rules_id::', params?.id)
const paper_id = paper_id ? paper_id : 0;
await handleUpdatePaper(params?.id, uuidPaper, paper_id)
}}></Button>
</Space>
</div>
</Col>
@ -274,7 +365,7 @@ export default () => {
<ProDescriptions.Item dataIndex="id" hideInDescriptions />
<ProDescriptions.Item dataIndex="object" label="考试名称" valueType="text" />
<ProDescriptions.Item dataIndex="date" label="关联培训主题" valueType="text" />
<ProDescriptions.Item dataIndex="duration" label="考试时长" valueType="text" />
<ProDescriptions.Item dataIndex="duration" label="考试时长" valueType="money" />
<ProDescriptions.Item dataIndex="grade" label="考试信息" valueType="text" />
@ -286,19 +377,29 @@ export default () => {
</StepsForm.StepForm>
</StepsForm>
</ProCard>
<Modal
<ModalForm
title={`手动选题`}
//
width="60%"
visible={selectorModalVisible}
destroyOnClose
onCancel={() => {
handleSelectorModalVisible(false);
}}
onVisibleChange={handleSelectorModalVisible}
footer={null}
onFinish={async (values) => {
console.log('v::::', values.name);
const rows = childRef?.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)
// message.success('提交成功');
handleSelectorModalVisible(false)
return true;
}}
>
<QuestionSelector />
</Modal>
<QuestionSelector ref={childRef} />
</ModalForm>
</PageContainer>
);

@ -141,4 +141,52 @@ export async function removeRules(data: { key: number[] }, options?: Record<stri
requestType: 'form',
...(options || {}),
});
}
}
/** 组卷,查询试题临时表(当前选题列表) */
export async function queryTempQuestionList(
params: {
/** 当前的页码 */
current?: number;
/** 页面的容量 */
pageSize?: number;
},
options?: Record<string, any>,
) {
return request<{
data: TableListItem[];
/** 列表的内容总数 */
total?: number;
success?: boolean;
}>('/dsideal_yy/zygh/training/rules/getTempQuestionList', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 组卷详情查询 */
export async function queryRulesPaper(
params: {
/** 当前的页码 */
current?: number;
/** 页面的容量 */
pageSize?: number;
},
options?: Record<string, any>,
) {
return request<{
data: TableListItem[];
/** 列表的内容总数 */
total?: number;
success?: boolean;
}>('/dsideal_yy/zygh/training/rules/getRulesPaper', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}

@ -42,7 +42,7 @@ const AnswersSelector = () => {
return (
<Form.List
initialValue={['','','','']}
name="names"
name="answers"
rules={[
{
validator: async (_, names) => {

@ -1,6 +1,6 @@
/** 资质考试 */
//import { AlignLeftOutlined, PlusOutlined } from '@ant-design/icons';
import { Switch, Button, Card, Col, List, Menu, Progress, Row, Typography, Space, Divider, Radio, Checkbox, Tag, Dropdown, Upload, Modal, Form, Input } from 'antd';
import { Switch, Button, Card, Col, List, Menu, Progress, Row, Typography, Space, Divider, Radio, Checkbox, Tag, Dropdown, Upload, Modal, Form, Input, message } from 'antd';
import { PageContainer } from '@ant-design/pro-layout';
//import { useRequest } from 'umi';
//import { queryFakeList } from './service';
@ -11,7 +11,7 @@ import styles from './style.less';
import ProList from '@ant-design/pro-list';
import { ReactText, useEffect, useRef, useState } from 'react';
import { PlusOutlined, DeleteOutlined, DownloadOutlined, UploadOutlined, EditOutlined, EyeOutlined, EyeInvisibleOutlined, DownOutlined, UserOutlined } from '@ant-design/icons';
import { exportQuestionTemplate, queryQuestionById, queryQuestionList, queryQuestionType } from './service';
import { exportQuestionTemplate, queryQuestionById, queryQuestionList, queryQuestionType, saveQuestion } from './service';
import { useParams, useRequest, history, useRouteMatch } from 'umi';
import { queryCourseListByTag, queryCourseView, queryTagList } from '@/pages/course/option/service';
import ProForm, { BetaSchemaForm, ProFormList, ProFormSelect, ProFormText } from '@ant-design/pro-form';
@ -21,10 +21,31 @@ import ProFormRichEdit from '../course/subject/components/ProFormRichEdit';
import { TableListItem } from '../course/option/data';
import AnswersSelector from './components/AnswersEditor';
//const { Paragraph } = Typography;
const { Text, Link } = Typography;
const labels = ['A','B','C','D','E','F','G','H','I','J','K'];
const parsingMap = new Map()
console.log('first');
/**
*
*
* @param fields
*/
const handleAdd = async (fields: TableListItem) => {
const hide = message.loading('正在添加');
try {
await saveQuestion({ ...fields});
hide();
message.success('添加成功');
return true;
} catch (error) {
hide();
message.error('添加失败请重试!');
return false;
}
};
const QuestionBank = () => {
const match = useRouteMatch();
console.log('match', match);
@ -60,13 +81,13 @@ const QuestionBank = () => {
{
title: '课程',
valueType: 'select',
dataIndex: 'course_ids',
dataIndex: 'course_id',
sorter: false,
hideInTable: false,
hideInForm: false,
hideInSearch: true,
fieldProps: {
mode: "multiple"
//mode: "multiple"
},
formItemProps: {
rules: [
@ -158,7 +179,7 @@ const QuestionBank = () => {
},
{
title: '解析',
dataIndex: 'chapter_describe',
dataIndex: 'parsing',
valueType: 'textarea',
sorter: false,
hideInTable: false,
@ -175,7 +196,7 @@ const QuestionBank = () => {
renderText: (val: string) => (<div dangerouslySetInnerHTML={{__html: val}} />),
renderFormItem: (item, { defaultRender, ...rest }, form) => (
<ProFormRichEdit
name="chapter_describe"
name="parsing"
label=""
width="xl"
// tooltip="最长为 6 位汉字,需要与考生身份证一致"
@ -220,7 +241,7 @@ const QuestionBank = () => {
parsingMap.clear();
}
}, [data]);
//saveQuestion
return (
<PageContainer content={false} extraContent={false} className={styles.questionbank}>
<ProList<any>
@ -337,7 +358,7 @@ const QuestionBank = () => {
metas={{
title: {
dataIndex: 'question_stem',
render: (text: React.ReactNode, record: T, index: number) => `1. ${text}`,
render: (text: React.ReactNode, record: T, index: number) => (<><Text code style={{width:80, fontSize:10, color:'bfbfbf'}}>{record?.id}</Text> {text}</>),
},
avatar: {
dataIndex: 'question_type',
@ -491,10 +512,18 @@ const QuestionBank = () => {
// 表单处理
console.log('columns:', columns);
console.log('values:', values);
const success = await handleAddChapter({
const opts = [];
values?.answers?.forEach((item)=>{
opts.push({answer:item, is_true:0})
})
const success = await handleAdd({
...values,
subject_id: params?.id || 0,
type: type, // 必填0-常规题,1-资质考试题
answers: JSON.stringify(opts),
question_type: addType.value,
// subject_id: params?.id || 0,
});
console.log('123')
if(success){
handleCreateModalVisible(false);
actionRef.current?.reloadAndRest?.();

Loading…
Cancel
Save