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
43cb0f32
Commit
43cb0f32
authored
Jan 19, 2022
by
peco
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
http://106.15.103.105/lihuizhen/ec-report-refactor
into develop
# Conflicts: # pages/index/index.vue
parents
9dcef732
d974d9e8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
443 additions
and
56 deletions
+443
-56
BasicText.vue
components/BasicText/BasicText.vue
+48
-9
CountTo.vue
components/CountTo/CountTo.vue
+57
-0
NormalImage.vue
components/NormalImage/NormalImage.vue
+68
-0
NumberScroll.vue
components/NumberScroll/NumberScroll.vue
+163
-0
echartElementData.js
mixins/echartElementData.js
+14
-1
index.vue
pages/index/index.vue
+66
-43
index.js
store/index.js
+2
-2
common.js
utils/common.js
+25
-1
No files found.
components/BasicText/BasicText.vue
View file @
43cb0f32
<
template
>
<
template
>
<view>
<view
class=
"merquee"
>
<p
:class=
"[elementInfo.marquee.isOpen ? 'merquee-txt' : '' ]"
:style=
"
{
'font-size':`${elementInfo.option.title.textStyle.fontSize}px`,
'color': elementInfo.option.title.textStyle.color,
'font-weight': elementInfo.option.title.textStyle.fontWeight,
'text-align': elementInfo.option.title.left,
'animation-duration':`${elementInfo.marquee.speed ? elementInfo.marquee.speed : defaultSpeed}s`
}"
>
{{
elementInfo
.
option
.
title
.
text
}}
</p>
</view>
</view>
</
template
>
</
template
>
<
script
>
<
script
>
export
default
{
export
default
{
name
:
"BasicText"
,
name
:
"BasicText"
,
data
()
{
props
:
{
return
{
elementInfo
:
{
type
:
Object
,
};
required
:
true
}
}
},
data
()
{
return
{
defaultSpeed
:
5
};
}
}
}
</
script
>
</
script
>
<
style
>
<
style
lang=
"scss"
scoped
>
/* 文字滚动 */
.merquee
{
word-break
:
break-all
;
white-space
:
nowrap
;
overflow
:
hidden
;
}
.merquee-txt
{
display
:
inline-block
;
padding-left
:
100%
;
animation-name
:marqueeTransform
;
animation-iteration-count
:infinite
;
animation-timing-function
:linear
;
}
@keyframes
marqueeTransform
{
0
%
{
transform
:
translate
(
0
,
0
);
}
100
%
{
transform
:
translate
(
-100%
,
0
);
}
}
</
style
>
</
style
>
components/CountTo/CountTo.vue
0 → 100644
View file @
43cb0f32
<
template
>
<view
class=
"count-to"
:style=
"
{height: `${height}px`,}">
<BasicText
:elementInfo=
"elementInfo"
></BasicText>
<!-- warning:count-to的font-size单位为rpx -->
<u-count-to
:start-val=
"startVal"
:end-val=
"endVal"
:color=
"elementInfo.option.countTo.color"
:font-size=
"elementInfo.option.countTo.fontSize"
></u-count-to>
</view>
</
template
>
<
script
>
import
echartElementData
from
'@/mixins/echartElementData.js'
export
default
{
name
:
"CountTo"
,
mixins
:
[
echartElementData
],
data
()
{
return
{
startVal
:
0
,
endVal
:
0
,
height
:
0
};
},
onReady
()
{
this
.
getComponentHeight
()
},
methods
:
{
initChart
()
{
this
.
$nextTick
(()
=>
{
this
.
startVal
=
this
.
endVal
this
.
endVal
=
this
.
elementData
.
dataList
.
endVal
})
},
// 计算组件高度
getComponentHeight
()
{
const
{
windowWidth
}
=
uni
.
getSystemInfoSync
()
this
.
height
=
this
.
elementInfo
.
height
if
(
this
.
elementInfo
.
width
>
windowWidth
)
{
this
.
height
=
this
.
elementInfo
.
height
/
this
.
elementInfo
.
width
*
windowWidth
}
},
},
}
</
script
>
<
style
>
.count-to
{
font-size
:
30px
;
color
:
#f9bb70
;
font-weight
:
bold
;
text-align
:
center
;
width
:
100%
;
}
</
style
>
components/NormalImage/NormalImage.vue
0 → 100644
View file @
43cb0f32
<
template
>
<view
class=
"normal-image"
>
<BasicText
:elementInfo=
"elementInfo.option.title"
></BasicText>
<u-empty
v-if=
"!elementInfo.option.images.list.length"
></u-empty>
<u-image
v-if=
"elementInfo.option.images.list.length === 1"
width=
"100%"
:height=
"imageHeight"
:src=
"elementInfo.option.images.list[0].url"
>
</u-image>
<u-swiper
v-if=
"elementInfo.option.images.list.length > 1"
mode=
"dot"
:autoplay=
"elementInfo.optison.images.autoplay"
:interval=
"elementInfo.option.images.autoplaySpeed * 1000"
:indicator=
"elementInfo.option.images.dots"
:list=
"elementInfo.option.images.list"
width=
"100%"
:height=
"imageHeight"
name=
"url"
>
</u-swiper>
</view>
</
template
>
<
script
>
export
default
{
name
:
"NormalImage"
,
props
:
{
elementInfo
:
{
type
:
Object
,
required
:
true
}
},
data
()
{
return
{
windowWidth
:
0
,
//屏幕宽度
imageHeight
:
0
//图片高度
};
},
mounted
()
{
uni
.
getSystemInfo
({
success
:
res
=>
{
this
.
windowWidth
=
res
.
windowWidth
;
this
.
imageHeight
=
(
this
.
windowWidth
*
this
.
elementInfo
.
height
)
/
this
.
elementInfo
.
width
;
}
});
},
onLoad
()
{
}
}
</
script
>
<
style
lang=
"scss"
scoped
>
.normal-image
{
display
:
flex
;
flex-direction
:
column
;
height
:
100%
;
overflow
:
hidden
;
image
{
max-width
:
100%
;
max-height
:
100%
;
object-fit
:
contain
;
}
}
</
style
>
components/NumberScroll/NumberScroll.vue
0 → 100644
View file @
43cb0f32
<
template
>
<view
class=
"chart-num"
:style=
"
{height: `${height}px`,}">
<BasicText
:elementInfo=
"elementInfo"
></BasicText>
<ul
class=
"box-item marginTop20"
>
<li
v-for=
"(item, index) in orderNum"
:key=
"index"
:class=
"
{'number-item': !isNaN(item), 'mark-item': isNaN(item)}" :style="{
width: `${elementInfo.option.title.numItemWidth}px`,
height: `${elementInfo.option.title.numItemHeight}px`,
fontSize: `${elementInfo.option.title.numItemFontSize}px`
}">
<span
v-if=
"!isNaN(item)"
:class=
"
{'hasDividingLine': elementInfo.option.title.dividingLine
&&
!isNaN(item)}"
:style="{'background': elementInfo.option.title.backgroundColor}">
<!-- 第一个数字为0,不显示 -->
<i
v-if=
"item === '0' && index === 0"
:class=
"[numberItemsClass()]"
:id=
"index"
:style=
"
{transform:setTransformByIndex(index)}"/>
<i
v-else
:id=
"index"
:class=
"[numberItemsClass()]"
:style=
"
{transform:setTransformByIndex(index)}">0123456789
</i>
</span>
<span
v-else
class=
"comma"
>
<!-- 第一个数字为0,不显示逗号 -->
<i
v-if=
"orderNum[index - 1] === '0' && index === 1"
/>
<i
v-else
>
{{
item
}}
</i>
</span>
</li>
</ul>
</view>
</
template
>
<
script
>
import
echartElementData
from
'@/mixins/echartElementData.js'
export
default
{
name
:
"NumberScroll"
,
mixins
:
[
echartElementData
],
data
()
{
return
{
orderNum
:
[],
endVal
:
100
,
height
:
0
};
},
onReady
()
{
this
.
getComponentHeight
()
},
methods
:
{
initChart
()
{
this
.
$nextTick
(()
=>
{
this
.
endVal
=
this
.
elementData
.
dataList
.
endVal
this
.
toOrderNumber
(
this
.
endVal
)
})
},
// 计算组件高度
getComponentHeight
()
{
const
{
windowWidth
}
=
uni
.
getSystemInfoSync
()
this
.
height
=
this
.
elementInfo
.
height
if
(
this
.
elementInfo
.
width
>
windowWidth
)
{
this
.
height
=
this
.
elementInfo
.
height
/
this
.
elementInfo
.
width
*
windowWidth
}
},
toOrderNumber
(
num
)
{
if
(
!
num
)
return
// numDigit代表前面预留几个空格
let
len
=
num
.
toString
().
length
this
.
orderNum
=
this
.
$u
.
common
.
toThousands
(
num
).
split
(
''
)
// len
<
8
,
超过
8
位,前面不预留空格
if
(
this
.
elementInfo
.
option
.
title
.
numDigit
&&
len
<
8
)
{
len
=
len
+
this
.
elementInfo
.
option
.
title
.
numDigit
// 手动往前面填充空格
let
l
=
this
.
elementInfo
.
option
.
title
.
numDigit
for
(
let
i
=
0
;
i
<
l
;
i
++
)
{
this
.
orderNum
.
unshift
(
'0'
)
}
}
},
setTransformByIndex
(
index
)
{
return
`translate(-50%, -
${
this
.
orderNum
[
index
]
*
10
}
%)`
},
numberItemsClass
()
{
return
'numberItems-'
+
this
.
elementInfo
.
id
}
},
}
</
script
>
<
style
scoped
lang=
"scss"
>
.chart-num
{
width
:
100%
;
overflow-x
:
hidden
;
}
.box-item
{
font-family
:
'微软雅黑'
;
text-align
:
left
;
white-space
:
nowrap
;
}
.hasDividingLine
{
&
:
:
before
{
display
:
block
;
position
:
absolute
;
top
:
50%
;
transform
:
translateY
(
-50%
);
content
:
' '
;
width
:
100%
;
height
:
4%
;
background
:
#0c0062
;
}
}
.number-item
{
display
:
inline-block
;
position
:
relative
;
width
:
11%
;
list-style
:
none
;
color
:
#f2a867
;
margin-right
:
6px
;
border-radius
:
4px
;
&
>
span
{
position
:
relative
;
display
:
inline-block
;
margin-right
:
10px
;
width
:
100%
;
height
:
100%
;
writing-mode
:
vertical-rl
;
text-orientation
:
upright
;
-webkit-text-orientation
:
upright
;
overflow
:
hidden
;
&
>
i
{
font-style
:
normal
;
position
:
absolute
;
top
:
5px
;
left
:
50%
;
transform
:
translate
(
-50%
,
0
);
transition
:
transform
1s
ease-in-out
;
letter-spacing
:
10px
;
}
}
}
.number-item
:last-child
{
margin-right
:
0
;
}
.comma
{
display
:
inline-block
;
color
:
#fff
;
font-size
:
20px
;
}
.mark-item
{
display
:
inline-block
;
margin-right
:
6px
;
width
:
5px
!
important
;
}
</
style
>
mixins/echartElementData.js
View file @
43cb0f32
...
@@ -38,7 +38,14 @@ export default {
...
@@ -38,7 +38,14 @@ export default {
* 全局数据
* 全局数据
*/
*/
handlePublicData
(
value
)
{
handlePublicData
(
value
)
{
if
(
!
this
.
globalData
)
return
const
{
dataProcessing
}
=
{
...
value
}
if
(
dataProcessing
)
{
this
.
elementData
.
dataList
=
this
.
$u
.
common
.
converFunction
(
dataProcessing
,
JSON
.
parse
(
this
.
globalData
))
}
else
{
this
.
elementData
.
dataList
=
JSON
.
parse
(
this
.
globalData
)
}
this
.
initChart
()
},
},
/**
/**
* 配置数据 - 数据集
* 配置数据 - 数据集
...
@@ -101,6 +108,12 @@ export default {
...
@@ -101,6 +108,12 @@ export default {
},
},
immediate
:
true
,
immediate
:
true
,
deep
:
true
deep
:
true
},
/**
* 全局数据更新监测
*/
globalData
()
{
if
(
this
.
elementInfo
.
data
.
dataType
===
'public'
)
this
.
handlePublicData
(
this
.
elementInfo
.
data
)
}
}
}
}
}
}
pages/index/index.vue
View file @
43cb0f32
...
@@ -22,6 +22,10 @@
...
@@ -22,6 +22,10 @@
<BarMixMap
v-if=
"element.type == 'BarMixMap'"
:elementInfo=
"element"
></BarMixMap>
<BarMixMap
v-if=
"element.type == 'BarMixMap'"
:elementInfo=
"element"
></BarMixMap>
<!-- 雷达图 -->
<!-- 雷达图 -->
<NormalRadar
v-if=
"element.type == 'NormalRadar'"
:elementInfo=
"element"
></NormalRadar>
<NormalRadar
v-if=
"element.type == 'NormalRadar'"
:elementInfo=
"element"
></NormalRadar>
<!-- 普通数字滚动 -->
<CountTo
v-if=
"element.type == 'CountTo'"
:elementInfo=
"element"
></CountTo>
<!-- 数字滚动 -->
<NumberScroll
v-if=
"element.type == 'NumberScroll'"
:elementInfo=
"element"
></NumberScroll>
<!-- 普通选项卡 -->
<!-- 普通选项卡 -->
<NormalTabs
v-if=
"element.type == 'NormalTabs'"
:elementInfo=
"element"
></NormalTabs>
<NormalTabs
v-if=
"element.type == 'NormalTabs'"
:elementInfo=
"element"
></NormalTabs>
<!-- 文本框 -->
<!-- 文本框 -->
...
@@ -30,6 +34,8 @@
...
@@ -30,6 +34,8 @@
<RealTime
v-if=
"element.type == 'RealTime'"
:elementInfo=
"element"
></RealTime>
<RealTime
v-if=
"element.type == 'RealTime'"
:elementInfo=
"element"
></RealTime>
<!-- 普通进度条 -->
<!-- 普通进度条 -->
<NormalProgress
v-if=
"element.type == 'NormalProgress'"
:elementInfo=
"element"
></NormalProgress>
<NormalProgress
v-if=
"element.type == 'NormalProgress'"
:elementInfo=
"element"
></NormalProgress>
<!-- 普通图片 -->
<NormalImage
v-if=
"element.type == 'NormalImage'"
:elementInfo=
"element"
></NormalImage>
</view>
</view>
</view>
</view>
</
template
>
</
template
>
...
@@ -39,7 +45,8 @@
...
@@ -39,7 +45,8 @@
data
()
{
data
()
{
return
{
return
{
reportInfo
:
{},
reportInfo
:
{},
reportData
:
[]
reportData
:
[],
timer
:
null
}
}
},
},
computed
:
{
computed
:
{
...
@@ -56,52 +63,68 @@
...
@@ -56,52 +63,68 @@
async
onLoad
()
{
async
onLoad
()
{
this
.
getReportList
()
this
.
getReportList
()
},
},
onShow
()
{
onShow
()
{
this
.
userAuthCheck
()
this
.
userAuthCheck
()
},
},
methods
:
{
methods
:
{
//检查是否登录
//检查是否登录
userAuthCheck
()
{
userAuthCheck
()
{
var
userId
=
uni
.
getStorageSync
(
'userId'
)
var
userId
=
uni
.
getStorageSync
(
'userId'
)
this
.
getNewestAuthFromServer
()
this
.
getNewestAuthFromServer
()
var
authorized
=
uni
.
getStorageSync
(
'authorized'
)
var
authorized
=
uni
.
getStorageSync
(
'authorized'
)
if
(
userId
)
{
if
(
userId
)
{
if
(
authorized
)
{
if
(
authorized
)
{
}
else
{
}
else
{
uni
.
reLaunch
({
uni
.
reLaunch
({
url
:
'../login/authorized'
url
:
'../login/authorized'
})
})
}
}
}
else
{
}
else
{
uni
.
reLaunch
({
uni
.
reLaunch
({
url
:
'../login/login'
url
:
'../login/login'
})
})
}
}
},
//获取最新的授权信息
},
getNewestAuthFromServer
()
{
var
param
=
{
//获取最新的授权信息
id
:
uni
.
getStorageSync
(
'userId'
)
getNewestAuthFromServer
()
{
}
var
param
=
{
this
.
$u
.
api
.
getAuthorized
(
param
).
then
(
res
=>
{
id
:
uni
.
getStorageSync
(
'userId'
)
const
{
Status
,
Result
}
=
res
.
data
}
if
(
Status
===
'true'
)
{
this
.
$u
.
api
.
getAuthorized
(
param
).
then
(
res
=>
{
uni
.
setStorageSync
(
'authorized'
,
Result
.
authorized
)
const
{
Status
,
Result
}
=
res
.
data
}
if
(
Status
===
'true'
)
{
})
uni
.
setStorageSync
(
'authorized'
,
Result
.
authorized
)
},
}
/**
})
* 获取页面报表配置
},
*/
async
getReportList
()
{
async
getReportList
()
{
let
res
=
await
this
.
$u
.
api
.
getReportList
({
id
:
'61c424a4c06bff0ce05d9a53'
})
clearInterval
(
this
.
timer
)
const
{
Status
,
Result
}
=
res
.
data
let
res
=
await
this
.
$u
.
api
.
getReportList
({
id
:
'61c424a4c06bff0ce05d9a53'
})
const
{
Status
,
Result
:
{
info
,
list
}
}
=
res
.
data
if
(
Status
===
'true'
)
{
if
(
Status
===
'true'
)
{
this
.
reportInfo
=
Result
.
info
this
.
reportInfo
=
info
this
.
reportData
=
Result
.
list
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
()
{
onReachBottom
()
{
...
...
store/index.js
View file @
43cb0f32
...
@@ -12,7 +12,7 @@ try {
...
@@ -12,7 +12,7 @@ try {
}
}
// 需要永久存储,且在下次 APP 启动需要取出的,在 state 中的变量名。
// 需要永久存储,且在下次 APP 启动需要取出的,在 state 中的变量名。
let
saveStateKeys
=
[
'vuex_
user'
,
'vuex_
token'
]
let
saveStateKeys
=
[
'vuex_token'
]
// 保存变量到本地存储中
// 保存变量到本地存储中
const
saveLifeData
=
function
(
key
,
value
)
{
const
saveLifeData
=
function
(
key
,
value
)
{
...
@@ -30,8 +30,8 @@ const saveLifeData = function(key, value) {
...
@@ -30,8 +30,8 @@ const saveLifeData = function(key, value) {
const
store
=
new
Vuex
.
Store
({
const
store
=
new
Vuex
.
Store
({
state
:
{
state
:
{
vuex_user
:
lifeData
.
vuex_user
||
{
name
:
'test'
},
vuex_token
:
lifeData
.
vuex_token
||
''
,
vuex_token
:
lifeData
.
vuex_token
||
''
,
globalData
:
""
},
},
mutations
:
{
mutations
:
{
$uStore
(
state
,
payload
)
{
$uStore
(
state
,
payload
)
{
...
...
utils/common.js
View file @
43cb0f32
...
@@ -9,8 +9,32 @@ const install = (Vue, vm) => {
...
@@ -9,8 +9,32 @@ const install = (Vue, vm) => {
return
new
Function
(
'"use strict";return ('
+
func
+
')'
)()(
data
);
return
new
Function
(
'"use strict";return ('
+
func
+
')'
)()(
data
);
}
}
/**
* 补足数字位数
* @param digit 数字
* @param len 位数
*/
const
fillDigit
=
(
digit
,
len
)
=>
{
return
padStart
(
''
+
digit
,
len
,
'0'
)
}
const
toThousands
=
(
value
)
=>
{
let
result
=
''
let
num
=
(
parseInt
(
value
)
||
0
).
toString
()
while
(
num
.
length
>
3
)
{
result
=
','
+
num
.
slice
(
-
3
)
+
result
num
=
num
.
slice
(
0
,
num
.
length
-
3
)
}
if
(
num
)
{
result
=
num
+
result
}
return
result
}
vm
.
$u
.
common
=
{
vm
.
$u
.
common
=
{
converFunction
converFunction
,
fillDigit
,
toThousands
}
}
}
}
...
...
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