<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-08-07 10:55:41
 * @LastEditors: 无尘
 * @LastEditTime: 2019-08-07 10:55:41
 -->
<!--
<back-info-table></back-info-table>

import backInfoTable from '@/components/api/back-info-table.vue';
-->
<template>
  <div>
    <template v-for="(itemValue, itemName, index) in itemData.properties">
      <table cellspacing="0" cellpadding="0" border="0" class="el-table__body" style="width: 100%;table-layout: fixed;" :key="index + itemName + 121">
        <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"></i></div>
            </td>
            <td rowspan="1" colspan="1" class="el-table_1_column_1">
              <div class="cell el-tooltip">{{ itemName }}</div>
            </td>
            <td rowspan="1" colspan="1" class="el-table_1_column_2">
              <div class="cell el-tooltip">{{ itemValue.type }}</div>
            </td>
            <td rowspan="1" colspan="1" class="el-table_1_column_3">
              <div class="cell el-tooltip">{{ itemValue.defaultVal }}</div>
            </td>
          </tr>
        </tbody>
      </table>
      <table-row class="el-table__row" style="padding-left: 10px;" v-if="itemValue.type == 'array' && Object.keys(itemValue.items.properties).length" :itemData="itemValue.items" :key="index + '122' + itemName"> </table-row>
      <table-row class="el-table__row" style="padding-left: 10px;" v-if="itemValue.type == 'object' && Object.keys(itemValue.properties).length" :itemData="itemValue" :key="index + '122' + itemName"> </table-row>
    </template>
  </div>
</template>
<script>
export default {
  name: 'table-row',
  props: {
    itemData: {
      type: [Object, Array],
      default() {
        return {};
      }
    }
  },
  data() {
    return {
      trData: {
        protocol: 'http',
        interfaceUrl: '/',
        requestType: 'post',
        frontParams: {
          type: 'object', //object，array,string,number,boolean,
          properties: {
            name: {
              originType: 'query', //来源类型 query,body,header
              type: 'object',
              isBackendField: 0, //是否后端字段
              defaultVal: 'val', //默认值
              isRootKey: 0, //是否是后端参数字段
              rootKey: '', //后端参数字段
              objectClass: '', //如果是object 并且是dubbo
              description: '描述',
              check: true,
              required: [],
              properties: {
                nameId: {
                  originType: 'query', //来源类型 query,body,header
                  type: 'object',
                  isBackendField: 0, //是否后端字段
                  defaultVal: 'val', //默认值
                  isRootKey: 0, //是否是后端参数字段
                  rootKey: '', //后端参数字段
                  objectClass: '', //如果是object 并且是dubbo
                  description: '描述',
                  check: true
                }
              }
            },
            id: {
              originType: 'query', //来源类型 query,body,header
              type: 'string',
              isBackendField: 0, //是否后端字段
              defaultVal: 'val', //默认值
              isRootKey: 0, //是否是后端参数字段
              rootKey: '', //后端参数字段
              objectClass: '', //如果是object 并且是dubbo
              description: '描述',
              check: true
            }
          },
          required: []
        }
      }
    };
  },

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