|
|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<div class="number-box">
|
|
|
<div
|
|
|
- v-for="(item, index) in arr"
|
|
|
+ v-for="(item, index) in data"
|
|
|
:key="item.title"
|
|
|
:class="['box', 'df', 'aic', `${index == 2 ? '' : 'mb45'}`]"
|
|
|
>
|
|
|
@@ -11,7 +11,7 @@
|
|
|
<div class="count">
|
|
|
<div class="title mb2">{{ item.title }}</div>
|
|
|
<div class="number pl10">
|
|
|
- <span :id="item.icon">{{ item.num }}</span>
|
|
|
+ <span :id="item.icon"></span>
|
|
|
<span style="font-size: 10px">个</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -20,12 +20,16 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { ref, onMounted } from "vue";
|
|
|
+import { ref, onMounted, watch } from "vue";
|
|
|
import CountUp from "countup";
|
|
|
+import store from "store/index";
|
|
|
import exchangeUrl from "utils/exchangeUrl";
|
|
|
|
|
|
export default {
|
|
|
- setup() {
|
|
|
+ props: {
|
|
|
+ data: Array,
|
|
|
+ },
|
|
|
+ setup(props) {
|
|
|
let options = {
|
|
|
useEasing: true, // 过渡动画效果,默认ture
|
|
|
smartEasingThreshold: 2000,
|
|
|
@@ -36,28 +40,29 @@ export default {
|
|
|
prefix: "", // 前置符号
|
|
|
suffix: "", // 后置符号,可汉字
|
|
|
};
|
|
|
+ watch(
|
|
|
+ () => props.data,
|
|
|
+ (a, b) => {
|
|
|
+ init();
|
|
|
+ }
|
|
|
+ );
|
|
|
|
|
|
- let arr = ref([
|
|
|
- { icon: "loading", title: "装货中船舶数量", num: 0 },
|
|
|
- { icon: "transit", title: "运输中船舶数量", num: 0 },
|
|
|
- { icon: "unloading", title: "卸货中船舶数量", num: 0 },
|
|
|
- ]);
|
|
|
- function init(arr = [16090, 20090, 69422]) {
|
|
|
+ function init() {
|
|
|
+ if (store.state.currentTabText == "数字化赋能中心") return;
|
|
|
// target,startVal,endVal,decimals,duration,options
|
|
|
// dom节点, 初始值, 结束值, 小数位数, 过渡几秒 , 初始参数
|
|
|
- let num1 = new CountUp("loading", 0, arr[0], 0, 3, options),
|
|
|
- num2 = new CountUp("transit", 0, arr[1], 0, 3, options),
|
|
|
- num3 = new CountUp("unloading", 0, arr[2], 0, 3, options);
|
|
|
- num1.start();
|
|
|
- num2.start();
|
|
|
- num3.start();
|
|
|
+ setTimeout(() => {
|
|
|
+ for (let i of props.data) {
|
|
|
+ let num1 = new CountUp(i.icon, 0, i.num, 0, 2, options);
|
|
|
+ num1.start();
|
|
|
+ }
|
|
|
+ }, 100);
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
init();
|
|
|
});
|
|
|
return {
|
|
|
- arr,
|
|
|
init,
|
|
|
exchangeUrl,
|
|
|
};
|