|
|
|
@ -9,7 +9,7 @@ import { Button, message } from 'antd';
|
|
|
|
|
//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 { forwardRef, Key, 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 { queryCourseListByTag, queryCourseView, queryTagList } from '@/pages/course/option/service';
|
|
|
|
@ -17,6 +17,8 @@ import { queryQuestionList, queryQuestionType } from '@/pages/questionbank/servi
|
|
|
|
|
//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 { FooterToolbar } from '@ant-design/pro-layout';
|
|
|
|
|
import { constant } from 'lodash';
|
|
|
|
|
|
|
|
|
|
export type TableListItem = {
|
|
|
|
|
id: string;
|
|
|
|
@ -120,10 +122,12 @@ const QuestionSelector = (props: any, ref: any) => {
|
|
|
|
|
|
|
|
|
|
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 [selectedRowsState, setSelectedRows] = useState([]);
|
|
|
|
|
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
|
|
|
|
|
|
|
|
//const [addType, setAddType] = useState({name: '', value: 0});
|
|
|
|
|
|
|
|
|
|
const labels = ['A','B','C','D','E','F','G','H','I']
|
|
|
|
|
//const labels = ['A','B','C','D','E','F','G','H','I']
|
|
|
|
|
|
|
|
|
|
/** 获取题型 */
|
|
|
|
|
const { data } = useRequest(() => {
|
|
|
|
@ -143,6 +147,9 @@ const QuestionSelector = (props: any, ref: any) => {
|
|
|
|
|
// 暴露组件的方法 接受外部获取的ref
|
|
|
|
|
useImperativeHandle(ref, () => ({
|
|
|
|
|
// 构造ref的获取数据方法
|
|
|
|
|
getSelectedRowKeys: () => {
|
|
|
|
|
return selectedRowKeys;
|
|
|
|
|
},
|
|
|
|
|
getSelectedRows: () => {
|
|
|
|
|
return selectedRowsState;
|
|
|
|
|
},
|
|
|
|
@ -151,6 +158,7 @@ const QuestionSelector = (props: any, ref: any) => {
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
|
|
<ProTable
|
|
|
|
|
pagination={{
|
|
|
|
|
defaultPageSize: 10,
|
|
|
|
@ -185,7 +193,7 @@ const QuestionSelector = (props: any, ref: any) => {
|
|
|
|
|
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({
|
|
|
|
@ -202,8 +210,20 @@ const QuestionSelector = (props: any, ref: any) => {
|
|
|
|
|
};
|
|
|
|
|
}}
|
|
|
|
|
rowSelection={{
|
|
|
|
|
onChange: (_, selectedRows) => {
|
|
|
|
|
setSelectedRows(selectedRows);
|
|
|
|
|
selectedRowKeys: selectedRowKeys,
|
|
|
|
|
onChange: (selectedKeys, _) => {
|
|
|
|
|
const res = selectedRowsState?.filter(item=>(item.page === actionRef.current?.pageInfo?.current)).length
|
|
|
|
|
let rows = [];
|
|
|
|
|
rows = selectedRowsState?.map(item=>(item?.page === actionRef.current?.pageInfo?.current ? {page: actionRef.current?.pageInfo?.current, selected: selectedKeys} : item))
|
|
|
|
|
if(res === 0){
|
|
|
|
|
rows.push({page: actionRef.current?.pageInfo?.current, selected: selectedKeys})
|
|
|
|
|
}
|
|
|
|
|
const _data: any = []
|
|
|
|
|
rows?.forEach((item)=>{
|
|
|
|
|
_data.push(...item?.selected)
|
|
|
|
|
})
|
|
|
|
|
setSelectedRowKeys(_data)
|
|
|
|
|
setSelectedRows(rows); // selectedRowsState
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
columns={columns}
|
|
|
|
|