require("../css/selfKnowledgeGraph.less")
require("./../css/common.less");
// require("element-ui/lib/theme-chalk/index.css")
const { post, get, api, getUrlArgObject } = require('./api.js');
const $ = require('jquery')
const Vue = require("vue/dist/vue.esm.js").default;
// const ElementUI = require("../public/elementUI/index.js");

const ElementUI = require("element-ui/lib/index.js");
// import UmyUi from 'umy-ui'
// Vue.use(UmyUi);

Vue.use(ElementUI)

const vm = new Vue({
  el: "#app",
  name: "selfKnowledgeGraph",
  data() {
    return {
      isShowKG: false,
      currentKnowledgeGraph: {
        label: '症状',
        name: "头痛"
      },
      listData: [
        {
          id: 1,
          title: "测试图1",
          label: '症状',
          name: "头痛"
        },
        {
          id: 2,
          title: "测试图2",
          label: '症状',
          name: "头痛"
        }
      ]
    }
  },
  methods: {
    handleView(data) {
      // Object.assign(this.currentKnowledgeGraph, { ...data })
      this.currentKnowledgeGraph.label = data.label
      this.currentKnowledgeGraph.name = data.name
      this.isShowKG = true
    },
    getUserGraphs: function () {
      get(api.userGraphs, {
        user_id: localStorage.getItem("userId") ? +JSON.parse(localStorage.getItem("userId")) : -1,
        pageNo: 1,
        pageSize: 10,
      }).then(res => {
        const { code, records } = res.data
        if (code === 200) {
          this.listData = records
        }
      }).catch(e => {
        console.log(e)
      })
    }
  },
  computed: {
    kgUrl() {
      return `./knowledgeGraph.html?self=true&input=${this.currentKnowledgeGraph.name}&label=${this.currentKnowledgeGraph.label}`;
    }
  },
  watch: {

  },
  mounted() {
    this.getUserGraphs()
  },
  beforeDestroy() {

  },
})