Top.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div class="top-container">
  3. <v-row>
  4. <!-- tx信息过滤 -->
  5. <v-col cols="18" md="2">
  6. <v-text-field required label="Tx.Hash" v-model="query.tx.hash" />
  7. </v-col>
  8. <v-col cols="18" md="2">
  9. <v-text-field required label="Tx.From" v-model="query.tx.from" />
  10. </v-col>
  11. <v-col cols="18" md="2">
  12. <v-text-field required label="Tx.To" v-model="query.tx.to" />
  13. </v-col>
  14. <!-- block过滤 -->
  15. <v-col cols="18" md="2">
  16. <v-text-field required label="Tx.BlockNumber" v-model="query.tx.block" />
  17. </v-col>
  18. <!-- 搜索按钮 -->
  19. <v-col cols="18" md="2">
  20. <v-btn outlined x-large tile color="primary" @click="generateTableDataAgain">
  21. <v-icon left>mdi-cloud-search-outline</v-icon>
  22. 拉取想要的
  23. </v-btn>
  24. </v-col>
  25. </v-row>
  26. <v-row>
  27. <!-- transfer信息过滤 -->
  28. <v-col cols="18" md="2">
  29. <v-text-field required label="Transfer.Token" v-model="query.transfer.token" />
  30. </v-col>
  31. <v-col cols="18" md="2">
  32. <v-text-field required label="Transfer.From" v-model="query.transfer.from" />
  33. </v-col>
  34. <v-col cols="18" md="2">
  35. <v-text-field required label="Transfer.To" v-model="query.transfer.to" />
  36. </v-col>
  37. <!-- 数据刷新时间 -->
  38. <v-col cols="18" md="2">
  39. <v-text-field required label="自定义刷新时间" v-model="query.autoFlushTime" />
  40. </v-col>
  41. <!-- 自动刷新提示 -->
  42. <v-col v-if='query.autoFlushTime === 0' cols="18" md="2">
  43. <v-btn outlined x-large tile color="teal" @click='query.autoFlushTime = 20'>
  44. <v-icon left>mdi-clock</v-icon>
  45. 以20s/次刷新
  46. </v-btn>
  47. </v-col>
  48. <!-- 自动刷新提示 -->
  49. <v-col v-else-if='query.autoFlushTime !== 0' cols="18" md="2">
  50. <v-btn outlined x-large tile color="red" @click='query.autoFlushTime = 0'>停止刷新</v-btn>
  51. </v-col>
  52. </v-row>
  53. </div>
  54. </template>
  55. <script>
  56. export default {
  57. name: 'Top',
  58. props: ['query', 'page', 'table'],
  59. inject: ['packQuery'],
  60. methods: {
  61. async generateTableDataAgain() {
  62. await this.packQuery()
  63. }
  64. },
  65. async mounted() {
  66. let prevFlushTime = 0
  67. setInterval(async function(top) {
  68. if (top.query.autoFlushTime > 0) {
  69. let now = parseInt(new Date().getTime() / 1000)
  70. if (now - top.query.autoFlushTime > prevFlushTime) {
  71. await top.generateTableDataAgain()
  72. prevFlushTime = now
  73. }
  74. }
  75. }, 1000, this)
  76. }
  77. }
  78. </script>
  79. <style scoped>
  80. .top-container {
  81. width: 95%;
  82. margin: auto;
  83. }
  84. </style>