<template>
	<Dialog
		:options="{
			title: this.tableName,
			size: '2xl'
		}"
	>
		<template #body-content>
			<ObjectList :options="listOptions" />
		</template>
	</Dialog>
</template>
<script>
import { Badge } from 'jingrow-ui';
import ObjectList from '../../ObjectList.vue';
import { h } from 'vue';

export default {
	name: 'DatabaseTableSchemaInfoDialog',
	props: ['tableName', 'columns'],
	components: {
		ObjectList
	},
	computed: {
		listOptions() {
			return {
				data: () => this.columns || [],
				columns: [
					{
						label: '列',
						fieldname: 'column',
						width: 0.5
					},
					{
						label: '数据类型',
						fieldname: 'data_type',
						width: 0.2,
						align: 'center'
					},
					{
						label: '可为空',
						fieldname: 'is_nullable',
						width: 0.2,
						format(value) {
							return value ? '是' : '否';
						},
						align: 'center'
					},
					{
						label: '默认值',
						fieldname: 'default',
						width: 0.3,
						align: 'center'
					}
				]
			};
		}
	}
};
</script>