Skip to content

Commit

Permalink
支持在上传附件时新建分组
Browse files Browse the repository at this point in the history
  • Loading branch information
LEIYOUSU committed Oct 26, 2024
1 parent 733679d commit 9ebe7e3
Showing 1 changed file with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@ import {
import AttachmentGroupBadge from "./AttachmentGroupBadge.vue";
import AttachmentPolicyBadge from "./AttachmentPolicyBadge.vue";
import AttachmentPolicyEditingModal from "./AttachmentPolicyEditingModal.vue";
import AttachmentGroupEditingModal from "./AttachmentGroupEditingModal.vue";
import UppyUpload from "@/components/upload/UppyUpload.vue";
const emit = defineEmits<{
(event: "close"): void;
}>();
const { groups } = useFetchAttachmentGroup();
const { groups, handleFetchGroups } = useFetchAttachmentGroup();
const { policies, handleFetchPolicies } = useFetchAttachmentPolicy();
const { policyTemplates } = useFetchAttachmentPolicyTemplate();
const modal = ref<InstanceType<typeof VModal> | null>(null);
const selectedGroupName = useLocalStorage("attachment-upload-group", "");
const selectedPolicyName = useLocalStorage("attachment-upload-policy", "");
const policyEditingModal = ref(false);
const groupEditingModal = ref(false);
const policyTemplateNameToCreate = ref();
onMounted(() => {
Expand All @@ -43,13 +46,23 @@ const handleOpenCreateNewPolicyModal = (policyTemplate: PolicyTemplate) => {
policyEditingModal.value = true;
};
const handleOpenCreateNewGroupModal = () => {
groupEditingModal.value = true;
};
const onEditingModalClose = async () => {
await handleFetchPolicies();
policyTemplateNameToCreate.value = undefined;
selectedPolicyName.value = policies.value?.[0].metadata.name;
policyEditingModal.value = false;
};
const onGroupEditingModalClose = async () => {
await handleFetchGroups();
groupEditingModal.value = false;
};
</script>

<template>
<VModal
ref="modal"
Expand Down Expand Up @@ -128,7 +141,15 @@ const onEditingModalClose = async () => {
:is-selected="group.metadata.name === selectedGroupName"
:features="{ actions: false, checkIcon: true }"
@click="selectedGroupName = group.metadata.name"
>
/>

<AttachmentGroupBadge @click="handleOpenCreateNewGroupModal">
<template #text>
<span>{{ $t("core.common.buttons.new") }}</span>
</template>
<template #actions>
<IconAddCircle />
</template>
</AttachmentGroupBadge>
</div>
<UppyUpload
Expand All @@ -155,4 +176,9 @@ const onEditingModalClose = async () => {
:template-name="policyTemplateNameToCreate"
@close="onEditingModalClose"
/>

<AttachmentGroupEditingModal
v-if="groupEditingModal"
@close="onGroupEditingModalClose"
/>
</template>

0 comments on commit 9ebe7e3

Please sign in to comment.