数据结构优化
This commit is contained in:
@@ -21,10 +21,11 @@
|
||||
+ 新建分类
|
||||
</button>
|
||||
</div>
|
||||
<select v-model="selectedCategoryId" class="admin-input">
|
||||
<option :value="0">请选择分类</option>
|
||||
<option v-for="cat in categories" :key="cat.id" :value="cat.id">{{ cat.name }}</option>
|
||||
</select>
|
||||
<CustomSelect
|
||||
v-model="selectedCategoryId"
|
||||
:options="categoryOptions"
|
||||
placeholder="请选择分类"
|
||||
/>
|
||||
|
||||
<!-- Quick Create Category -->
|
||||
<div v-if="showCreateCategory" class="admin-card p-3 space-y-2">
|
||||
@@ -49,10 +50,11 @@
|
||||
+ 新建专栏
|
||||
</button>
|
||||
</div>
|
||||
<select v-model="selectedColumnId" class="admin-input">
|
||||
<option :value="0">不选择专栏</option>
|
||||
<option v-for="col in columns" :key="col.id" :value="col.id">{{ col.name }}</option>
|
||||
</select>
|
||||
<CustomSelect
|
||||
v-model="selectedColumnId"
|
||||
:options="columnOptions"
|
||||
placeholder="不选择专栏"
|
||||
/>
|
||||
|
||||
<!-- Quick Create Column -->
|
||||
<div v-if="showCreateColumn" class="admin-card p-3 space-y-2">
|
||||
@@ -132,7 +134,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted } from 'vue'
|
||||
import { ref, watch, onMounted, computed } from 'vue'
|
||||
import {
|
||||
fetchCategories,
|
||||
fetchColumns,
|
||||
@@ -147,6 +149,7 @@ import {
|
||||
Post
|
||||
} from '../../services/api'
|
||||
import { useToast } from '../../composables/useToast'
|
||||
import CustomSelect from '../CustomSelect.vue'
|
||||
|
||||
const props = defineProps<{
|
||||
isOpen: boolean
|
||||
@@ -178,6 +181,22 @@ const newTag = ref({ name: '', slug: '' })
|
||||
|
||||
const saving = ref(false)
|
||||
|
||||
// 计算属性:分类选项
|
||||
const categoryOptions = computed(() => {
|
||||
return [
|
||||
{ value: 0, label: '请选择分类' },
|
||||
...categories.value.map(cat => ({ value: cat.id, label: cat.name }))
|
||||
]
|
||||
})
|
||||
|
||||
// 计算属性:专栏选项
|
||||
const columnOptions = computed(() => {
|
||||
return [
|
||||
{ value: 0, label: '不选择专栏' },
|
||||
...columns.value.map(col => ({ value: col.id, label: col.name }))
|
||||
]
|
||||
})
|
||||
|
||||
const close = () => {
|
||||
emit('update:isOpen', false)
|
||||
showCreateCategory.value = false
|
||||
|
||||
Reference in New Issue
Block a user