<script setup>
// Copyright 2024 FlexCDN root@flexcdn.cn. All rights reserved. Official site: https://flexcdn.cn .

import ctxRef from "@/utils/ctx_ref.js"
import Context from "./createRecords.js"
import Menu from "@/views/ns/domains/batch/@menu.vue";
import TCheckboxBinary from "@/components/ui/TCheckboxBinary.vue";
import SubmitButton from "@/components/form/SubmitButton.vue";
import PostForm from "@/components/form/PostForm.vue";
import TTextarea from "@/components/ui/TTextarea.vue";
import NSCreateRecordsTable from "@/components/ns/NSCreateRecordsTable.vue";
import DefinitionTable from "@/components/common/DefinitionTable.vue";

const ctx = ctxRef(new Context())

</script>

<template>
	<Menu :ctx="ctx"></Menu>

	<PostForm action="$" @success="ctx.success">
		<DefinitionTable>
			<tbody>
			<tr>
				<td class="title">域名 *</td>
				<td>
					<TTextarea rows="15" name="names" placeholder="每行一个域名" autofocus class="w-full"></TTextarea>
				</td>
			</tr>
			<tr>
				<td>解析记录 *</td>
				<td>
					<NSCreateRecordsTable :v-types="ctx.types" :v-default-ttl="ctx.defaultTTL"></NSCreateRecordsTable>
				</td>
			</tr>
			<tr>
				<td>删除原有同名记录</td>
				<td>
					<TCheckboxBinary name="removeOld"></TCheckboxBinary>
					<p class="comment">选中后，在导入新的记录之前，先删除域名中的同名且同类型记录。</p>
				</td>
			</tr>
			<tr>
				<td>清空原有记录</td>
				<td>
					<TCheckboxBinary name="removeAll"></TCheckboxBinary>
					<p class="comment">选中后，在导入新的记录之前，先清空域名中的所有记录。</p>
				</td>
			</tr>
			</tbody>
		</DefinitionTable>
		<SubmitButton></SubmitButton>
	</PostForm>
</template>

<style lang="postcss" scoped>
</style>