<!--
 * @Descripttion: 当前组件信息
 * @version: 1.0.0
 * @Author: 无尘
 * @Date: 2019-08-22 10:22:59
 * @LastEditors: 无尘
 * @LastEditTime: 2019-08-22 10:22:59
 -->
<!--
<back-const-table :itemData="itemData" :interfaceType="interfaceType"></back-const-table>

import backConstTable from '@/components/api/back-const-table.vue';
-->
<template>
  <div>
    <div class="el-table el-table--fit el-table--enable-row-hover el-table--enable-row-transition" style="width: 100%; table-layout: fixed;">
      <div class="el-table__header-wrapper">
        <table cellspacing="0" cellpadding="0" border="0" class="el-table__header" style="width: 100%; table-layout: fixed;">
          <thead class="has-gutter">
            <tr class="">
              <th colspan="1" rowspan="1" class="el-table_1_column_1 is-leaf">
                <div class="cell">参数名</div>
              </th>
              <th v-if="interfaceType == '0'" colspan="1" rowspan="1" class="el-table_1_column_2 is-leaf">
                <div class="cell">参数位置</div>
              </th>
              <th colspan="1" rowspan="1" class="el-table_1_column_2 is-leaf">
                <div class="cell">参数类型</div>
              </th>
              <th colspan="1" rowspan="1" class="el-table_1_column_4 is-leaf">
                <div class="cell">参数值</div>
              </th>
            </tr>
          </thead>
        </table>
      </div>
      <div class="el-table__body-wrapper is-scrolling-none">
        <div class="table-content">
          <template v-for="(itemValue, itemName, index) in itemData.properties">
            <table v-if="itemValue.constFlag" 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">
                    <div class="cell el-tooltip">
                      {{ itemValue.currentKey }}
                    </div>
                  </td>
                  <td v-if="interfaceType == '0'" rowspan="1" colspan="1" class="el-table_1_column_2">
                    <div class="cell el-tooltip">
                      {{ itemValue.backendOriginType }}
                    </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>
          </template>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'back-constant',
  props: {
    itemData: {
      type: Object,
      default() {
        return {};
      }
    },
    interfaceType: {
      type: [String, Number],
      default() {
        return '0';
      }
    }
  },
  data() {
    return {
      trData: {}
    };
  },
  watch: {
    itemData: function(newData, oldData) {
      const that = this;
      that.trData = JSON.parse(JSON.stringify(newData));
    }
  },
  mounted() {
    const that = this;
    that.trData = JSON.parse(JSON.stringify(that.itemData));
  }
};
</script>
<style lang="less" scoped>
.w-320 {
  width: 320px;
}
.m-t-14 {
  margin-top: 14px;
}
.add-line {
  height: 48px;
  line-height: 48px;
  border-bottom: 1px solid #e4e7ed;
  cursor: pointer;
}
.el-table th {
  padding: 7px 0;
}
</style>
