<template>
  <m-info :format="infoFormat" :toApi="toApi"></m-info>
</template>

<script>
import MInfo from '../../components/mInfo'
import { api } from '@/api/dataGovernance'
export default {
  name: 'details-info',
  components: {
    MInfo
  },
  computed: {
    toApi () {
      return api.getModelDetails
    }
  },
  methods: {
    infoFormat (info) {
      if (!info.data_model) {
        return [
          { label: '中文名', value: '' },
          { label: '英文名', value: '' },
          { label: '数据来源', value: [] }
        ]
      }
      const value = info.data_model.childrenId
        ? info.data_model.childrenId.map(e => {
          return {
            label: null,
            value: [e?.name_zh]
          }
        })
        : []
      return [
        { label: '中文名', value: info.data_model.name_zh },
        { label: '英文名', value: info.data_model.name_en },
        {
          label: '数据来源',
          value,
          format: 'array'
        },
        { label: '层级', value: info.data_model.level },
        { label: '标签', value: info.data_model.tag?.name_zh },
        { label: '描述', value: info.data_model.describe },
        { label: '时间', value: info.data_model.create_time }
      ]
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
