Table.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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 large>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.isMev="{ item }">
  90. {{ item.isMev }}
  91. </template>
  92. <template v-slot:item.isBot="{ item }">
  93. {{ item.isBot }}
  94. </template>
  95. <template v-slot:item.maybeBot="{ item }">
  96. {{ item.maybeBot }}
  97. </template>
  98. <template v-slot:item.pending="{ item }">
  99. <div v-if="item.pending !== undefined">
  100. {{ item.pending }}
  101. </div>
  102. <div v-else>
  103. [pending]
  104. </div>
  105. </template>
  106. <!--tradeInfo-->
  107. <template v-slot:item.transferList="{ item }">
  108. <div v-if="page.name === 'Pending Page'">
  109. <div class="tradeInfoBtn" @click="showTradeInfo(item)">
  110. <v-chip v-for="tokenAddress in item.tokenAddressList" :key='tokenAddress'
  111. :color="item.tokenMap[tokenAddress] ? hashKit.generateColorByHash(tokenAddress) : undefined" class="tokenChip">
  112. {{ item.tokenMap[tokenAddress] ? item.tokenMap[tokenAddress] : '**' + hashKit.headAndEnd2(tokenAddress) }}
  113. </v-chip>
  114. </div>
  115. </div>
  116. <div v-else>
  117. <TradeInfo :item="item"></TradeInfo>
  118. </div>
  119. </template>
  120. <template v-slot:item.comment="{ item }">
  121. <div v-if="item.comment">
  122. <span class="memo-span">{{ item.comment }}</span>
  123. </div>
  124. <div v-else>
  125. [comment]
  126. </div>
  127. </template>
  128. </v-data-table>
  129. <!-- 底部分页 -->
  130. <div class="mt-2">
  131. <v-row>
  132. <v-col cols="2"></v-col>
  133. <v-col cols="2">
  134. <v-text-field type="number" required label="page" v-model="tempPage" @change="inputPageNum" />
  135. </v-col>
  136. <v-col cols="4">
  137. <v-pagination :disabled="table.loading" :length="99" v-model="table.pageNum" @input="generateTableDataAgain"></v-pagination>
  138. </v-col>
  139. </v-row>
  140. </div>
  141. </v-card>
  142. <v-dialog v-model="dialog.visible" max-width="800">
  143. <v-card>
  144. <v-card-title>交易详情</v-card-title>
  145. <v-card-text><TradeInfo :item="dialog.data"></TradeInfo></v-card-text>
  146. <v-card-actions>
  147. <v-spacer></v-spacer>
  148. <v-btn
  149. color="primary"
  150. text
  151. @click="dialog.visible = false"
  152. >
  153. 我知道了
  154. </v-btn>
  155. </v-card-actions>
  156. </v-card>
  157. </v-dialog>
  158. </div>
  159. </template>
  160. <script>
  161. import TradeInfo from '@/components/viewer/table/TradeInfoDetails'
  162. import HashKit from '@/plugins/kit/HashKit'
  163. import HttpKit from '@/plugins/kit/HttpKit'
  164. export default {
  165. name: 'Table',
  166. components: {TradeInfo},
  167. props: ['query', 'page', 'table'],
  168. inject: ['generateTableData'],
  169. data: () => ({
  170. hashKit: HashKit,
  171. httpKit: HttpKit,
  172. dialog: {
  173. data: [],
  174. visible: false
  175. },
  176. tempPage: 1
  177. }),
  178. methods: {
  179. async deleteByHash(hash_code) {
  180. if (confirm('要删吗?\n' + hash_code)) {
  181. // const rst = await EthMev.deleteByHash(hash_code)
  182. //
  183. // if (rst.data.state) {
  184. // this.$msgkit.success(rst.data.msg)
  185. //
  186. // await this.pullData()
  187. // } else {
  188. // this.$msgkit.error(rst.data.msg)
  189. // }
  190. }
  191. },
  192. showTradeInfo(item) {
  193. this.dialog.data = item
  194. this.dialog.visible = true
  195. },
  196. async inputPageNum() {
  197. console.log(typeof this.tempPage, parseInt(this.tempPage))
  198. this.table.pageNum = parseInt(this.tempPage)
  199. await this.generateTableDataAgain()
  200. },
  201. async generateTableDataAgain() {
  202. this.tempPage = this.table.pageNum
  203. await this.generateTableData()
  204. }
  205. }
  206. }
  207. </script>
  208. <style scoped>
  209. .table-container {
  210. width: 100%;
  211. }
  212. #dataTableHeader {
  213. max-width: none;
  214. }
  215. .tokenChip {
  216. margin-top: 5px;
  217. margin-left: 5px;
  218. margin-bottom: 5px;
  219. }
  220. .tradeInfoBtn {
  221. padding: 15px !important;
  222. border: grey 2px solid;
  223. }
  224. .tradeInfoBtn:hover {
  225. background: beige;
  226. }
  227. .memo-span {
  228. width: 200px;
  229. display:block;
  230. padding: 10px;
  231. }
  232. </style>