no message

Former-commit-id: 34bfc333be64a3f8f774f49a571be0db887098b1
Former-commit-id: 31b3d27fe5719fea3583f80f1498cd19b214b644
Former-commit-id: 1e07d94e6e1a349f538703ea6a5b04b2b65d1ac6
This commit is contained in:
李杨
2018-02-17 22:30:49 +08:00
parent 54450481e2
commit 5c2055d113
4 changed files with 34 additions and 14 deletions

View File

@@ -7,6 +7,9 @@ import propsChart from './props/chart'
// 扩展属性 // 扩展属性
import propsD2 from './props/d2' import propsD2 from './props/d2'
// 工具
import sleep from '@/utils/sleep.js'
// 关闭 G2 的体验改进计划打点请求 // 关闭 G2 的体验改进计划打点请求
G2.track(false) G2.track(false)
@@ -27,15 +30,15 @@ export default {
chart: null chart: null
} }
}, },
mounted () { async mounted () {
// 如果设置了在 mounted 后自动初始化 就在这里初始化 // 如果设置了在 mounted 后自动初始化 就在这里初始化
if (this.autoInit) { if (this.autoInit) {
// 可以设置延时初始化 默认时间为 0 // 延时
setTimeout(() => { await sleep(this.autoInitDelay)
this.$nextTick(() => { // 初始化
this.init() this.$nextTick(() => {
}) this.init()
}, this.autoInitDelay) })
} }
}, },
watch: { watch: {

View File

@@ -4,6 +4,7 @@
<span class="dd-fr"> <span class="dd-fr">
<Icon <Icon
class="chart-card-header-icon" class="chart-card-header-icon"
:class="{active}"
name="refresh" name="refresh"
@click.native="handleRefresh"> @click.native="handleRefresh">
</Icon> </Icon>
@@ -20,8 +21,17 @@ export default {
default: '' default: ''
} }
}, },
data () {
return {
active: false
}
},
methods: { methods: {
handleRefresh () { handleRefresh () {
this.active = true
setTimeout(() => {
this.active = false
}, 1000)
this.$emit('refresh') this.$emit('refresh')
} }
} }
@@ -32,6 +42,10 @@ export default {
@import '~@/assets/style/public.scss'; @import '~@/assets/style/public.scss';
.chart-card-header-icon { .chart-card-header-icon {
color: $color-text-sub; color: $color-text-sub;
transition: all .3s;
&.active {
transform: rotate(360deg);
}
} }
</style> </style>

View File

@@ -68,12 +68,6 @@ export default {
}) })
})) }))
}, },
// 更新指定的图表
chartResize (name) {
this.$nextTick(() => {
this.$refs[name].resize()
})
},
// 布局组件发生变化 // 布局组件发生变化
layoutUpdatedHandler (newLayout) { layoutUpdatedHandler (newLayout) {
console.group('layoutUpdatedHandler') console.group('layoutUpdatedHandler')
@@ -84,7 +78,9 @@ export default {
}, },
// 改变尺寸完成 // 改变尺寸完成
handleResized (name) { handleResized (name) {
this.chartResize(name) this.$nextTick(() => {
this.$refs[name].resize()
})
}, },
// 用户触发了卡片右上角的刷新按钮 // 用户触发了卡片右上角的刷新按钮
handleRefreshData (index) { handleRefreshData (index) {

7
src/utils/sleep.js Normal file
View File

@@ -0,0 +1,7 @@
export default async (time = 0) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, time)
})
}