<template>
  <a-card :bordered="false" v-show="visible" class="card" :title="modalTitle">
    <h1 style="margin:20px auto; text-align: center"> DCS车间-数据展示 </h1>
    <a-card v-for="position in treeData" :key="position.key" :title="position.title">
      <a-card-grid v-for="child in position.children" :key="child.key" style="cursor: pointer;width:25%;text-align:center" @click="showScreen(child, position.key)">
        {{ child.title }}
      </a-card-grid>
    </a-card>
  </a-card>
</template>

<script>

import { getSbPositionTree } from '@/api/sb/position'

export default {
  name: 'OpcPosition',
  components: {
  },
  data () {
    return {
      confirmLoading: false,
      modalTitle: null,
      treeData: [],
      visible: true
    }
  },
  props: {
  },
  created () {
    getSbPositionTree({ opcFlag: 1 }).then(res => {
      this.treeData = res.data
    })
  },
  methods: {
    showScreen (position, parentId) {
      const a = document.createElement('a')
      a.href = '/opc?line=' + position.key + '&parentId=' + parentId
      a.target = '_blank'
      a.click()
    }
  }
}
</script>
