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
454ae70b
Commit
454ae70b
authored
Jan 18, 2022
by
Jenny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 全局数据
parent
4cfcbebd
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
45 deletions
+75
-45
echartElementData.js
mixins/echartElementData.js
+14
-1
index.vue
pages/index/index.vue
+59
-42
index.js
store/index.js
+2
-2
No files found.
mixins/echartElementData.js
View file @
454ae70b
...
...
@@ -38,7 +38,13 @@ export default {
* 全局数据
*/
handlePublicData
(
value
)
{
if
(
!
this
.
globalData
)
return
const
{
dataProcessing
}
=
{
...
value
}
if
(
dataProcessing
)
{
elementData
.
value
.
dataList
=
this
.
$u
.
common
.
converFunction
(
dataProcessing
,
JSON
.
parse
(
this
.
globalData
))
return
false
}
elementData
.
value
.
dataList
=
JSON
.
parse
(
this
.
globalData
)
},
/**
* 配置数据 - 数据集
...
...
@@ -101,6 +107,13 @@ export default {
},
immediate
:
true
,
deep
:
true
},
/**
* 全局数据更新监测
*/
globalData
()
{
console
.
log
(
'----globalData----'
,
this
.
globalData
)
if
(
this
.
elementInfo
.
data
.
dataType
===
'public'
)
this
.
handlePublicData
(
this
.
elementInfo
.
data
)
}
}
}
pages/index/index.vue
View file @
454ae70b
...
...
@@ -37,7 +37,8 @@
data
()
{
return
{
reportInfo
:
{},
reportData
:
[]
reportData
:
[],
timer
:
null
}
},
computed
:
{
...
...
@@ -58,7 +59,6 @@
this
.
userAuthCheck
()
},
methods
:
{
//检查是否登录
userAuthCheck
()
{
var
userId
=
uni
.
getStorageSync
(
'userId'
)
...
...
@@ -77,9 +77,7 @@
url
:
'../login/login'
})
}
},
//获取最新的授权信息
getNewestAuthFromServer
()
{
var
param
=
{
...
...
@@ -92,16 +90,35 @@
}
})
},
/**
* 获取页面报表配置
*/
async
getReportList
()
{
clearInterval
(
this
.
timer
)
let
res
=
await
this
.
$u
.
api
.
getReportList
({
id
:
'61c424a4c06bff0ce05d9a53'
})
const
{
Status
,
Result
}
=
res
.
data
const
{
Status
,
Result
:
{
info
,
list
}
}
=
res
.
data
if
(
Status
===
'true'
)
{
this
.
reportInfo
=
Result
.
info
this
.
reportData
=
Result
.
list
this
.
reportInfo
=
info
this
.
reportData
=
list
if
(
info
.
dataUrl
)
{
this
.
getGlobalData
(
info
)
if
(
info
.
dataPollingInterval
)
{
this
.
timer
=
setInterval
(()
=>
{
this
.
getGlobalData
(
info
)
},
parseInt
(
info
.
dataPollingInterval
)
*
1000
)
}
}
}
},
/**
* 获取全局接口数据
*/
async
getGlobalData
(
info
)
{
const
dataUrl
=
info
.
dataUrl
.
replace
(
/^
(\/
dashboardCharts
)?
|^
(\/
dashboardAPI
)?
/
,
''
)
let
res
=
await
this
.
$u
[
info
.
dataMethod
.
toLowerCase
()](
dataUrl
,
info
.
dataFormatter
)
this
.
$u
.
vuex
(
'globalData'
,
JSON
.
stringify
(
res
.
data
))
}
},
onReachBottom
()
{
}
...
...
store/index.js
View file @
454ae70b
...
...
@@ -12,7 +12,7 @@ try {
}
// 需要永久存储,且在下次 APP 启动需要取出的,在 state 中的变量名。
let
saveStateKeys
=
[
'vuex_
user'
,
'vuex_
token'
]
let
saveStateKeys
=
[
'vuex_token'
]
// 保存变量到本地存储中
const
saveLifeData
=
function
(
key
,
value
)
{
...
...
@@ -30,8 +30,8 @@ const saveLifeData = function(key, value) {
const
store
=
new
Vuex
.
Store
({
state
:
{
vuex_user
:
lifeData
.
vuex_user
||
{
name
:
'test'
},
vuex_token
:
lifeData
.
vuex_token
||
''
,
globalData
:
""
},
mutations
:
{
$uStore
(
state
,
payload
)
{
...
...
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