Table.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <div class="table-container">
  3. <v-card elevation="0">
  4. <!-- 表格上功能区 -->
  5. <v-card-title>
  6. <v-container id="dataTableHeader">
  7. <v-row>
  8. <v-col cols="4">
  9. {{ page.name }}
  10. </v-col>
  11. <v-col cols="8">
  12. <v-text-field hide-details single-line label="Local Search" append-icon="mdi-magnify" v-model="table.search"/>
  13. </v-col>
  14. </v-row>
  15. </v-container>
  16. </v-card-title>
  17. <!-- 表格主体 -->
  18. <v-data-table calculate-widths multi-sort hide-default-footer
  19. :group-by="table.groupBy" :group-desc="table.groupDesc"
  20. :headers="table.headers" :items="table.data" :search="table.search" :loading="table.loading"
  21. :items-per-page="table.pageSize"
  22. :sort-by="table.sortBy" :sort-desc="table.sortDesc">
  23. <!-- 操作区 -->
  24. <template v-slot:item.option="{ item }">
  25. <div>
  26. <v-row>
  27. <v-col cols="5">
  28. <v-btn icon elevation="0" color="red" large @click="deleteByHash(item.hash)">
  29. <v-icon>mdi-delete-forever-outline</v-icon>
  30. </v-btn>
  31. </v-col>
  32. </v-row>
  33. </div>
  34. </template>
  35. <!-- Block -->
  36. <template v-slot:item.block="{ item }">
  37. <div>
  38. {{ item.block }}
  39. </div>
  40. </template>
  41. <!-- Hash -->
  42. <template v-slot:item.hash="{ item }">
  43. <v-btn v-if="item.hash.indexOf('0x') !== -1" outlined text target="_blank" :href="'https://www.oklink.com/en/ethw/tx/' + item.hash">
  44. {{ hashKit.head5(item.hash) + '..' }}
  45. </v-btn>
  46. <v-chip v-else label target="_blank">
  47. {{ hashKit.head5(item.hash) + '..' }}
  48. </v-chip>
  49. </template>
  50. <!-- From -->
  51. <template v-slot:item.from="{ item }">
  52. <v-chip label color="green lighten-3" target="_blank" @click="httpKit.jumpToEthw(item.from)">
  53. {{ hashKit.headAndEnd2(item.from) }}
  54. </v-chip>
  55. </template>
  56. <!-- to -->
  57. <template v-slot:item.to="{ item }">
  58. <v-chip v-if="!item.toName" label color="indigo lighten-4" @click="httpKit.jumpToEthw(item.to)">
  59. {{ hashKit.headAndEnd2(item.to) }}
  60. </v-chip>
  61. <v-chip v-else label color="indigo lighten-4" @click="httpKit.jumpToEthw(item.to)">
  62. {{ item.toName }}
  63. </v-chip>
  64. </template>
  65. <template v-slot:item.type="{ item }">
  66. <div v-if="item.type !== undefined && item.type !== ''">
  67. {{ item.type }}
  68. </div>
  69. <div v-else>
  70. [type]
  71. </div>
  72. </template>
  73. <template v-slot:item.index="{ item }">
  74. <div v-if="item.index !== undefined">
  75. {{ item.index }}
  76. </div>
  77. <div v-else>
  78. [index]
  79. </div>
  80. </template>
  81. <template v-slot:item.status="{ item }">
  82. <div v-if="item.state !== undefined">
  83. {{ item.status }}
  84. </div>
  85. <div v-else>
  86. [status]
  87. </div>
  88. </template>
  89. <template v-slot:item.ping="{ item }">
  90. <div v-if="item.ping !== undefined">
  91. {{ item.ping }}
  92. </div>
  93. <div v-else>
  94. [ping]
  95. </div>
  96. </template>
  97. <template v-slot:item.isMev="{ item }">
  98. <BooleanViewer :value="item.isMev"></BooleanViewer>
  99. </template>
  100. <template v-slot:item.isBot="{ item }">
  101. <BooleanViewer :value="item.isBot"></BooleanViewer>
  102. </template>
  103. <template v-slot:item.maybeBot="{ item }">
  104. <BooleanViewer :value="item.maybeBot"></BooleanViewer>
  105. </template>
  106. <template v-slot:item.timestamp="{ item }">
  107. {{ formatTimeBySixBitTimestamp(item.timestamp) }}
  108. </template>
  109. <template v-slot:item.comment="{ item }">
  110. <div v-if="item.comment">
  111. <span class="memo-span">{{ item.comment }}</span>
  112. </div>
  113. <div v-else>
  114. [comment]
  115. </div>
  116. </template>
  117. <!--tradeInfo-->
  118. <template v-slot:item.transferList="{ item }">
  119. <div v-if="page.name === 'Pending Page'">
  120. <div class="tradeInfoBtn" @click="showTradeInfo(item)">
  121. <v-chip v-for="tokenAddress in item.tokenAddressList" :key='tokenAddress'
  122. :color="item.tokenMap[tokenAddress] ? hashKit.generateColorByHash(tokenAddress) : undefined" class="tokenChip">
  123. {{ item.tokenMap[tokenAddress] ? item.tokenMap[tokenAddress] : '**' + hashKit.headAndEnd2(tokenAddress) }}
  124. </v-chip>
  125. </div>
  126. </div>
  127. <div v-else>
  128. <TradeInfo :item="item"></TradeInfo>
  129. </div>
  130. </template>
  131. </v-data-table>
  132. <!-- 底部分页 -->
  133. <div class="mt-2">
  134. <v-row>
  135. <v-col cols="2"></v-col>
  136. <v-col cols="2">
  137. <v-text-field type="number" required label="page" v-model="tempPage" @change="inputPageNum" />
  138. </v-col>
  139. <v-col cols="4">
  140. <v-pagination :disabled="table.loading" :length="99" v-model="table.pageNum" @input="generateTableDataAgain"></v-pagination>
  141. </v-col>
  142. </v-row>
  143. </div>
  144. </v-card>
  145. <v-dialog v-model="dialog.visible" max-width="800">
  146. <v-card>
  147. <v-card-title>交易详情</v-card-title>
  148. <v-card-text><TradeInfo :item="dialog.data"></TradeInfo></v-card-text>
  149. <v-card-actions>
  150. <v-spacer></v-spacer>
  151. <v-btn
  152. color="primary"
  153. text
  154. @click="dialog.visible = false"
  155. >
  156. 我知道了
  157. </v-btn>
  158. </v-card-actions>
  159. </v-card>
  160. </v-dialog>
  161. </div>
  162. </template>
  163. <script>
  164. import TradeInfo from '@/components/viewer/table/TradeInfoDetails'
  165. import BooleanViewer from '@/components/viewer/table/BooleanViewer'
  166. import HashKit from '@/plugins/kit/HashKit'
  167. import HttpKit from '@/plugins/kit/HttpKit'
  168. import TimeKit from '@/plugins/kit/TimeKit'
  169. export default {
  170. name: 'Table',
  171. components: {BooleanViewer, TradeInfo},
  172. props: ['query', 'page', 'table'],
  173. inject: ['generateTableData'],
  174. data: () => ({
  175. hashKit: HashKit,
  176. httpKit: HttpKit,
  177. timeKit: TimeKit,
  178. dialog: {
  179. data: [],
  180. visible: false
  181. },
  182. tempPage: 1
  183. }),
  184. methods: {
  185. async deleteByHash(hash_code) {
  186. if (confirm('要删吗?\n' + hash_code)) {
  187. this.$msgkit.warning('还没有做,别急啊')
  188. // const rst = await EthMev.deleteByHash(hash_code)
  189. //
  190. // if (rst.data.state) {
  191. // this.$msgkit.success(rst.data.msg)
  192. //
  193. // await this.pullData()
  194. // } else {
  195. // this.$msgkit.error(rst.data.msg)
  196. // }
  197. }
  198. },
  199. showTradeInfo(item) {
  200. this.dialog.data = item
  201. this.dialog.visible = true
  202. },
  203. async inputPageNum() {
  204. console.log(typeof this.tempPage, parseInt(this.tempPage))
  205. this.table.pageNum = parseInt(this.tempPage)
  206. await this.generateTableDataAgain()
  207. },
  208. async generateTableDataAgain() {
  209. this.tempPage = this.table.pageNum
  210. await this.generateTableData()
  211. },
  212. formatTimeBySixBitTimestamp(sixBitTimestamp) {
  213. let lastThreeBit = (sixBitTimestamp + '').slice(-3)
  214. return this.timeKit.getTime(sixBitTimestamp) + lastThreeBit
  215. }
  216. }
  217. }
  218. </script>
  219. <style scoped>
  220. .table-container {
  221. width: 100%;
  222. }
  223. #dataTableHeader {
  224. max-width: none;
  225. }
  226. .tokenChip {
  227. margin-top: 5px;
  228. margin-left: 5px;
  229. margin-bottom: 5px;
  230. }
  231. .tradeInfoBtn {
  232. padding: 15px !important;
  233. border: grey 2px solid;
  234. }
  235. .tradeInfoBtn:hover {
  236. background: beige;
  237. }
  238. .memo-span {
  239. width: 200px;
  240. display:block;
  241. padding: 10px;
  242. }
  243. </style>