Commit 923386ed authored by Bill's avatar Bill

fix: 修改首页以及加工能力bug

parent 1ec40826
......@@ -17,6 +17,7 @@ import { GlobalConfig } from '@/global/config';
import LRU from '@/utils/lru';
const recent = new LRU(6);
recent.init();
setup()
// 与用户登录相关路由
......
......@@ -32,7 +32,7 @@ const columns = [
{title: '收货批次', dataIndex: 'batch'},
{title: '收货时间', dataIndex: 'receiveTime'},
{title: '收货数量', dataIndex: 'receiveTime'},
{title: '加工单价', dataIndex: 'processPrice'},
// {title: '加工单价', dataIndex: 'processPrice'},
{title: '结算金额', dataIndex: 'settlementAmount'},
]
......
......@@ -32,7 +32,7 @@ const columns = [
{title: '收货批次', dataIndex: 'batch'},
{title: '收货时间', dataIndex: 'receiveTime'},
{title: '收货数量', dataIndex: 'receiveTime'},
{title: '加工单价', dataIndex: 'processPrice'},
// {title: '加工单价', dataIndex: 'processPrice'},
{title: '结算金额', dataIndex: 'settlementAmount'},
]
......
import React, { useState, useCallback, useEffect } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined } from '@ant-design/icons';
import { Button, Card, Select, DatePicker, Radio, Table, Space } from 'antd';
import { Button, Card, Select, DatePicker, Radio, Table, Space, message } from 'antd';
import { history } from 'umi';
import ReutrnEle from '@/components/ReturnEle';
import { createFormActions, FormEffectHooks } from '@formily/antd';
......@@ -274,9 +274,17 @@ const Add: React.FC<{}> = () => {
...rest
} = values;
const deliveryDateFormat = deliveryDate.unix() * 1000;
const isSomeFieldNotFill = someLists.some((item) => {
return typeof item.processNum === 'undefined' || typeof item.processUnitPrice === 'undefined'
})
if(isSomeFieldNotFill) {
message.error("通知单明细中有加工商品的加工数量或加工单价未填写");
return
}
const detailList = someLists.map((item) => {
return {
orederNo: null,
orederNo: item.orderNo, // 如果是商品加工,那么他没有订单号
productId: item.id, // skuid
productName: item.name,
category: item.customerCategoryName,
......
......@@ -227,7 +227,13 @@ const detailTab = {
prefix: "{{tableAddButton}}",
columns: "{{noticesDetailColumn}}"
// columns: "{{tableColumns}}",
}
},
'x-rules': [
{
required: true,
message: '请选择要加工的商品'
}
]
}
}
}
......
......@@ -158,67 +158,77 @@ export const outerWorkflowRecordsColumn: ColumnsType = [
* 生产通知单收货统计
*/
export const receiveColumns: ColumnsType = [
{
title: '订单号',
dataIndex: 'orderNo',
},
{
title: 'ID',
dataIndex: 'id',
},
{
title: '商品名称',
dataIndex: 'productName',
},
{
title: '品类',
dataIndex: 'category',
},
{
title: '品牌',
dataIndex: 'brand',
},
{
title: '单位',
dataIndex: 'unit',
},
{
title: '加工数量',
dataIndex: 'processNum',
},
{
title: '加工单价',
dataIndex: 'processPrice',
},
{
title: '加工费',
dataIndex: 'processTotalPrice',
},
{
title: '交期',
dataIndex: 'deliveryDate',
render: (text, record) => {
return moment(text).format('YYYY-MM-DD');
export const receiveColumns = (type: "order" | 'product'): ColumnsType<any> => {
/**
* 如果是商品加工,那么没有订单号
*/
const temp = [
{
title: '订单号',
dataIndex: 'orderNo',
},
{
title: 'ID',
dataIndex: 'id',
},
{
title: '商品名称',
dataIndex: 'productName',
},
{
title: '品类',
dataIndex: 'category',
},
{
title: '品牌',
dataIndex: 'brand',
},
{
title: '单位',
dataIndex: 'unit',
},
{
title: '加工数量',
dataIndex: 'processNum',
},
{
title: '加工单价',
dataIndex: 'processPrice',
},
{
title: '加工费',
dataIndex: 'processTotalPrice',
},
{
title: '交期',
dataIndex: 'deliveryDate',
render: (text, record) => {
return moment(text).format('YYYY-MM-DD');
}
},
{
title: '已发货',
dataIndex: 'deliverNum'
},
{
title: '已收货',
dataIndex: 'receiveNum'
},
{
title: '差异数量',
dataIndex: 'differenceNum'
},
{
title: '未发货',
dataIndex: 'notDeliverNum'
}
},
{
title: '已发货',
dataIndex: 'deliverNum'
},
{
title: '已收货',
dataIndex: 'receiveNum'
},
{
title: '差异数量',
dataIndex: 'differenceNum'
},
{
title: '未发货',
dataIndex: 'notDeliverNum'
}
];
];
if(type === 'order') {
return temp
}
return temp.slice(1)
}
export const pnoReceiveDeliverDetailDOListColumns = [
{
......
......@@ -2,7 +2,7 @@ import React, {useState, useEffect, useCallback, useMemo} from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { history } from 'umi';
import AvatarWrap from '@/components/AvatarWrap';
import { PageHeader, Descriptions, Card, Tabs, Row, Col, Button, Badge, Table, Popconfirm } from 'antd';
import { PageHeader, Descriptions, Card, Tabs, Row, Col, Button, Badge, Table, Popconfirm, Space } from 'antd';
import Circulation from '../../components/Circulation';
import OtherRequirement from '../../components/OtherRequirement';
import Appendix from '../../components/Appendix';
......@@ -78,24 +78,20 @@ const Detail: React.FC<{}> = () => {
const [loading, setLoading] = useState<boolean>(false);
const [deliverAddressOption, setDeliverAddressOption] = useState([]);
const [activeAddress, setActiveAddress] = useState<string | null>(null)
const tips = useMemo(() => {
let string = ""
const hasProductNoDelievery = useMemo(() => {
let res = false
if(pathname === `${PENDING_RECEIPT_PATH}/detail`) {
if(!info || !info.pnoReceiveDeliverDetailDOList) {
return ""
return false
}
const flag = info.pnoReceiveDeliverDetailDOList.some((item) => {
res = info.pnoReceiveDeliverDetailDOList.some((item) => {
return item.pnoReceiveDeliverDetailProductBOList.some((row) => {
return row.processNum - row.deliverNum > 0 // 还有未发货的
})
});
if(flag) {
string = "您还有未发货的商品,是否确认全部发货已完成"
} else {
string = "确认本单全部发货单是否已全部收到回单"
}
return res
}
return string
return res;
}, [info])
const getInfo = () => {
......@@ -210,12 +206,14 @@ const Detail: React.FC<{}> = () => {
/**
* 确认全部发货
*/
const handleAllReceiptReceive = () => {
const handleAllReceiptReceive = (status: boolean) => {
postService(
PublicApi.postEnhanceProcessToBeConfirmReceiptConfirmAllReceipt,
{
produceNoticeOrderId: id, status: true}
)
produceNoticeOrderId: id,
status: status
}
)
}
const renderExtra = () => {
......@@ -227,9 +225,23 @@ const Detail: React.FC<{}> = () => {
const SubmitBtn = <Button loading={loading} icon={<FormOutlined />} onClick={submit} type="primary"> 提交通知单</Button>
const NextBtn = <Button loading={loading} onClick={toNext}>提交</Button>
const AllReceiptReceive = (
<Popconfirm title={tips} onConfirm={handleAllReceiptReceive}>
<Button loading={loading} type="primary">确认本单全部发货单已收到回单</Button>
</Popconfirm>
<Space direction={"vertical"}>
<Popconfirm
title={hasProductNoDelievery ? '您还有未发货的商品,是否确认全部发货已完成' : '确认本单全部发货单是否已全部收到回单'}
onConfirm={() => handleAllReceiptReceive(true)}
>
<Button loading={loading} type="primary" style={{width: '100%'}}>确认本单全部发货单已收到回单</Button>
</Popconfirm>
<div style={{display: 'flex', justifyContent: 'flex-end'}}>
<Popconfirm
title={hasProductNoDelievery ? '是否继续发货' : '您商品都已发货,是否确认还需要继续发货'}
onConfirm={() => handleAllReceiptReceive(false)}
>
<Button loading={loading}>继续发货</Button>
</Popconfirm>
</div>
</Space>
)
const COMPONENT_MAP = {
......@@ -345,12 +357,12 @@ const Detail: React.FC<{}> = () => {
{/* 这里全部是走 非手工发货,当有手工发货按钮是,此时下面收发货明细隐藏 */}
<div style={{marginTop: '20px'}}>
<ReceiptDeliveryDetailsCard>
<StatisticsTab tab="收发货统计" columns={receiveColumns} dataSource={info.details}></StatisticsTab>
<StatisticsTab tab="收发货统计" columns={receiveColumns(info.source === 2 ? 'product' : 'order')} dataSource={info.details}></StatisticsTab>
{
info.pnoReceiveDeliverDetailDOList &&
info.pnoReceiveDeliverDetailDOList.length > 0
? <DetailTab
tab="生产通知单收发货明细"
tab="收发货明细"
columns={pnoReceiveDeliverDetailDOListColumns}
dataSource={info.pnoReceiveDeliverDetailDOList}
handleConfirm={handleConfirm}
......
......@@ -23,10 +23,20 @@ const styles = {
const AppendixItem = (props) => {
const handleDownload = (name:string, url: string) => {
let link = document.createElement("a");
link.style.display = "none";
link.href = url;
link.setAttribute("download", name);
document.body.appendChild(link) //a标签插至页面中
link.click();
document.body.removeChild(link);
}
return (
<div style={styles}>
<img src={pdf_icon} style={{width: '20px', marginRight: '15px'}} />
<div >{props.name}</div>
<div onClick={() => handleDownload(props.name, props.value)}>{props.name}</div>
</div>
)
}
......
......@@ -38,7 +38,6 @@ const SearchForm = (props) => {
state.props["x-component-props"]["loading"] = true;
})
props.request(values).then((res) => {
console.log(res);
if(res.code === 1000) {
setTableStatus({dataSource:res.data.data, totalCount: res.data.totalCount})
} else {
......@@ -59,7 +58,7 @@ const SearchForm = (props) => {
})
actions.setFieldState('pagination', state => {
//@ts-ignore
state.props["x-component-props"]["total"] = totalCount || 1;
state.props["x-component-props"]["total"] = totalCount || 0;
})
}
......
import React from 'react';
import { Modal } from 'antd';
const WrapModal = () => {
return (
<div></div>
)
}
export default WrapModal;
\ No newline at end of file
......@@ -48,7 +48,7 @@ const ProcessProducts = ({visible, cancel, ...restProps}) => {
const expandable = {
expandedRowRender: record => {
const renderData = record.productDateilss.map(
const renderData = record.productDateilss && record.productDateilss.map(
(item) => {
return {
orderNo: record.orderNo,
......
......@@ -3,7 +3,7 @@
* @description 加工通用列表页列表页, 用于 ["生产通知单","待生产通知单","待审核生产通知单(一级)", ""]等
*/
import React, { useRef, useState } from 'react';
import React, { useRef, useState, useCallback } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Card, Space, Button, Menu, Dropdown, Badge, Spin } from 'antd';
import NiceForm from '@/components/NiceForm';
......@@ -15,6 +15,7 @@ import { createFormActions } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { PlusOutlined } from '@ant-design/icons';
import { useAsyncInitSelect } from '@/formSchema/effects/useAsyncInitSelect';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import { ColumnsType } from 'antd/es/table';
import { DownOutlined, DeleteOutlined } from '@ant-design/icons';
import { querySchema, tobeAddQuerySchema, pendingFirstQuerySchema } from './schema';
......@@ -42,7 +43,6 @@ const formActions = createFormActions();
[ASSIGN_PENDING_FIRST]: pendingFirstQuerySchema,
[ASSIGN_PENDING_SECOND]: pendingFirstQuerySchema,
[ASSIGN_PENDING_SUBMIT]: pendingFirstQuerySchema, // 带审核生产通知单
// [PENDING_RECEIVE]: querySchema
}
// 根据 path, 得到对应的列表页 service
......@@ -52,7 +52,6 @@ const SERVICES = {
[ASSIGN_PENDING_FIRST]: PublicApi.getEnhanceSupplierToBeFirstExamList,
[ASSIGN_PENDING_SECOND]: PublicApi.getEnhanceSupplierToBeSecondExamList,
[ASSIGN_PENDING_SUBMIT]: PublicApi.getEnhanceSupplierToBeSubmitList,
// [PENDING_RECEIVE]: PublicApi.getEnhanceSupplierToBeReceiveList
}
const Query: React.FC<{}> = (props) => {
......@@ -72,9 +71,16 @@ const Query: React.FC<{}> = (props) => {
};
// 初始化高级筛选选项
const fetchSelectOptions = async () => {
return {};
};
const fetchSelectOptions = useCallback(async () => {
const { data, code } = await PublicApi.getEnhanceSupplierAllOuterAndInner()
if(code === 1000) {
return {
innerStatus: data.innerList.map((item: any) => ({label: item.message, value: item.code})),
outerStatus: data.outerList.map((item: any) => ({label: item.message, value: item.code})),
}
}
return {}
}, []);
const menu = (
<Menu >
......@@ -283,7 +289,7 @@ const Query: React.FC<{}> = (props) => {
* 查询
* @params values 表单字段
*/
const handleSearch = (values: any) => {
const handleSearch = useCallback((values: any) => {
const {docTime, ...rest} = values;
const {st, et} = timeRange(docTime);
let searchData = {
......@@ -291,9 +297,8 @@ const Query: React.FC<{}> = (props) => {
startTime: st,
endTtime: et
}
ref.current.reload(searchData)
}
}, [ref])
return (
<PageHeaderWrapper
......
......@@ -133,7 +133,7 @@ export const tobeAddQuerySchema: ISchema = {
allowClear: true,
},
},
time: {
docTime: {
type: 'string',
default: 0,
enum: docTime,
......@@ -227,7 +227,7 @@ export const pendingFirstQuerySchema: ISchema = {
allowClear: true,
},
},
time: {
docTime: {
type: 'string',
default: undefined,
enum: [],
......
......@@ -24,6 +24,7 @@
.fileName {
color: @main-color;
font-size: 14px;
display: block;
}
.remove {
......
......@@ -31,7 +31,7 @@ const FileList: React.FC<Iprops> = (props) => {
<div className={styles.icon}>
<img src={pdf_icon} className={styles.img} />
</div>
<div className={styles.fileName}>{name}</div>
<a className={styles.fileName} download={name} href={url} target={"_blank"}>{name}</a>
<div className={styles.remove} onClick={() => !!props.removeFile && props.removeFile(name)}>
<DeleteOutlined />
</div>
......
......@@ -4,6 +4,7 @@ import { Upload, Button, message } from 'antd';
import { UploadOutlined } from '@ant-design/icons'
import { UPLOAD_TYPE } from '@/constants'
import FileListItem from './FileList';
import url from '*.svg';
const UploadFile = (props) => {
const { fileList = [], onChange, fileMaxSize = 20 } = props
......@@ -64,7 +65,7 @@ const UploadFile = (props) => {
<FileListItem
key={item}
name={item.name}
url={""}
url={item.url}
removeFile={removeFile}
/>
)
......
......@@ -74,10 +74,17 @@ const Query: React.FC<{}> = (props) => {
// 初始化高级筛选选项
const fetchSelectOptions = async () => {
return {};
};
// 初始化高级筛选选项
const fetchSelectOptions = useCallback(async () => {
const { data, code } = await PublicApi.getEnhanceSupplierAllOuterAndInner()
if(code === 1000) {
return {
innerStatus: data.innerList.map((item: any) => ({label: item.message, value: item.code})),
outerStatus: data.outerList.map((item: any) => ({label: item.message, value: item.code})),
}
}
return {}
}, []);
const columns: ColumnsType = [
......@@ -195,7 +202,7 @@ const Query: React.FC<{}> = (props) => {
* 查询
* @params values 表单字段
*/
const handleSearch = (values: any) => {
const handleSearch = useCallback((values: any) => {
const {docTime, ...rest} = values;
const {st, et} = timeRange(docTime);
let searchData = {
......@@ -205,7 +212,7 @@ const Query: React.FC<{}> = (props) => {
}
ref.current.reload(searchData)
}
}, [ref])
return (
<PageHeaderWrapper
......
......@@ -203,7 +203,7 @@ export const pendingFirstQuerySchema: ISchema = {
allowClear: true,
},
},
time: {
docTime: {
type: 'string',
default: undefined,
enum: [],
......
......@@ -2,7 +2,8 @@ import React from 'react';
import { getAuth } from '@/utils/auth';
interface Iprops {
url: string
url: string,
canView?: boolean
}
const Authorize: React.FC<Iprops> = (props) => {
......@@ -11,7 +12,7 @@ const Authorize: React.FC<Iprops> = (props) => {
return (
<>
{
authUrls.includes(props.url)
authUrls.includes(props.url) || props.canView
? props.children
: null
}
......@@ -19,4 +20,8 @@ const Authorize: React.FC<Iprops> = (props) => {
)
}
Authorize.defaultProps = {
canView: false
}
export default Authorize
\ No newline at end of file
import React, { useCallback} from 'react';
import AbilityContainer from './Container';
import styles from './center.less'
import logistics from '@/assets/imgs/logistics.png';
import logistics_form from '@/assets/imgs/logistics_form.png';
import logistics_address from '@/assets/imgs/logistics_address.png';
import logistics_cost from '@/assets/imgs/logistics_cost.png';
import settlement_platformCollection from '@/assets/imgs/settlement_platformCollection.png';
import settlement_integrate from '@/assets/imgs/settlement_integrate.png';
import settlement_accountReceive from '@/assets/imgs/settlement_accountReceive.png';
import settlement_accountPayable from '@/assets/imgs/settlement_accountPayable.png';
import settlement_invoice from '@/assets/imgs/settlement_invoice.png';
import { Row, Col, Skeleton } from 'antd';
import { PublicApi } from '@/services/api';
import { Link } from 'umi'
import { getAuth } from '@/utils/auth';
interface Iprops {};
const KEY_TO_TITLE = {
......@@ -22,6 +23,32 @@ const FundCenter: React.FC<Iprops> = () => {
return res;
}, [])
const userAuth = getAuth();
const urls = userAuth.urls;
const tagsList = [
{
icon: settlement_platformCollection,
text: '资金账户',
url: '/memberCenter/payandSettle/capitalAccounts/accountLists'
},
{
icon: settlement_integrate,
text: '授信账户',
url: '/memberCenter/payandSettle/creditManage/quotaMenage'
},
{
icon: settlement_accountReceive,
text: '资金账户管理',
url: '/memberCenter/payandSettle/capitalAccounts/accountLists'
},
{
icon: settlement_accountPayable,
text: '授信管理',
url: '/memberCenter/payandSettle/creditManage/quotaMenage'
},
]
return (
<AbilityContainer
title="资金账户管理"
......@@ -37,6 +64,24 @@ const FundCenter: React.FC<Iprops> = () => {
? <Skeleton active />
: (
<>
<div className={styles.tags}>
{
tagsList.map((item) => {
const hasAuth = !urls.includes(item.url);
if(!hasAuth) {
return null
}
return (
<Link to={item.url} className={styles.tagsItem} key={item.text}>
<div className={styles.icon}>
<img src={item.icon} />
</div>
<div className={styles.text}>{item.text}</div>
</Link>
)
})
}
</div>
<div>
{
Object.keys(requestData).map((item) => {
......
......@@ -22,23 +22,28 @@ const LogisticsCenter: React.FC<Iprops> = () => {
const data = [
{
icon: logistics,
text: '物流派单'
text: '物流派单',
url: '/memberCenter/logisticsAbility/logisticsSubmit/toOrderSumitList'
},
{
icon: logistics_form,
text: '接单报价'
text: '接单报价',
url: '/memberCenter/logisticsAbility/logisticsResult/toOrderComfirmList'
},
{
icon: logistics_address,
text: '收货地址管理'
text: '收货地址管理',
url: "/memberCenter/logisticsAbility/logistics/receivingAddress"
},
{
icon: logistics_address,
text: '发货地址管理'
text: '发货地址管理',
url: "/memberCenter/logisticsAbility/logistics/deliveryAddress",
},
{
icon: logistics_cost,
text: '运费模板'
text: '运费模板',
url: "/memberCenter/logisticsAbility/logistics/template"
}
]
return (
......
import React from 'react';
import React, { useCallback } from 'react';
import AbilityContainer from './Container';
import styles from './center.less'
import create_shop from '@/assets/imgs/create_shop.png';
import { BellOutlined } from '@ant-design/icons'
import { getAuth } from '@/utils/auth';
import { Link } from 'umi';
import Authorize from '../Authorize';
import { PublicApi } from '@/services/api';
import { Skeleton } from 'antd';
interface Iprops {}
const SHOP_CENTER = '/memberCenter/shopAbility/template'
const CREATE_SHOP = '/memberCenter/shopAbility/infoManage';
const ShopCenter: React.FC<Iprops> = () => {
///template/shop/findShopList
const request = useCallback(async () => {
const {code, data} = await PublicApi.getTemplateShopFindShopList({current: '1', pageSize: '1', categoryId: '0', areaCode: '', memberName: ''});
if(code === 1000) {
return {totalCount: data.totalCount}
}
return {
totalCount: 0
}
}, [])
return (
<AbilityContainer
title="店铺中心"
......@@ -23,43 +35,56 @@ const ShopCenter: React.FC<Iprops> = () => {
<Link to={SHOP_CENTER}>进入店铺中心</Link>
</div>
</Authorize>
}
request={request}
>
<div className={styles.tags}>
<Authorize url={CREATE_SHOP}>
<div className={styles.tagsSpecial} >
<Link to={CREATE_SHOP} className={styles.tagsItem}>
<div className={styles.icon}>
<img src={create_shop} />
</div>
<div className={styles.text}>创建店铺</div>
</Link>
<div className={styles.ding_tips}>
<div className={styles.ding_icon}>
<BellOutlined />
{
({loading, requestData}) => {
return (
loading
? <Skeleton active />
: <div className={styles.tags}>
<Authorize url={CREATE_SHOP} canView={true}>
<div className={styles.tagsSpecial} >
<Link to={CREATE_SHOP} className={styles.tagsItem}>
<div className={styles.icon}>
<img src={create_shop} />
</div>
<div className={styles.text}>创建店铺</div>
</Link>
{
requestData.totalCount
? <div className={styles.ding_tips}>
<div className={styles.ding_icon}>
<BellOutlined />
</div>
<span>你还没有创建店铺,请先创建店铺</span>
</div>
: null
}
</div>
</Authorize>
<Authorize url={SHOP_CENTER}>
<Link to={SHOP_CENTER} className={styles.tagsItem} >
<div className={styles.icon}>
<img src={create_shop} />
</div>
<div className={styles.text}>店铺模板</div>
</Link>
</Authorize>
<Authorize url={SHOP_CENTER}>
<Link to={SHOP_CENTER} className={styles.tagsItem} >
<div className={styles.icon}>
<img src={create_shop} />
</div>
<div className={styles.text}>店铺装修</div>
</Link>
</Authorize>
</div>
<span>你还没有创建店铺,请先创建店铺</span>
</div>
</div>
</Authorize>
<Authorize url={SHOP_CENTER}>
<Link to={SHOP_CENTER} className={styles.tagsItem} >
<div className={styles.icon}>
<img src={create_shop} />
</div>
<div className={styles.text}>店铺模板</div>
</Link>
</Authorize>
<Authorize url={SHOP_CENTER}>
<Link to={SHOP_CENTER} className={styles.tagsItem} >
<div className={styles.icon}>
<img src={create_shop} />
</div>
<div className={styles.text}>店铺装修</div>
</Link>
</Authorize>
</div>
)
}
}
</AbilityContainer>
)
}
......
/**
* 最近未使用算法
* 设置最长的长度为6,之而立其实不能用map,后面再改进吧,应为map的话不能放到localstorage,需要遍历一次,
* 设置最长的长度为6,好像只能用map,后面再改进吧,应为map的话不能放到localstorage,需要遍历一次,
* 双向链表 用JSON.stringify 会报错,应该是因为有一个环
*/
var LRUCache = function (capacity: number) {
const LRUCache = function (capacity: number) {
this.cache = new Map();
this.capacity = capacity;
this.instance = null
};
LRUCache.prototype.get = function (key) {
if (this.cache.has(key)) {
// 存在即更新
let temp = this.cache.get(key);
this.cache.delete(key);
this.cache.set(key, temp);
return temp;
}
return -1;
};
LRUCache.prototype.init = function() {
const recentVisit = localStorage.getItem('recentVisit') && JSON.parse(localStorage.getItem('recentVisit')) || {};
Object.keys(recentVisit).map((item) => {
this.cache.set(item, recentVisit[item]);
})
// return recentVisit;
}
LRUCache.prototype.put = function (key: string, value: string) {
if (this.cache.has(key)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment