<template>
  <div class="target-info_content">
    <div class="target-info-left-content">
      <tsLoading :loading="loading" />
      <p
        v-for="(key,index) of Object.keys(infoData)"
        :key="index"
        class="flexbox content_item font12"
      >
        <span class="co999"  style="width:65px">{{key}}</span>
        <span  style="width:calc(100% - 65px)">{{infoData[key]}}</span>
      </p>
    </div>
  </div>
</template>

<script>
export default {
  name: 'biTargetInfo',
  components: {  },
  props: {
    target: {
      type: Object,
      default: () => {
        return { targetId_: '60002' }
      }
    }
  },
  data() {
    return {
      loading: false,
      infoData: {
        // 业务分类: '-',
        // 指标版本: '-',
        指标编码: '-',
        // 指标名称: '-',
        指标定义: '-',
        // 计算指标: '-',
        指标说明: '-',
        指标来源: '-',
        // 计算类别: '-',
        // 指标导向: '-',
        // 指标状态: '-',
        // 指标属性: '-',
        // 备注: '-',
        // 统计频次: '-'
      }
    }
  },
  created() {},
  mounted() {
    this.getDetailInfo(this.target.targetId)
  },
  methods: {
    // 获取详情信息
    getDetailInfo(id) {
      const _this = this
      this.loading = true
      this.$api({
        url: '/ts-bi/api/OfBusiCode/selectByBusiCodeCode/' + id,
        data: {
          showDictionaryName: true
        },
        headers: {
          'Content-Type': 'application/json;charset=UTF-8'
        },
        method: 'get'
      })
        .then(res => {
          _this.loading = false
          if (res.success) {
            let info = res.object
            // _this.infoData['业务分类'] = info.busTypeName || '-'
            // _this.infoData['指标版本'] = info.targetVersion || '-'
            _this.infoData['指标编码'] = info.code || '-'
            // _this.infoData['指标名称'] = info.name || '-'
            _this.infoData['指标定义'] = info.definition || '-'
            // _this.infoData['计算指标'] =
            //   info.calculateFlag == '01' ? '是' : '否'
            if (info.calculateFlag == '01') {
              _this.infoData['计算方法'] = info.calculateMethod || '-'
            }else{
              // _this.infoData['视图位置'] = info.dataView || '-'
            }
            _this.infoData['指标来源'] = info.source || '-'
            _this.infoData['指标说明'] = info.zbkDesc || '-'
            // _this.infoData['指标单位'] = info.targetUnit || '-'
            // _this.infoData['计算类别'] = info.dataOf || '-'
            // _this.infoData['指标导向'] = info.goodDirection || '-'
            // _this.infoData['指标状态'] = info.status=='01'?'正常':'禁用'
            // _this.infoData['指标属性'] = info.targetAttribute|| '-'
            // _this.infoData['备注'] = info.remark || '-'
            // _this.infoData['统计频次'] = info.frequency || '-'
          } else {
            _this.loading = false
            _this.$utils.msg(_this, '获取配置信息失败！', 'error')
          }
        })
        .catch(function(error) {
          _this.loading = false
          _this.$utils.msg(_this, error.message || '系统异常', 'error')
        })
    }
  },
  watch: {
    'target.targetId': {
      handler(n) {
        this.getDetailInfo(n)
      }
    }
  },
  beforeDestroy: function() {}
}
</script>
<style lang="less" scoped>
.target-info_content {
  .no_data {
    width: 100%;
  }
  padding: 0px 5px 0 10px;
  .target-info-left-content {
    overflow: hidden;
    overflow-y: auto;
    p {
      line-height: 28px;
    }
    ul {
      line-height: 28px;
      width: 100%;
      font-size: 12px;
      li {
        width: 100%;
        float: left;
        display: flex;
        .param-name {
          width: 10%;
          color: #888;
          text-align: left;
        }
        .param-value {
          text-indent: 1em;
          width: 60%;
          color: var(--base-black);
        }
      }
    }
  }
}
</style>
