From d9872d4404707e462e8f89ef949138dd1cab24f2 Mon Sep 17 00:00:00 2001 From: zhengpengju Date: Mon, 14 Feb 2022 11:39:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E9=A2=98=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/config/config.ts | 4 +- admin/config/defaultSettings.ts | 2 +- .../questionbank/{attestation => }/_mock.ts | 0 .../pages/questionbank/attestation/index.tsx | 207 ------------------ .../pages/questionbank/attestation/service.ts | 10 - .../components/OperationModal.tsx | 0 .../questionbank/{attestation => }/data.d.ts | 0 .../pages/questionbank/{normal => }/index.tsx | 16 +- admin/src/pages/questionbank/normal/_mock.ts | 160 -------------- .../normal/components/OperationModal.tsx | 105 --------- admin/src/pages/questionbank/normal/data.d.ts | 29 --- .../src/pages/questionbank/normal/style.less | 23 -- .../questionbank/normal/utils/utils.less | 50 ----- .../questionbank/{normal => }/service.ts | 0 .../questionbank/{attestation => }/style.less | 0 .../{attestation => }/utils/utils.less | 0 16 files changed, 12 insertions(+), 594 deletions(-) rename admin/src/pages/questionbank/{attestation => }/_mock.ts (100%) delete mode 100644 admin/src/pages/questionbank/attestation/index.tsx delete mode 100644 admin/src/pages/questionbank/attestation/service.ts rename admin/src/pages/questionbank/{attestation => }/components/OperationModal.tsx (100%) rename admin/src/pages/questionbank/{attestation => }/data.d.ts (100%) rename admin/src/pages/questionbank/{normal => }/index.tsx (96%) delete mode 100644 admin/src/pages/questionbank/normal/_mock.ts delete mode 100644 admin/src/pages/questionbank/normal/components/OperationModal.tsx delete mode 100644 admin/src/pages/questionbank/normal/data.d.ts delete mode 100644 admin/src/pages/questionbank/normal/style.less delete mode 100644 admin/src/pages/questionbank/normal/utils/utils.less rename admin/src/pages/questionbank/{normal => }/service.ts (100%) rename admin/src/pages/questionbank/{attestation => }/style.less (100%) rename admin/src/pages/questionbank/{attestation => }/utils/utils.less (100%) diff --git a/admin/config/config.ts b/admin/config/config.ts index 15c9f95..316b083 100644 --- a/admin/config/config.ts +++ b/admin/config/config.ts @@ -128,13 +128,13 @@ export default defineConfig({ name: '常规题库维护', icon: 'smile', path: '/questionbank/normal', - component: './questionbank/normal', + component: './questionbank', }, { name: '资质考试题库维护', icon: 'smile', path: '/questionbank/attestation', - component: './questionbank/attestation', + component: './questionbank', }, ], }, diff --git a/admin/config/defaultSettings.ts b/admin/config/defaultSettings.ts index df63e04..520c723 100644 --- a/admin/config/defaultSettings.ts +++ b/admin/config/defaultSettings.ts @@ -14,7 +14,7 @@ const Settings: LayoutSettings & { colorWeak: false, title: '生涯在线学习-资质考试', pwa: false, - logo: '../logo.svg', + logo: './logo.svg', iconfontUrl: '', menu:{ locale: false } // 关闭国际化语言 }; diff --git a/admin/src/pages/questionbank/attestation/_mock.ts b/admin/src/pages/questionbank/_mock.ts similarity index 100% rename from admin/src/pages/questionbank/attestation/_mock.ts rename to admin/src/pages/questionbank/_mock.ts diff --git a/admin/src/pages/questionbank/attestation/index.tsx b/admin/src/pages/questionbank/attestation/index.tsx deleted file mode 100644 index 6b3cba8..0000000 --- a/admin/src/pages/questionbank/attestation/index.tsx +++ /dev/null @@ -1,207 +0,0 @@ -/** 资质考试 */ -//import { AlignLeftOutlined, PlusOutlined } from '@ant-design/icons'; -import { Switch, Button, Card, Col, List, Menu, Progress, Row, Typography, Space, Divider, Radio, Checkbox, Tag, Dropdown } 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, useState } from 'react'; -import { PlusOutlined, DeleteOutlined, DownloadOutlined, UploadOutlined, EditOutlined, EyeOutlined, EyeInvisibleOutlined, DownOutlined } from '@ant-design/icons'; -//const { Paragraph } = Typography; -const QuestionBank = () => { - const [selectedRowsState, setSelectedRows] = useState([]); - const [expandedDescRowKeys, setExpandedDescRowKeys] = useState([]); // 展开解析设置 - const [addType, setAddType] = useState(0); - const numbers = []; - for(let i=0;i<50;i++){ - numbers.push({id: `${i}`}) - } - - const dataSource = [ - { - id: 1, - name: '下面哪个词语能体现未来思维?', - type: '单选', - options: [ - {label: '井底之蛙', value: 'A'}, - {label: '鼠目寸光', value: 'B'}, - {label: '未雨绸缪', value: 'C'}, - {label: '即时行乐', value: 'D'}, - ], - - time: '2022/12/12', - tag: '生涯理论', - course: '特质因素理论', - - answer:'C', - desc: '该成语意思是天还没有下雨,先把门窗绑牢。比喻事先做好准备工作。该成语意思是天还没有下雨,先把门窗绑牢。比喻事先做好准备工作。该成语意思是天还没有下雨,先把门窗绑牢。比喻事先做好准备工作。该成语意思是天还没有下雨,先把门窗绑牢。比喻事先做好准备工作。', - }, - { - id: 2, - name: 'Ant Design', - type: '多选', - image: - 'https://gw.alipayobjects.com/zos/antfincdn/efFD%24IOql2/weixintupian_20170331104822.jpg', - desc: '我是一条测试的描述', - }, - { - id: 3, - name: '蚂蚁金服体验科技', - type: '判断', - image: - 'https://gw.alipayobjects.com/zos/antfincdn/efFD%24IOql2/weixintupian_20170331104822.jpg', - desc: '我是一条测试的描述', - }, - { - id: 4, - name: 'TechUI', - type: '单选', - image: - 'https://gw.alipayobjects.com/zos/antfincdn/efFD%24IOql2/weixintupian_20170331104822.jpg', - desc: '我是一条测试的描述', - }, - ]; - - return ( - - - itemLayout="vertical" - rowClassName='questionbank-list-item' - pagination={{ - defaultPageSize: 10, - showSizeChanger: false, - }} - toolBarRender={() => { - const menu = ( - setAddType(value)}> - 单选 - 多选 - 判断 - - ); - return [ - - - , - , - , - , - ]; - }} - onRow={(record: any) => { - return { - onMouseEnter: () => { - console.log(record); - }, - onClick: () => { - console.log(record); - }, - }; - }} - rowKey="id" - headerTitle={false} - tooltip={false} - dataSource={dataSource} - rowSelection={{ - onChange: (_, selectedRows) => { - setSelectedRows(selectedRows); - }, - }} - // grid={{ gutter: 16, column: 1 }} - showActions="always" - showExtra="always" - metas={{ - title: { - dataIndex: 'name', - render: (text: React.ReactNode, record: T, index: number) => `1. ${text}`, - }, - avatar: { - dataIndex: 'type', - valueType: 'text', - render: (text: React.ReactNode, record: T, index: number) => `[${record.type}]`, - }, - description: { - dataIndex: 'options', - valueType: 'checkbox', - render: (text: React.ReactNode, record: T, index: number) => { - return ( - ( - - {`${item?.value}. ${item?.label}`} - - )} - /> - ); - }, - }, - subTitle: { }, - content: { - render: (text: React.ReactNode, record: T, index: number) => { - return ( - - 正确答案:{record.answer} - 解析:{record.desc} - - ); - }, - }, - actions: { - cardActionProps: 'extra', - render: (text: React.ReactNode, record: T, _index: number) => { - return( - - - - 创建时间:{record.time} - 标签:{record.tag} - 所属课程:{record.course} - - - - - - 编辑 - - - 删除 - - { - setExpandedDescRowKeys([...expandedDescRowKeys, record.id]); - console.log('record id:', record.id); - console.log('expandedDescRowKeys', expandedDescRowKeys) - }} - > - 查看解析 - - - - - ) - } - }, - }} - /> - - ); -}; - -export default QuestionBank; diff --git a/admin/src/pages/questionbank/attestation/service.ts b/admin/src/pages/questionbank/attestation/service.ts deleted file mode 100644 index fee9a31..0000000 --- a/admin/src/pages/questionbank/attestation/service.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { request } from 'umi'; -import type { CardListItemDataType } from './data.d'; - -export async function queryFakeList(params: { - count: number; -}): Promise<{ data: { list: CardListItemDataType[] } }> { - return request('/api/card_fake_list', { - params, - }); -} diff --git a/admin/src/pages/questionbank/attestation/components/OperationModal.tsx b/admin/src/pages/questionbank/components/OperationModal.tsx similarity index 100% rename from admin/src/pages/questionbank/attestation/components/OperationModal.tsx rename to admin/src/pages/questionbank/components/OperationModal.tsx diff --git a/admin/src/pages/questionbank/attestation/data.d.ts b/admin/src/pages/questionbank/data.d.ts similarity index 100% rename from admin/src/pages/questionbank/attestation/data.d.ts rename to admin/src/pages/questionbank/data.d.ts diff --git a/admin/src/pages/questionbank/normal/index.tsx b/admin/src/pages/questionbank/index.tsx similarity index 96% rename from admin/src/pages/questionbank/normal/index.tsx rename to admin/src/pages/questionbank/index.tsx index 26a0810..0a00f3a 100644 --- a/admin/src/pages/questionbank/normal/index.tsx +++ b/admin/src/pages/questionbank/index.tsx @@ -12,14 +12,18 @@ import ProList from '@ant-design/pro-list'; import { ReactText, useEffect, useState } from 'react'; import { PlusOutlined, DeleteOutlined, DownloadOutlined, UploadOutlined, EditOutlined, EyeOutlined, EyeInvisibleOutlined, DownOutlined } from '@ant-design/icons'; import { exportQuestionTemplate, queryQuestionById, queryQuestionList, queryQuestionType } from './service'; -import { useRequest } from 'umi'; +import { useParams, useRequest, history, useRouteMatch } from 'umi'; import { queryCourseView } from '@/pages/course/option/service'; //const { Paragraph } = Typography; const parsingMap = new Map() console.log('first'); const QuestionBank = () => { - console.log('second'); + const match = useRouteMatch(); + console.log('match', match); + + const type = history.location.pathname === '/questionbank/attestation' ? 1 : 0 ; // 题库类型 + const [questionType, setQuestionType] = useState([]); const [parsing, setParsing] = useState(); @@ -50,8 +54,6 @@ const QuestionBank = () => { parsingMap.clear(); } }, [data]); - - return ( @@ -91,10 +93,10 @@ const QuestionBank = () => { @@ -129,7 +131,7 @@ const QuestionBank = () => { const questions = await queryQuestionList({ ...value, - type: 0, + type: type, page_number: value?.current || 1, page_size: value?.pageSize, }); diff --git a/admin/src/pages/questionbank/normal/_mock.ts b/admin/src/pages/questionbank/normal/_mock.ts deleted file mode 100644 index 438153b..0000000 --- a/admin/src/pages/questionbank/normal/_mock.ts +++ /dev/null @@ -1,160 +0,0 @@ -// eslint-disable-next-line import/no-extraneous-dependencies -import type { Request, Response } from 'express'; -import type { BasicListItemDataType } from './data.d'; - -const titles = [ - 'Alipay', - 'Angular', - 'Ant Design', - 'Ant Design Pro', - 'Bootstrap', - 'React', - 'Vue', - 'Webpack', -]; -const avatars = [ - 'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png', // Alipay - 'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png', // Angular - 'https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png', // Ant Design - 'https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png', // Ant Design Pro - 'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png', // Bootstrap - 'https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png', // React - 'https://gw.alipayobjects.com/zos/rmsportal/ComBAopevLwENQdKWiIn.png', // Vue - 'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png', // Webpack -]; - -const covers = [ - 'https://gw.alipayobjects.com/zos/rmsportal/uMfMFlvUuceEyPpotzlq.png', - 'https://gw.alipayobjects.com/zos/rmsportal/iZBVOIhGJiAnhplqjvZW.png', - 'https://gw.alipayobjects.com/zos/rmsportal/iXjVmWVHbCJAyqvDxdtx.png', - 'https://gw.alipayobjects.com/zos/rmsportal/gLaIAoVWTtLbBWZNYEMg.png', -]; -const desc = [ - '那是一种内在的东西, 他们到达不了,也无法触及的', - '希望是一个好东西,也许是最好的,好东西是不会消亡的', - '生命就像一盒巧克力,结果往往出人意料', - '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆', - '那时候我只会想自己想要什么,从不想自己拥有什么', -]; - -const user = [ - '付小小', - '曲丽丽', - '林东东', - '周星星', - '吴加好', - '朱偏右', - '鱼酱', - '乐哥', - '谭小仪', - '仲尼', -]; - -function fakeList(count: number): BasicListItemDataType[] { - const list = []; - for (let i = 0; i < count; i += 1) { - list.push({ - id: `fake-list-${i}`, - owner: user[i % 10], - title: titles[i % 8], - avatar: avatars[i % 8], - cover: parseInt(`${i / 4}`, 10) % 2 === 0 ? covers[i % 4] : covers[3 - (i % 4)], - status: ['active', 'exception', 'normal'][i % 3] as - | 'normal' - | 'exception' - | 'active' - | 'success', - percent: Math.ceil(Math.random() * 50) + 50, - logo: avatars[i % 8], - href: 'https://ant.design', - updatedAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(), - createdAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i).getTime(), - subDescription: desc[i % 5], - description: - '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。', - activeUser: Math.ceil(Math.random() * 100000) + 100000, - newUser: Math.ceil(Math.random() * 1000) + 1000, - star: Math.ceil(Math.random() * 100) + 100, - like: Math.ceil(Math.random() * 100) + 100, - message: Math.ceil(Math.random() * 10) + 10, - content: - '段落示意:蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。', - members: [ - { - avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png', - name: '曲丽丽', - id: 'member1', - }, - { - avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png', - name: '王昭君', - id: 'member2', - }, - { - avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png', - name: '董娜娜', - id: 'member3', - }, - ], - }); - } - - return list; -} - -let sourceData: BasicListItemDataType[] = []; - -function getFakeList(req: Request, res: Response) { - const params = req.query as any; - - const count = Number(params.count) * 1 || 20; - - const result = fakeList(count); - sourceData = result; - return res.json({ - data: { - list: result, - }, - }); -} - -function postFakeList(req: Request, res: Response) { - const { /* url = '', */ body } = req; - // const params = getUrlParams(url); - const { method, id } = body; - // const count = (params.count * 1) || 20; - let result = sourceData || []; - - switch (method) { - case 'delete': - result = result.filter((item) => item.id !== id); - break; - case 'update': - result.forEach((item, i) => { - if (item.id === id) { - result[i] = { ...item, ...body }; - } - }); - break; - case 'post': - result.unshift({ - ...body, - id: `fake-list-${result.length}`, - createdAt: new Date().getTime(), - }); - break; - default: - break; - } - - return res.json({ - data: { - list: result, - }, - }); -} - -export default { - 'GET /api/get_list': getFakeList, - 'POST /api/post_fake_list': postFakeList, -}; diff --git a/admin/src/pages/questionbank/normal/components/OperationModal.tsx b/admin/src/pages/questionbank/normal/components/OperationModal.tsx deleted file mode 100644 index d524727..0000000 --- a/admin/src/pages/questionbank/normal/components/OperationModal.tsx +++ /dev/null @@ -1,105 +0,0 @@ -import type { FC } from 'react'; -import { - ModalForm, - ProFormSelect, - ProFormDateTimePicker, - ProFormText, - ProFormTextArea, -} from '@ant-design/pro-form'; -import type { BasicListItemDataType } from '../data.d'; -import styles from '../style.less'; -import { Button, Result } from 'antd'; - -type OperationModalProps = { - done: boolean; - visible: boolean; - current: Partial | undefined; - onDone: () => void; - onSubmit: (values: BasicListItemDataType) => void; -}; - -const OperationModal: FC = (props) => { - const { done, visible, current, onDone, onSubmit, children } = props; - if (!visible) { - return null; - } - return ( - - 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 ? ( - <> - - - - - - ) : ( - - 知道了 - - } - className={styles.formResult} - /> - )} - - ); -}; - -export default OperationModal; diff --git a/admin/src/pages/questionbank/normal/data.d.ts b/admin/src/pages/questionbank/normal/data.d.ts deleted file mode 100644 index c7e663f..0000000 --- a/admin/src/pages/questionbank/normal/data.d.ts +++ /dev/null @@ -1,29 +0,0 @@ -export type Member = { - avatar: string; - name: string; - id: string; -}; - -export type CardListItemDataType = { - id: string; - owner: string; - title: string; - avatar: string; - cover: string; - status: 'normal' | 'exception' | 'active' | 'success'; - percent: number; - logo: string; - href: string; - body?: any; - updatedAt: number; - createdAt: number; - subDescription: string; - description: string; - activeUser: number; - newUser: number; - star: number; - like: number; - message: number; - content: string; - members: Member[]; -}; diff --git a/admin/src/pages/questionbank/normal/style.less b/admin/src/pages/questionbank/normal/style.less deleted file mode 100644 index a59b424..0000000 --- a/admin/src/pages/questionbank/normal/style.less +++ /dev/null @@ -1,23 +0,0 @@ -@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%; - } - } -} diff --git a/admin/src/pages/questionbank/normal/utils/utils.less b/admin/src/pages/questionbank/normal/utils/utils.less deleted file mode 100644 index de1aa64..0000000 --- a/admin/src/pages/questionbank/normal/utils/utils.less +++ /dev/null @@ -1,50 +0,0 @@ -.textOverflow() { - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - word-break: break-all; -} - -.textOverflowMulti(@line: 3, @bg: #fff) { - position: relative; - max-height: @line * 1.5em; - margin-right: -1em; - padding-right: 1em; - overflow: hidden; - line-height: 1.5em; - text-align: justify; - &::before { - position: absolute; - right: 14px; - bottom: 0; - padding: 0 1px; - background: @bg; - content: '...'; - } - &::after { - position: absolute; - right: 14px; - width: 1em; - height: 1em; - margin-top: 0.2em; - background: white; - content: ''; - } -} - -// mixins for clearfix -// ------------------------ -.clearfix() { - zoom: 1; - &::before, - &::after { - display: table; - content: ' '; - } - &::after { - clear: both; - height: 0; - font-size: 0; - visibility: hidden; - } -} diff --git a/admin/src/pages/questionbank/normal/service.ts b/admin/src/pages/questionbank/service.ts similarity index 100% rename from admin/src/pages/questionbank/normal/service.ts rename to admin/src/pages/questionbank/service.ts diff --git a/admin/src/pages/questionbank/attestation/style.less b/admin/src/pages/questionbank/style.less similarity index 100% rename from admin/src/pages/questionbank/attestation/style.less rename to admin/src/pages/questionbank/style.less diff --git a/admin/src/pages/questionbank/attestation/utils/utils.less b/admin/src/pages/questionbank/utils/utils.less similarity index 100% rename from admin/src/pages/questionbank/attestation/utils/utils.less rename to admin/src/pages/questionbank/utils/utils.less