品类OA问题与审核详情解密参数问题
This commit is contained in:
@ -3,26 +3,43 @@ import React, { useState, useEffect } from 'react';
|
||||
import { useLocation } from 'umi'; // 或者 'react-router-dom'
|
||||
import ResultModal from './components/ResultModal';
|
||||
import ViewModal from './components/ViewModal';
|
||||
import { refreshDictCache } from '@/servers/api/login';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
|
||||
const ViewReviewPage: React.FC = () => {
|
||||
const [modalVisible, setModalVisible] = useState(false); // 控制弹窗
|
||||
const [modalRecord, setModalRecord] = useState<any>(null);
|
||||
|
||||
|
||||
// 解析url参数 ?id=xxx
|
||||
const location = useLocation();
|
||||
useEffect(() => {
|
||||
// 获取id参数
|
||||
const params = new URLSearchParams(location.search);
|
||||
const id = params.get('id');
|
||||
if (id) {
|
||||
setModalRecord({ id }); // 只传id也可以,后面可以根据id扩展更多参数
|
||||
const base64 = params.get('code');
|
||||
console.log(base64);
|
||||
|
||||
if (!base64) return;
|
||||
// 解码
|
||||
const decodedStr = atob(base64);
|
||||
// 再次转成参数
|
||||
const p2 = new URLSearchParams(decodedStr);
|
||||
if (p2.get('id')) {
|
||||
if (!sessionStorage.getItem('dict')) {
|
||||
refreshDictCache().then((res) => {
|
||||
if (res.code == 200) {
|
||||
sessionStorage.setItem('dict', JSON.stringify(res.data))
|
||||
}
|
||||
})
|
||||
}
|
||||
const nowStr = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
||||
sessionStorage.setItem('userId', `${p2.get('userId')}_${nowStr}` )
|
||||
setModalRecord({ id: p2.get('id') });
|
||||
setModalVisible(true);
|
||||
}
|
||||
}, [location.search]);
|
||||
}, []);
|
||||
|
||||
|
||||
return (
|
||||
<div style={{padding: '20px'}}>
|
||||
<div style={{ padding: '20px' }}>
|
||||
{/* 其他页面内容 */}
|
||||
<ViewModal
|
||||
visible={modalVisible}
|
||||
|
Reference in New Issue
Block a user