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

import PopupLayout from "@/layouts/PopupLayout.vue";
import ctxRef from "@/utils/ctx_ref.js"
import Context from "./updateIPPopup.js"
import SubmitButton from "@/components/form/SubmitButton.vue";
import DatetimeInput from "@/components/common/DatetimeInput.vue";
import TInputText from "@/components/ui/TInputText.vue";
import PostForm from "@/components/form/PostForm.vue";
import MoreOptionsIndicator from "@/components/common/MoreOptionsIndicator.vue";
import DefinitionTable from "@/components/common/DefinitionTable.vue";

const ctx = ctxRef(new Context())

</script>

<template>
	<PopupLayout>
		<header>修改IP</header>

		<PostForm action="$" @success="ctx.success">
			<input type="hidden" name="itemId" :value="ctx.item.id"/>
			<DefinitionTable>
				<tbody>
				<tr>
					<td>IP或IP段 *</td>
					<td>
						<TInputText name="value" maxlength="64" placeholder="x.x.x.x" autofocus class="w-full" v-model="ctx.item.value"/>
						<p class="comment">支持IPv4和IPv6；支持三种格式：单个IP（比如192.168.1.100）、IP范围（比如192.168.1.1-192.168.1.255）、CIDR（比如192.168.1.1/24）。</p>
					</td>
				</tr>
				<tr>
					<td class="title">过期时间</td>
					<td>
						<DatetimeInput :v-name="'expiredAt'" :v-timestamp="ctx.item.expiredAt"></DatetimeInput>
						<p class="comment">在加入名单某一段时间后会失效，留空表示永久有效。</p>
					</td>
				</tr>
				<tr>
					<td colspan="2"><MoreOptionsIndicator></MoreOptionsIndicator></td>
				</tr>
				</tbody>
				<tbody v-show="ctx.moreOptionsVisible">
				<tr>
					<td>备注</td>
					<td><TInputText name="reason" maxlength="100" v-model="ctx.item.reason" class="w-full"/></td>
				</tr>
				</tbody>
			</DefinitionTable>
			<SubmitButton></SubmitButton>
		</PostForm>
	</PopupLayout>
</template>

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