Hddress.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <v-card elevation="1">
  3. <!-- 顶部组件 -->
  4. <Top :query='query' :page='page' :table='table' :visible="editDialog.visible"></Top>
  5. <!-- 中间表格组件 -->
  6. <Table :query='query' :page='page' :table='table' :addressModel="addressModel" :explorer="chain.explorer"
  7. :editDialog="editDialog" ref="table"></Table>
  8. </v-card>
  9. </template>
  10. <script>
  11. import Top from '@/components/viewer/hddress/Top'
  12. import Table from '@/components/viewer/hddress/Table'
  13. import TxModel from '@/plugins/model/TxModel'
  14. import AddressModel from "@/plugins/model/AddressModel";
  15. export default {
  16. name: 'Hddress',
  17. components: {Top, Table},
  18. props: ['chain'],
  19. data: () => ({
  20. addressModel: undefined,
  21. editDialog: {
  22. item: {},
  23. visible: false,
  24. addOrUpdate: true,
  25. },
  26. query: {
  27. // hddress: {
  28. // name: '',
  29. // hash: process.env.NODE_ENV === 'development' ? '0x1a97a8fe340933a8b050dd3d1c823116d31178a253a74ea5a42ea909b37901c4' : '',
  30. // },
  31. // tx: {
  32. // block: '',
  33. // from: '',
  34. // to: ''
  35. // },
  36. // transfer: {
  37. // from: '',
  38. // to: '',
  39. // token: ''
  40. // },
  41. // autoFlushTime: 0
  42. },
  43. page: {
  44. name: 'Hddress Page'
  45. },
  46. table: {
  47. search: '',
  48. loading: false,
  49. groupBy: 'chainId',
  50. groupDesc: true,
  51. sortBy: ['chainId', 'index'],
  52. sortDesc: [true, false],
  53. pageSize: process.env.NODE_ENV === 'development' ? 100 : 200,
  54. pageNum: 1,
  55. pageLength:99,
  56. data: [],
  57. headers: [
  58. {text: 'Option', value: 'option', width: '5%'},
  59. {text: 'ChainId', value: 'chainId', width: '5%'},
  60. {text: 'Hash', value: 'hash', width: '10%'},
  61. {text: "Other", value: 'other'},
  62. {text: 'Name', value: 'name', width: '10%'},
  63. {text: 'Type', value: 'type'},
  64. {text: 'Comment', value: 'comment'},
  65. ]
  66. },
  67. }),
  68. methods: {
  69. // 获取数据
  70. async generateTableData() {
  71. this.createAddressModel()
  72. this.table.loading = true
  73. this.table.data.length = 0
  74. const rst = await this.addressModel.find(this.table.pageNum, this.table.pageSize)
  75. if (rst.state) {
  76. console.log("data--:", rst)
  77. this.table.data = rst.data
  78. console.log("data--_:", this.table.data)
  79. this.$msgkit.success(rst.msg)
  80. } else {
  81. this.$msgkit.error(rst.msg)
  82. }
  83. this.table.loading = false
  84. },
  85. createAddressModel() {
  86. if (!this.addressModel) this.addressModel = new AddressModel(this.chain.id, TxModel.MODULES.ADDRESS)
  87. },
  88. //设置 新增按钮编辑
  89. showVisible() {
  90. this.editDialog.item = {hash: '', name: ''}
  91. this.editDialog.visible = true
  92. this.editDialog.addOrUpdate = true
  93. },
  94. async prePackQuery() {
  95. // await this.$refs.table.remButClick()
  96. },
  97. async packQuery() {
  98. await this.prePackQuery()//查询数据之前移除 多余的临时标签
  99. await this.generateTableData()//拿到数据
  100. await this.afterPackQuery()//添加标签 ,添加点击按钮事件
  101. },
  102. async afterPackQuery() {
  103. },
  104. },
  105. provide() {
  106. return {
  107. packQuery: this.packQuery,
  108. showVisible: this.showVisible
  109. }
  110. },
  111. async mounted() {
  112. await this.packQuery()
  113. }
  114. }
  115. </script>