|
@@ -2,7 +2,7 @@
|
|
|
import { onMounted, ref } from 'vue'
|
|
import { onMounted, ref } from 'vue'
|
|
|
import type { Category, CategorySearchFilter } from '@/model/category'
|
|
import type { Category, CategorySearchFilter } from '@/model/category'
|
|
|
import RegularPage from '@/components/RegularPage.vue'
|
|
import RegularPage from '@/components/RegularPage.vue'
|
|
|
-import { searchCategoryRequest, deleteCategoryRequest } from '@/api/category'
|
|
|
|
|
|
|
+import { searchCategories, deleteCategoryRequest } from '@/api/category'
|
|
|
import type { BaseTableColumns } from 'tdesign-vue-next'
|
|
import type { BaseTableColumns } from 'tdesign-vue-next'
|
|
|
import { useSearchable } from '@/composables/useSearchable'
|
|
import { useSearchable } from '@/composables/useSearchable'
|
|
|
import CategoryDialog from '@/pages/category/components/CategoryDialog.vue'
|
|
import CategoryDialog from '@/pages/category/components/CategoryDialog.vue'
|
|
@@ -11,7 +11,7 @@ import { MessagePlugin } from 'tdesign-vue-next'
|
|
|
const { data, loading, pagination, onPageChange, fetchData } = useSearchable<
|
|
const { data, loading, pagination, onPageChange, fetchData } = useSearchable<
|
|
|
CategorySearchFilter,
|
|
CategorySearchFilter,
|
|
|
Category
|
|
Category
|
|
|
->(searchCategoryRequest)
|
|
|
|
|
|
|
+>(searchCategories)
|
|
|
const columns: BaseTableColumns = [
|
|
const columns: BaseTableColumns = [
|
|
|
{
|
|
{
|
|
|
title: '分类名称',
|
|
title: '分类名称',
|
|
@@ -36,7 +36,7 @@ const columns: BaseTableColumns = [
|
|
|
]
|
|
]
|
|
|
const categoryDialogVisible = ref(false)
|
|
const categoryDialogVisible = ref(false)
|
|
|
const isEdit = ref(false)
|
|
const isEdit = ref(false)
|
|
|
-const currentTableData = ref<Category | {}>({})
|
|
|
|
|
|
|
+const currentTableData = ref<Category | null>(null)
|
|
|
onMounted(fetchData)
|
|
onMounted(fetchData)
|
|
|
const editClick = (category: Category) => {
|
|
const editClick = (category: Category) => {
|
|
|
isEdit.value = true
|
|
isEdit.value = true
|
|
@@ -49,8 +49,9 @@ const handleCategoryDialogSuccess = () => {
|
|
|
}
|
|
}
|
|
|
const handleCategoryDialogClosed = () => {
|
|
const handleCategoryDialogClosed = () => {
|
|
|
isEdit.value = false
|
|
isEdit.value = false
|
|
|
- currentTableData.value = {}
|
|
|
|
|
|
|
+ currentTableData.value = null
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
const deleteCategoryClick = async (id: string) => {
|
|
const deleteCategoryClick = async (id: string) => {
|
|
|
await deleteCategoryRequest(id)
|
|
await deleteCategoryRequest(id)
|
|
|
fetchData()
|
|
fetchData()
|
|
@@ -97,7 +98,6 @@ const deleteCategoryClick = async (id: string) => {
|
|
|
</TTable>
|
|
</TTable>
|
|
|
<CategoryDialog
|
|
<CategoryDialog
|
|
|
headerTitle="分类"
|
|
headerTitle="分类"
|
|
|
- :isEdit="isEdit"
|
|
|
|
|
:category="currentTableData"
|
|
:category="currentTableData"
|
|
|
v-model:visible="categoryDialogVisible"
|
|
v-model:visible="categoryDialogVisible"
|
|
|
@closed="handleCategoryDialogClosed"
|
|
@closed="handleCategoryDialogClosed"
|