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
37973c96
Commit
37973c96
authored
Oct 28, 2022
by
leon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: use request repleace eval
parent
1dc9a745
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
471 additions
and
49 deletions
+471
-49
http.api.js
common/http.api.js
+5
-1
BarMixMap.vue
components/BarMixMap/BarMixMap.vue
+15
-5
ChinaMap.vue
components/ChinaMap/ChinaMap.vue
+1
-0
HorizontalBar.vue
components/HorizontalBar/HorizontalBar.vue
+102
-16
LineMixBar.vue
components/LineMixBar/LineMixBar.vue
+93
-6
NormalBar.vue
components/NormalBar/NormalBar.vue
+87
-5
NormalLine.vue
components/NormalLine/NormalLine.vue
+91
-6
NormalPie.vue
components/NormalPie/NormalPie.vue
+54
-6
echartElementData.js
mixins/echartElementData.js
+23
-4
No files found.
common/http.api.js
View file @
37973c96
...
...
@@ -40,6 +40,9 @@ const install = (Vue, vm) => {
// 获取OPENID
const
getOpenId
=
params
=>
getHttp
(
`
${
baseUrl
}
/report/user/getOpenId`
,
params
)
// 脚本转换
const
jsScript
=
params
=>
postHttp
(
`
${
reportUrl
}
/report/js/script`
,
params
)
vm
.
$u
.
api
=
{
getHttp
,
postHttp
,
...
...
@@ -54,7 +57,8 @@ const install = (Vue, vm) => {
changePassword
,
getAuthorizedList
,
authorizeOrUnauthorize
,
getOpenId
getOpenId
,
jsScript
}
}
...
...
components/BarMixMap/BarMixMap.vue
View file @
37973c96
...
...
@@ -82,9 +82,9 @@
...
this
.
elementInfo
.
option
.
bar
,
label
:
{
...
this
.
elementInfo
.
option
.
dataset
,
formatter
:
(
val
)
=>
{
return
this
.
$u
.
common
.
converFunction
(
this
.
elementInfo
.
option
.
dataset
.
formatter
,
val
)
}
//
formatter: (val) => {
//
return this.$u.common.converFunction(this.elementInfo.option.dataset.formatter, val)
//
}
},
animationDurationUpdate
:
1000
,
universalTransition
:
true
,
...
...
@@ -132,12 +132,21 @@
tooltip
:
{
show
:
this
.
elementInfo
.
option
.
dataset
.
show
,
trigger
:
'item'
,
formatter
:
(
val
ue
)
=>
{
formatter
:
(
val
,
ticket
,
callback
)
=>
{
if
(
!
value
.
data
)
{
return
""
}
if
(
this
.
elementInfo
.
option
.
dataset
.
formatter
)
{
return
this
.
$u
.
common
.
converFunction
(
this
.
elementInfo
.
option
.
dataset
.
formatter
,
value
)
const
params
=
{
script
:
tooltip
.
formatter
,
data
:
JSON
.
stringify
(
val
)
}
this
.
$u
.
api
.
jsScript
(
params
).
then
(
res
=>
{
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
return
callback
(
ticket
,
Result
)
}
})
}
else
{
return
`
${
value
.
data
.
name
}
:
${
value
.
data
.
value
[
2
]}
`
}
...
...
@@ -166,6 +175,7 @@
show
:
this
.
elementInfo
.
option
.
dataset
.
show
,
position
:
'inside'
,
formatter
:
(
value
)
=>
{
return
this
.
elementInfo
.
option
.
dataset
.
show
?
value
.
data
.
name
:
""
if
(
this
.
elementInfo
.
option
.
dataset
.
formatter
)
{
return
this
.
$u
.
common
.
converFunction
(
this
.
elementInfo
.
option
.
dataset
.
formatter
,
value
)
}
else
{
...
...
components/ChinaMap/ChinaMap.vue
View file @
37973c96
...
...
@@ -120,6 +120,7 @@
show
:
true
,
position
:
'right'
,
formatter
:
value
=>
{
return
this
.
elementInfo
.
option
.
dataset
.
show
?
`
${
value
.
data
.
name
}
:
${
value
.
data
.
value
[
2
]}
`
:
value
.
data
.
name
if
(
this
.
elementInfo
.
option
.
dataset
.
formatter
)
{
return
this
.
$u
.
common
.
converFunction
(
this
.
elementInfo
.
option
.
dataset
.
formatter
,
value
)
}
else
{
...
...
components/HorizontalBar/HorizontalBar.vue
View file @
37973c96
...
...
@@ -22,7 +22,8 @@
option
:
{}
},
labelShow
:
false
,
// 记录当前设置的label.show的值
index
:
0
,
// 记录dataZoom切换当前的下标
index
:
0
,
// 记录dataZoom切换当前的下标
formatter
:
{},
// 记录formatter之后的对象
}
},
components
:
{
...
...
@@ -72,14 +73,16 @@
images
}
=
that
.
elementData
.
dataList
var
urls
=
[]
var
caches
=
uni
.
getStorageSync
(
'cacheImages'
)
images
.
forEach
(
url
=>
{
if
(
caches
.
hasOwnProperty
(
url
))
{
urls
.
push
(
caches
[
url
])
}
else
{
urls
.
push
(
url
)
}
})
var
caches
=
uni
.
getStorageSync
(
'cacheImages'
)
if
(
images
&&
image
.
length
)
{
images
.
forEach
(
url
=>
{
if
(
caches
.
hasOwnProperty
(
url
))
{
urls
.
push
(
caches
[
url
])
}
else
{
urls
.
push
(
url
)
}
})
}
// 特殊处理,如果preview为true,代表点击显示图片
if
(
preview
)
{
uni
.
previewImage
({
...
...
@@ -118,7 +121,7 @@
}
lastCount
=
count
}
this
.
getLabelFormatter
(
series
)
const
dealSeries
=
this
.
dealSeriesData
(
series
)
this
.
$set
(
this
.
ec
.
option
,
'yAxis.show'
,
true
)
this
.
$set
(
this
.
ec
.
option
,
'yAxis.data'
,
categories
)
...
...
@@ -148,7 +151,72 @@
this
.
cacheImages
(
images
)
}
})
},
},
// 获取label的formatter信息
async
getLabelFormatter
(
series
)
{
const
formatter
=
this
.
elementInfo
.
option
.
dataset
.
formatter
if
(
!
formatter
||
!
formatter
.
length
)
{
return
}
console
.
log
(
this
.
elementInfo
.
dataZoom
)
var
arr
=
[]
// 当前显示的label,formatter需要阻塞线程
var
all
=
[]
// 除当前显示label之外的值,formatter可以在异步线程请求处理
const
count
=
this
.
elementData
.
dataList
.
categories
.
length
var
start
=
parseInt
(
this
.
elementInfo
.
dataZoom
.
start
/
100
*
count
)
start
=
start
>
1
?
start
-
1
:
start
const
end
=
parseInt
(
this
.
elementInfo
.
dataZoom
.
end
/
100
*
count
)
series
.
forEach
(
item
=>
{
const
data
=
item
.
data
const
name
=
item
.
name
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
i
>=
start
&&
i
<=
end
-
1
)
{
arr
.
push
({
seriesName
:
name
,
value
:
data
[
i
]})
}
else
{
all
.
push
({
seriesName
:
name
,
value
:
data
[
i
]})
}
}
})
// 把所有的请求加入req数组中
var
req
=
[]
arr
.
forEach
(
item
=>
{
if
(
!
this
.
formatter
.
hasOwnProperty
(
item
.
value
))
{
const
params
=
{
script
:
this
.
elementInfo
.
option
.
dataset
.
formatter
,
data
:
JSON
.
stringify
(
item
)
}
req
.
push
(
this
.
$u
.
api
.
jsScript
(
params
))
}
})
// req的线程需要同步执行
await
Promise
.
all
(
req
).
then
(
res
=>
{
res
.
forEach
(
item
=>
{
const
{
Status
,
Result
}
=
item
.
data
if
(
Status
===
'true'
)
{
const
data
=
item
.
config
.
data
.
data
const
key
=
JSON
.
parse
(
data
).
value
this
.
formatter
[
key
]
=
Result
}
})
})
// all的线程可以异步处理
all
.
forEach
(
item
=>
{
if
(
!
this
.
formatter
.
hasOwnProperty
(
item
.
value
))
{
let
params
=
{
script
:
this
.
elementInfo
.
option
.
dataset
.
formatter
,
data
:
JSON
.
stringify
(
item
)
}
this
.
$u
.
api
.
jsScript
(
params
).
then
(
res
=>
{
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
this
.
formatter
[
item
.
value
]
=
Result
}
})
}
})
},
/**
*
* @param tooltip 表单的tooltip设置
...
...
@@ -160,8 +228,20 @@
if
(
tooltip
.
formatter
&&
tooltip
.
formatter
.
length
)
{
return
{
...
tooltip
,
formatter
:
(
val
)
=>
{
return
this
.
$u
.
common
.
converFunction
(
tooltip
.
formatter
,
val
)
formatter
:
(
val
,
ticket
,
callback
)
=>
{
const
params
=
{
script
:
tooltip
.
formatter
,
data
:
JSON
.
stringify
(
val
)
}
this
.
$u
.
api
.
jsScript
(
params
).
then
(
res
=>
{
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
return
callback
(
ticket
,
Result
)
}
})
return
"加载中......"
// return this.$u.common.converFunction(tooltip.formatter, val)
},
trigger
:
"axis"
}
...
...
@@ -183,9 +263,14 @@
...
that
.
elementInfo
.
option
.
bar
,
label
:
{
...
that
.
elementInfo
.
option
.
dataset
,
formatter
:
val
=>
{
return
that
.
$u
.
common
.
converFunction
(
that
.
elementInfo
.
option
.
dataset
.
formatter
,
val
)
formatter
:
val
=>
{
if
(
this
.
formatter
.
hasOwnProperty
(
val
.
value
))
{
return
this
.
formatter
[
val
.
value
]
}
return
val
.
value
// return that.$u.common.converFunction(that.elementInfo.option.dataset
// .formatter, val)
}
}
}
...
...
@@ -285,6 +370,7 @@
setChartDatas
(
event
)
{
const
categories
=
this
.
elementData
.
dataList
.
datas
[
this
.
index
].
categories
const
series
=
this
.
elementData
.
dataList
.
datas
[
this
.
index
].
series
this
.
getLabelFormatter
(
series
)
const
dealSeries
=
this
.
dealSeriesData
(
series
)
this
.
$set
(
this
.
ec
.
option
,
'yAxis.data'
,
categories
)
this
.
$set
(
this
.
ec
.
option
,
'series'
,
dealSeries
)
...
...
components/LineMixBar/LineMixBar.vue
View file @
37973c96
...
...
@@ -27,6 +27,7 @@
},
labelShow
:
false
,
// 记录当前设置的label.show的值
index
:
0
,
// 记录dataZoom切换当前的下标
formatter
:
{},
// 记录formatter之后的对象
}
},
components
:
{
...
...
@@ -110,7 +111,8 @@
}
lastCount
=
count
}
const
dealSeries
=
this
.
dealSeriesData
(
series
)
this
.
getLabelFormatter
(
series
)
const
dealSeries
=
this
.
dealSeriesData
(
series
)
this
.
$set
(
this
.
ec
.
option
,
'xAxis.data'
,
categories
)
this
.
$set
(
this
.
ec
.
option
,
'series'
,
dealSeries
)
this
.
$set
(
this
.
ec
.
option
,
'dataZoom'
,
this
.
elementInfo
.
dataZoom
&&
this
.
elementInfo
.
dataZoom
.
show
?
[{...
this
.
elementInfo
.
dataZoom
,...
DATAZOOM_DEFAULT
}]
:
[{
show
:
false
}])
...
...
@@ -121,7 +123,73 @@
chart
.
setOption
(
option
)
}
})
},
},
// 获取label的formatter信息
async
getLabelFormatter
(
series
)
{
const
formatter
=
this
.
elementInfo
.
option
.
dataset
.
formatter
if
(
!
formatter
||
!
formatter
.
length
)
{
return
}
var
arr
=
[]
// 当前显示的label,formatter需要阻塞线程
var
all
=
[]
// 除当前显示label之外的值,formatter可以在异步线程请求处理
const
count
=
this
.
elementData
.
dataList
.
categories
.
length
var
start
=
parseInt
(
this
.
elementInfo
.
dataZoom
.
start
/
100
*
count
)
start
=
start
>
1
?
start
-
1
:
start
const
end
=
parseInt
(
this
.
elementInfo
.
dataZoom
.
end
/
100
*
count
)
series
.
forEach
(
item
=>
{
const
data
=
item
.
data
const
name
=
item
.
name
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
i
>=
start
&&
i
<=
end
-
1
)
{
arr
.
push
({
seriesName
:
name
,
value
:
data
[
i
]})
}
else
{
all
.
push
({
seriesName
:
name
,
value
:
data
[
i
]})
}
}
})
// 把所有的请求加入req数组中
var
req
=
[]
arr
.
forEach
(
item
=>
{
if
(
!
this
.
formatter
.
hasOwnProperty
(
item
.
value
))
{
const
params
=
{
script
:
this
.
elementInfo
.
option
.
dataset
.
formatter
,
data
:
JSON
.
stringify
(
item
)
}
req
.
push
(
this
.
$u
.
api
.
jsScript
(
params
))
}
})
// req的线程需要同步执行
await
Promise
.
all
(
req
).
then
(
res
=>
{
res
.
forEach
(
item
=>
{
const
{
Status
,
Result
}
=
item
.
data
if
(
Status
===
'true'
)
{
const
data
=
item
.
config
.
data
.
data
const
key
=
JSON
.
parse
(
data
).
value
this
.
formatter
[
key
]
=
Result
}
})
})
console
.
log
(
all
)
// all的线程可以异步处理
all
.
forEach
(
item
=>
{
if
(
!
this
.
formatter
.
hasOwnProperty
(
item
.
value
))
{
let
params
=
{
script
:
this
.
elementInfo
.
option
.
dataset
.
formatter
,
data
:
JSON
.
stringify
(
item
)
}
this
.
$u
.
api
.
jsScript
(
params
).
then
(
res
=>
{
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
this
.
formatter
[
item
.
value
]
=
Result
}
})
}
})
console
.
log
(
this
.
formatter
)
},
/**
*
* @param tooltip 表单的tooltip设置
...
...
@@ -133,8 +201,21 @@
if
(
tooltip
.
formatter
&&
tooltip
.
formatter
.
length
)
{
return
{
...
tooltip
,
formatter
:
(
val
)
=>
{
return
this
.
$u
.
common
.
converFunction
(
tooltip
.
formatter
,
val
)
formatter
:
(
val
,
ticket
,
callback
)
=>
{
console
.
log
(
val
)
const
params
=
{
script
:
tooltip
.
formatter
,
data
:
JSON
.
stringify
(
val
)
}
this
.
$u
.
api
.
jsScript
(
params
).
then
(
res
=>
{
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
return
callback
(
ticket
,
Result
)
}
})
return
"加载中......"
// return this.$u.common.converFunction(tooltip.formatter, val)
},
trigger
:
"axis"
}
...
...
@@ -154,8 +235,13 @@
let
config
=
{
label
:
{
...
that
.
elementInfo
.
option
.
dataset
,
formatter
:
val
=>
{
return
that
.
$u
.
common
.
converFunction
(
that
.
elementInfo
.
option
.
dataset
.
formatter
,
val
)
formatter
:
val
=>
{
if
(
this
.
formatter
.
hasOwnProperty
(
val
.
value
))
{
return
this
.
formatter
[
val
.
value
]
}
return
val
.
value
// return that.$u.common.converFunction(that.elementInfo.option.dataset.formatter, val)
}
}
}
...
...
@@ -244,6 +330,7 @@
setChartDatas
()
{
const
categories
=
this
.
elementData
.
dataList
.
datas
[
this
.
index
].
categories
const
series
=
this
.
elementData
.
dataList
.
datas
[
this
.
index
].
series
this
.
getLabelFormatter
(
series
)
const
dealSeries
=
this
.
dealSeriesData
(
series
)
this
.
$set
(
this
.
ec
.
option
,
'xAxis.data'
,
categories
)
this
.
$set
(
this
.
ec
.
option
,
'series'
,
dealSeries
)
...
...
components/NormalBar/NormalBar.vue
View file @
37973c96
...
...
@@ -22,6 +22,7 @@
},
labelShow
:
false
,
// 记录当前设置的label.show的值
index
:
0
,
// 记录dataZoom切换当前的下标
formatter
:
{},
// 记录formatter之后的对象
}
},
components
:
{
...
...
@@ -96,6 +97,7 @@
}
lastCount
=
count
}
this
.
getLabelFormatter
(
series
)
const
dealSeries
=
this
.
dealSeriesData
(
series
)
this
.
$set
(
this
.
ec
.
option
,
'xAxis.data'
,
categories
)
this
.
$set
(
this
.
ec
.
option
,
'series'
,
dealSeries
)
...
...
@@ -107,6 +109,69 @@
chart
.
setOption
(
option
)
}
})
},
// 获取label的formatter信息
async
getLabelFormatter
(
series
)
{
const
formatter
=
this
.
elementInfo
.
option
.
dataset
.
formatter
if
(
!
formatter
||
!
formatter
.
length
)
{
return
}
var
arr
=
[]
// 当前显示的label,formatter需要阻塞线程
var
all
=
[]
// 除当前显示label之外的值,formatter可以在异步线程请求处理
const
count
=
this
.
elementData
.
dataList
.
categories
.
length
var
start
=
parseInt
(
this
.
elementInfo
.
dataZoom
.
start
/
100
*
count
)
start
=
start
>
1
?
start
-
1
:
start
const
end
=
parseInt
(
this
.
elementInfo
.
dataZoom
.
end
/
100
*
count
)
series
.
forEach
(
item
=>
{
const
data
=
item
.
data
const
name
=
item
.
name
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
i
>=
start
&&
i
<=
end
-
1
)
{
arr
.
push
({
seriesName
:
name
,
value
:
data
[
i
]})
}
else
{
all
.
push
({
seriesName
:
name
,
value
:
data
[
i
]})
}
}
})
// 把所有的请求加入req数组中
var
req
=
[]
arr
.
forEach
(
item
=>
{
if
(
!
this
.
formatter
.
hasOwnProperty
(
item
.
value
))
{
const
params
=
{
script
:
this
.
elementInfo
.
option
.
dataset
.
formatter
,
data
:
JSON
.
stringify
(
item
)
}
req
.
push
(
this
.
$u
.
api
.
jsScript
(
params
))
}
})
// req的线程需要同步执行
await
Promise
.
all
(
req
).
then
(
res
=>
{
res
.
forEach
(
item
=>
{
const
{
Status
,
Result
}
=
item
.
data
if
(
Status
===
'true'
)
{
const
data
=
item
.
config
.
data
.
data
const
key
=
JSON
.
parse
(
data
).
value
this
.
formatter
[
key
]
=
Result
}
})
})
// all的线程可以异步处理
all
.
forEach
(
item
=>
{
if
(
!
this
.
formatter
.
hasOwnProperty
(
item
.
value
))
{
let
params
=
{
script
:
this
.
elementInfo
.
option
.
dataset
.
formatter
,
data
:
JSON
.
stringify
(
item
)
}
this
.
$u
.
api
.
jsScript
(
params
).
then
(
res
=>
{
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
this
.
formatter
[
item
.
value
]
=
Result
}
})
}
})
},
/**
*
...
...
@@ -119,8 +184,20 @@
if
(
tooltip
.
formatter
&&
tooltip
.
formatter
.
length
)
{
return
{
...
tooltip
,
formatter
:
(
val
)
=>
{
return
this
.
$u
.
common
.
converFunction
(
tooltip
.
formatter
,
val
)
formatter
:
(
val
,
ticket
,
callback
)
=>
{
const
params
=
{
script
:
tooltip
.
formatter
,
data
:
JSON
.
stringify
(
val
)
}
this
.
$u
.
api
.
jsScript
(
params
).
then
(
res
=>
{
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
return
callback
(
ticket
,
Result
)
}
})
return
"加载中......"
// return this.$u.common.converFunction(tooltip.formatter, val)
},
trigger
:
"axis"
}
...
...
@@ -142,9 +219,13 @@
...
that
.
elementInfo
.
option
.
bar
,
label
:
{
...
that
.
elementInfo
.
option
.
dataset
,
formatter
:
val
=>
{
return
that
.
$u
.
common
.
converFunction
(
that
.
elementInfo
.
option
.
dataset
.
formatter
,
val
)
formatter
:
val
=>
{
if
(
this
.
formatter
.
hasOwnProperty
(
val
.
value
))
{
return
this
.
formatter
[
val
.
value
]
}
return
val
.
value
// return that.$u.common.converFunction(that.elementInfo.option.dataset
// .formatter, val)
}
}
}
...
...
@@ -221,6 +302,7 @@
setChartDatas
(
event
)
{
const
categories
=
this
.
elementData
.
dataList
.
datas
[
this
.
index
].
categories
const
series
=
this
.
elementData
.
dataList
.
datas
[
this
.
index
].
series
this
.
getLabelFormatter
(
series
)
const
dealSeries
=
this
.
dealSeriesData
(
series
)
this
.
$set
(
this
.
ec
.
option
,
'xAxis.data'
,
categories
)
this
.
$set
(
this
.
ec
.
option
,
'series'
,
dealSeries
)
...
...
components/NormalLine/NormalLine.vue
View file @
37973c96
...
...
@@ -21,6 +21,7 @@
},
labelShow
:
false
,
// 记录当前设置的label.show的值
index
:
0
,
// 记录dataZoom切换当前的下标
formatter
:
{},
// 记录formatter之后的对象
}
},
components
:
{
...
...
@@ -98,6 +99,8 @@
}
lastCount
=
count
}
this
.
getLabelFormatter
(
series
)
const
dealSeries
=
this
.
dealSeriesData
(
series
)
this
.
$set
(
this
.
ec
.
option
,
'xAxis.data'
,
categories
)
this
.
$set
(
this
.
ec
.
option
,
'series'
,
dealSeries
)
...
...
@@ -109,6 +112,73 @@
})
}
})
},
// 获取label的formatter信息
async
getLabelFormatter
(
series
)
{
const
formatter
=
this
.
elementInfo
.
option
.
dataset
.
formatter
if
(
!
formatter
||
!
formatter
.
length
)
{
return
}
var
arr
=
[]
// 当前显示的label,formatter需要阻塞线程
var
all
=
[]
// 除当前显示label之外的值,formatter可以在异步线程请求处理
const
count
=
this
.
elementData
.
dataList
.
categories
.
length
var
start
=
parseInt
(
this
.
elementInfo
.
dataZoom
.
start
/
100
*
count
)
start
=
start
>
1
?
start
-
1
:
start
const
end
=
parseInt
(
this
.
elementInfo
.
dataZoom
.
end
/
100
*
count
)
series
.
forEach
(
item
=>
{
const
data
=
item
.
data
const
name
=
item
.
name
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
if
(
i
>=
start
&&
i
<=
end
-
1
)
{
arr
.
push
({
seriesName
:
name
,
value
:
data
[
i
]})
}
else
{
all
.
push
({
seriesName
:
name
,
value
:
data
[
i
]})
}
}
})
// 把所有的请求加入req数组中
var
req
=
[]
arr
.
forEach
(
item
=>
{
if
(
!
this
.
formatter
.
hasOwnProperty
(
item
.
value
))
{
const
params
=
{
script
:
this
.
elementInfo
.
option
.
dataset
.
formatter
,
data
:
JSON
.
stringify
(
item
)
}
req
.
push
(
this
.
$u
.
api
.
jsScript
(
params
))
}
})
// req的线程需要同步执行
await
Promise
.
all
(
req
).
then
(
res
=>
{
res
.
forEach
(
item
=>
{
const
{
Status
,
Result
}
=
item
.
data
if
(
Status
===
'true'
)
{
const
data
=
item
.
config
.
data
.
data
const
key
=
JSON
.
parse
(
data
).
value
this
.
formatter
[
key
]
=
Result
}
})
})
console
.
log
(
all
)
// all的线程可以异步处理
all
.
forEach
(
item
=>
{
if
(
!
this
.
formatter
.
hasOwnProperty
(
item
.
value
))
{
let
params
=
{
script
:
this
.
elementInfo
.
option
.
dataset
.
formatter
,
data
:
JSON
.
stringify
(
item
)
}
this
.
$u
.
api
.
jsScript
(
params
).
then
(
res
=>
{
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
this
.
formatter
[
item
.
value
]
=
Result
}
})
}
})
},
/**
*
...
...
@@ -121,8 +191,19 @@
if
(
tooltip
.
formatter
&&
tooltip
.
formatter
.
length
)
{
return
{
...
tooltip
,
formatter
:
(
val
)
=>
{
return
this
.
$u
.
common
.
converFunction
(
tooltip
.
formatter
,
val
)
formatter
:
(
val
,
ticket
,
callback
)
=>
{
const
params
=
{
script
:
tooltip
.
formatter
,
data
:
JSON
.
stringify
(
val
)
}
this
.
$u
.
api
.
jsScript
(
params
).
then
(
res
=>
{
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
return
callback
(
ticket
,
Result
)
}
})
return
"加载中......"
// return this.$u.common.converFunction(tooltip.formatter, val)
},
trigger
:
"axis"
}
...
...
@@ -137,16 +218,19 @@
*/
dealSeriesData
(
data
)
{
if
(
!
data
)
return
[]
const
that
=
this
const
that
=
this
const
newData
=
data
.
map
(
item
=>
{
const
config
=
{
type
:
'line'
,
...
that
.
elementInfo
.
option
.
line
,
label
:
{
...
that
.
elementInfo
.
option
.
dataset
,
formatter
:
val
=>
{
return
that
.
$u
.
common
.
converFunction
(
that
.
elementInfo
.
option
.
dataset
.
formatter
,
val
)
formatter
:
val
=>
{
if
(
this
.
formatter
.
hasOwnProperty
(
val
.
value
))
{
return
this
.
formatter
[
val
.
value
]
}
return
val
.
value
// return that.$u.common.converFunction(that.elementInfo.option.dataset.formatter, val)
},
}
}
...
...
@@ -223,6 +307,7 @@
setChartDatas
(
event
)
{
const
categories
=
this
.
elementData
.
dataList
.
datas
[
this
.
index
].
categories
const
series
=
this
.
elementData
.
dataList
.
datas
[
this
.
index
].
series
this
.
getLabelFormatter
(
series
)
const
dealSeries
=
this
.
dealSeriesData
(
series
)
this
.
$set
(
this
.
ec
.
option
,
'xAxis.data'
,
categories
)
this
.
$set
(
this
.
ec
.
option
,
'series'
,
dealSeries
)
...
...
components/NormalPie/NormalPie.vue
View file @
37973c96
...
...
@@ -21,8 +21,9 @@ export default {
return
{
ec
:
{
lazyLoad
:
true
,
option
:
{}
}
option
:
{},
},
formatter
:
{},
// 记录formatter之后的对象
};
},
...
...
@@ -55,7 +56,8 @@ export default {
return
chart
},
initChart
()
{
const
{
series
}
=
this
.
elementData
.
dataList
const
{
series
}
=
this
.
elementData
.
dataList
this
.
getLabelFormatter
(
series
)
this
.
$set
(
this
.
ec
.
option
,
'series'
,
this
.
dealSeriesData
(
series
))
if
(
chart
)
{
// 重新setOption,使得设置的formatter生效
...
...
@@ -75,7 +77,19 @@ export default {
return
{
...
tooltip
,
formatter
:
(
val
)
=>
{
return
this
.
$u
.
common
.
converFunction
(
tooltip
.
formatter
,
val
)
const
params
=
{
script
:
tooltip
.
formatter
,
data
:
JSON
.
stringify
(
val
)
}
this
.
$u
.
api
.
jsScript
(
params
).
then
(
res
=>
{
const
{
Status
,
Result
}
=
res
.
data
if
(
Status
===
'true'
)
{
return
callback
(
ticket
,
Result
)
}
})
return
"加载中......"
// return this.$u.common.converFunction(tooltip.formatter, val)
},
trigger
:
"item"
}
...
...
@@ -86,6 +100,35 @@ export default {
}
},
// 获取label的formatter信息
async
getLabelFormatter
(
series
)
{
const
formatter
=
this
.
elementInfo
.
option
.
dataset
.
formatter
if
(
!
formatter
||
!
formatter
.
length
)
{
return
}
// 把所有的请求加入req数组中
var
req
=
[]
series
.
forEach
(
item
=>
{
if
(
!
this
.
formatter
.
hasOwnProperty
(
item
.
value
))
{
const
params
=
{
script
:
this
.
elementInfo
.
option
.
dataset
.
formatter
,
data
:
JSON
.
stringify
(
item
)
}
req
.
push
(
this
.
$u
.
api
.
jsScript
(
params
))
}
})
// req的线程需要同步执行
await
Promise
.
all
(
req
).
then
(
res
=>
{
res
.
forEach
(
item
=>
{
const
{
Status
,
Result
}
=
item
.
data
if
(
Status
===
'true'
)
{
const
data
=
item
.
config
.
data
.
data
const
key
=
JSON
.
parse
(
data
).
value
this
.
formatter
[
key
]
=
Result
}
})
})
},
dealSeriesData
(
data
)
{
if
(
!
data
)
return
const
series
=
[{
...
...
@@ -94,8 +137,13 @@ export default {
...
this
.
elementInfo
.
option
.
pie
,
label
:
{
...
this
.
elementInfo
.
option
.
dataset
,
formatter
:
(
val
)
=>
{
return
this
.
$u
.
common
.
converFunction
(
this
.
elementInfo
.
option
.
dataset
.
formatter
,
val
)
formatter
:
(
val
)
=>
{
if
(
this
.
formatter
.
hasOwnProperty
(
val
.
value
))
{
return
this
.
formatter
[
val
.
value
]
}
return
val
.
value
// return this.$u.common.converFunction(this.elementInfo.option.dataset.formatter, val)
}
},
labelLine
:
{
...
...
mixins/echartElementData.js
View file @
37973c96
...
...
@@ -34,7 +34,13 @@ export default {
custom
:
{
loading
:
false
}
})
if
(
dataProcessing
)
{
that
.
elementData
.
dataList
=
that
.
$u
.
common
.
converFunction
(
dataProcessing
,
res
.
data
)
// that.elementData.dataList = that.$u.common.converFunction(dataProcessing, res.data)
let
params
=
{
script
:
dataProcessing
,
data
:
JSON
.
stringify
(
res
.
data
)
}
let
r
=
await
that
.
$u
.
api
.
jsScript
(
params
)
that
.
elementData
.
dataList
=
r
.
data
.
Result
}
else
{
that
.
elementData
.
dataList
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
.
Result
))
}
...
...
@@ -42,11 +48,18 @@ export default {
/**
* 全局数据
*/
handlePublicData
(
value
)
{
async
handlePublicData
(
value
)
{
if
(
!
this
.
vuex_globalData
)
return
const
{
dataProcessing
}
=
{
...
value
}
if
(
dataProcessing
)
{
this
.
elementData
.
dataList
=
this
.
$u
.
common
.
converFunction
(
dataProcessing
,
this
.
vuex_globalData
)
// this.elementData.dataList = this.$u.common.converFunction(dataProcessing, this.vuex_globalData)
let
params
=
{
script
:
dataProcessing
,
data
:
JSON
.
stringify
(
this
.
vuex_globalData
)
}
let
r
=
await
this
.
$u
.
api
.
jsScript
(
params
)
this
.
elementData
.
dataList
=
r
.
data
.
Result
}
else
{
this
.
elementData
.
dataList
=
this
.
vuex_globalData
}
...
...
@@ -61,7 +74,13 @@ export default {
const
{
Status
,
Msg
}
=
res
.
data
;
if
(
Status
==
"true"
)
{
if
(
dataSetInfo
.
script
)
{
that
.
elementData
.
dataList
=
that
.
$u
.
common
.
converFunction
(
dataSetInfo
.
script
,
res
.
data
.
Result
)
// that.elementData.dataList = that.$u.common.converFunction(dataSetInfo.script, res.data.Result)
let
params
=
{
script
:
dataSetInfo
.
script
,
data
:
JSON
.
stringify
(
res
.
data
.
Result
)
}
let
r
=
await
that
.
$u
.
api
.
jsScript
(
params
)
that
.
elementData
.
dataList
=
r
.
data
.
Result
}
else
{
that
.
elementData
.
dataList
=
res
.
data
.
Result
}
...
...
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