
export default {
    data(){
        return {
            ethTopAddrMonitorListLoading:false,
            params:{
                req:"ethTopAddrMonitorList",
                radius:"ETH",             
            },               
            tabelData:[],
            page:1,
            limit:50,
            currentPage4:1,
            totalPage:0,
            value:"",
            valueList: [
                {
                    value: 50000,
                    label: "value > 5W",
                },
                {
                    value: 100000,
                    label: "value > 10W",
                },
                {
                    value: 150000,
                    label: "value > 15W",
                },
                {
                    value: 250000,
                    label: "value > 25W",
                },
                {
                    value: 500000,
                    label: "value > 50W",
                },
                {
                    value: 1000000,
                    label: "value > 100W",
                },
            ],
            state:"",
        }
    },
    mounted(){      
      
        //不显示时间框
         this.$addStorageEvent(1, "timeShow", false);
        this.fetchMonitorList(this.params.req,this.params.radius,this.page,this.limit)
    },
    methods:{
       
        async fetchMonitorList(req, radius, page,limit,total){
            this.ethTopAddrMonitorListLoading = true
            const { data } = await this.$API.getNewContract(req, radius, page,limit,total)
            this.tabelData = data.data.data  

            



            this.tabelData.forEach(item=>{
                item.amount = Number(parseInt(item.amount*100)/100)
                if (item.fromAbbr) {
                    item.fromAddress = `${item.fromAddress}(${item.fromAbbr})`                    
                }
                if (item.toAbbr) {
                    item.toAddress = `${item.toAddress}(${item.toAbbr})`                    
                }
            }) 
            this.totalPage=data.data.totalPage
            this.currentPage4 =page
            
            this.ethTopAddrMonitorListLoading = false
        },     

        formatTime(time){
            let date = time.split("T")[0]
            let hour = time.split("T")[1].split(".")[0]
            return `${date} ${hour}`
        },
         //点击的改变页数
         handleCurrentChange(value) {
            this.page = value;
            this.fetchMonitorList(this.params.req,this.params.radius,this.page,this.limit)
        },
        //改变每页条数
        handleSizeChange(val) {
            this.page = 1;
            this.limit = val;
            this.fetchMonitorList(this.params.req,this.params.radius,this.page,this.limit)

        },
          //双击表格单元格复制
          cellDblclick(row, column, cell, event) {
            if (event.type === "dblclick") {
                var save = (e) => {
                    e.clipboardData.setData("text/plain", event.target.innerText);
                    e.preventDefault(); //阻止默认行为
                };
                document.addEventListener("copy", save);
                document.execCommand("copy");
                document.removeEventListener("copy", save);
            }
            this.$message({ message: this.$t(`home.copy`), type: "success" }); //加提示
        },
              //下拉框选择
              handelChang(e) {
                // this.fetchEthTopAddrList(this.value,this.params.page,this.params.limit)
                this.fetchMonitorList(this.params.req,this.params.radius,this.page,this.limit,this.value)
                this.state = ""
            },
              //搜索框输入参数     
        handelSearch() {
            this.fetchMonitorList(this.params.req,this.params.radius,this.page,this.limit,this.state)
            this.value = ""
        },
      
       
    }
}