parent
ecbece7dfa
commit
30e2181e84
@ -0,0 +1,180 @@
|
||||
/** 资质考试 */
|
||||
//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 { 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 { 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';
|
||||
|
||||
export type TableListItem = {
|
||||
id: string;
|
||||
code: number;
|
||||
name: string;
|
||||
creator: string;
|
||||
status: string;
|
||||
createdAt: number;
|
||||
progress: number;
|
||||
money: number;
|
||||
memo: string;
|
||||
};
|
||||
|
||||
//const { Paragraph } = Typography;
|
||||
|
||||
console.log('first');
|
||||
const QuestionSelector = () => {
|
||||
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,
|
||||
},
|
||||
{
|
||||
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 [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']
|
||||
|
||||
/** 获取题型 */
|
||||
const { data } = useRequest(() => {
|
||||
return queryQuestionType();
|
||||
},{
|
||||
formatResult: (result) => {
|
||||
return result.list;
|
||||
}
|
||||
});
|
||||
/*
|
||||
const { data: template } = useRequest(() => {
|
||||
return exportQuestionTemplate();
|
||||
});
|
||||
*/
|
||||
useEffect(() => {
|
||||
setQuestionType(data || []);
|
||||
return ()=>{
|
||||
/** 退出当前页面清空Map */
|
||||
//parsingMap.clear();
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
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, index: number) => {
|
||||
const type = questionType?.filter((item, idx, self)=>{
|
||||
return item?.code === record.question_type
|
||||
});
|
||||
return `[${type[0]?.name}]`
|
||||
},
|
||||
},
|
||||
description: {
|
||||
},
|
||||
|
||||
}}
|
||||
/>
|
||||
|
||||
);
|
||||
};
|
||||
|
||||
export default QuestionSelector;
|
@ -0,0 +1,23 @@
|
||||
@import '~antd/es/style/themes/default.less';
|
||||
.questionbank{
|
||||
:global {
|
||||
.ant-list-split.ant-list-something-after-last-item .ant-spin-container > .ant-list-items > .ant-list-item:last-child{
|
||||
border: none;
|
||||
}
|
||||
.questionbank-list-item{
|
||||
//background: #f0f0f0;
|
||||
border: solid 1px #f0f0f0 !important;
|
||||
margin: 15px 0;
|
||||
}
|
||||
.ant-list-vertical .ant-list-item-action{
|
||||
padding: 0 !important;
|
||||
margin: 0 -18px -12px -24px !important;
|
||||
}
|
||||
.ant-list-item-action li{
|
||||
padding: 10px 18px;
|
||||
background: #f0f0f0;
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue