<template>
  <div>
    <el-container>
      <el-aside width="30%">
        <el-tree :data="dataList" :props="defaultProps" @node-click="handleNodeClick">
        </el-tree>
      </el-aside>

      <el-main>
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>资产结构基本信息</span>
          </div>
          <el-descriptions class="margin-top" title="带边框列表" :column="2"  border>
            <el-descriptions-item>
              <template slot="label">表名称</template>
              {{ tableList.tableName }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">表备注</template>
              {{ tableList.tableRemark }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">数据量</template>
              {{ tableList.dataNum }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template slot="label">是否核心</template>
              <dict-tag :options="dict.type.sys_yes_no" :value="tableList.isCenter"/>
            </el-descriptions-item>
          </el-descriptions>
        </el-card>

        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>资产结构详细信息</span>
          </div>
          <el-table
            :data="tableData" style="width: 100%">
            <el-table-column label="名称" prop="columnName"></el-table-column>
            <el-table-column label="注释" prop="columnRemark"></el-table-column>
            <el-table-column label="是否主键" prop="isPrimary">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.isPrimary"/>
              </template>
            </el-table-column>
            <el-table-column label="类型" prop="columnType"></el-table-column>
            <el-table-column label="映射类型" prop="javaType"></el-table-column>
            <el-table-column label="长度" prop="columnLength"></el-table-column>
            <el-table-column label="小数位" prop="columnDecimals"></el-table-column>
            <el-table-column label="是否为空" prop="isNull">
              <template slot-scope="scope">
                <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.isNull"/>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-main>
    </el-container>




  </div>
</template>
<script setup>
import { selectTableData} from "@/api/tableData/data";
import {findByTableName} from "@/api/source/source";

export default {
  name: 'Type',
  dicts: ['sys_yes_no'],
  data() {
    return {
      tableData:[],
      tableList:{},
      form:{},
      dataList:[
        {
          children:[],
        }
      ],
      defaultProps: {
        children: 'children',
        label: 'tableName'
      },
      columnList:[],

    };
  },
  created() {
  this.findTableInfoList();

  },
  methods: {
   findTableInfoList(){
     findByTableName().then(res=>{
       this.dataList=res.data
     })
   },
    handleNodeClick(data) {
      this.tableList=data
      selectTableData(data.id).then(res=>{
        console.log(res.data)
      this.tableData=res.data;
      })
      console.log(data);
    }
  }
}
</script>
<style scoped lang="scss">

</style>
