提交 5c8e8b81 编写于 作者: View Design's avatar View Design

更新合集

上级 106195e1
<template>
<UDropdown class="flex flex-grow" :items="actionItems">
<UButton
color="gray"
variant="ghost"
icon="i-heroicons-ellipsis-horizontal"
/>
</UDropdown>
<ILibraryEdit :id="id" ref="refEdit" />
</template>
<script setup>
const props = defineProps({
id: {
type: [String, Number],
default: ''
}
})
const actionItems = [
[
{
label: '编辑合集',
icon: 'i-heroicons-pencil-square',
click: () => {
handleOpen()
}
},
{
label: '删除合集',
icon: 'i-heroicons-trash'
}
]
]
const refEdit = ref(null)
function handleOpen () {
refEdit.value.open()
}
</script>
<template> <template>
<UModal v-model="$isLibraryCreateOpen" :ui="{ width: 'w-96 sm:max-w-screen-md' }"> <UModal
:model-value="!id ? $isLibraryCreateOpen : updateVisible"
@update:modelValue="handleCloseModal"
:ui="{ width: 'w-96 sm:max-w-screen-md' }"
>
<UCard :ui="{ ring: '', divide: 'divide-y divide-gray-100 dark:divide-gray-800' }"> <UCard :ui="{ ring: '', divide: 'divide-y divide-gray-100 dark:divide-gray-800' }">
<template #header> <template #header>
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<div class="text-xl">创建合集</div> <div class="text-xl" v-if="!id">创建合集</div>
<div class="text-xl" v-else>更新合集</div>
<UButton <UButton
leading-icon="i-heroicons-x-mark-20-solid" leading-icon="i-heroicons-x-mark-20-solid"
color="gray" color="gray"
...@@ -39,12 +44,21 @@ ...@@ -39,12 +44,21 @@
<template #footer> <template #footer>
<div class="flex justify-end"> <div class="flex justify-end">
<UButton <UButton
v-if="!id"
size="md" size="md"
label="创建" label="创建"
:loading="loading" :loading="loading"
:disabled="!title" :disabled="!title"
@click="handleCreate" @click="handleCreate"
/> />
<UButton
v-else
size="md"
label="更新"
:loading="loading"
:disabled="!title"
@click="handleUpdate"
/>
</div> </div>
</template> </template>
</UCard> </UCard>
...@@ -54,11 +68,19 @@ ...@@ -54,11 +68,19 @@
const { $isLibraryCreateOpen } = storeToRefs(useLibraryStore()) const { $isLibraryCreateOpen } = storeToRefs(useLibraryStore())
const { $closeLibraryCreate, $getCollection } = useLibraryStore() const { $closeLibraryCreate, $getCollection } = useLibraryStore()
const { setOrUpdateCollection } = useCollectionRequest() const { setOrUpdateCollection } = useCollectionRequest()
const props = defineProps({
id: {
type: [String, Number],
default: ''
}
})
const updateVisible = ref(false)
const title = ref('') const title = ref('')
const description = ref('') const description = ref('')
const loading = ref(false) const loading = ref(false)
function handleClose () { function handleClose () {
$closeLibraryCreate() if (!props.id) $closeLibraryCreate()
else updateVisible.value = false
} }
async function handleCreate () { async function handleCreate () {
if (loading.value) return if (loading.value) return
...@@ -72,4 +94,18 @@ async function handleCreate () { ...@@ -72,4 +94,18 @@ async function handleCreate () {
$closeLibraryCreate() $closeLibraryCreate()
$getCollection() $getCollection()
} }
function handleCloseModal () {
if (!props.id) $isLibraryCreateOpen.value = false
else updateVisible.value = false
}
function handleUpdate () {
}
function openUpdate () {
updateVisible.value = true
// todo 获取合集数据
}
defineExpose({
openUpdate
})
</script> </script>
<template>
<ILibraryCreate :id="id" ref="refCreate" />
</template>
<script setup>
defineProps({
id: {
type: [String, Number],
default: ''
}
})
const refCreate = ref(null)
function open () {
refCreate.value.openUpdate()
}
defineExpose({
open
})
</script>
\ No newline at end of file
...@@ -21,13 +21,18 @@ ...@@ -21,13 +21,18 @@
</div> </div>
</template> </template>
</div> </div>
<div class="flex"> <div class="flex flex-grow justify-end items-center gap-4">
<UInput <div class="flex">
v-model="searchQuery" <IActionCollect :id="collectId" />
icon="i-heroicons-magnifying-glass-20-solid" </div>
placeholder="搜索你的主题..." <div class="flex">
size="md" <UInput
/> v-model="searchQuery"
icon="i-heroicons-magnifying-glass-20-solid"
placeholder="搜索你的主题..."
size="md"
/>
</div>
</div> </div>
</div> </div>
<div v-if="description" class="text-gray-500 ml-12 mt-2">{{ description }}</div> <div v-if="description" class="text-gray-500 ml-12 mt-2">{{ description }}</div>
...@@ -48,6 +53,10 @@ defineProps({ ...@@ -48,6 +53,10 @@ defineProps({
count: { count: {
type: Number, type: Number,
default: 0 default: 0
},
collectId: {
type: [String, Number],
default: ''
} }
}) })
const searchQuery = ref('') const searchQuery = ref('')
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
:collect="currentCollect.name" :collect="currentCollect.name"
:description="currentCollect.description" :description="currentCollect.description"
:count="currentCollect.record_count" :count="currentCollect.record_count"
:collect-id="currentCollect.id"
/> />
<div class="container max-w-screen-lg flex flex-col p-6"> <div class="container max-w-screen-lg flex flex-col p-6">
<div class="flex gap-10"> <div class="flex gap-10">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册