| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- <template>
- <div class="table-container">
- <v-card elevation="0">
- <!-- 表格上功能区 -->
- <v-card-title>
- <v-container id="dataTableHeader">
- <v-row>
- <v-col cols="4">
- {{ page.name }}
- </v-col>
- <v-col cols="8">
- <v-text-field hide-details single-line label="Local Search" append-icon="mdi-magnify" v-model="table.search"/>
- </v-col>
- </v-row>
- </v-container>
- </v-card-title>
- <!-- 顶部分页 -->
- <div class="mt-2">
- <v-row>
- <v-col cols="2"></v-col>
- <v-col cols="2">
- <v-text-field required type="number" label="page" v-model="tempPage" @change="inputPageNum" />
- </v-col>
- <v-col cols="4">
- <v-pagination color="teal" :disabled="table.loading" :length="99" v-model="table.pageNum" @input="generateTableDataAgain"></v-pagination>
- </v-col>
- </v-row>
- </div>
- <!-- 表格主体 -->
- <v-data-table calculate-widths multi-sort hide-default-footer
- :group-by="table.groupBy" :group-desc="table.groupDesc"
- :headers="table.headers" :items="table.data" :search="table.search" :loading="table.loading"
- :items-per-page="table.pageSize"
- :sort-by="table.sortBy" :sort-desc="table.sortDesc">
- <!-- 操作区 -->
- <template v-slot:item.option="{ item }">
- <div>
- <v-row>
- <v-col cols="5">
- <v-btn icon elevation="0" color="red" large @click="deleteByHash(item.hash, item)">
- <v-icon>mdi-delete-forever-outline</v-icon>
- </v-btn>
- </v-col>
- </v-row>
- </div>
- </template>
- <!-- Block -->
- <template v-slot:item.block="{ item }">
- <div>
- {{ item.block }}
- </div>
- </template>
- <!-- Hash -->
- <template v-slot:item.hash="{ item }">
- <v-btn v-if="item.hash.indexOf('0x') !== -1" outlined text target="_blank" @click="httpKit.jumpToExplorer(item.hash, 'tx')">
- {{ hashKit.head5(item.hash) + '..' }}
- </v-btn>
- <v-chip v-else label target="_blank">
- {{ hashKit.head5(item.hash) + '..' }}
- </v-chip>
- </template>
- <!-- From -->
- <template v-slot:item.from="{ item }">
- <v-chip label color="green lighten-3" target="_blank" @click="httpKit.jumpToExplorer(item.from)">
- {{ hashKit.headAndEnd2(item.from) }}
- </v-chip>
- </template>
- <!-- to -->
- <template v-slot:item.to="{ item }">
- <v-chip v-if="!item.toName" label color="indigo lighten-4" @click="httpKit.jumpToExplorer(item.to)">
- {{ hashKit.headAndEnd2(item.to) }}
- </v-chip>
- <v-chip v-else label color="indigo lighten-4" @click="httpKit.jumpToExplorer(item.to)">
- {{ item.toName }}
- </v-chip>
- </template>
- <template v-slot:item.type="{ item }">
- <div v-if="item.type !== undefined && item.type !== ''">
- {{ item.type }}
- </div>
- <div v-else>
- [type]
- </div>
- </template>
- <template v-slot:item.index="{ item }">
- <div v-if="item.index !== undefined">
- {{ item.index }}
- </div>
- <div v-else>
- [index]
- </div>
- </template>
- <template v-slot:item.status="{ item }">
- <div v-if="item.state !== undefined">
- {{ item.status }}
- </div>
- <div v-else>
- [status]
- </div>
- </template>
- <template v-slot:item.ping="{ item }">
- <div v-if="item.ping !== undefined">
- {{ item.ping }}
- </div>
- <div v-else>
- [ping]
- </div>
- </template>
- <template v-slot:item.isMev="{ item }">
- <BooleanViewer :value="item.isMev"></BooleanViewer>
- </template>
- <template v-slot:item.isBot="{ item }">
- <BooleanViewer :value="item.isBot"></BooleanViewer>
- </template>
- <template v-slot:item.maybeBot="{ item }">
- <BooleanViewer :value="item.maybeBot"></BooleanViewer>
- </template>
- <template v-slot:item.timestamp="{ item }">
- {{ formatTimeBySixBitTimestamp(item.timestamp) }}
- </template>
- <template v-slot:item.comment="{ item }">
- <div v-if="item.comment">
- <span class="memo-span">{{ item.comment }}</span>
- </div>
- <div v-else>
- [comment]
- </div>
- </template>
- <!--tradeInfo-->
- <template v-slot:item.transferList="{ item }">
- <div v-if="page.name === 'Pending Page'">
- <div class="tradeInfoBtn" @click="showTradeInfo(item)">
- <v-chip v-for="tokenAddress in item.tokenAddressList" :key='tokenAddress'
- :color="item.tokenMap[tokenAddress] ? hashKit.generateColorByHash(tokenAddress) : undefined" class="tokenChip">
- {{ item.tokenMap[tokenAddress] ? item.tokenMap[tokenAddress] : '**' + hashKit.headAndEnd2(tokenAddress) }}
- </v-chip>
- </div>
- </div>
- <div v-else>
- <TradeInfo :item="item"></TradeInfo>
- </div>
- </template>
- </v-data-table>
- <!-- 底部分页 -->
- <div class="mt-2">
- <v-row>
- <v-col cols="2"></v-col>
- <v-col cols="2">
- <v-text-field type="number" required label="page" v-model="tempPage" @change="inputPageNum" />
- </v-col>
- <v-col cols="4">
- <v-pagination :disabled="table.loading" :length="99" v-model="table.pageNum" @input="generateTableDataAgain"></v-pagination>
- </v-col>
- </v-row>
- </div>
- </v-card>
- <v-dialog v-model="dialog.visible" max-width="800">
- <v-card>
- <v-card-title>交易详情</v-card-title>
- <v-card-text><TradeInfo :item="dialog.data"></TradeInfo></v-card-text>
- <v-card-actions>
- <v-spacer></v-spacer>
- <v-btn
- color="primary"
- text
- @click="dialog.visible = false"
- >
- 我知道了
- </v-btn>
- </v-card-actions>
- </v-card>
- </v-dialog>
- </div>
- </template>
- <script>
- import TradeInfo from '@/components/viewer/table/TradeInfoDetails'
- import BooleanViewer from '@/components/viewer/table/BooleanViewer'
- import HashKit from '@/plugins/kit/HashKit'
- import HttpKit from '@/plugins/kit/HttpKit'
- import TimeKit from '@/plugins/kit/TimeKit'
- export default {
- name: 'Table',
- components: {BooleanViewer, TradeInfo},
- props: ['query', 'page', 'table'],
- inject: ['generateTableData'],
- data: () => ({
- hashKit: HashKit,
- httpKit: HttpKit,
- timeKit: TimeKit,
- dialog: {
- data: [],
- visible: false
- },
- tempPage: 1
- }),
- methods: {
- async deleteByHash(hash_code, item) {
- if (confirm('要删吗?\n' + hash_code)) {
- console.log(JSON.stringify(item))
- this.$msgkit.warning('还没有做,别急啊')
- // const rst = await EthMev.deleteByHash(hash_code)
- //
- // if (rst.data.state) {
- // this.$msgkit.success(rst.data.msg)
- //
- // await this.pullData()
- // } else {
- // this.$msgkit.error(rst.data.msg)
- // }
- }
- },
- showTradeInfo(item) {
- this.dialog.data = item
- this.dialog.visible = true
- },
- async inputPageNum() {
- console.log(typeof this.tempPage, parseInt(this.tempPage))
- this.table.pageNum = parseInt(this.tempPage)
- await this.generateTableDataAgain()
- },
- async generateTableDataAgain() {
- this.tempPage = this.table.pageNum
- this.table.data = []
- await this.generateTableData()
- },
- formatTimeBySixBitTimestamp(sixBitTimestamp) {
- let lastThreeBit = (sixBitTimestamp + '').slice(-3)
- return this.timeKit.getTime(sixBitTimestamp) + lastThreeBit
- }
- }
- }
- </script>
- <style scoped>
- .table-container {
- width: 100%;
- }
- #dataTableHeader {
- max-width: none;
- }
- .tokenChip {
- margin-top: 5px;
- margin-left: 5px;
- margin-bottom: 5px;
- }
- .tradeInfoBtn {
- padding: 15px !important;
- border: grey 2px solid;
- }
- .tradeInfoBtn:hover {
- background: beige;
- }
- .memo-span {
- width: 200px;
- display:block;
- padding: 10px;
- }
- </style>
|