master
zhengpengju 3 years ago
parent da9bef00de
commit 177e76029c

@ -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 = () => {
>
</a>,
<a
key="remove"
onClick={ () => {
handleRemove([{ key: record?.course_id }]); // 调用批量删除函数如果接口不支持批量需要在service中处理
setSelectedRows([]);
actionRef.current?.reloadAndRest?.();
}}>
</a>,
<Popconfirm key="popconfirm" title={`确认删除当前项吗?`} okText="是" cancelText="否"
onConfirm={async () => {
const success = await handleRemove([{ key: record?.course_id }]); // 调用批量删除函数如果接口不支持批量需要在service中处理
if (success) {
// handleModalVisible(false);
if (actionRef.current) {
setSelectedRows([]);
actionRef.current?.reloadAndRest?.();
}
}
}}
>
<a key="remove"></a>
</Popconfirm>
,
],
},
];

@ -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<string, any>,

@ -41,7 +41,7 @@ const AutoSelector = (props: any, ref: any) => {
const { questionType } = props;
// const actionRef = useRef<ActionType>();
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) => {
<Row><Col style={{padding:10}}></Col></Row>
<Row style={{padding:5}}>
<Col offset={1} span={5}>{`常规题库 ( ${normalQuestionSum} 道题)`}</Col>
<Col offset={1} span={10}>: <InputNumber defaultValue={50} style={{textAlign:'center'}} onChange={(value)=>{
setQuestionCount([value, questionCount[1]])
<Col offset={1} span={10}>: <InputNumber defaultValue={50} style={{textAlign:'center'}} value={questionCount[0]} onChange={(value)=>{
setQuestionCount([value, 100 - value])
}} /> %</Col>
</Row>
<Row style={{padding:5}}>
<Col offset={1} span={5}>{`资质考试题库 ( ${attestationQuestionSum} 道题)`}</Col>
<Col offset={1} span={10}>: <InputNumber defaultValue={50} style={{textAlign:'center'}} onChange={(value)=>{
setQuestionCount([questionCount[0], value])
<Col offset={1} span={10}>: <InputNumber defaultValue={50} style={{textAlign:'center'}} value={questionCount[1]} onChange={(value)=>{
setQuestionCount([100 - value, value])
}} /> %</Col>
</Row>

@ -23,5 +23,8 @@
display: inline-block;
}
}
.ant-descriptions-item-label{
min-width: 100px;
}
}
}

@ -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 () => {
>
<Row gutter={24}>
<Col lg={12} md={12} sm={12} offset={8}>
<ProDescriptions
<Col lg={16} md={16} sm={16} offset={6}>
{currentStep === 2 && <ProDescriptions
layout='horizontal'
column={1}
//actionRef={actionRef}
title="模拟考试"
request={async () => {
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}
>
<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="rules_name" label="考试名称" valueType="text" />
<ProDescriptions.Item dataIndex="subject_name" label="关联培训主题" valueType="text" />
<ProDescriptions.Item dataIndex="examination_time" label="考试时长" valueType="text" renderText={(text)=>(`${text} 分钟`)} />
<ProDescriptions.Item dataIndex="grade" label="试卷信息" valueType="text" render={()=>{
return <Space direction="vertical">
<span> 0 , 100 </span>
<span>: 0 : 0 : 0 </span>
<span>线 60 </span>
</Space>
}} />
<ProDescriptions.Item dataIndex="grade" label="考试信息" valueType="text" />
<ProDescriptions.Item dataIndex="paper_count" label="试卷数量" valueType="text" render={()=>{
return <div stype={{padding:0}}><span style={{display:'inline-block', width:200}}>0</span> <span><ExclamationCircleOutlined /> </span></div>
}} />
<ProDescriptions.Item dataIndex="live_time" label="试卷有效期" valueType="text" render={()=>{
return <div stype={{padding:0}}><span style={{display:'inline-block', width:200}}>2020/03/01</span> <span><ExclamationCircleOutlined /> </span></div>
}} />
<ProDescriptions.Item dataIndex="through" label="通过标准" valueType="text" />
<ProDescriptions.Item dataIndex="times" label="考试次数" valueType="text" />
</ProDescriptions>
}
</Col>
</Row>
</StepsForm.StepForm>

@ -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<API.RuleListItem[]>([]);
//const [addType, setAddType] = useState({name: '', value: 0});
const [sumScore, setSumScore] = useState(0); // 总分
let sumScore = 0 // 总分
const formRef = useRef();
//const actionRef = useRef<ActionType>();
@ -68,21 +70,26 @@ const ScoreSetter = (props: any, ref: any) => {
render: (text, record, index) =>
<Space direction='horizontal'>
<span></span>
<Form.Item style={{margin:0}} name={`score[${index}]`}><InputNumber type="number" defaultValue={questionTypeValues[index]?.score} placeholder="请输入" size="small" onChange={(value)=>{
<Form.Item style={{margin:0}} name={`score[${index}]`}><InputNumber type="number" defaultValue={questionTypeValues ? questionTypeValues[index]?.score : 0} placeholder="请输入" size="small" onChange={(value)=>{
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)
}}/></Form.Item>
<span></span>
{ (record?.code === 1) &&
<>
<span>:: </span>
<Form.Item style={{margin:0}} name={`score_harf`}><InputNumber type="number" defaultValue={questionTypeValues[index]?.score_harf} placeholder="请输入" size="small" name='score_harf' onChange={(value)=>{
<Form.Item style={{margin:0}} name={`score_harf`}><InputNumber type="number" defaultValue={questionTypeValues ? questionTypeValues[index]?.score_harf : 0} placeholder="请输入" size="small" name='score_harf' onChange={(value)=>{
//
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 (
<Form
ref={formRef}
>
<EditableProTable
title={()=>{
questionTypeValues
return <Space> 0 , {sumScore} 线
return <Space> {sumQuestion} , {sumScore} 线
<Form.Item style={{margin:0}} name='win' initialValue={0}><InputNumber /></Form.Item>
</Space>}}
//formMapRef={formMapRef}

@ -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<boolean>(false);
const [subjectId, setSubjectId] = useState<number>(0); // 关联主题id
const [subjectName, setSubjectName] = useState(''); // 关联主题name
const [uuidPaper, setUuidPaper] = useState<number>(0);
const [createType, setCreateType] = useState<number>(1); // 组卷类型
const [rulesName, setRulesName] = useState<string>(''); // 组卷类型
@ -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;
}}
>
<Row gutter={24}>
<Col lg={12} md={12} sm={12} offset={8}>
<ProDescriptions
{currentStep === 2 && <ProDescriptions
layout='horizontal'
column={1}
//actionRef={actionRef}
title="模拟考试"
request={async () => {
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}
>
<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="money" />
<ProDescriptions.Item dataIndex="rules_name" label="考试名称" valueType="text" />
<ProDescriptions.Item dataIndex="subject_name" label="关联培训主题" valueType="text" />
<ProDescriptions.Item dataIndex="examination_time" label="考试时长" valueType="text" renderText={(text)=>(`${text} 分钟`)} />
<ProDescriptions.Item dataIndex="grade" label="试卷信息" valueType="text" render={()=>{
return <Space direction="vertical">
<span> 0 , 100 </span>
<span>: 0 : 0 : 0 </span>
<span>线 60 </span>
</Space>
}} />
<ProDescriptions.Item dataIndex="grade" label="考试信息" valueType="text" />
<ProDescriptions.Item dataIndex="through" label="通过标准" valueType="text" />
<ProDescriptions.Item dataIndex="times" label="考试次数" valueType="text" />
</ProDescriptions>
}
</Col>
</Row>
</StepsForm.StepForm>

@ -38,9 +38,7 @@ export async function saveRules(data: Record<string, any>, options?: Record<stri
});
}
/** 获取考试规则详情 GET /dsideal_yy/zygh/training/examination/getExaminationList */
/** 获取考试规则详情 */
export async function queryRulesView(
params: {
// query
@ -58,10 +56,6 @@ export async function queryRulesView(
});
}
/**
*
* http://10.10.14.252:8080/workspace/myWorkspace.do?projectId=382#6426

@ -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, message } from 'antd';
import { Switch, Button, Card, Col, List, Menu, Progress, Row, Typography, Space, Divider, Radio, Checkbox, Tag, Dropdown, Upload, Modal, Form, Input, message, Popconfirm } from 'antd';
import { PageContainer } from '@ant-design/pro-layout';
//import { useRequest } from 'umi';
//import { queryFakeList } from './service';
@ -11,10 +11,10 @@ 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, saveQuestion } from './service';
import { exportQuestionTemplate, queryQuestionById, queryQuestionList, queryQuestionType, removeQuestion, 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';
import ProForm, { BetaSchemaForm, ProFormCheckbox, ProFormList, ProFormRadio, ProFormSelect, ProFormText } from '@ant-design/pro-form';
import { DataItem } from '../dashboard/analysis/data';
import { ActionType, ProColumns } from '@ant-design/pro-table';
import ProFormRichEdit from '../course/subject/components/ProFormRichEdit';
@ -80,6 +80,17 @@ const QuestionBank = () => {
const type = history.location.pathname === '/questionbank/attestation' ? 1 : 0 ; // 题库类型
const actionRef = useRef<ActionType>();
const [questionType, setQuestionType] = useState([]);
const [parsing, setParsing] = useState();
const [createModalVisible, handleCreateModalVisible] = useState<boolean>(false);
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
const [selectedRowsState, setSelectedRows] = useState<API.RuleListItem[]>([]);
const [expandedDescRowKeys, setExpandedDescRowKeys] = useState<readonly ReactText[]>([]); // 展开解析设置
const [addType, setAddType] = useState({name: '', value: 0});
/** 表单项定义 */
const columns: ProColumns<TableListItem>[] = [
{
@ -185,24 +196,20 @@ const QuestionBank = () => {
hideInForm: false,
hideInSearch: true,
renderFormItem: (item, { defaultRender, ...rest }, form) => (
<Checkbox.Group style={{ width: '100%' }} onChange={(e)=>{
//console.log(`checked = ${e.target.checked}`);
}}>
<Row>
<Col span={3}>
<Checkbox value="A">A</Checkbox>
</Col>
<Col span={3}>
<Checkbox value="B">B</Checkbox>
</Col>
<Col span={3}>
<Checkbox value="C">C</Checkbox>
</Col>
<Col span={3}>
<Checkbox value="D">D</Checkbox>
</Col>
</Row>
</Checkbox.Group>
// 0 单选 1 多选 2 判断
(addType?.value !== 1 ) ?
<ProFormRadio.Group
label=""
initialValue={'A'}
options={['A', 'B', 'C', 'D']}
/>
:
<ProFormCheckbox.Group
label=""
initialValue={[]}
options={['A', 'B', 'C', 'D']}
/>
)
/*
formItemProps: {
@ -245,16 +252,7 @@ const QuestionBank = () => {
),
},
]
const [questionType, setQuestionType] = useState([]);
const [parsing, setParsing] = useState();
const [createModalVisible, handleCreateModalVisible] = useState<boolean>(false);
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
const [selectedRowsState, setSelectedRows] = useState<API.RuleListItem[]>([]);
const [expandedDescRowKeys, setExpandedDescRowKeys] = useState<readonly ReactText[]>([]); // 展开解析设置
const [addType, setAddType] = useState({name: '', value: 0});
/** 获取题型 */
const { data } = useRequest(() => {
@ -281,6 +279,7 @@ const QuestionBank = () => {
<PageContainer content={false} extraContent={false} className={styles.questionbank}>
<ProList<any>
itemLayout="vertical"
actionRef={actionRef}
rowClassName='questionbank-list-item'
pagination={{
defaultPageSize: 10,
@ -322,7 +321,7 @@ const QuestionBank = () => {
<Upload
accept='.xlsx'
showUploadList={false}
action="dsideal_yy/zygh/training/importQuestionData"
action="/dsideal_yy/zygh/training/importQuestionData"
data={
{
type: type,
@ -456,7 +455,7 @@ const QuestionBank = () => {
<Typography>
{answer}
</Typography>
<Typography>{parsing.get(record.id)}</Typography>
<Typography><div dangerouslySetInnerHTML={{__html: parsing.get(record.id)}} /></Typography>
</Space>
);
}else{
@ -497,9 +496,21 @@ const QuestionBank = () => {
}} target="_blank" rel="noopener noreferrer" key="link">
<EditOutlined />
</a>
<a href={record.html_url} target="_blank" rel="noopener noreferrer" key="warning" >
<DeleteOutlined />
</a>
<Popconfirm key="popconfirm" title={`确认删除当前项吗?`} okText="是" cancelText="否"
onConfirm={async () => {
const success = await handleRemove([{ key: record?.id }]); // 调用批量删除函数如果接口不支持批量需要在service中处理
if (success) {
// handleModalVisible(false);
if (actionRef.current) {
setSelectedRows([]);
actionRef.current?.reload();
}
}
}}
>
<a key="remove" ><DeleteOutlined /> </a>
</Popconfirm>
<a
key="view"
onClick={async ()=>{
@ -565,7 +576,7 @@ const QuestionBank = () => {
console.log('123')
if(success){
handleCreateModalVisible(false);
actionRef.current?.reloadAndRest?.();
actionRef.current?.reload();
}
}}
submitter={{

@ -76,8 +76,13 @@ export async function queryQuestionById(params: {
/** 删除试题 */
export async function removeQuestion(data: { key: number[] }, options?: Record<string, any>) {
console.log('data:::', data);
const ids = [];
data.key?.forEach((value)=>{
ids.push({id: value})
})
return request<Record<string, any>>('/dsideal_yy/zygh/training/delQuestion', {
data: { ids: data?.key[0] }, // 当前接口支持批量操作
data: { ids: JSON.stringify(ids) }, // 当前接口支持批量操作
method: 'POST',
requestType: 'form',
...(options || {}),

@ -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';

@ -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<Record<string, any>>('/api/login/outLogin', {
return request<Record<string, any>>('/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<API.LoginResult>('/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.NoticeIconList>('/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.RuleList>('/api/rule', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 新建规则 PUT /api/rule */
export async function updateRule(options?: { [key: string]: any }) {
return request<API.RuleListItem>('/api/rule', {
method: 'PUT',
...(options || {}),
});
}
/** 新建规则 POST /api/rule */
export async function addRule(options?: { [key: string]: any }) {
return request<API.RuleListItem>('/api/rule', {
method: 'POST',
...(options || {}),
});
}
/** 删除规则 DELETE /api/rule */
export async function removeRule(options?: { [key: string]: any }) {
return request<Record<string, any>>('/api/rule', {
method: 'DELETE',
...(options || {}),
});
}

@ -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.FakeCaptcha>('/api/login/captcha', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}

@ -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,
};

@ -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<any>('/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<any>('/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<API.Pet[]>('/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<API.Pet[]>('/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<API.Pet>(`/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<any>(`/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<any>(`/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<API.ApiResponse>(`/pet/${param0}/uploadImage`, {
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data',
},
params: { ...params },
data: formData,
...(options || {}),
});
}

@ -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<Record<string, any>>('/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<API.Order>('/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<API.Order>(`/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<any>(`/store/order/${param0}`, {
method: 'DELETE',
params: { ...params },
...(options || {}),
});
}

@ -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;
};
}

@ -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<any>('/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<any>('/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<any>('/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<string>('/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<any>('/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<API.User>(`/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<any>(`/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<any>(`/user/${param0}`, {
method: 'DELETE',
params: { ...params },
...(options || {}),
});
}

@ -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',

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

@ -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;
},
};

@ -76,12 +76,12 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
</Menu.Item>
)}
{menu && (
{/*menu && (
<Menu.Item key="settings">
<SettingOutlined />
</Menu.Item>
)}
)*/}
{menu && <Menu.Divider />}
<Menu.Item key="logout">

@ -39,7 +39,7 @@ export default () => {
const menuHeaderDropdown = (
<Menu selectedKeys={[]}>
<Menu.Item key="center">个人中心</Menu.Item>
<Menu.Item key="settings">个人设置</Menu.Item>
{/*<Menu.Item key="settings">个人设置</Menu.Item>*/}
<Menu.Divider />
<Menu.Item key="logout">退出登录</Menu.Item>
</Menu>

@ -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,
});
}

@ -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%;
}

@ -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 = () => {
</div>
<div className={styles.content}>
<LoginForm
logo={<img alt="logo" src="/logo.svg" />}
title="生涯在线学习-资质考试"
subTitle="V1.0.0"
logo={<img alt="logo" src="../edusoa.png" />}
//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);
}}
>
<Tabs activeKey={type} onChange={setType}>
<Tabs.TabPane key="account" tab="账户密码登录" />
<Tabs.TabPane key="mobile" tab="手机号登录" />
</Tabs>
{status === 'error' && loginType === 'account' && (
<LoginMessage content="账户或密码错误(admin/ant.design)" />
)}
@ -94,12 +89,12 @@ const Login: React.FC = () => {
<>
<ProFormText
name="username"
initialValue="admin"
initialValue="feiliming"
fieldProps={{
size: 'large',
prefix: <UserOutlined className={styles.prefixIcon} />,
}}
placeholder="用户名: admin or user"
placeholder="用户名: feiliming or user"
rules={[
{
required: true,
@ -114,12 +109,12 @@ const Login: React.FC = () => {
/>
<ProFormText.Password
name="password"
initialValue="ant.design"
initialValue="220250"
fieldProps={{
size: 'large',
prefix: <LockOutlined className={styles.prefixIcon} />,
}}
placeholder="密码: ant.design"
placeholder="密码: 220250"
rules={[
{
required: true,
@ -217,22 +212,6 @@ const Login: React.FC = () => {
/>
</>
)}
<div
style={{
marginBottom: 24,
}}
>
<ProFormCheckbox noStyle name="autoLogin">
<></>
</ProFormCheckbox>
<a
style={{
float: 'right',
}}
>
<></>
</a>
</div>
</LoginForm>
</div>
<Footer />

@ -2,19 +2,35 @@
/* eslint-disable */
import { request } from 'umi';
/** 获取当前的用户 GET /api/currentUser */
export async function currentUser(options?: { [key: string]: any }) {
return request<{
data: API.CurrentUser;
}>('/api/currentUser', {
/** 获取当前的用户 GET */
export async function currentUser(params: {
person_id: number;
identity_id: number;
u_type: number;
random_num?: number;
}) {
return request('/dsideal_yy/ypt/userinfo/getUserInfo', {
method: 'GET',
...(options || {}),
params,
});
}
/** 获取用户头像 GET */
export async function queryPersonTxByYw(params: {
person_id: number;
identity_id: number;
u_type?: number;
random_num?: number;
}) {
return request('/dsideal_yy/person/getPersonTxByYw', {
method: 'GET',
params,
});
}
/** 退出登录接口 POST /api/login/outLogin */
export async function outLogin(options?: { [key: string]: any }) {
return request<Record<string, any>>('/api/login/outLogin', {
return request<Record<string, any>>('/dsideal_yy/login/doLogout?login_type=1', {
method: 'POST',
...(options || {}),
});
@ -22,11 +38,9 @@ export async function outLogin(options?: { [key: string]: any }) {
/** 登录接口 POST /api/login/account */
export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
return request<API.LoginResult>('/api/login/account', {
return request<API.LoginResult>('/dsideal_yy/login/doLogin?login_type=1', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
requestType: 'form',
data: body,
...(options || {}),
});

Loading…
Cancel
Save