<template>
  <j-editable-table
    ref="editableTable"
    :loading="loading"
    :columns="columns"
    :dataSource="dataSource"
    :rowNumber="true"
    :maxHeight="340"
    :disabled="!actionButton"
    :disabledRows="{dbFieldName: 'id'}"
  />
</template>

<script>

import {FormTypes} from '@/utils/JEditableTableUtil'
import {syncAllTable} from '@views/codegen/form/util/TableUtils';

export default {
  name: 'ForeignKeyTable',
  components: {},
  props: {
    actionButton: {
      type: Boolean,
      default: true,
      required: false
    }
  },
  inject: ["getAllTable"],
  data() {
    return {
      loading: false,
      dataSource: [],
      columns: [
        {
          title: "字段名称",
          key: "dbFieldName",
          width: "160px",
          type: FormTypes.input,
          defaultValue: "",
          placeholder: "",
          props: {
            disabled: true
          }
        },
        {
          title: "字段备注",
          key: "dbFieldTxt",
          width: "160px",
          type: FormTypes.input,
          defaultValue: "",
          placeholder: "",
          props: {
            disabled: true
          }
        },
        {
          title: "主表名",
          key: "mainTable",
          width: "120px",
          type: FormTypes.input,
          defaultValue: ""
        },
        {
          title: "主表字段",
          key: "mainField",
          width: "120px",
          type: FormTypes.input,
          defaultValue: ""
        }
      ]
    }
  },
  methods: {
    syncTable: function (t) {
      syncAllTable(this,t)
    }
  }

}
</script>

<style scoped>

</style>