日常常用代码



滚动条上移动到顶部
    scrollToTop() {
      if (!this.$refs.table) {
        return
      }
      const table = this.$refs.table.$el
      const tableBody = table.querySelector('.ant-table-body')

      if (tableBody) {
        this.$nextTick(() => {
          tableBody.scrollTop = 0
        })
      }
    },


页码切换
 pageChange(pageNo) {
      if (pageNo !== 1) {
        this.scrollToTop()
      }
      this.queryParam.pageNum = pageNo
      this.getList()
    },


获取列表数据
 getList() {
      this.isLoading = true


      let obj = {
        startLoginTime: this.queryParam.startDate,
        endLoginTime: this.queryParam.endDate,
        fuzzyStr: this.queryParam.fuzzyStr,
       alertType: this.queryParam.alertType,
        pageNum: this.page.pageNo,
        pageSize: this.page.pageSize,
      }
        console.log('chuancna',obj)

      getList(obj).then((res) => { 
        this.isLoading = false

        console.log('ddd', res)
        // this.page.totalCount = arr
        // this.clueList = arr

        this.clueList = res.body.items

          this.page.totalCount = res.body.total //总条数
        // this.page.pageNo = res.body.pageNum // 当前页数
        // this.page.pageSize = res.body.pageSize // 页面共22条数据
      })
    },

设置日期时间显示 
  setDate() {
      // var startDate = moment().startOf('year')

       var startDate =  moment().startOf('month')
       var endDate=  moment().endOf('month')
      // var today = moment() // 今天
      this.dateValue.push(startDate, endDate)
      //  let x = this.dateValue[0].format('YYYY-MM-DD').toString()
      // let y= this.dateValue[1].format('YYYY-MM-DD').toString()
      this.queryParam.startDate = this.dateValue[0].format('YYYY-MM-DD').toString()
      this.queryParam.endDate = this.dateValue[1].format('YYYY-MM-DD').toString()
      this.onSearch()
    },

解决表头下面有 滚动部分  和背景为白色挡住水印
/deep/ .ant-table-hide-scrollbar {
  overflow-x: hidden !important;
  padding-bottom: 20px !important;
}
/deep/ .ant-table-content > .ant-table-scroll > .ant-table-body {
  // position: relative;
  background: none;
}


你可能感兴趣的:(日常常用代码)