<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-08-06 21:01:14
 * @LastEditors: 无尘
 * @LastEditTime: 2020-10-16 17:29:19
 -->
<!--
<back-table-right></back-table-right>

import backTableRight from '@/components/api/back-table-right.vue';
-->
<template>
  <div>
    <template v-for="(itemValue, itemName, index) in itemData.properties">
      <table
        v-if="!itemValue.constFlag"
        :key="index + itemName + 121"
        cellspacing="0"
        cellpadding="0"
        border="0"
        class="el-table__body"
        style="width: 100%;table-layout: fixed;">
        <tbody>
          <tr class="el-table__row">
            <td
              rowspan="1"
              colspan="1"
              class="el-table_1_column_1"
              style="width: 36px;">
              <div
                v-if="itemValue.type == 'object' || itemValue.type == 'array'"
                class="cell">
                <i class="el-icon-minus" />
              </div>
            </td>
            <td
              v-if="interfaceType == '0'"
              rowspan="1"
              colspan="1"
              class="el-table_1_column_1">
              <div class="cell el-tooltip">
                <el-tooltip
                  class="item"
                  effect="dark"
                  :content="itemValue.rootKey"
                  placement="top">
                  <span>{{ itemValue.rootKey }}</span>
                </el-tooltip>
              </div>
            </td>
            <td
              rowspan="1"
              colspan="1"
              class="el-table_1_column_2">
              <div class="cell el-tooltip">
                {{ itemValue.type }}
              </div>
            </td>
            <td
              v-if="interfaceType == 1"
              rowspan="1"
              colspan="1"
              class="el-table_1_column_3">
              <div class="cell el-tooltip">
                {{ itemValue.objectClass }}
              </div>
            </td>
            <td
              rowspan="1"
              colspan="1"
              class="el-table_1_column_4">
              <div class="cell el-tooltip">
                <el-tooltip
                  class="item"
                  effect="dark"
                  :content="itemValue.defaultVal"
                  placement="top">
                  <span>{{ itemValue.defaultVal }}</span>
                </el-tooltip>
              </div>
            </td>
          </tr>
        </tbody>
      </table>
      <back-table-row
        v-if="itemValue.type == 'array' && Object.keys(itemValue.items.properties).length"
        :key="index + '122' + itemName"
        class="el-table__row child-row"
        :interface-type="interfaceType"
        :item-data="itemValue.items" />
      <back-table-row
        v-if="itemValue.type == 'object' && Object.keys(itemValue.properties).length"
        :key="index + '123' + itemName"
        :interface-type="interfaceType"
        class="el-table__row child-row"
        :item-data="itemValue" />
    </template>
  </div>
</template>
<script>
export default {
  name: 'BackTableRow',
  props: {
    itemData: {
      type: [ Object, Array ],
      default() {
        return {};
      }
    },
    interfaceType: {
      type: [ String, Number ],
      default() {
        return '0';
      }
    }
  },
  data() {
    return {
      trData: {}
    };
  },
  mounted() {
    const that = this;
    that.trData = that.itemData;
  },

  watch: {
    itemData: function(newData, oldData) {
      const that = this;
      that.trData = newData;
    }
  }
};
</script>
<style lang="less" scoped>
.w-320 {
  width: 320px;
}
.m-t-14 {
  margin-top: 14px;
}
.child-row {
  padding-left: 10px;
}
</style>
