Compare commits
9
Commits
c827568088
...
024eef682e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
024eef682e | ||
|
|
73fb136b91 | ||
|
|
0558261ba7 | ||
|
|
f8fc42dfec | ||
|
|
21b59e8272 | ||
|
|
3e12b596b2 | ||
|
|
0e521db11e | ||
|
|
df4d5848a2 | ||
|
|
7e407f68a6 |
No files matched your search
@@ -1,3 +1,3 @@
|
||||
VITE_ENABLE_MOCK=false
|
||||
VITE_API_PREFIX=/api
|
||||
VITE_PROXY_ENDPOINT=http://localhost:8000
|
||||
VITE_PROXY_ENDPOINT=https://bright.yilibili.com/api
|
||||
+1
-4
@@ -1,4 +1 @@
|
||||
VITE_ENABLE_MOCK=false
|
||||
VITE_API_PREFIX=/api
|
||||
VITE_PROXY_ENDPOINT=https://bright.yilibili.com
|
||||
|
||||
VITE_ENABLE_MOCK=true
|
||||
Vendored
+4
@@ -8,6 +8,7 @@ export {}
|
||||
declare module 'vue' {
|
||||
export interface GlobalComponents {
|
||||
Copyright: typeof import('./src/components/Copyright.vue')['default']
|
||||
ImagePreviewer: typeof import('./src/components/ImagePreviewer.vue')['default']
|
||||
ImageUpload: typeof import('./src/components/ImageUpload.vue')['default']
|
||||
RegularPage: typeof import('./src/components/RegularPage.vue')['default']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
@@ -18,8 +19,11 @@ declare module 'vue' {
|
||||
TCard: typeof import('tdesign-vue-next')['Card']
|
||||
TDialog: typeof import('tdesign-vue-next')['Dialog']
|
||||
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']
|
||||
TIcon: typeof import('tdesign-vue-next')['Icon']
|
||||
TImage: typeof import('tdesign-vue-next')['Image']
|
||||
TImageViewer: typeof import('tdesign-vue-next')['ImageViewer']
|
||||
TInput: typeof import('tdesign-vue-next')['Input']
|
||||
TInputNumber: typeof import('tdesign-vue-next')['InputNumber']
|
||||
|
||||
+9
-8
@@ -1,19 +1,20 @@
|
||||
import httpClient from './httpClient'
|
||||
import type { CreateCarousalsRequest, GetCarousalsRequest } from '@/model/carousals'
|
||||
import type { CarousalResult, CreateCarousalsRequest, SearchCarousalsFilter } from '@/model/carousals'
|
||||
import type { PageResult } from '@/model/base'
|
||||
|
||||
export const createCarousal = (createCarousalsRequest: CreateCarousalsRequest) => {
|
||||
return httpClient.post('/carousals', createCarousalsRequest)
|
||||
return httpClient.post<PageResult<CarousalResult>>('/carousals', createCarousalsRequest)
|
||||
}
|
||||
|
||||
export const getCarousalList = (getCarousalsRequest:GetCarousalsRequest) => {
|
||||
return httpClient.get('/carousals',getCarousalsRequest)
|
||||
export const searchCarousals = (searchCarousalsFilter: SearchCarousalsFilter) => {
|
||||
return httpClient.get<PageResult<CarousalResult>>('/carousals',searchCarousalsFilter)
|
||||
}
|
||||
export const getCarousalItem = (id:string) => {
|
||||
return httpClient.get(`/carousals/${id}`)
|
||||
return httpClient.get<CarousalResult>(`/carousals/${id}`)
|
||||
}
|
||||
|
||||
export const updateCarousalItem = (id:number,updateCarousalsRequest: CreateCarousalsRequest) => {
|
||||
return httpClient.put(`/carousals/${id}`,updateCarousalsRequest)
|
||||
return httpClient.put<CarousalResult>(`/carousals/${id}`,updateCarousalsRequest)
|
||||
}
|
||||
|
||||
export const deleteCarousal = (id:string | number) => {
|
||||
@@ -21,9 +22,9 @@ export const deleteCarousal = (id:string | number) => {
|
||||
}
|
||||
|
||||
export const activeCarousal = (id: string | number) => {
|
||||
return httpClient.put(`/carousals/${id}/active`)
|
||||
return httpClient.put<CarousalResult>(`/carousals/${id}/active`)
|
||||
}
|
||||
|
||||
export const inactiveCarousal = (id: string | number ) => {
|
||||
return httpClient.put(`/carousals/${id}/inactive`)
|
||||
return httpClient.put<CarousalResult>(`/carousals/${id}/inactive`)
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@ import httpClient from '@/api/httpClient'
|
||||
import type { PageResult } from '@/model/base'
|
||||
import type { Category,CategorySearchFilter, } from '@/model/category'
|
||||
|
||||
export const searchCategoryRequest = (categoryFilterParam:CategorySearchFilter ) => {
|
||||
export const searchCategories = (categoryFilterParam:CategorySearchFilter ) => {
|
||||
return httpClient.get<PageResult<Category>>('/categories',categoryFilterParam)
|
||||
}
|
||||
export const searchCategoryListRequest = ( ) => {
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<template>
|
||||
<TImageViewer :images="[url]">
|
||||
<template #trigger="{ open }">
|
||||
<div class="w-[100px] h-[100px] relative flex justify-center items-center rounded overflow-hidden">
|
||||
<img alt="test" :src="url" class="w-full h-full object-contain" />
|
||||
<div class="transition-all hover:opacity-100 opacity-0 w-full h-full absolute top-0 left-0 bg-[#00000099] text-white flex items-center justify-center" @click="open">
|
||||
<span><BrowseIcon size="1.4em" /> 预览</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</TImageViewer>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
|
||||
import { BrowseIcon } from 'tdesign-icons-vue-next'
|
||||
|
||||
defineProps<{
|
||||
url: string,
|
||||
}>()
|
||||
|
||||
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -10,10 +10,10 @@ const sizeLimit = ref<UploadProps['sizeLimit']>({
|
||||
unit: 'MB',
|
||||
});
|
||||
const file1 = ref<UploadProps['value']>([]);
|
||||
const disabled = ref(false);
|
||||
const autoUpload = ref(true);
|
||||
const showImageFileName = ref(true);
|
||||
const uploadAllFilesInOneRequest = ref(false);
|
||||
const disabled = ref<boolean>(false);
|
||||
const autoUpload = ref<boolean>(true);
|
||||
const showImageFileName = ref<boolean>(true);
|
||||
const uploadAllFilesInOneRequest = ref<boolean>(false);
|
||||
const handleFail: UploadProps['onFail'] = ({ file }) => {
|
||||
MessagePlugin.error(`文件 ${file.name} 上传失败`);
|
||||
};
|
||||
@@ -36,15 +36,16 @@ const props = defineProps({
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const emits = defineEmits(['on-success'])
|
||||
watch(() => props.imageUrl,(newVal) => {
|
||||
if(newVal){
|
||||
if(newVal.url !== ''){
|
||||
file1.value = [{ ...newVal }]
|
||||
}else{
|
||||
if (!newVal) return
|
||||
if (newVal.url !== '') {
|
||||
file1.value = [{...newVal}]
|
||||
} else {
|
||||
file1.value = []
|
||||
}
|
||||
}
|
||||
|
||||
},{
|
||||
deep:true,
|
||||
immediate:true
|
||||
|
||||
@@ -42,4 +42,9 @@ const slots = defineSlots<{
|
||||
</TCard>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
<style scoped>
|
||||
:deep(.t-card__body) {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -1,12 +1,17 @@
|
||||
import type { BaseModel } from '@/model/base'
|
||||
|
||||
export interface CreateCarousalsRequest {
|
||||
imageUrl:string,
|
||||
targetType:string,
|
||||
targetUrl?:string,
|
||||
targetId?:string
|
||||
}
|
||||
export interface GetCarousalsRequest {
|
||||
export interface SearchCarousalsFilter {
|
||||
page:number,
|
||||
size:number,
|
||||
order?:[string]
|
||||
}
|
||||
|
||||
export interface CarousalResult extends BaseModel,CreateCarousalsRequest{
|
||||
status:string
|
||||
}
|
||||
@@ -60,9 +60,9 @@ const props = defineProps<{
|
||||
article?: Article | {}
|
||||
categoryList: Category[] | []
|
||||
}>()
|
||||
const form = ref<FormInstanceFunctions | null>(null)
|
||||
const header = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
||||
const confirmBtn = computed(() => (props.isEdit ? '保存' : '确定'))
|
||||
const formRef = ref<FormInstanceFunctions | null>(null)
|
||||
const headerText = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
||||
const confirmBtnText = computed(() => (props.isEdit ? '保存' : '确定'))
|
||||
const articleData: FormProps['data'] = reactive({ categoryName: '' })
|
||||
|
||||
const popupVisible = ref(false)
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
<template>
|
||||
<t-dialog
|
||||
width="70%"
|
||||
:header="header"
|
||||
:confirmBtn="confirmBtn"
|
||||
<TDialog
|
||||
width="980px"
|
||||
:header="headerText"
|
||||
:confirmBtn="confirmBtnText"
|
||||
:closeOnOverlayClick="false"
|
||||
@close="handleCloseDialog"
|
||||
@confirm="fetchSaveCarousalData"
|
||||
>
|
||||
<t-space direction="vertical" style="width: 100%">
|
||||
<TForm ref="form" :data="carousalData" :rules="rules" resetType="initial" label-width="100">
|
||||
<TForm v-if="carousalData" ref="formRef" :data="carousalData" :rules="rules" resetType="initial" label-width="100">
|
||||
<TFormItem label="轮播图:" name="imageUrl">
|
||||
<ImageUpload @on-success="handleSuccessImg" :image-url="imgUrl"/>
|
||||
</TFormItem>
|
||||
@@ -24,25 +23,33 @@
|
||||
<t-input v-model.trim="carousalData.targetUrl" clearable placeholder="请输入网址路径" />
|
||||
</TFormItem>
|
||||
</TForm>
|
||||
</t-space>
|
||||
</t-dialog>
|
||||
</TDialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, reactive, watch } from 'vue'
|
||||
import type { FormInstanceFunctions, FormProps } from 'tdesign-vue-next'
|
||||
import ImageUpload from '@/components/ImageUpload.vue'
|
||||
import { createCarousal, updateCarousalItem } from '@/api/carousal'
|
||||
// Todo: 改为ts方式
|
||||
const props = defineProps<{
|
||||
isEdit?: Boolean | null
|
||||
headerTitle?: String | null
|
||||
carousal: {} | number
|
||||
}>()
|
||||
const emit = defineEmits(['success'])
|
||||
const form = ref<FormInstanceFunctions | null>(null)
|
||||
const header = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
||||
const emit = defineEmits<{
|
||||
success: [string]
|
||||
}>()
|
||||
const formRef = ref<FormInstanceFunctions | null>(null)
|
||||
const headerText = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
||||
const confirmBtnText = computed(() => (props.isEdit ? '保存' : '确定'))
|
||||
const formType = computed(() => `${props.isEdit ? 'update' : 'add'}`)
|
||||
const confirmBtn = computed(() => (props.isEdit ? '保存' : '确定'))
|
||||
const carousalData: FormProps['data'] = ref({})
|
||||
|
||||
const carousalData = ref<FormProps['data']>({
|
||||
imageUrl: '',
|
||||
targetType: 'article',
|
||||
targetId: '',
|
||||
targetUrl: '',
|
||||
})
|
||||
const imgUrl = ref({})
|
||||
const rules = computed(() => {
|
||||
const commonRules = {
|
||||
@@ -104,14 +111,15 @@ watch(
|
||||
)
|
||||
const fetchSaveCarousalData = async () => {
|
||||
/* TODO: 保存分类数据 */
|
||||
if (form.value) {
|
||||
const valid = await form.value.validate()
|
||||
if (formRef.value) {
|
||||
const valid = await formRef.value.validate()
|
||||
// console.log(valid,'valid')
|
||||
if (valid && typeof valid === 'boolean') {
|
||||
/* TODO: 校验通过保存分类数据 */
|
||||
handleFormTypeData()
|
||||
// console.log(formType.value,'formType')
|
||||
let res
|
||||
|
||||
switch (formType.value){
|
||||
case 'create':
|
||||
res = await createCarousal(carousalData.value)
|
||||
@@ -143,9 +151,9 @@ const fetchSaveCarousalData = async () => {
|
||||
}
|
||||
const handleCloseDialog = () => {
|
||||
// 数据&&规则校验结果重置
|
||||
if (form.value) {
|
||||
form.value.reset()
|
||||
form.value.clearValidate()
|
||||
if (formRef.value) {
|
||||
formRef.value.reset()
|
||||
formRef.value.clearValidate()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
+40
-117
@@ -1,84 +1,69 @@
|
||||
<script setup lang="ts">
|
||||
import RegularPage from '@/components/RegularPage.vue'
|
||||
import { onMounted, ref, reactive } from 'vue'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import type { BaseTableColumns } from 'tdesign-vue-next'
|
||||
import CarousalDialog from '@/pages/carousal/components/CarousalDialog.vue'
|
||||
import { activeCarousal, deleteCarousal, getCarousalList, inactiveCarousal } from '@/api/carousal'
|
||||
import { BrowseIcon } from 'tdesign-icons-vue-next'
|
||||
import { activeCarousal, deleteCarousal, searchCarousals, inactiveCarousal } from '@/api/carousal'
|
||||
import type { CarousalResult, SearchCarousalsFilter } from '@/model/carousals'
|
||||
import ImagePreviewer from '@/components/ImagePreviewer.vue'
|
||||
import { useSearchable } from '@/composables/useSearchable'
|
||||
|
||||
const columns: BaseTableColumns = [
|
||||
{
|
||||
title: 'ID',
|
||||
colKey: 'id',
|
||||
width: 100,
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '轮播图',
|
||||
colKey: 'imageUrl',
|
||||
width: 100,
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '显示状态',
|
||||
colKey: 'status',
|
||||
width: 100,
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
colKey: 'operation',
|
||||
width: 100,
|
||||
width: 100
|
||||
}
|
||||
]
|
||||
const loading = ref(false)
|
||||
const data = ref([])
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
size: 10,
|
||||
total:0
|
||||
})
|
||||
const query = reactive({
|
||||
page:1,
|
||||
size:10,
|
||||
})
|
||||
const carousalDialogVisible = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const currentTableData = ref<{}>({})
|
||||
const fetchSaveCarousalData = async () => {
|
||||
/* TODO: 获取轮播图表格数据 */
|
||||
query.page = pagination.page
|
||||
query.size = pagination.size
|
||||
const getCarousalListApi = await getCarousalList(query)
|
||||
data.value = getCarousalListApi.data
|
||||
pagination.total = getCarousalListApi.pagination.total
|
||||
}
|
||||
onMounted(fetchSaveCarousalData)
|
||||
const editClick = (row:object) => {
|
||||
|
||||
const { loading, data, pagination, fetchData, onPageChange } = useSearchable<CarousalResult, SearchCarousalsFilter>(searchCarousals)
|
||||
onMounted(fetchData)
|
||||
|
||||
|
||||
const carousalDialogVisible = ref<boolean>(false)
|
||||
const isEdit = ref<boolean>(false)
|
||||
const currentTableData = ref<CarousalResult | null>(null)
|
||||
|
||||
|
||||
const handleEdit = (row: object): void => {
|
||||
isEdit.value = true
|
||||
currentTableData.value = Object.assign({}, row)
|
||||
carousalDialogVisible.value = true
|
||||
}
|
||||
const showClick = async (res:object) => {
|
||||
if (res.status === 'active'){
|
||||
const handleShow = async (res: CarousalResult): Promise<void> => {
|
||||
if (res.status === 'active') {
|
||||
await inactiveCarousal(res.id)
|
||||
} else {
|
||||
await activeCarousal(res.id)
|
||||
}
|
||||
await fetchSaveCarousalData()
|
||||
await fetchData()
|
||||
}
|
||||
const delClick = async (row:object) => {
|
||||
console.log(row,'删除')
|
||||
const handleDelete = async (row: CarousalResult): Promise<void> => {
|
||||
await deleteCarousal(row.id)
|
||||
await fetchSaveCarousalData()
|
||||
await fetchData()
|
||||
}
|
||||
const handleCreateCarousal = () => {
|
||||
const handleCreateCarousal = (): void => {
|
||||
isEdit.value = false
|
||||
carousalDialogVisible.value = true
|
||||
currentTableData.value = {}
|
||||
}
|
||||
const onPageChange = () => {
|
||||
/* TODO: 分页切换 */
|
||||
}
|
||||
const handleSuccessDialog = async () => {
|
||||
await fetchSaveCarousalData()
|
||||
const handleSuccessDialog = async (): Promise<void> => {
|
||||
await fetchData()
|
||||
carousalDialogVisible.value = false
|
||||
}
|
||||
</script>
|
||||
@@ -91,8 +76,8 @@ const handleSuccessDialog = async () => {
|
||||
<TTable
|
||||
class="w-full h-full"
|
||||
row-key="id"
|
||||
height="92%"
|
||||
table-layout="auto"
|
||||
height="92%"
|
||||
:data="data"
|
||||
:loading="loading"
|
||||
:columns="columns"
|
||||
@@ -105,23 +90,14 @@ const handleSuccessDialog = async () => {
|
||||
onChange: onPageChange
|
||||
}"
|
||||
>
|
||||
<template #imageUrl="{row}">
|
||||
<div class="tdesign-demo-image-viewer__base">
|
||||
<t-image-viewer :images="[row.imageUrl]">
|
||||
<template #trigger="{ open }">
|
||||
<div class="tdesign-demo-image-viewer__ui-image">
|
||||
<img alt="test" :src="row.imageUrl" class="tdesign-demo-image-viewer__ui-image--img" />
|
||||
<div class="tdesign-demo-image-viewer__ui-image--hover" @click="open">
|
||||
<span><BrowseIcon size="1.4em" /> 预览</span>
|
||||
</div>
|
||||
</div>
|
||||
<template #imageUrl="{ row }">
|
||||
<ImagePreviewer :url="row.imageUrl"/>
|
||||
</template>
|
||||
</t-image-viewer>
|
||||
</div>
|
||||
</template>
|
||||
<template #status="{row}">
|
||||
<template #status="{ row }">
|
||||
<TSpace>
|
||||
<TTag :theme="row.status === 'active' ? 'success' : 'danger'" variant="light">{{row.status === 'active' ? '显示中' : '已关闭'}}</TTag>
|
||||
<TTag :theme="row.status === 'active' ? 'success' : 'danger'" variant="light">{{
|
||||
row.status === 'active' ? '显示中' : '已关闭'
|
||||
}}</TTag>
|
||||
</TSpace>
|
||||
</template>
|
||||
<template #roles="{ row }">
|
||||
@@ -132,9 +108,11 @@ const handleSuccessDialog = async () => {
|
||||
</TSpace>
|
||||
</template>
|
||||
<template #operation="{ row }">
|
||||
<TButton variant="text" size="small" theme="primary" @click="editClick(row)">编辑</TButton>
|
||||
<TButton variant="text" size="small" theme="primary" @click="showClick(row)">{{ row.status === 'active' ? '关闭显示' : '开启显示'}}</TButton>
|
||||
<TButton variant="text" size="small" theme="danger" @click="delClick(row)">删除</TButton>
|
||||
<TButton variant="text" size="small" theme="primary" @click="handleEdit(row)">编辑</TButton>
|
||||
<TButton variant="text" size="small" theme="primary" @click="handleShow(row)">{{
|
||||
row.status === 'active' ? '关闭显示' : '开启显示'
|
||||
}}</TButton>
|
||||
<TButton variant="text" size="small" theme="danger" @click="handleDelete(row)">删除</TButton>
|
||||
</template>
|
||||
</TTable>
|
||||
<CarousalDialog
|
||||
@@ -148,60 +126,5 @@ const handleSuccessDialog = async () => {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
:deep(.t-card__body) {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
.tdesign-demo-image-viewer__ui-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: inline-flex;
|
||||
position: relative;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
border-radius: var(--td-radius-small);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.tdesign-demo-image-viewer__ui-image--hover {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
opacity: 0;
|
||||
background-color: rgba(0, 0, 0, 0.6);
|
||||
color: var(--td-text-color-anti);
|
||||
line-height: 22px;
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
.tdesign-demo-image-viewer__ui-image:hover .tdesign-demo-image-viewer__ui-image--hover {
|
||||
opacity: 1;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tdesign-demo-image-viewer__ui-image--img {
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
cursor: pointer;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
|
||||
.tdesign-demo-image-viewer__ui-image--icons .tdesign-demo-icon {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tdesign-demo-image-viewer__base {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border: 4px solid var(--td-bg-color-secondarycontainer);
|
||||
border-radius: var(--td-radius-medium);
|
||||
}
|
||||
</style>
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<t-dialog
|
||||
width="40%"
|
||||
:header="header"
|
||||
:confirmBtn="confirmBtn"
|
||||
:header="headerText"
|
||||
:confirmBtn="confirmBtnText"
|
||||
:closeOnOverlayClick="false"
|
||||
@close="handleCloseDialog"
|
||||
@confirm="SaveCategoryData"
|
||||
@@ -36,13 +36,12 @@ import { createCategoryRequest, updateCategoryByIdRequest } from '@/api/category
|
||||
import type { FormInstanceFunctions, FormProps } from 'tdesign-vue-next'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
const props = defineProps<{
|
||||
isEdit?: Boolean | null
|
||||
headerTitle?: String | null
|
||||
category: Category | {}
|
||||
headerTitle?: string
|
||||
category: Category | null
|
||||
}>()
|
||||
const form = ref<FormInstanceFunctions | null>(null)
|
||||
const header = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
||||
const confirmBtn = computed(() => (props.isEdit ? '保存' : '确定'))
|
||||
const formRef = ref<FormInstanceFunctions | null>(null)
|
||||
const headerText = computed(() => `${props.category ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
||||
const confirmBtnText = computed(() => (props.category ? '保存' : '确定'))
|
||||
const categoryData: FormProps['data'] = reactive({ name: '', order: 1 })
|
||||
const rules: FormProps['rules'] = {
|
||||
name: [
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { onMounted, ref } from 'vue'
|
||||
import type { Category, CategorySearchFilter } from '@/model/category'
|
||||
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 { useSearchable } from '@/composables/useSearchable'
|
||||
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<
|
||||
CategorySearchFilter,
|
||||
Category
|
||||
>(searchCategoryRequest)
|
||||
>(searchCategories)
|
||||
const columns: BaseTableColumns = [
|
||||
{
|
||||
title: '分类名称',
|
||||
@@ -36,7 +36,7 @@ const columns: BaseTableColumns = [
|
||||
]
|
||||
const categoryDialogVisible = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const currentTableData = ref<Category | {}>({})
|
||||
const currentTableData = ref<Category | null>(null)
|
||||
onMounted(fetchData)
|
||||
const editClick = (category: Category) => {
|
||||
isEdit.value = true
|
||||
@@ -49,8 +49,9 @@ const handleCategoryDialogSuccess = () => {
|
||||
}
|
||||
const handleCategoryDialogClosed = () => {
|
||||
isEdit.value = false
|
||||
currentTableData.value = {}
|
||||
currentTableData.value = null
|
||||
}
|
||||
|
||||
const deleteCategoryClick = async (id: string) => {
|
||||
await deleteCategoryRequest(id)
|
||||
fetchData()
|
||||
@@ -97,7 +98,6 @@ const deleteCategoryClick = async (id: string) => {
|
||||
</TTable>
|
||||
<CategoryDialog
|
||||
headerTitle="分类"
|
||||
:isEdit="isEdit"
|
||||
:category="currentTableData"
|
||||
v-model:visible="categoryDialogVisible"
|
||||
@closed="handleCategoryDialogClosed"
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ export const asyncRoutes: RouteRecordRaw[] = [
|
||||
component: () => import('@/pages/article/index.vue'),
|
||||
meta: {
|
||||
title: '咨询管理',
|
||||
icon: 'folder-details'
|
||||
icon: 'collection'
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -29,7 +29,7 @@ export const asyncRoutes: RouteRecordRaw[] = [
|
||||
component: () => import('@/pages/carousal/index.vue'),
|
||||
meta: {
|
||||
title: '轮播图管理',
|
||||
icon: 'system-3'
|
||||
icon: 'image'
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ export default defineConfig(({ command, mode }) => {
|
||||
'/api': {
|
||||
target: env.VITE_PROXY_ENDPOINT,
|
||||
changeOrigin: true,
|
||||
rewrite: (path) => path.replace(/^\/api/, '')
|
||||
// rewrite: (path) => path.replace(/^\/api/, '')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user