require("../css/graphDataStatistics.less")
require("./../css/common.less");
// require("element-ui/lib/theme-chalk/index.css")
const { post, api, getUrlArgObject } = require('./api.js');
const $ = require('jquery')
const Vue = require("vue/dist/vue.esm.js").default;
const ElementUI = require("element-ui/lib/index.js");
// import UmyUi from 'umy-ui'
// Vue.use(UmyUi);
// const ElementUI = require("../public/elementUI/index.js");
Vue.use(ElementUI)
let myChart = null
let timer = null //计时器标志

const vm = new Vue({
  el: "#app",
  name: "graphDataStatistics",
  data() {
    return {
      total: 10,
      countInfo: {},
      totalElements: {},
      MAX_TABLE_HEIGHT: 1000,
      currentPage: 1,
      selectPageSize: 10,
      tableData: [
        {
          nodeType: "疾病",
          nodeNum: 5000,
          nodeAttributeNum: 5000,
          coefficientType: 5000,
          coefficientNum: 5000,
        },
        {
          nodeType: "症状",
          nodeNum: 5000,
          nodeAttributeNum: 5000,
          coefficientType: 5000,
          coefficientNum: 5000,
        },
        {
          nodeType: "并发症",
          nodeNum: 5000,
          nodeAttributeNum: 5000,
          coefficientType: 5000,
          coefficientNum: 5000,
        },
      ],
    }
  },
  methods: {
    getCountList() {
      const params = {
        pageNo: this.currentPage,
        pageSize: this.selectPageSize,
      }
      post(api.getCountList, params).then((res) => {
        const { data, code, msg } = res.data
        if (code === '0') {
          this.tableData = [...data.content]
          this.total = data.totalElements
          this.$nextTick(() => {
            this.calculateTableMaxHeight()
          })
        }
      }).catch(e => {
        console.log(e)
      })
    },
    getCountInfo() {
      post(api.getCountInfo).then(res => {
        const { data, code, msg } = res.data
        if (code === '0') {
          this.countInfo = data
          this.$nextTick(() => {
            this.calculateTableMaxHeight()
          })
        }
      }).catch(e => {
        console.log(e)
      }

      )
    },
    paginationChange(getCurrentPages, pageSize) {
      this.currentPage = getCurrentPages;
      this.selectPageSize = pageSize;
      this.getCountList(getCurrentPages, pageSize)
    },
    handleCurrentChang(page) {
      this.currentPage = page
    },
    handleSizeChange(size) {
      this.selectPageSize = size
    },
    calculateTableMaxHeight() {
      // console.log("#app", $('#app').outerHeight(), $('header').outerHeight(), $('footer').outerHeight())
      this.MAX_TABLE_HEIGHT = $('#app').outerHeight() - $('header').outerHeight() - $('footer').outerHeight() - 40
    }
  },
  watch: {
    currentPage(newVal) {
      this.getCountList()
    },
    selectPageSize(newVal) {
      this.getCountList()
    }
  },
  computed: {

  },
  created() {
    this.getCountInfo()
    this.getCountList()
  },
  mounted() {
  },
  destroyed() {

  }
})
