<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-08-06 09:51:25
 * @LastEditors: 无尘
 * @LastEditTime: 2019-10-21 14:58:25
 -->
<!--
<base-info-show></base-info-show>

import baseInfoShow from '@/components/api/base-info-show.vue';
-->
<template>
  <div class="base-info-show border-box">
    <div v-if="apiType==2">
      <el-form
        label-width="120px"
        :model="apiInfoData">
        <el-form-item label="API名称:">
          {{ apiInfoData.interfaceName }}
        </el-form-item>
        <el-form-item label="配置code:">
          {{ apiInfoData.code }}
        </el-form-item>
        <el-form-item
          label="描述:"
          class="max-w-1000">
          {{ apiInfoData.interfaceDescribe }}
        </el-form-item>
      </el-form>
    </div>
    <div v-else>
      <el-form
        label-width="120px"
        :model="apiInfoData">
        <el-form-item label="API名称:">
          {{ apiInfoData.interfaceName }}
        </el-form-item>
        <el-form-item label="API类型:">
          {{ apiInfoData.target == 1 ? '公开' : '私有' }}
        </el-form-item>
        <el-form-item label="访问类型:">
          {{ apiInfoData.requestType }}
        </el-form-item>
        <el-form-item
          label="描述:"
          class="max-w-1000">
          {{ apiInfoData.interfaceDescribe }}
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
export default {
  name: 'BaseInfoShow',
  props: {
    apiData: {
      type: [ Object, Array ],
      default() {
        return {};
      },
    },
    apiType: {
      type: Number,
      default(){
        return 0;
      }
    }
  },
  data() {
    return {
      apiInfoData: {
        /*  interfaceName: '1',
        target: '1',
        requestType: 'get',
        interfaceDescribe: 'test' */
      }
    };
  },
  mounted() {
    const that = this;
    that.apiInfoData = that.apiData;
  },

  watch: {
    apiData: function(newData, oldData) {
      const that = this;
      that.apiInfoData = newData;
    }
  }
};
</script>
<style lang="less" scoped>
.w-320 {
  width: 320px;
}
.m-t-14 {
  margin-top: 14px;
}
.max-w-1000 {
  max-width: 1000px;
}
.base-info-show {
  width: 100%;

  .el-form {
    /deep/ .el-form-item__label {
      color: #606266;
    }
    /deep/ .el-form-item__content {
      color: #303133;
    }
  }
}
</style>
