<!--
 * @Author: 曹捷
 * @Date: 2021-03-15 14:54:07
 * @LastEditors: 曹捷
 * @LastEditTime: 2021-05-31 12:48:38
 * @Description: 系统参数管理
-->
<template>
  <a-page-header style="border: 1px solid rgb(235, 237, 240)" title="返回" @back="() => $router.go(-1)" />
  <a-tabs v-model:activeKey="activeKey">
    <a-tab-pane tab="基础信息" key="1">
      <basic-info-form ref="basicInfo" v-if="activeKey==1" :tableInfo="tableInfo" @reload="queryList(true)" />
    </a-tab-pane>
    <a-tab-pane tab="字段信息" key="2">
      <field-info-form ref="fieldInfo" v-if="activeKey==2" :cloumns="cloumns" @reload="queryList(true)" />
    </a-tab-pane>
    <a-tab-pane tab="生成信息" key="3">
      <gen-info-form ref="genInfo" v-if="activeKey==3" :tables="tables" :tableInfo="tableInfo" :cloumns="cloumns"
        @reload="queryList(true)" />
    </a-tab-pane>
  </a-tabs>
</template>

<script>
import { getCurrentInstance, onMounted, reactive, toRefs, inject, nextTick } from 'vue'
import basicInfoForm from "./basicInfoForm.vue";
import genInfoForm from "./genInfoForm.vue";
import fieldInfoForm from "./fieldInfoForm.vue";
import { useRoute, useRouter } from 'vue-router'
import { util } from '../../../entery'
export default {
  components: { basicInfoForm, genInfoForm, fieldInfoForm },
  setup (props, contenxt) {
    let http = inject('http')
    let { proxy } = getCurrentInstance()
    let route = useRoute()
    let _data = reactive({
      tableInfo: {},
      tables: [],
      cloumns: [],
      activeKey: '',
    })
    let _methods = {
      changeTabs (item) {
        _data.activeKey = item
      },
      queryList () {
        http.getGenTable(route.query.tableId).then(res => {
          _data.cloumns = util.util.cloneObj(res.data.rows)
          _data.tableInfo = util.util.cloneObj(res.data.info)
          _data.tables = res.data.tables;
          _data.activeKey = '2'
        })
      },
    }
    onMounted(() => {
      _methods.queryList();
    })
    return {
      ...toRefs(_data),
      ..._methods,
    }
  },
}
</script>

<style>
</style>