fix: refactoring
This commit is contained in:
1 parent
c827568088
commit
21b59e8272
6 files changed
+15
-14
No files matched your search
Vendored
+2
@@ -18,6 +18,8 @@ declare module 'vue' {
|
|||||||
TCard: typeof import('tdesign-vue-next')['Card']
|
TCard: typeof import('tdesign-vue-next')['Card']
|
||||||
TDialog: typeof import('tdesign-vue-next')['Dialog']
|
TDialog: typeof import('tdesign-vue-next')['Dialog']
|
||||||
TDropdown: typeof import('tdesign-vue-next')['Dropdown']
|
TDropdown: typeof import('tdesign-vue-next')['Dropdown']
|
||||||
|
TForm: typeof import('tdesign-vue-next')['Form']
|
||||||
|
TFormItem: typeof import('tdesign-vue-next')['FormItem']
|
||||||
THeader: typeof import('tdesign-vue-next')['Header']
|
THeader: typeof import('tdesign-vue-next')['Header']
|
||||||
TIcon: typeof import('tdesign-vue-next')['Icon']
|
TIcon: typeof import('tdesign-vue-next')['Icon']
|
||||||
TImageViewer: typeof import('tdesign-vue-next')['ImageViewer']
|
TImageViewer: typeof import('tdesign-vue-next')['ImageViewer']
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ import httpClient from '@/api/httpClient'
|
|||||||
import type { PageResult } from '@/model/base'
|
import type { PageResult } from '@/model/base'
|
||||||
import type { Category,CategorySearchFilter, } from '@/model/category'
|
import type { Category,CategorySearchFilter, } from '@/model/category'
|
||||||
|
|
||||||
export const searchCategoryRequest = (categoryFilterParam:CategorySearchFilter ) => {
|
export const searchCategories = (categoryFilterParam:CategorySearchFilter ) => {
|
||||||
return httpClient.get<PageResult<Category>>('/categories',categoryFilterParam)
|
return httpClient.get<PageResult<Category>>('/categories',categoryFilterParam)
|
||||||
}
|
}
|
||||||
export const searchCategoryListRequest = ( ) => {
|
export const searchCategoryListRequest = ( ) => {
|
||||||
|
|||||||
@@ -36,13 +36,12 @@ import { createCategoryRequest, updateCategoryByIdRequest } from '@/api/category
|
|||||||
import type { FormInstanceFunctions, FormProps } from 'tdesign-vue-next'
|
import type { FormInstanceFunctions, FormProps } from 'tdesign-vue-next'
|
||||||
import { MessagePlugin } from 'tdesign-vue-next'
|
import { MessagePlugin } from 'tdesign-vue-next'
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
isEdit?: Boolean | null
|
headerTitle?: string
|
||||||
headerTitle?: String | null
|
category: Category | null
|
||||||
category: Category | {}
|
|
||||||
}>()
|
}>()
|
||||||
const form = ref<FormInstanceFunctions | null>(null)
|
const form = ref<FormInstanceFunctions | null>(null)
|
||||||
const header = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
const header = computed(() => `${props.category ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
||||||
const confirmBtn = computed(() => (props.isEdit ? '保存' : '确定'))
|
const confirmBtn = computed(() => (props.category ? '保存' : '确定'))
|
||||||
const categoryData: FormProps['data'] = reactive({ name: '', order: 1 })
|
const categoryData: FormProps['data'] = reactive({ name: '', order: 1 })
|
||||||
const rules: FormProps['rules'] = {
|
const rules: FormProps['rules'] = {
|
||||||
name: [
|
name: [
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
+2
-2
@@ -20,7 +20,7 @@ export const asyncRoutes: RouteRecordRaw[] = [
|
|||||||
component: () => import('@/pages/article/index.vue'),
|
component: () => import('@/pages/article/index.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '咨询管理',
|
title: '咨询管理',
|
||||||
icon: 'folder-details'
|
icon: 'collection'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -29,7 +29,7 @@ export const asyncRoutes: RouteRecordRaw[] = [
|
|||||||
component: () => import('@/pages/carousal/index.vue'),
|
component: () => import('@/pages/carousal/index.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
title: '轮播图管理',
|
title: '轮播图管理',
|
||||||
icon: 'system-3'
|
icon: 'image'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ export default defineConfig(({ command, mode }) => {
|
|||||||
'/api': {
|
'/api': {
|
||||||
target: env.VITE_PROXY_ENDPOINT,
|
target: env.VITE_PROXY_ENDPOINT,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(/^\/api/, '')
|
// rewrite: (path) => path.replace(/^\/api/, '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user