<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 "./selectPopup.js"
import PostForm from "@/components/form/PostForm.vue";
import SubmitButton from "@/components/form/SubmitButton.vue";
import TTag from "@/components/ui/TTag.vue";
import DefinitionTable from "@/components/common/DefinitionTable.vue";

const ctx = ctxRef(new Context())
console.log(ctx)
</script>

<template>
	<PopupLayout>
		<header>选择分组</header>
		<div class="select-container">
			<div class="text-[14px] font-[400] leading-[14px] text-[#313131]">选择分组</div>
			<div class="select-form mt-[12px] p-[12px] border border-[#E5E8F2] border-solid rounded-[4px]">
				<PostForm action="$" @success="ctx.success">
					<input type="hidden" name="groupId" :value="ctx.groupId" />
					<div v-if="ctx.groups.length > 0">
						<div class="label-group">
							<a href="" v-for="group in ctx.groups" @click.prevent="ctx.selectGroup(group)">
								<TTag :secondary="group.id != ctx.groupId">{{ group.name }}</TTag>
							</a>
						</div>
						<p class="comment" style="margin-top: 12px; margin-bottom: 0;">点击可已选中要使用的分组。</p>
					</div>
					<div v-else>
						<p class="comment">暂时还没有可以使用的分组。</p>
					</div>
				</PostForm>
			</div>
		</div>
		<!-- <PostForm action="$" @success="ctx.success">
			<input type="hidden" name="groupId" :value="ctx.groupId"/>
			<DefinitionTable>
				<tbody>
				<tr>
					<td class="title">选择分组</td>
					<td>
						<div v-if="ctx.groups.length > 0">
							<div class="label-group">
								<a href="" v-for="group in ctx.groups" @click.prevent="ctx.selectGroup(group)">
									<TTag :secondary="group.id != ctx.groupId">{{ group.name }}</TTag>
								</a>
							</div>
							<p class="comment">点击可已选中要使用的分组。</p>
						</div>
						<div v-else>
							<p class="comment">暂时还没有可以使用的分组。</p>
						</div>
					</td>
				</tr>
				</tbody>
			</DefinitionTable>
			<SubmitButton>确定</SubmitButton>
		</PostForm> -->
	</PopupLayout>
</template>

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