diff --git a/admin/src/pages/course/option/index.tsx b/admin/src/pages/course/option/index.tsx index d73c16a..59c91f4 100644 --- a/admin/src/pages/course/option/index.tsx +++ b/admin/src/pages/course/option/index.tsx @@ -1,6 +1,6 @@ import React, { useState, useRef } from 'react'; import { PlusOutlined, TagsOutlined, UploadOutlined } from '@ant-design/icons'; -import { Button, message, Modal, Col, Row, Space, Upload } from 'antd'; +import { Button, message, Modal, Col, Row, Space, Upload, Popconfirm } from 'antd'; import { PageContainer, FooterToolbar } from '@ant-design/pro-layout'; import type { ProColumns, ActionType } from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table'; @@ -334,15 +334,21 @@ const CourseList: React.FC = () => { > 编辑 , - { - handleRemove([{ key: record?.course_id }]); // 调用批量删除函数(如果接口不支持批量需要在service中处理) - setSelectedRows([]); - actionRef.current?.reloadAndRest?.(); - }}> - 删除 - , + { + const success = await handleRemove([{ key: record?.course_id }]); // 调用批量删除函数(如果接口不支持批量需要在service中处理) + if (success) { + // handleModalVisible(false); + if (actionRef.current) { + setSelectedRows([]); + actionRef.current?.reloadAndRest?.(); + } + } + }} + > + 删除 + + , ], }, ]; diff --git a/admin/src/pages/course/subject/service.ts b/admin/src/pages/course/subject/service.ts index e8d8b47..4fcb799 100644 --- a/admin/src/pages/course/subject/service.ts +++ b/admin/src/pages/course/subject/service.ts @@ -31,11 +31,9 @@ export async function rule( -/** 获取主题详情 GET /dsideal_yy/ypt/careerTraining/subject/getSubjectInfo */ +/** 获取主题详情 */ export async function getSubjectInfo( params: { - // query - /** 当前的页码 */ id?: number; }, options?: Record, diff --git a/admin/src/pages/examinationrules/attestation/components/AutoSelector.tsx b/admin/src/pages/examinationrules/attestation/components/AutoSelector.tsx index ced6334..b18c68d 100644 --- a/admin/src/pages/examinationrules/attestation/components/AutoSelector.tsx +++ b/admin/src/pages/examinationrules/attestation/components/AutoSelector.tsx @@ -41,7 +41,7 @@ const AutoSelector = (props: any, ref: any) => { const { questionType } = props; // const actionRef = useRef(); - const [questionCount, setQuestionCount] = useState([0,0]) // 题库抽取数量 + const [questionCount, setQuestionCount] = useState([50,50]) // 题库抽取数量 const [questionTypeCount, setQuestionTypeCount] = useState(questionType.map(()=>(0))) // 题型抽取数量 const [normalQuestionSum, setNormalQuestionSum] = useState(0) // 常规题库试题数量 @@ -91,14 +91,14 @@ const AutoSelector = (props: any, ref: any) => { 题库选择 {`常规题库 ( ${normalQuestionSum} 道题)`} - 抽取比例: { - setQuestionCount([value, questionCount[1]]) + 抽取比例: { + setQuestionCount([value, 100 - value]) }} /> % {`资质考试题库 ( ${attestationQuestionSum} 道题)`} - 抽取比例: { - setQuestionCount([questionCount[0], value]) + 抽取比例: { + setQuestionCount([100 - value, value]) }} /> % diff --git a/admin/src/pages/examinationrules/attestation/step/index.less b/admin/src/pages/examinationrules/attestation/step/index.less index 74c6c5b..21578ef 100644 --- a/admin/src/pages/examinationrules/attestation/step/index.less +++ b/admin/src/pages/examinationrules/attestation/step/index.less @@ -23,5 +23,8 @@ display: inline-block; } } + .ant-descriptions-item-label{ + min-width: 100px; + } } } diff --git a/admin/src/pages/examinationrules/attestation/step/index.tsx b/admin/src/pages/examinationrules/attestation/step/index.tsx index 7d7cea5..97e6f1f 100644 --- a/admin/src/pages/examinationrules/attestation/step/index.tsx +++ b/admin/src/pages/examinationrules/attestation/step/index.tsx @@ -12,11 +12,12 @@ import { saveRules, querySubjectList, queryRulesView, queryRulesList, queryRules import { queryQuestionType } from '@/pages/questionbank/service'; import ProTable, { ActionType, EditableProTable, ProColumns } from '@ant-design/pro-table'; //import { TableListPagination } from '@/pages/ListTableList2/data'; -import { DiffOutlined, PlusOutlined } from '@ant-design/icons'; +import { DiffOutlined, ExclamationCircleOutlined, PlusOutlined } from '@ant-design/icons'; //import { TableListItem } from '../../components/QuestionSelector'; import ScoreSetter from '../../components/ScoreSetter'; import AutoSelector from '../components/AutoSelector'; import QuestionSelector from '../../components/QuestionSelector'; +import { getSubjectInfo } from '@/pages/course/subject/service'; /** 题型序号 */ const numberType = ['一','二','三','四','五','六','七','八','九','十']; @@ -29,6 +30,8 @@ export default () => { const setterRef = useRef(); const autoRef = useRef(); + const [currentStep, setCurrentStep] = useState(0); + const [questionTypeValues, setQuestionTypeValues] = useState([]); // 题型数据[{count:0, score:0, score_harf:0}] /** 自动组卷窗口 */ @@ -226,6 +229,7 @@ export default () => { start_time: fileds.dateRange[0], end_time: fileds.dateRange[1] }); + setCurrentStep(1) return true; }} @@ -294,6 +298,7 @@ export default () => { }} onFinish={async () => { console.log(formRef.current?.getFieldsValue()); + setCurrentStep(2) return true; }} > @@ -389,30 +394,44 @@ export default () => { > - - + {currentStep === 2 && { - return Promise.resolve({ - success: true, - data: { id: '这是一段文本', object: '', date: '2020-07-30 08:00', duration: '', grade: 100, through: '>60', learn: '>20 min', times: 2 }, - }); + title={false} + request={async () => { + const result = await queryRulesView(params) + console.log('queryRulesView', result) + const subjectInfo = await getSubjectInfo({subject_id: result.bean.subject_id}) + console.log('subjectInfo', subjectInfo) + return {data: {...result.bean, subject_name: subjectInfo.data.subject_name}}; }} extra={false} > - - - + + + (`${text} 分钟`)} /> + + { + return + 共 0 道题, 100 分 + 单选: 0 道题 单选: 0 道题 单选: 0 道题 + 通过线 60 分 + + + }} /> - + { + return
0 试卷数量是学生重复考试次数
+ }} /> + { + return
2020/03/01 超过试卷有效期将重新生成试卷
+ }} /> - -
+ }
diff --git a/admin/src/pages/examinationrules/components/ScoreSetter.tsx b/admin/src/pages/examinationrules/components/ScoreSetter.tsx index 573bcb5..9daaf3e 100644 --- a/admin/src/pages/examinationrules/components/ScoreSetter.tsx +++ b/admin/src/pages/examinationrules/components/ScoreSetter.tsx @@ -40,14 +40,16 @@ const ScoreSetter = (props: any, ref: any) => { const match = useRouteMatch(); console.log('match', match); + + const [typeScore, setTypeScore] = useState([]) ; // 题型分数数组 [{"question_type": "0","score": "3","score_harf": "0"},] //const type = history.location.pathname === '/questionbank/attestation' ? 1 : 0 ; // 题库类型 const [dataSource, setDataSource] = useState([]); //const [selectedRowsState, setSelectedRows] = useState([]); //const [addType, setAddType] = useState({name: '', value: 0}); - const [sumScore, setSumScore] = useState(0); // 总分 - + let sumScore = 0 // 总分 + const formRef = useRef(); //const actionRef = useRef(); @@ -68,21 +70,26 @@ const ScoreSetter = (props: any, ref: any) => { render: (text, record, index) => 每题 - { + { console.log('row', index) console.log('v1',value) const _data = []; console.log('typeScore1',typeScore) + //const _sumItems = []; typeScore?.forEach((item, key)=>{ - _data.push({...item, score: ((index === key) ? value : item?.score)}) + _data.push({...item, score: ((index === key) ? value : item?.score)}) // 题型分数 + //_sumItems.push((index === key) ? (value * questionTypeValues[index].count) : sumScoreItems[index]) // 题型总分 }) setTypeScore(_data) + + //setSumScoreItems(_sumItems) + //console.log('setSumScoreItems', sumScoreItems) }}/> { (record?.code === 1) && <> 错选、漏选得:: - { + { // const _data = []; console.log('typeScore',typeScore) @@ -100,7 +107,7 @@ const ScoreSetter = (props: any, ref: any) => { title: '题目数量', dataIndex: 'count', width: 80, - render: (text, _, index) => <>{questionTypeValues[index].count}, + render: (text, _, index) => <>{questionTypeValues ? questionTypeValues[index].count : '0'}, /* editable: (text, record, index) => { return true; @@ -111,11 +118,25 @@ const ScoreSetter = (props: any, ref: any) => { dataIndex: 'score_sum', //key: 'age', width: 80, + render: (text, _, index) => { + //console.log('===',typeScore ? typeScore[index].score * questionTypeValues[index].count : '0') + sumScore = sumScore + ((typeScore && questionTypeValues) ? typeScore[index]?.score * questionTypeValues[index]?.count : 0) + return <> + {(typeScore && questionTypeValues) ? typeScore[index]?.score * questionTypeValues[index]?.count : '0'} + + }, + } ]; //const labels = ['A','B','C','D','E'] + /** 获取总题数 */ + let sumQuestion = 0; + questionTypeValues?.forEach((item) => { + sumQuestion += item.count; + }); + // 获取题型 const { data } = useRequest(() => { return queryQuestionType(); @@ -156,14 +177,14 @@ const ScoreSetter = (props: any, ref: any) => { return typeScore; }, })); + return (
{ - questionTypeValues - return 共计 0 题, 总计 {sumScore} 分 通过分数线 + return 共计 {sumQuestion} 题, 总计 {sumScore} 分 通过分数线 }} //formMapRef={formMapRef} diff --git a/admin/src/pages/examinationrules/normal/step/index.tsx b/admin/src/pages/examinationrules/normal/step/index.tsx index 5b55dc7..8d2e48c 100644 --- a/admin/src/pages/examinationrules/normal/step/index.tsx +++ b/admin/src/pages/examinationrules/normal/step/index.tsx @@ -28,6 +28,8 @@ import ProTable, { EditableProTable } from '@ant-design/pro-table'; import QuestionSelector from '../../components/QuestionSelector'; import ScoreSetter from '../../components/ScoreSetter'; import AutoSelector from '../components/AutoSelector'; +import { ConsoleMessage } from 'puppeteer-core'; +import { getSubjectInfo } from '@/pages/course/subject/service'; /** * 保存选题 @@ -99,6 +101,8 @@ export default () => { const [autoModalVisible, handleAutoModalVisible] = useState(false); const [subjectId, setSubjectId] = useState(0); // 关联主题id + const [subjectName, setSubjectName] = useState(''); // 关联主题name + const [uuidPaper, setUuidPaper] = useState(0); const [createType, setCreateType] = useState(1); // 组卷类型 const [rulesName, setRulesName] = useState(''); // 组卷类型 @@ -110,6 +114,8 @@ export default () => { const setterRef = useRef(); const autoRef = useRef(); + const [currentStep, setCurrentStep] = useState(0); + const params = useParams(); const [questionType, setQuestionType] = useState([]); // 题型 @@ -187,8 +193,6 @@ export default () => { if (params?.id) { fileds = { ...fileds, id: params.id } } - console.log(fileds, 'fileds', params); - await saveRules({ ...fileds, b_use: 0, @@ -198,8 +202,10 @@ export default () => { // console.log('模拟考试基本信息', fileds) setSubjectId(fileds?.subject_id) // 设置当前关联主题 setRulesName(fileds?.rules_name) // 设置模拟考试规则名称 - + console.log('fileds', fileds) + console.log('formRef', formRef.current?.getFieldValue('')) // await waitTime(2000); + setCurrentStep(1) // 设置步骤号 return true; }} @@ -227,6 +233,10 @@ export default () => { return querySubjectList().then(({ data }) => { console.log(data, 'querySubjectList') return data.list.map((item) => { + if(item?.subject_id === ruleData?.subject_id){ + setSubjectName(item?.subject_name) // 设置关联主题名称 + console.log('label::', item?.subject_name) + } return { label: item?.subject_name, value: item?.subject_id, @@ -234,6 +244,9 @@ export default () => { }); }); }} + onChange={(value)=>{ + console.log('on change', value) + }} rules={[{ required: true, message: '请选择主题' }]} name="subject_id" label="关联主题" @@ -260,6 +273,7 @@ export default () => { }} onFinish={async () => { console.log(formRef.current?.getFieldsValue()); + setCurrentStep(2) // 设置步骤号 return true; }} > @@ -392,32 +406,39 @@ export default () => { return true; }} > - - { - return Promise.resolve({ - success: true, - data: { id: '这是一段文本', object: '', date: '2020-07-30 08:00', duration: '', grade: 100, through: '>60', learn: '>20 min', times: 2 }, - }); + title={false} + request={async () => { + const result = await queryRulesView(params) + console.log('queryRulesView', result) + const subjectInfo = await getSubjectInfo({subject_id: result.bean.subject_id}) + console.log('subjectInfo', subjectInfo) + return {data: {...result.bean, subject_name: subjectInfo.data.subject_name}}; }} extra={false} > - - - + + + (`${text} 分钟`)} /> + + { + return + 共 0 道题, 100 分 + 单选: 0 道题 单选: 0 道题 单选: 0 道题 + 通过线 60 分 + + + }} /> - - - + } diff --git a/admin/src/pages/examinationrules/service.ts b/admin/src/pages/examinationrules/service.ts index f485591..603e974 100644 --- a/admin/src/pages/examinationrules/service.ts +++ b/admin/src/pages/examinationrules/service.ts @@ -38,9 +38,7 @@ export async function saveRules(data: Record, options?: Record { const type = history.location.pathname === '/questionbank/attestation' ? 1 : 0 ; // 题库类型 const actionRef = useRef(); + const [questionType, setQuestionType] = useState([]); + + const [parsing, setParsing] = useState(); + + const [createModalVisible, handleCreateModalVisible] = useState(false); + const [updateModalVisible, handleUpdateModalVisible] = useState(false); + + const [selectedRowsState, setSelectedRows] = useState([]); + const [expandedDescRowKeys, setExpandedDescRowKeys] = useState([]); // 展开解析设置 + const [addType, setAddType] = useState({name: '', value: 0}); + /** 表单项定义 */ const columns: ProColumns[] = [ { @@ -185,24 +196,20 @@ const QuestionBank = () => { hideInForm: false, hideInSearch: true, renderFormItem: (item, { defaultRender, ...rest }, form) => ( - { - //console.log(`checked = ${e.target.checked}`); - }}> - - - A - - - B - - - C - - - D - - - + // 0 单选 1 多选 2 判断 + (addType?.value !== 1 ) ? + + : + + ) /* formItemProps: { @@ -245,16 +252,7 @@ const QuestionBank = () => { ), }, ] - const [questionType, setQuestionType] = useState([]); - - const [parsing, setParsing] = useState(); - - const [createModalVisible, handleCreateModalVisible] = useState(false); - const [updateModalVisible, handleUpdateModalVisible] = useState(false); - - const [selectedRowsState, setSelectedRows] = useState([]); - const [expandedDescRowKeys, setExpandedDescRowKeys] = useState([]); // 展开解析设置 - const [addType, setAddType] = useState({name: '', value: 0}); + /** 获取题型 */ const { data } = useRequest(() => { @@ -281,6 +279,7 @@ const QuestionBank = () => { itemLayout="vertical" + actionRef={actionRef} rowClassName='questionbank-list-item' pagination={{ defaultPageSize: 10, @@ -322,7 +321,7 @@ const QuestionBank = () => { { 正确答案: {answer} - 解析:{parsing.get(record.id)} + 解析:
); }else{ @@ -497,9 +496,21 @@ const QuestionBank = () => { }} target="_blank" rel="noopener noreferrer" key="link"> 编辑 - - 删除 - + { + const success = await handleRemove([{ key: record?.id }]); // 调用批量删除函数(如果接口不支持批量需要在service中处理) + if (success) { + // handleModalVisible(false); + if (actionRef.current) { + setSelectedRows([]); + actionRef.current?.reload(); + } + } + }} + > + 删除 + + { @@ -565,7 +576,7 @@ const QuestionBank = () => { console.log('123') if(success){ handleCreateModalVisible(false); - actionRef.current?.reloadAndRest?.(); + actionRef.current?.reload(); } }} submitter={{ diff --git a/admin/src/pages/questionbank/service.ts b/admin/src/pages/questionbank/service.ts index f727b20..05bc563 100644 --- a/admin/src/pages/questionbank/service.ts +++ b/admin/src/pages/questionbank/service.ts @@ -76,8 +76,13 @@ export async function queryQuestionById(params: { /** 删除试题 */ export async function removeQuestion(data: { key: number[] }, options?: Record) { console.log('data:::', data); + const ids = []; + data.key?.forEach((value)=>{ + ids.push({id: value}) + }) + return request>('/dsideal_yy/zygh/training/delQuestion', { - data: { ids: data?.key[0] }, // 当前接口支持批量操作 + data: { ids: JSON.stringify(ids) }, // 当前接口支持批量操作 method: 'POST', requestType: 'form', ...(options || {}), diff --git a/admin/src/pages/user/Login/index.tsx b/admin/src/pages/user/Login/index.tsx index 89b6f84..095326b 100644 --- a/admin/src/pages/user/Login/index.tsx +++ b/admin/src/pages/user/Login/index.tsx @@ -5,7 +5,7 @@ import { ProFormCaptcha, ProFormCheckbox, ProFormText, LoginForm } from '@ant-de import { useIntl, history, FormattedMessage, SelectLang, useModel } from 'umi'; import Footer from '@/components/Footer'; import { login } from '@/services/ant-design-pro/api'; -import { getFakeCaptcha } from '@/services/ant-design-pro/login'; +//import { getFakeCaptcha } from '@/services/ant-design-pro/login'; import styles from './index.less'; diff --git a/admin/src/services/ant-design-pro/api.ts b/admin/src/services/ant-design-pro/api.ts index c972fef..78f07c4 100644 --- a/admin/src/services/ant-design-pro/api.ts +++ b/admin/src/services/ant-design-pro/api.ts @@ -15,7 +15,7 @@ export async function currentUser(params: { }); } -/** 获取用户头像 GET */ +/** 获取用户头像 GET */ export async function queryPersonTxByYw(params: { person_id: number; identity_id: number; @@ -28,15 +28,15 @@ export async function queryPersonTxByYw(params: { }); } -/** 退出登录接口 POST /api/login/outLogin */ +/** 退出登录接口 */ export async function outLogin(options?: { [key: string]: any }) { - return request>('/api/login/outLogin', { + return request>('/dsideal_yy/login/doLogout?login_type=1', { method: 'POST', ...(options || {}), }); } -/** 登录接口 POST /api/login/account */ +/** 登录接口 POST */ export async function login(body: API.LoginParams, options?: { [key: string]: any }) { return request('/dsideal_yy/login/doLogin?login_type=1', { method: 'POST', @@ -45,55 +45,3 @@ export async function login(body: API.LoginParams, options?: { [key: string]: an ...(options || {}), }); } - -/** 此处后端没有提供注释 GET /api/notices */ -export async function getNotices(options?: { [key: string]: any }) { - return request('/api/notices', { - method: 'GET', - ...(options || {}), - }); -} - -/** 获取规则列表 GET /api/rule */ -export async function rule( - params: { - // query - /** 当前的页码 */ - current?: number; - /** 页面的容量 */ - pageSize?: number; - }, - options?: { [key: string]: any }, -) { - return request('/api/rule', { - method: 'GET', - params: { - ...params, - }, - ...(options || {}), - }); -} - -/** 新建规则 PUT /api/rule */ -export async function updateRule(options?: { [key: string]: any }) { - return request('/api/rule', { - method: 'PUT', - ...(options || {}), - }); -} - -/** 新建规则 POST /api/rule */ -export async function addRule(options?: { [key: string]: any }) { - return request('/api/rule', { - method: 'POST', - ...(options || {}), - }); -} - -/** 删除规则 DELETE /api/rule */ -export async function removeRule(options?: { [key: string]: any }) { - return request>('/api/rule', { - method: 'DELETE', - ...(options || {}), - }); -} diff --git a/admin/src/services/ant-design-pro/login.ts b/admin/src/services/ant-design-pro/login.ts deleted file mode 100644 index 42f95ff..0000000 --- a/admin/src/services/ant-design-pro/login.ts +++ /dev/null @@ -1,21 +0,0 @@ -// @ts-ignore -/* eslint-disable */ -import { request } from 'umi'; - -/** 发送验证码 POST /api/login/captcha */ -export async function getFakeCaptcha( - params: { - // query - /** 手机号 */ - phone?: string; - }, - options?: { [key: string]: any }, -) { - return request('/api/login/captcha', { - method: 'GET', - params: { - ...params, - }, - ...(options || {}), - }); -} diff --git a/admin/src/services/swagger/index.ts b/admin/src/services/swagger/index.ts deleted file mode 100644 index 83cf97c..0000000 --- a/admin/src/services/swagger/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -// @ts-ignore -/* eslint-disable */ -// API 更新时间: -// API 唯一标识: -import * as pet from './pet'; -import * as store from './store'; -import * as user from './user'; -export default { - pet, - store, - user, -}; diff --git a/admin/src/services/swagger/pet.ts b/admin/src/services/swagger/pet.ts deleted file mode 100644 index de8d6d2..0000000 --- a/admin/src/services/swagger/pet.ts +++ /dev/null @@ -1,166 +0,0 @@ -// @ts-ignore -/* eslint-disable */ -import { request } from 'umi'; - -/** Update an existing pet PUT /pet */ -export async function updatePet(body: API.Pet, options?: { [key: string]: any }) { - return request('/pet', { - method: 'PUT', - headers: { - 'Content-Type': 'application/json', - }, - data: body, - ...(options || {}), - }); -} - -/** Add a new pet to the store POST /pet */ -export async function addPet(body: API.Pet, options?: { [key: string]: any }) { - return request('/pet', { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - data: body, - ...(options || {}), - }); -} - -/** Finds Pets by status Multiple status values can be provided with comma separated strings GET /pet/findByStatus */ -export async function findPetsByStatus( - params: { - // query - /** Status values that need to be considered for filter */ - status: 'available' | 'pending' | 'sold'[]; - }, - options?: { [key: string]: any }, -) { - return request('/pet/findByStatus', { - method: 'GET', - params: { - ...params, - }, - - ...(options || {}), - }); -} - -/** Finds Pets by tags Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. GET /pet/findByTags */ -export async function findPetsByTags( - params: { - // query - /** Tags to filter by */ - tags: string[]; - }, - options?: { [key: string]: any }, -) { - return request('/pet/findByTags', { - method: 'GET', - params: { - ...params, - }, - - ...(options || {}), - }); -} - -/** Find pet by ID Returns a single pet GET /pet/${param0} */ -export async function getPetById( - params: { - // path - /** ID of pet to return */ - petId: number; - }, - options?: { [key: string]: any }, -) { - const { petId: param0 } = params; - return request(`/pet/${param0}`, { - method: 'GET', - params: { ...params }, - - ...(options || {}), - }); -} - -/** Updates a pet in the store with form data POST /pet/${param0} */ -export async function updatePetWithForm( - params: { - // path - /** ID of pet that needs to be updated */ - petId: number; - }, - body: { name?: string; status?: string }, - options?: { [key: string]: any }, -) { - const { petId: param0 } = params; - const formData = new FormData(); - - Object.keys(body).forEach((ele) => { - const item = (body as any)[ele]; - - if (item !== undefined && item !== null) { - formData.append(ele, typeof item === 'object' ? JSON.stringify(item) : item); - } - }); - - return request(`/pet/${param0}`, { - method: 'POST', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - }, - params: { ...params }, - data: formData, - ...(options || {}), - }); -} - -/** Deletes a pet DELETE /pet/${param0} */ -export async function deletePet( - params: { - // header - api_key?: string; - // path - /** Pet id to delete */ - petId: number; - }, - options?: { [key: string]: any }, -) { - const { petId: param0 } = params; - return request(`/pet/${param0}`, { - method: 'DELETE', - params: { ...params }, - ...(options || {}), - }); -} - -/** uploads an image POST /pet/${param0}/uploadImage */ -export async function uploadFile( - params: { - // path - /** ID of pet to update */ - petId: number; - }, - body: { additionalMetadata?: string; file?: string }, - options?: { [key: string]: any }, -) { - const { petId: param0 } = params; - const formData = new FormData(); - - Object.keys(body).forEach((ele) => { - const item = (body as any)[ele]; - - if (item !== undefined && item !== null) { - formData.append(ele, typeof item === 'object' ? JSON.stringify(item) : item); - } - }); - - return request(`/pet/${param0}/uploadImage`, { - method: 'POST', - headers: { - 'Content-Type': 'multipart/form-data', - }, - params: { ...params }, - data: formData, - ...(options || {}), - }); -} diff --git a/admin/src/services/swagger/store.ts b/admin/src/services/swagger/store.ts deleted file mode 100644 index c4b6d61..0000000 --- a/admin/src/services/swagger/store.ts +++ /dev/null @@ -1,54 +0,0 @@ -// @ts-ignore -/* eslint-disable */ -import { request } from 'umi'; - -/** Returns pet inventories by status Returns a map of status codes to quantities GET /store/inventory */ -export async function getInventory(options?: { [key: string]: any }) { - return request>('/store/inventory', { - method: 'GET', - ...(options || {}), - }); -} - -/** Place an order for a pet POST /store/order */ -export async function placeOrder(body: API.Order, options?: { [key: string]: any }) { - return request('/store/order', { - method: 'POST', - data: body, - ...(options || {}), - }); -} - -/** Find purchase order by ID For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions GET /store/order/${param0} */ -export async function getOrderById( - params: { - // path - /** ID of pet that needs to be fetched */ - orderId: number; - }, - options?: { [key: string]: any }, -) { - const { orderId: param0 } = params; - return request(`/store/order/${param0}`, { - method: 'GET', - params: { ...params }, - ...(options || {}), - }); -} - -/** Delete purchase order by ID For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors DELETE /store/order/${param0} */ -export async function deleteOrder( - params: { - // path - /** ID of the order that needs to be deleted */ - orderId: number; - }, - options?: { [key: string]: any }, -) { - const { orderId: param0 } = params; - return request(`/store/order/${param0}`, { - method: 'DELETE', - params: { ...params }, - ...(options || {}), - }); -} diff --git a/admin/src/services/swagger/typings.d.ts b/admin/src/services/swagger/typings.d.ts deleted file mode 100644 index 8fddfd7..0000000 --- a/admin/src/services/swagger/typings.d.ts +++ /dev/null @@ -1,52 +0,0 @@ -// @ts-ignore -/* eslint-disable */ - -declare namespace API { - type Order = { - id?: number; - petId?: number; - quantity?: number; - shipDate?: string; - /** Order Status */ - status?: 'placed' | 'approved' | 'delivered'; - complete?: boolean; - }; - - type Category = { - id?: number; - name?: string; - }; - - type User = { - id?: number; - username?: string; - firstName?: string; - lastName?: string; - email?: string; - password?: string; - phone?: string; - /** User Status */ - userStatus?: number; - }; - - type Tag = { - id?: number; - name?: string; - }; - - type Pet = { - id?: number; - category?: Category; - name: string; - photoUrls: string[]; - tags?: Tag[]; - /** pet status in the store */ - status?: 'available' | 'pending' | 'sold'; - }; - - type ApiResponse = { - code?: number; - type?: string; - message?: string; - }; -} diff --git a/admin/src/services/swagger/user.ts b/admin/src/services/swagger/user.ts deleted file mode 100644 index 46ce5e9..0000000 --- a/admin/src/services/swagger/user.ts +++ /dev/null @@ -1,114 +0,0 @@ -// @ts-ignore -/* eslint-disable */ -import { request } from 'umi'; - -/** Create user This can only be done by the logged in user. POST /user */ -export async function createUser(body: API.User, options?: { [key: string]: any }) { - return request('/user', { - method: 'POST', - data: body, - ...(options || {}), - }); -} - -/** Creates list of users with given input array POST /user/createWithArray */ -export async function createUsersWithArrayInput( - body: API.User[], - options?: { [key: string]: any }, -) { - return request('/user/createWithArray', { - method: 'POST', - data: body, - ...(options || {}), - }); -} - -/** Creates list of users with given input array POST /user/createWithList */ -export async function createUsersWithListInput(body: API.User[], options?: { [key: string]: any }) { - return request('/user/createWithList', { - method: 'POST', - data: body, - ...(options || {}), - }); -} - -/** Logs user into the system GET /user/login */ -export async function loginUser( - params: { - // query - /** The user name for login */ - username: string; - /** The password for login in clear text */ - password: string; - }, - options?: { [key: string]: any }, -) { - return request('/user/login', { - method: 'GET', - params: { - ...params, - }, - ...(options || {}), - }); -} - -/** Logs out current logged in user session GET /user/logout */ -export async function logoutUser(options?: { [key: string]: any }) { - return request('/user/logout', { - method: 'GET', - ...(options || {}), - }); -} - -/** Get user by user name GET /user/${param0} */ -export async function getUserByName( - params: { - // path - /** The name that needs to be fetched. Use user1 for testing. */ - username: string; - }, - options?: { [key: string]: any }, -) { - const { username: param0 } = params; - return request(`/user/${param0}`, { - method: 'GET', - params: { ...params }, - ...(options || {}), - }); -} - -/** Updated user This can only be done by the logged in user. PUT /user/${param0} */ -export async function updateUser( - params: { - // path - /** name that need to be updated */ - username: string; - }, - body: API.User, - options?: { [key: string]: any }, -) { - const { username: param0 } = params; - return request(`/user/${param0}`, { - method: 'PUT', - params: { ...params }, - data: body, - ...(options || {}), - }); -} - -/** Delete user This can only be done by the logged in user. DELETE /user/${param0} */ -export async function deleteUser( - params: { - // path - /** The name that needs to be deleted */ - username: string; - }, - options?: { [key: string]: any }, -) { - const { username: param0 } = params; - return request(`/user/${param0}`, { - method: 'DELETE', - params: { ...params }, - ...(options || {}), - }); -} diff --git a/web/config/config.ts b/web/config/config.ts index b8c7bde..6875529 100644 --- a/web/config/config.ts +++ b/web/config/config.ts @@ -253,13 +253,13 @@ export default defineConfig({ routes: [ { path: '/account', - redirect: '/account/center', + redirect: '/personalCenter', }, { name: 'center', icon: 'smile', path: '/account/center', - component: './account/center', + component: './personalCenter/index', }, { name: 'settings', diff --git a/web/public/edusoa.png b/web/public/edusoa.png new file mode 100644 index 0000000..eac0d3a Binary files /dev/null and b/web/public/edusoa.png differ diff --git a/web/public/login_bg.png b/web/public/login_bg.png new file mode 100644 index 0000000..d7d459f Binary files /dev/null and b/web/public/login_bg.png differ diff --git a/web/src/app.tsx b/web/src/app.tsx index 599777e..6ad7a30 100644 --- a/web/src/app.tsx +++ b/web/src/app.tsx @@ -4,8 +4,12 @@ import type { RunTimeLayoutConfig } from 'umi'; import { history, Link } from 'umi'; import RightContent from '@/components/RightContent'; import Footer from '@/components/Footer'; -import { currentUser as queryCurrentUser } from './services/ant-design-pro/api'; +import { currentUser as queryCurrentUser, queryPersonTxByYw } from './services/ant-design-pro/api'; import { BookOutlined, LinkOutlined } from '@ant-design/icons'; +import { RequestConfig } from 'umi'; +import { ResponseError } from 'umi-request'; +import { notification } from 'antd'; +import cookie from 'react-cookies'; const isDev = process.env.NODE_ENV === 'development'; const loginPath = '/user/login'; @@ -25,8 +29,20 @@ export async function getInitialState(): Promise<{ }> { const fetchUserInfo = async () => { try { - const msg = await queryCurrentUser(); - return msg.data; + const msg = await queryCurrentUser({ + person_id: cookie.load('person_id'), + identity_id: cookie.load('identity_id'), + u_type: 1, // 用户类型 + random_num: new Date().getTime(), + }); + const tx = await queryPersonTxByYw({ + person_id: cookie.load('person_id'), + identity_id: cookie.load('identity_id'), + u_type: 1, // 用户类型 + random_num: new Date().getTime(), + }); + console.log('avatar: ',`/dsideal_yy/html/thumb/Material/${tx?.file_id?.substr(0,2)}/${tx?.file_id}.${tx?.extension}`) + return {name: msg?.person_name, userid: msg?.person_id, avatar: `/dsideal_yy/html/thumb/Material/${tx?.file_id?.substr(0,2)}/${tx?.file_id}.${tx?.extension}`}; } catch (error) { history.push(loginPath); } @@ -70,3 +86,14 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => { ...initialState?.settings, }; }; + +/** request 用于配置全局的网络请求,你可以在这里做拦截器,全局错误处理,鉴权的配置。*/ +export const request: RequestConfig = { + errorHandler: (error: ResponseError) => { + notification.error({ + description: '您的网络发生异常,无法连接服务器', + message: '网络异常', + }); + throw error; + }, +}; \ No newline at end of file diff --git a/web/src/components/RightContent/AvatarDropdown.tsx b/web/src/components/RightContent/AvatarDropdown.tsx index d9e6731..e3e5bc7 100644 --- a/web/src/components/RightContent/AvatarDropdown.tsx +++ b/web/src/components/RightContent/AvatarDropdown.tsx @@ -76,12 +76,12 @@ const AvatarDropdown: React.FC = ({ menu }) => { 个人中心 )} - {menu && ( + {/*menu && ( 个人设置 - )} + )*/} {menu && } diff --git a/web/src/components/index.md b/web/src/components/index.md index 408da93..e202dfb 100644 --- a/web/src/components/index.md +++ b/web/src/components/index.md @@ -39,7 +39,7 @@ export default () => { const menuHeaderDropdown = ( 个人中心 - 个人设置 + {/*个人设置*/} 退出登录 diff --git a/web/src/pages/account/center/service.ts b/web/src/pages/account/center/service.ts index b6bfad7..a98d237 100644 --- a/web/src/pages/account/center/service.ts +++ b/web/src/pages/account/center/service.ts @@ -12,3 +12,14 @@ export async function queryFakeList(params: { params, }); } + +/** 查询用户信息 */ +export async function queryUserInfo(params: { + person_id: number; + identity_id: number; + u_type: number; +}): Promise<{ data: any }> { + return request('/dsideal_yy/ypt/userinfo/getUserInfo', { + params, + }); +} \ No newline at end of file diff --git a/web/src/pages/user/Login/index.less b/web/src/pages/user/Login/index.less index 84c5fdd..af22052 100644 --- a/web/src/pages/user/Login/index.less +++ b/web/src/pages/user/Login/index.less @@ -5,7 +5,19 @@ flex-direction: column; height: 100vh; overflow: auto; - background: @layout-body-background; + background: url('../../../../public/login_bg.png'); + background-position: top left; + padding-left: 40%; + :global { + .ant-pro-form-login-header{ + height: 124px; + } + .ant-pro-form-login-logo{ + margin: 0; + width: 328px; + height: auto; + } + } } .lang { @@ -25,9 +37,9 @@ @media (min-width: @screen-md-min) { .container { - background-image: url('https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg'); + //background-image: url('https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg'); background-repeat: no-repeat; - background-position: center 110px; + background-position: left top; background-size: 100%; } diff --git a/web/src/pages/user/Login/index.tsx b/web/src/pages/user/Login/index.tsx index 181b0b9..89b6f84 100644 --- a/web/src/pages/user/Login/index.tsx +++ b/web/src/pages/user/Login/index.tsx @@ -43,7 +43,7 @@ const Login: React.FC = () => { try { // 登录 const msg = await login({ ...values, type }); - if (msg.status === 'ok') { + if (msg.success === true) { const defaultLoginSuccessMessage = '登录成功!'; message.success(defaultLoginSuccessMessage); await fetchUserInfo(); @@ -71,22 +71,17 @@ const Login: React.FC = () => {
} - title="生涯在线学习-资质考试" - subTitle="V1.0.0" + logo={logo} + //title={false} + subTitle={false} initialValues={{ autoLogin: true, }} actions={[]} onFinish={async (values) => { - await handleSubmit(values as API.LoginParams); + await handleSubmit({user: values.username, pwd: values.password} as API.LoginParams); }} > - - - - - {status === 'error' && loginType === 'account' && ( )} @@ -94,12 +89,12 @@ const Login: React.FC = () => { <> , }} - placeholder="用户名: admin or user" + placeholder="用户名: feiliming or user" rules={[ { required: true, @@ -114,12 +109,12 @@ const Login: React.FC = () => { /> , }} - placeholder="密码: ant.design" + placeholder="密码: 220250" rules={[ { required: true, @@ -217,22 +212,6 @@ const Login: React.FC = () => { /> )} -