Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
merchant-manage-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ui
merchant-manage-ui
Commits
d82815ac
Commit
d82815ac
authored
Jan 03, 2023
by
武广
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修改缓存保存空数据问题
parent
4813ee40
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
39 deletions
+12
-39
index.jsx
src/pages/ServiceGoods/index.jsx
+1
-0
utils.js
src/pages/ServiceGoods/utils.js
+11
-39
No files found.
src/pages/ServiceGoods/index.jsx
View file @
d82815ac
...
...
@@ -160,6 +160,7 @@ const ServiceGoods = options => {
const
addResponse
=
await
sendAsyncHttpRequest
(
sendData
);
if
(
addResponse
.
data
)
{
message
.
success
(
`
${
isEdit
?
'
修改
'
:
'
添加
'
}
成功!`
);
localStorage
.
remove
(
localAutoSaveKey
);
handleCancel
(
true
);
}
setPageLoading
(
false
);
...
...
src/pages/ServiceGoods/utils.js
View file @
d82815ac
...
...
@@ -2,7 +2,7 @@ import { message } from 'antd';
import
{
sortBy
}
from
'
lodash
'
;
import
UUID
from
'
../../utils/uuid
'
;
import
localStorage
from
'
@/utils/localStorage
'
;
import
{
debounce
,
getObjectType
}
from
'
@/utils/utils
'
;
import
{
debounce
,
getObjectType
,
isClass
}
from
'
@/utils/utils
'
;
export
const
clearCurrent
=
currentList
=>
currentList
.
filter
(
item
=>
item
.
current
);
...
...
@@ -258,6 +258,16 @@ export const createProductData = (props, isEdit, skuList) => {
export
const
localAutoSaveKey
=
'
good-info-auto-save
'
;
export
const
onAutoSaveValue
=
(
e
,
isClear
)
=>
{
const
keys
=
Object
.
keys
(
e
);
if
(
e
&&
isClass
(
e
)
===
'
Object
'
&&
keys
.
length
===
1
&&
isClass
(
e
[
keys
[
0
]])
===
'
Object
'
&&
Object
.
keys
(
e
[
keys
[
0
]])
<
1
)
{
return
;
}
if
(
isClear
)
{
localStorage
.
set
(
localAutoSaveKey
,
Object
.
assign
({},
e
));
}
else
{
...
...
@@ -265,41 +275,3 @@ export const onAutoSaveValue = (e, isClear) => {
localStorage
.
set
(
localAutoSaveKey
,
Object
.
assign
({
type
:
1
},
info
,
e
));
}
};
// export const onAutoSaveValue = (e, isClear) => {
// const localkey = 'good-info-auto-save';
// if (isClear) {
// localStorage.set(localkey, Object.assign({}, e));
// } else {
// const info = localStorage.get(localkey) || {};
// const key = Object.keys(e)[0];
// if (info[key] === undefined) {
// info[key] = e[key];
// localStorage.set(localkey, Object.assign({}, info));
// return;
// }
// if (getObjectType(e[key]) === 'Array' && e[key].length && getObjectType(e[key][0]) === 'Object') {
// e[key].forEach((item, i) => {
// if (item !== null) {
// if (getObjectType(item) === 'Object') {
// const itemkeys = Object.keys(item);
// if (itemkeys.length > 1 || info[key][i] === null) {
// info[key][i] = item;
// } else {
// info[key][i][itemkeys[0]] = item[itemkeys[0]];
// }
// } else {
// info[key][i] = item;
// }
// }
// });
// localStorage.set(localkey, Object.assign({}, info));
// } else if (getObjectType(e[key]) === 'Object') {
// const okey = Object.keys(e[key])[0];
// info[key][okey] = e[key][okey];
// } else {
// localStorage.set(localkey, Object.assign({}, info, e));
// }
// }
// message.success('已自动保存至缓存');
// };
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment