<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-08-06 13:39:09
 * @LastEditors: 无尘
 * @LastEditTime: 2019-10-09 11:30:04
 -->
<!--
<table-tr></table-tr>

import tableTr from '@/components/api/table-tr.vue';
-->
<template>
  <div>
    <template v-for="(itemValue, itemName, index) in itemData">
      <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">
                <el-tooltip class="item" effect="dark" :content="itemName" placement="top">
                  <span>{{ itemName }}</span>
                </el-tooltip>
              </div>
            </td>
            <td rowspan="1" colspan="1" class="el-table_1_column_1">
              <div class="cell el-tooltip">{{ itemValue.frontOriginType }}</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"><el-checkbox disabled="true" v-model="itemValue.check"></el-checkbox></div>
            </td>
            <td rowspan="1" colspan="1" class="el-table_1_column_3">
              <div class="cell el-tooltip">
                <el-tooltip class="item" effect="dark" :content="itemValue.defaultVal" placement="top">
                  <span>{{ itemValue.defaultVal }}</span>
                </el-tooltip>
              </div>
            </td>
            <td rowspan="1" colspan="1" class="el-table_1_column_3">
              <div class="cell el-tooltip">
                <el-tooltip class="item" effect="dark" :content="itemValue.description" placement="top">
                  <span>{{ itemValue.description }}</span>
                </el-tooltip>
              </div>
            </td>
          </tr>
        </tbody>
      </table>
      <table-row class="el-table__row" style="padding-left: 10px;" v-if="itemValue.type == 'array'" :itemData="itemValue.items.properties" :key="index + '122' + itemName"> </table-row>
      <table-row class="el-table__row" style="padding-left: 10px;" v-if="itemValue.type == 'object'" :itemData="itemValue.properties" :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>
