更新字典获取方式
This commit is contained in:
15
src/app.tsx
Normal file
15
src/app.tsx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// src/app.ts
|
||||||
|
import { message } from 'antd';
|
||||||
|
import { refreshDictCache } from './servers/api';
|
||||||
|
|
||||||
|
export async function getInitialState() {
|
||||||
|
try {
|
||||||
|
const res = await refreshDictCache();
|
||||||
|
if (res.code == 200) {
|
||||||
|
sessionStorage.setItem('dict', JSON.stringify(res.data));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
message.error('初始化失败');
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
@ -146,6 +146,7 @@ const IndexPage: React.FC<any> = ({ user }) => {
|
|||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
setNoticeList(res.data.records);
|
setNoticeList(res.data.records);
|
||||||
});
|
});
|
||||||
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const toSystem = (type: string) => {
|
const toSystem = (type: string) => {
|
||||||
|
@ -42,7 +42,17 @@ export type DictItem = {
|
|||||||
* @returns 字典列表
|
* @returns 字典列表
|
||||||
*/
|
*/
|
||||||
export async function getDictList(code: string): Promise<DictResponse> {
|
export async function getDictList(code: string): Promise<DictResponse> {
|
||||||
return request(`/cosco/dictProject/getAllList/${code}`, {
|
const data: string | null = sessionStorage.getItem('dict');
|
||||||
method: 'GET',
|
if (data) {
|
||||||
});
|
const dictData = JSON.parse(data);
|
||||||
|
const codeType = `${code.trim()}=supplier_manage_type`;
|
||||||
|
return Promise.resolve({
|
||||||
|
code: 200,
|
||||||
|
data: dictData[codeType],
|
||||||
|
message: 'success',
|
||||||
|
success: true,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
return Promise.reject(new Error('请先请求字典数据'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,3 +14,11 @@ export async function getCoscoPortalsLinksFriendshipConnections() {
|
|||||||
method: 'get',
|
method: 'get',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 字典缓存接口
|
||||||
|
*/
|
||||||
|
export async function refreshDictCache() {
|
||||||
|
return request('/v1/dictProject/refreshDictCache', {
|
||||||
|
method: 'GET'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user