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
c91b002e
Commit
c91b002e
authored
Feb 21, 2023
by
leon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add dynamic params
parent
cd51368d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
208 additions
and
138 deletions
+208
-138
echartElementData.js
mixins/echartElementData.js
+1
-0
details.vue
pages/details/details.vue
+2
-1
index.vue
pages/index/index.vue
+2
-1
common.js
utils/common.js
+203
-136
No files found.
mixins/echartElementData.js
View file @
c91b002e
...
@@ -30,6 +30,7 @@ export default {
...
@@ -30,6 +30,7 @@ export default {
const
that
=
this
const
that
=
this
let
{
dataUrl
,
dataMethod
,
dataFormatter
,
dataProcessing
}
=
{
...
value
}
let
{
dataUrl
,
dataMethod
,
dataFormatter
,
dataProcessing
}
=
{
...
value
}
dataUrl
=
dataUrl
.
replace
(
/^
(\/(
dashboardCharts|dashboardAPI
))?
/
,
''
)
dataUrl
=
dataUrl
.
replace
(
/^
(\/(
dashboardCharts|dashboardAPI
))?
/
,
''
)
dataFormatter
=
that
.
$u
.
common
.
filterRequestParams
({...
dataFormatter
})
let
res
=
await
that
.
$u
.
api
[
`
${
dataMethod
.
toLowerCase
()}
Http`
](
dataUrl
,
dataFormatter
,
{
let
res
=
await
that
.
$u
.
api
[
`
${
dataMethod
.
toLowerCase
()}
Http`
](
dataUrl
,
dataFormatter
,
{
custom
:
{
loading
:
false
}
custom
:
{
loading
:
false
}
})
})
...
...
pages/details/details.vue
View file @
c91b002e
...
@@ -236,7 +236,8 @@
...
@@ -236,7 +236,8 @@
async
getGlobalData
(
info
)
{
async
getGlobalData
(
info
)
{
const
that
=
this
const
that
=
this
const
dataUrl
=
info
.
dataUrl
.
replace
(
/^
(\/(
dashboardCharts|dashboardAPI
))?
/
,
''
)
const
dataUrl
=
info
.
dataUrl
.
replace
(
/^
(\/(
dashboardCharts|dashboardAPI
))?
/
,
''
)
let
res
=
await
that
.
$u
.
api
[
`
${
info
.
dataMethod
.
toLowerCase
()}
Http`
](
dataUrl
,
info
.
dataFormatter
,
{
const
dataFormatter
=
this
.
$u
.
common
.
filterRequestParams
({...
info
.
dataFormatter
})
let
res
=
await
that
.
$u
.
api
[
`
${
info
.
dataMethod
.
toLowerCase
()}
Http`
](
dataUrl
,
dataFormatter
,
{
custom
:
{
loading
:
false
}
custom
:
{
loading
:
false
}
})
})
that
.
$u
.
vuex
(
'vuex_globalData'
,
res
.
data
)
that
.
$u
.
vuex
(
'vuex_globalData'
,
res
.
data
)
...
...
pages/index/index.vue
View file @
c91b002e
...
@@ -274,7 +274,8 @@
...
@@ -274,7 +274,8 @@
async
getGlobalData
(
info
)
{
async
getGlobalData
(
info
)
{
const
that
=
this
const
that
=
this
const
dataUrl
=
info
.
dataUrl
.
replace
(
/^
(\/(
dashboardCharts|dashboardAPI
))?
/
,
''
)
const
dataUrl
=
info
.
dataUrl
.
replace
(
/^
(\/(
dashboardCharts|dashboardAPI
))?
/
,
''
)
let
res
=
await
that
.
$u
.
api
[
`
${
info
.
dataMethod
.
toLowerCase
()}
Http`
](
dataUrl
,
info
.
dataFormatter
,
{
const
dataFormatter
=
this
.
$u
.
common
.
filterRequestParams
({...
info
.
dataFormatter
})
let
res
=
await
that
.
$u
.
api
[
`
${
info
.
dataMethod
.
toLowerCase
()}
Http`
](
dataUrl
,
dataFormatter
,
{
custom
:
{
loading
:
false
}
custom
:
{
loading
:
false
}
})
})
that
.
$u
.
vuex
(
'vuex_globalData'
,
res
.
data
)
that
.
$u
.
vuex
(
'vuex_globalData'
,
res
.
data
)
...
...
utils/common.js
View file @
c91b002e
import
{
Function
}
from
'../static/plugin/parse/parse.js'
import
{
Function
}
from
'../static/plugin/common/index.js'
const
install
=
(
Vue
,
vm
)
=>
{
const
install
=
(
Vue
,
vm
)
=>
{
/**
/**
* 数据转换
* 数据转换
*/
*/
const
converFunction
=
(
func
,
data
)
=>
{
const
converFunction
=
(
func
,
data
)
=>
{
if
(
!
func
)
return
if
(
!
func
)
return
return
new
Function
(
'"use strict";return ('
+
func
+
')'
)()(
data
);
return
new
Function
(
'"use strict";return ('
+
func
+
')'
)()(
data
);
}
}
...
@@ -103,23 +105,87 @@ const install = (Vue, vm) => {
...
@@ -103,23 +105,87 @@ const install = (Vue, vm) => {
*/
*/
const
getQueryFromString
=
(
string
)
=>
{
const
getQueryFromString
=
(
string
)
=>
{
const
num
=
string
.
indexOf
(
"?"
)
const
num
=
string
.
indexOf
(
"?"
)
const
qs
=
string
.
substr
(
num
+
1
)
// 获取url中"?"符后的字串
const
qs
=
string
.
substr
(
num
+
1
)
// 获取url中"?"符后的字串
let
args
=
{}
// 保存参数数据的对象
let
args
=
{}
// 保存参数数据的对象
const
items
=
qs
.
length
?
qs
.
split
(
"&"
)
:
[]
// 取得每一个参数项,
const
items
=
qs
.
length
?
qs
.
split
(
"&"
)
:
[]
// 取得每一个参数项,
let
item
=
null
let
item
=
null
const
len
=
items
.
length
;
const
len
=
items
.
length
;
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
for
(
var
i
=
0
;
i
<
len
;
i
++
)
{
item
=
items
[
i
].
split
(
"="
);
item
=
items
[
i
].
split
(
"="
);
var
name
=
decodeURIComponent
(
item
[
0
]),
var
name
=
decodeURIComponent
(
item
[
0
]),
value
=
decodeURIComponent
(
item
[
1
]);
value
=
decodeURIComponent
(
item
[
1
]);
if
(
name
)
{
if
(
name
)
{
args
[
name
]
=
value
;
args
[
name
]
=
value
;
}
}
}
}
return
args
;
return
args
;
}
}
const
filterRequestParams
=
(
params
)
=>
{
let
paramStr
=
JSON
.
stringify
(
params
)
if
(
paramStr
.
includes
(
'@year'
))
{
paramStr
=
paramStr
.
replace
(
/@year/g
,
yearly
())
}
if
(
paramStr
.
includes
(
'@month'
))
{
paramStr
=
paramStr
.
replace
(
/@month/g
,
monthly
())
}
if
(
paramStr
.
includes
(
'@day'
))
{
paramStr
=
paramStr
.
replace
(
/@day/g
,
day
())
}
if
(
paramStr
.
includes
(
'@daily'
))
{
const
d
=
daily
()
paramStr
=
paramStr
.
replace
(
/@daily/g
,
daily
())
}
if
(
paramStr
.
includes
(
'@yesterday'
))
{
paramStr
=
paramStr
.
replace
(
/@yesterday/g
,
yesterday
())
}
return
JSON
.
parse
(
paramStr
)
}
const
yearly
=
()
=>
{
const
date
=
new
Date
();
const
year
=
date
.
getFullYear
();
return
year
}
const
monthly
=
()
=>
{
const
date
=
new
Date
();
const
month
=
date
.
getMonth
()
+
1
<
10
?
"0"
+
(
date
.
getMonth
()
+
1
)
:
date
.
getMonth
()
+
1
;
return
month
}
const
day
=
()
=>
{
const
date
=
new
Date
();
const
day
=
date
.
getDate
()
<
10
?
"0"
+
date
.
getDate
()
:
date
.
getDate
();
return
day
}
const
daily
=
()
=>
{
const
date
=
new
Date
();
const
year
=
date
.
getFullYear
();
// 在日期格式中,月份是从0开始的,因此要加0,使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05
const
month
=
date
.
getMonth
()
+
1
<
10
?
"0"
+
(
date
.
getMonth
()
+
1
)
:
date
.
getMonth
()
+
1
;
const
day
=
date
.
getDate
()
<
10
?
"0"
+
date
.
getDate
()
:
date
.
getDate
();
// 拼接
return
year
+
"-"
+
month
+
"-"
+
day
;
}
const
yesterday
=
()
=>
{
const
date
=
new
Date
()
const
timestamp
=
date
.
getTime
()
-
1000
*
24
*
60
*
60
date
.
setTime
(
timestamp
)
console
.
log
(
date
)
const
year
=
date
.
getFullYear
();
// 在日期格式中,月份是从0开始的,因此要加0,使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05
const
month
=
date
.
getMonth
()
+
1
<
10
?
"0"
+
(
date
.
getMonth
()
+
1
)
:
date
.
getMonth
()
+
1
;
const
day
=
date
.
getDate
()
<
10
?
"0"
+
date
.
getDate
()
:
date
.
getDate
();
// 拼接
return
year
+
"-"
+
month
+
"-"
+
day
;
}
vm
.
$u
.
common
=
{
vm
.
$u
.
common
=
{
converFunction
,
converFunction
,
fillDigit
,
fillDigit
,
...
@@ -128,7 +194,8 @@ const install = (Vue, vm) => {
...
@@ -128,7 +194,8 @@ const install = (Vue, vm) => {
pxToRpx
,
pxToRpx
,
rpxToPx
,
rpxToPx
,
chunk
,
chunk
,
getQueryFromString
getQueryFromString
,
filterRequestParams
}
}
}
}
...
...
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