Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
ec-report-refactor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
lihuizhen
ec-report-refactor
Commits
06f09782
Commit
06f09782
authored
Oct 31, 2022
by
leon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:add data localstoarge
parent
97847911
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
6 deletions
+31
-6
echartElementData.js
mixins/echartElementData.js
+15
-5
index.vue
pages/index/index.vue
+15
-0
index.js
store/index.js
+1
-1
No files found.
mixins/echartElementData.js
View file @
06f09782
...
@@ -14,12 +14,14 @@ export default {
...
@@ -14,12 +14,14 @@ export default {
}
}
},
},
methods
:
{
methods
:
{
setStorageData
()
{
uni
.
setStorageSync
(
this
.
elementInfo
.
id
,
JSON
.
stringify
(
this
.
elementData
.
dataList
))
},
/**
/**
* 静态数据
* 静态数据
*/
*/
handleStaticData
(
value
)
{
handleStaticData
(
value
)
{
this
.
elementData
.
dataList
=
JSON
.
parse
(
JSON
.
stringify
({...
value
.
dataList
}))
this
.
elementData
.
dataList
=
JSON
.
parse
(
JSON
.
stringify
({...
value
.
dataList
}))
this
.
initChart
()
},
},
/**
/**
* 动态数据
* 动态数据
...
@@ -36,7 +38,6 @@ export default {
...
@@ -36,7 +38,6 @@ export default {
}
else
{
}
else
{
that
.
elementData
.
dataList
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
.
Result
))
that
.
elementData
.
dataList
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
.
Result
))
}
}
this
.
initChart
()
},
},
/**
/**
* 全局数据
* 全局数据
...
@@ -49,7 +50,6 @@ export default {
...
@@ -49,7 +50,6 @@ export default {
}
else
{
}
else
{
this
.
elementData
.
dataList
=
this
.
vuex_globalData
this
.
elementData
.
dataList
=
this
.
vuex_globalData
}
}
this
.
initChart
()
},
},
/**
/**
* 配置数据 - 数据集
* 配置数据 - 数据集
...
@@ -65,7 +65,6 @@ export default {
...
@@ -65,7 +65,6 @@ export default {
}
else
{
}
else
{
that
.
elementData
.
dataList
=
res
.
data
.
Result
that
.
elementData
.
dataList
=
res
.
data
.
Result
}
}
this
.
initChart
()
}
else
{
}
else
{
that
.
$u
.
toast
(
Msg
)
that
.
$u
.
toast
(
Msg
)
}
}
...
@@ -82,7 +81,6 @@ export default {
...
@@ -82,7 +81,6 @@ export default {
const
{
Status
,
Msg
,
Result
}
=
res
.
data
const
{
Status
,
Msg
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
if
(
Status
===
'true'
)
{
that
.
elementData
.
dataList
=
Result
that
.
elementData
.
dataList
=
Result
this
.
initChart
()
}
else
{
}
else
{
message
.
warning
(
Msg
)
message
.
warning
(
Msg
)
}
}
...
@@ -117,6 +115,10 @@ export default {
...
@@ -117,6 +115,10 @@ export default {
'elementInfo.data'
:
{
'elementInfo.data'
:
{
handler
(
newVal
)
{
handler
(
newVal
)
{
const
that
=
this
const
that
=
this
const
storageData
=
uni
.
getStorageSync
(
this
.
elementInfo
.
id
)
if
(
storageData
&&
newVal
.
dataType
!==
'static'
)
{
this
.
elementData
.
dataList
=
JSON
.
parse
(
storageData
)
}
if
(
that
.
elementInfo
.
hide
)
return
false
if
(
that
.
elementInfo
.
hide
)
return
false
if
(
newVal
.
dataType
===
'static'
)
{
if
(
newVal
.
dataType
===
'static'
)
{
that
.
handleStaticData
(
newVal
)
that
.
handleStaticData
(
newVal
)
...
@@ -159,6 +161,14 @@ export default {
...
@@ -159,6 +161,14 @@ export default {
*/
*/
'vuex_globalData'
()
{
'vuex_globalData'
()
{
if
(
this
.
elementInfo
.
data
.
dataType
===
'public'
)
this
.
handlePublicData
(
this
.
elementInfo
.
data
)
if
(
this
.
elementInfo
.
data
.
dataType
===
'public'
)
this
.
handlePublicData
(
this
.
elementInfo
.
data
)
},
'elementData.dataList'
:
{
handler
(
newVal
)
{
this
.
setStorageData
()
this
.
initChart
()
},
deep
:
true
,
immediate
:
true
}
}
}
}
}
}
pages/index/index.vue
View file @
06f09782
...
@@ -104,6 +104,9 @@
...
@@ -104,6 +104,9 @@
// detail页面也会监听这两个事件,所有index页面需要在onShow里面增加监听,在onHide里面移除监听
// detail页面也会监听这两个事件,所有index页面需要在onShow里面增加监听,在onHide里面移除监听
onShow
()
{
onShow
()
{
const
that
=
this
const
that
=
this
if
(
uni
.
getStorageSync
(
'reportInfo'
))
{
this
.
reportInfo
=
JSON
.
parse
(
uni
.
getStorageSync
(
'reportInfo'
))
}
/**
/**
* 组件交互 - 参数
* 组件交互 - 参数
*/
*/
...
@@ -222,6 +225,18 @@
...
@@ -222,6 +225,18 @@
}
}
}
}
that
.
reportInfo
=
res
.
data
.
Result
that
.
reportInfo
=
res
.
data
.
Result
// 清除数据
if
(
uni
.
getStorageSync
(
'reportInfo'
))
{
let
info
=
JSON
.
parse
(
uni
.
getStorageSync
(
'reportInfo'
))
info
.
list
.
forEach
(
item
=>
{
// 如果本地缓存的数组在接口请求的数组中不存在,则删除
if
(
!
that
.
reportInfo
.
list
.
some
(
idx
=>
idx
.
id
==
item
.
id
))
{
uni
.
removeStorageSync
(
item
.
id
)
}
})
}
uni
.
setStorageSync
(
'reportInfo'
,
JSON
.
stringify
(
res
.
data
.
Result
))
that
.
getStickyTables
()
that
.
getStickyTables
()
}
}
},
},
...
...
store/index.js
View file @
06f09782
...
@@ -12,7 +12,7 @@ try {
...
@@ -12,7 +12,7 @@ try {
}
}
// 需要永久存储,且在下次 APP 启动需要取出的,在 state 中的变量名。
// 需要永久存储,且在下次 APP 启动需要取出的,在 state 中的变量名。
let
saveStateKeys
=
[
'vuex_token'
]
let
saveStateKeys
=
[
'vuex_token'
,
'vuex_globalData'
]
// 保存变量到本地存储中
// 保存变量到本地存储中
const
saveLifeData
=
function
(
key
,
value
)
{
const
saveLifeData
=
function
(
key
,
value
)
{
...
...
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