Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d49b19cea0 | ||
|
|
c59a2587dd | ||
|
|
cda60022be | ||
|
|
f0f2d2b8ed | ||
|
|
d4b7f659a1 | ||
|
|
73fb136b91 | ||
|
|
0558261ba7 | ||
|
|
f8fc42dfec | ||
|
|
21b59e8272 | ||
|
|
3e12b596b2 |
No files matched your search
@@ -1,3 +1,3 @@
|
|||||||
VITE_ENABLE_MOCK=false
|
VITE_ENABLE_MOCK=false
|
||||||
VITE_API_PREFIX=/api
|
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_ENABLE_MOCK=true
|
||||||
VITE_API_PREFIX=/api
|
|
||||||
VITE_PROXY_ENDPOINT=https://bright.yilibili.com
|
|
||||||
|
|
||||||
Vendored
+1
-1
@@ -8,6 +8,7 @@ export {}
|
|||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
Copyright: typeof import('./src/components/Copyright.vue')['default']
|
Copyright: typeof import('./src/components/Copyright.vue')['default']
|
||||||
|
ImagePreviewer: typeof import('./src/components/ImagePreviewer.vue')['default']
|
||||||
ImageUpload: typeof import('./src/components/ImageUpload.vue')['default']
|
ImageUpload: typeof import('./src/components/ImageUpload.vue')['default']
|
||||||
RegularPage: typeof import('./src/components/RegularPage.vue')['default']
|
RegularPage: typeof import('./src/components/RegularPage.vue')['default']
|
||||||
RouterLink: typeof import('vue-router')['RouterLink']
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
@@ -31,7 +32,6 @@ declare module 'vue' {
|
|||||||
TPopconfirm: typeof import('tdesign-vue-next')['Popconfirm']
|
TPopconfirm: typeof import('tdesign-vue-next')['Popconfirm']
|
||||||
TRadioButton: typeof import('tdesign-vue-next')['RadioButton']
|
TRadioButton: typeof import('tdesign-vue-next')['RadioButton']
|
||||||
TRadioGroup: typeof import('tdesign-vue-next')['RadioGroup']
|
TRadioGroup: typeof import('tdesign-vue-next')['RadioGroup']
|
||||||
TSelectInput: typeof import('tdesign-vue-next')['SelectInput']
|
|
||||||
TSpace: typeof import('tdesign-vue-next')['Space']
|
TSpace: typeof import('tdesign-vue-next')['Space']
|
||||||
TTable: typeof import('tdesign-vue-next')['Table']
|
TTable: typeof import('tdesign-vue-next')['Table']
|
||||||
TTag: typeof import('tdesign-vue-next')['Tag']
|
TTag: typeof import('tdesign-vue-next')['Tag']
|
||||||
|
|||||||
+10
-4
@@ -1,19 +1,25 @@
|
|||||||
import httpClient from './httpClient'
|
import httpClient from './httpClient'
|
||||||
import type { CarousalResult, CreateCarousalsRequest, GetCarousalsRequest } from '@/model/carousals'
|
import type {
|
||||||
|
CarousalResult, Carousals,
|
||||||
|
CreateCarousalsRequest,
|
||||||
|
SearchCarousalsFilter,
|
||||||
|
UpdateCarousalsRequest
|
||||||
|
} from '@/model/carousals'
|
||||||
import type { PageResult } from '@/model/base'
|
import type { PageResult } from '@/model/base'
|
||||||
|
import type {UnwrapRef} from "vue";
|
||||||
|
|
||||||
export const createCarousal = (createCarousalsRequest: CreateCarousalsRequest) => {
|
export const createCarousal = (createCarousalsRequest: CreateCarousalsRequest) => {
|
||||||
return httpClient.post<PageResult<CarousalResult>>('/carousals', createCarousalsRequest)
|
return httpClient.post<PageResult<CarousalResult>>('/carousals', createCarousalsRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getCarousalList = (getCarousalsRequest:GetCarousalsRequest) => {
|
export const searchCarousals = (searchCarousalsFilter: SearchCarousalsFilter) => {
|
||||||
return httpClient.get<PageResult<CarousalResult>>('/carousals',getCarousalsRequest)
|
return httpClient.get<PageResult<Carousals>>('/carousals',searchCarousalsFilter)
|
||||||
}
|
}
|
||||||
export const getCarousalItem = (id:string) => {
|
export const getCarousalItem = (id:string) => {
|
||||||
return httpClient.get<CarousalResult>(`/carousals/${id}`)
|
return httpClient.get<CarousalResult>(`/carousals/${id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateCarousalItem = (id:number,updateCarousalsRequest: CreateCarousalsRequest) => {
|
export const updateCarousalItem = (id: UnwrapRef<UpdateCarousalsRequest["id"]> | undefined, updateCarousalsRequest: CreateCarousalsRequest) => {
|
||||||
return httpClient.put<CarousalResult>(`/carousals/${id}`,updateCarousalsRequest)
|
return httpClient.put<CarousalResult>(`/carousals/${id}`,updateCarousalsRequest)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+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 = ( ) => {
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -39,13 +39,13 @@ const props = defineProps({
|
|||||||
|
|
||||||
const emits = defineEmits(['on-success'])
|
const emits = defineEmits(['on-success'])
|
||||||
watch(() => props.imageUrl,(newVal) => {
|
watch(() => props.imageUrl,(newVal) => {
|
||||||
if(newVal){
|
if (!newVal) return
|
||||||
if(newVal.url !== ''){
|
if (newVal.url !== '') {
|
||||||
file1.value = [{ ...newVal }]
|
file1.value = [{...newVal}]
|
||||||
}else{
|
} else {
|
||||||
file1.value = []
|
file1.value = []
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
},{
|
},{
|
||||||
deep:true,
|
deep:true,
|
||||||
immediate:true
|
immediate:true
|
||||||
|
|||||||
@@ -42,4 +42,9 @@ const slots = defineSlots<{
|
|||||||
</TCard>
|
</TCard>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped>
|
||||||
|
:deep(.t-card__body) {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
+13
-9
@@ -1,17 +1,21 @@
|
|||||||
import type { BaseModel } from '@/model/base'
|
import type { AuditBaseModel, BaseModel, Paging } from '@/model/base'
|
||||||
|
|
||||||
export interface CreateCarousalsRequest {
|
export interface CreateCarousalsRequest {
|
||||||
imageUrl:string,
|
imageUrl:string
|
||||||
targetType:string,
|
targetType:string
|
||||||
targetUrl?:string,
|
targetUrl?:string | null
|
||||||
targetId?:string
|
targetId?:string | null
|
||||||
}
|
}
|
||||||
export interface GetCarousalsRequest {
|
export interface Carousals extends AuditBaseModel,CreateCarousalsRequest {
|
||||||
page:number,
|
}
|
||||||
size:number,
|
export interface UpdateCarousalsRequest extends CreateCarousalsRequest{
|
||||||
order?:[string]
|
id?:string
|
||||||
|
}
|
||||||
|
export interface SearchCarousalsFilter extends Partial<Paging> {
|
||||||
|
order?:string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CarousalResult extends BaseModel,CreateCarousalsRequest{
|
export interface CarousalResult extends BaseModel,CreateCarousalsRequest{
|
||||||
status:string
|
status:string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,9 +60,9 @@ const props = defineProps<{
|
|||||||
article?: Article | {}
|
article?: Article | {}
|
||||||
categoryList: Category[] | []
|
categoryList: Category[] | []
|
||||||
}>()
|
}>()
|
||||||
const form = ref<FormInstanceFunctions | null>(null)
|
const formRef = ref<FormInstanceFunctions | null>(null)
|
||||||
const header = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
const headerText = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
||||||
const confirmBtn = computed(() => (props.isEdit ? '保存' : '确定'))
|
const confirmBtnText = computed(() => (props.isEdit ? '保存' : '确定'))
|
||||||
const articleData: FormProps['data'] = reactive({ categoryName: '' })
|
const articleData: FormProps['data'] = reactive({ categoryName: '' })
|
||||||
|
|
||||||
const popupVisible = ref(false)
|
const popupVisible = ref(false)
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<t-dialog
|
<TDialog
|
||||||
width="70%"
|
width="980px"
|
||||||
:header="header"
|
:header="headerText"
|
||||||
:confirmBtn="confirmBtn"
|
:confirmBtn="confirmBtnText"
|
||||||
:closeOnOverlayClick="false"
|
:closeOnOverlayClick="false"
|
||||||
@close="handleCloseDialog"
|
@close="handleCloseDialog"
|
||||||
@confirm="fetchSaveCarousalData"
|
@confirm="fetchSaveCarousalData"
|
||||||
>
|
>
|
||||||
<t-space direction="vertical" style="width: 100%">
|
<TForm v-if="carousalData" ref="formRef" :data="carousalData" :rules="rules" resetType="initial" label-width="100">
|
||||||
<TForm ref="form" :data="carousalData" :rules="rules" resetType="initial" label-width="100">
|
|
||||||
<TFormItem label="轮播图:" name="imageUrl">
|
<TFormItem label="轮播图:" name="imageUrl">
|
||||||
<ImageUpload @on-success="handleSuccessImg" :image-url="imgUrl"/>
|
<ImageUpload @on-success="handleSuccessImg" :image-url="imgUrl"/>
|
||||||
</TFormItem>
|
</TFormItem>
|
||||||
@@ -24,25 +23,35 @@
|
|||||||
<t-input v-model.trim="carousalData.targetUrl" clearable placeholder="请输入网址路径" />
|
<t-input v-model.trim="carousalData.targetUrl" clearable placeholder="请输入网址路径" />
|
||||||
</TFormItem>
|
</TFormItem>
|
||||||
</TForm>
|
</TForm>
|
||||||
</t-space>
|
</TDialog>
|
||||||
</t-dialog>
|
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref, reactive, watch } from 'vue'
|
import { computed, ref, reactive, watch } from 'vue'
|
||||||
import type { FormInstanceFunctions, FormProps } from 'tdesign-vue-next'
|
import type { FormInstanceFunctions } from 'tdesign-vue-next'
|
||||||
import ImageUpload from '@/components/ImageUpload.vue'
|
import ImageUpload from '@/components/ImageUpload.vue'
|
||||||
import { createCarousal, updateCarousalItem } from '@/api/carousal'
|
import { createCarousal, updateCarousalItem } from '@/api/carousal'
|
||||||
const props = defineProps<{
|
import type {CreateCarousalsRequest, UpdateCarousalsRequest} from "@/model/carousals";
|
||||||
isEdit?: Boolean | null
|
const props = withDefaults(defineProps<{
|
||||||
headerTitle?: String | null
|
isEdit?: boolean | null
|
||||||
carousal: {} | number
|
headerTitle?: string | null
|
||||||
|
carousal: CreateCarousalsRequest
|
||||||
|
}>(),{
|
||||||
|
headerTitle:''
|
||||||
|
})
|
||||||
|
const emit = defineEmits<{
|
||||||
|
success: [void]
|
||||||
}>()
|
}>()
|
||||||
const emit = defineEmits(['success'])
|
const formRef = ref<FormInstanceFunctions | null>(null)
|
||||||
const form = ref<FormInstanceFunctions | null>(null)
|
const headerText = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
||||||
const header = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
const confirmBtnText = computed(() => (props.isEdit ? '保存' : '确定'))
|
||||||
const formType = computed(() => `${props.isEdit ? 'update' : 'add'}`)
|
const formType = computed(() => `${props.isEdit ? 'update' : 'add'}`)
|
||||||
const confirmBtn = computed(() => (props.isEdit ? '保存' : '确定'))
|
|
||||||
const carousalData: FormProps['data'] = ref({})
|
const carousalData = ref<UpdateCarousalsRequest>({
|
||||||
|
imageUrl: '',
|
||||||
|
targetType: 'article',
|
||||||
|
targetId: '',
|
||||||
|
targetUrl: '',
|
||||||
|
})
|
||||||
const imgUrl = ref({})
|
const imgUrl = ref({})
|
||||||
const rules = computed(() => {
|
const rules = computed(() => {
|
||||||
const commonRules = {
|
const commonRules = {
|
||||||
@@ -83,18 +92,17 @@ const typeOption = reactive([
|
|||||||
])
|
])
|
||||||
const handleFormTypeData = () => {
|
const handleFormTypeData = () => {
|
||||||
if (carousalData.value.targetType === 'article') {
|
if (carousalData.value.targetType === 'article') {
|
||||||
delete carousalData.value.targetUrl
|
carousalData.value.targetUrl = null
|
||||||
} else if (carousalData.value.targetType === 'url') {
|
} else if (carousalData.value.targetType === 'url') {
|
||||||
delete carousalData.value.targetId
|
carousalData.value.targetId = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.carousal,
|
() => props.carousal,
|
||||||
(newClassify) => {
|
(newClassify: CreateCarousalsRequest) => {
|
||||||
carousalData.value = Object.assign({}, newClassify)
|
carousalData.value = Object.assign({}, newClassify)
|
||||||
const carousalObj = Object.assign({},newClassify)
|
const carousalObj = Object.assign({},newClassify)
|
||||||
// imgUrl.value.url = carousalObj.imageUrl || ''
|
|
||||||
imgUrl.value = { url: carousalObj.imageUrl || '' }
|
imgUrl.value = { url: carousalObj.imageUrl || '' }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -104,48 +112,31 @@ watch(
|
|||||||
)
|
)
|
||||||
const fetchSaveCarousalData = async () => {
|
const fetchSaveCarousalData = async () => {
|
||||||
/* TODO: 保存分类数据 */
|
/* TODO: 保存分类数据 */
|
||||||
if (form.value) {
|
if (formRef.value) {
|
||||||
const valid = await form.value.validate()
|
const valid = await formRef.value.validate()
|
||||||
// console.log(valid,'valid')
|
|
||||||
if (valid && typeof valid === 'boolean') {
|
if (valid && typeof valid === 'boolean') {
|
||||||
/* TODO: 校验通过保存分类数据 */
|
/* TODO: 校验通过保存分类数据 */
|
||||||
handleFormTypeData()
|
handleFormTypeData()
|
||||||
// console.log(formType.value,'formType')
|
formType.value === 'add' ? await createCarousalData() : await updateCarousalData()
|
||||||
let res
|
|
||||||
switch (formType.value){
|
|
||||||
case 'create':
|
|
||||||
res = await createCarousal(carousalData.value)
|
|
||||||
emit('success')
|
|
||||||
break;
|
|
||||||
case 'update':
|
|
||||||
const fieldsToKeep = ["imageUrl", "targetType", "targetUrl", "targetId"];
|
|
||||||
const requestObj = {};
|
|
||||||
|
|
||||||
for (const field of fieldsToKeep) {
|
|
||||||
if (carousalData.value[field]!== null && carousalData.value[field]!== undefined) {
|
|
||||||
requestObj[field] = carousalData.value[field];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
handleFormTypeData()
|
|
||||||
res = await updateCarousalItem(carousalData.value.id,requestObj)
|
|
||||||
emit('success')
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
res = await createCarousal(carousalData.value)
|
|
||||||
emit('success')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// const createCarousalApi = createCarousal(carousalData.value)
|
|
||||||
// console.log(createCarousalApi,'createCarousalApi')
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const createCarousalData = async () => {
|
||||||
|
await createCarousal(carousalData.value)
|
||||||
|
emit('success')
|
||||||
|
}
|
||||||
|
const updateCarousalData = async () => {
|
||||||
|
handleFormTypeData()
|
||||||
|
const requestObj: CreateCarousalsRequest = {imageUrl: carousalData.value.imageUrl,targetType:carousalData.value.targetType,targetUrl:carousalData.value.targetUrl,targetId:carousalData.value.targetId}
|
||||||
|
await updateCarousalItem(carousalData.value.id, requestObj)
|
||||||
|
emit('success')
|
||||||
|
}
|
||||||
const handleCloseDialog = () => {
|
const handleCloseDialog = () => {
|
||||||
// 数据&&规则校验结果重置
|
// 数据&&规则校验结果重置
|
||||||
if (form.value) {
|
if (formRef.value) {
|
||||||
form.value.reset()
|
formRef.value.reset()
|
||||||
form.value.clearValidate()
|
formRef.value.clearValidate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
+51
-118
@@ -1,84 +1,79 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import RegularPage from '@/components/RegularPage.vue'
|
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 type { BaseTableColumns } from 'tdesign-vue-next'
|
||||||
import CarousalDialog from '@/pages/carousal/components/CarousalDialog.vue'
|
import CarousalDialog from '@/pages/carousal/components/CarousalDialog.vue'
|
||||||
import { activeCarousal, deleteCarousal, getCarousalList, inactiveCarousal } from '@/api/carousal'
|
import { activeCarousal, deleteCarousal, searchCarousals, inactiveCarousal } from '@/api/carousal'
|
||||||
import { BrowseIcon } from 'tdesign-icons-vue-next'
|
import type {
|
||||||
import type { CarousalResult } from '@/model/carousals'
|
CarousalResult, Carousals,
|
||||||
|
CreateCarousalsRequest,
|
||||||
|
SearchCarousalsFilter,
|
||||||
|
} from '@/model/carousals'
|
||||||
|
import ImagePreviewer from '@/components/ImagePreviewer.vue'
|
||||||
|
import { useSearchable } from '@/composables/useSearchable'
|
||||||
|
|
||||||
const columns: BaseTableColumns = [
|
const columns: BaseTableColumns = [
|
||||||
{
|
{
|
||||||
title: 'ID',
|
title: 'ID',
|
||||||
colKey: 'id',
|
colKey: 'id',
|
||||||
width: 100,
|
width: 100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '轮播图',
|
title: '轮播图',
|
||||||
colKey: 'imageUrl',
|
colKey: 'imageUrl',
|
||||||
width: 100,
|
width: 100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '显示状态',
|
title: '显示状态',
|
||||||
colKey: 'status',
|
colKey: 'status',
|
||||||
width: 100,
|
width: 100
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
colKey: 'operation',
|
colKey: 'operation',
|
||||||
width: 100,
|
width: 100
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
const loading = ref<boolean>(false)
|
|
||||||
const data = ref<CarousalResult[]>([])
|
const { loading, data, pagination, fetchData, onPageChange } = useSearchable<SearchCarousalsFilter,Carousals>(searchCarousals)
|
||||||
const pagination = reactive<{page:number,size:number,total:number}>({
|
onMounted(fetchData)
|
||||||
page: 1,
|
|
||||||
size: 10,
|
|
||||||
total:0
|
|
||||||
})
|
|
||||||
const query = reactive<{page:number,size:number}>({
|
|
||||||
page:1,
|
|
||||||
size:10,
|
|
||||||
})
|
|
||||||
const carousalDialogVisible = ref<boolean>(false)
|
const carousalDialogVisible = ref<boolean>(false)
|
||||||
const isEdit = ref<boolean>(false)
|
const isEdit = ref<boolean>(false)
|
||||||
const currentTableData = ref<CarousalResult | {}>({})
|
const currentTableData = ref<CreateCarousalsRequest>({
|
||||||
const fetchSaveCarousalData = async () :Promise<void> => {
|
imageUrl: '',
|
||||||
/* TODO: 获取轮播图表格数据 */
|
targetType: ''
|
||||||
query.page = pagination.page
|
})
|
||||||
query.size = pagination.size
|
const handleEdit = (row: CarousalResult): void => {
|
||||||
const getCarousalListApi = await getCarousalList(query)
|
|
||||||
data.value = getCarousalListApi.data
|
|
||||||
pagination.total = getCarousalListApi.pagination.total
|
|
||||||
}
|
|
||||||
onMounted(fetchSaveCarousalData)
|
|
||||||
const editClick = (row:object):void => {
|
|
||||||
isEdit.value = true
|
isEdit.value = true
|
||||||
currentTableData.value = Object.assign({}, row)
|
currentTableData.value = Object.assign({}, row)
|
||||||
carousalDialogVisible.value = true
|
carousalDialogVisible.value = true
|
||||||
}
|
}
|
||||||
const showClick = async (res:CarousalResult):Promise<void> => {
|
const handleShow = async (res: CarousalResult): Promise<void> => {
|
||||||
if (res.status === 'active'){
|
if (res.status === 'active') {
|
||||||
await inactiveCarousal(res.id)
|
await inactiveCarousal(res.id)
|
||||||
} else {
|
} else {
|
||||||
await activeCarousal(res.id)
|
await activeCarousal(res.id)
|
||||||
}
|
}
|
||||||
await fetchSaveCarousalData()
|
await fetchData()
|
||||||
}
|
}
|
||||||
const delClick = async (row:CarousalResult) :Promise<void>=> {
|
const handleDelete = async (row: CarousalResult): Promise<void> => {
|
||||||
await deleteCarousal(row.id)
|
await deleteCarousal(row.id)
|
||||||
await fetchSaveCarousalData()
|
await fetchData()
|
||||||
}
|
}
|
||||||
const handleCreateCarousal = () :void => {
|
const handleCreateCarousal = (): void => {
|
||||||
isEdit.value = false
|
isEdit.value = false
|
||||||
carousalDialogVisible.value = true
|
carousalDialogVisible.value = true
|
||||||
currentTableData.value = {}
|
currentTableData.value = {
|
||||||
|
imageUrl: '',
|
||||||
|
targetId: '',
|
||||||
|
targetType: '',
|
||||||
|
targetUrl: '',
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const onPageChange = ():void => {
|
const handleSuccessDialog = async (): Promise<void> => {
|
||||||
/* TODO: 分页切换 */
|
await fetchData()
|
||||||
}
|
|
||||||
const handleSuccessDialog = async () :Promise<void> => {
|
|
||||||
await fetchSaveCarousalData()
|
|
||||||
carousalDialogVisible.value = false
|
carousalDialogVisible.value = false
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -91,8 +86,8 @@ const handleSuccessDialog = async () :Promise<void> => {
|
|||||||
<TTable
|
<TTable
|
||||||
class="w-full h-full"
|
class="w-full h-full"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
height="92%"
|
|
||||||
table-layout="auto"
|
table-layout="auto"
|
||||||
|
height="92%"
|
||||||
:data="data"
|
:data="data"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
@@ -105,36 +100,29 @@ const handleSuccessDialog = async () :Promise<void> => {
|
|||||||
onChange: onPageChange
|
onChange: onPageChange
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<template #imageUrl="{row}">
|
<template #imageUrl="{ row }">
|
||||||
<div class="tdesign-demo-image-viewer__base">
|
<ImagePreviewer :url="row.imageUrl"/>
|
||||||
<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>
|
|
||||||
</t-image-viewer>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
<template #status="{row}">
|
<template #status="{ row }">
|
||||||
<TSpace>
|
<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>
|
</TSpace>
|
||||||
</template>
|
</template>
|
||||||
<template #roles="{ row }">
|
<template #roles="{ row }">
|
||||||
<TSpace>
|
<TSpace>
|
||||||
<TTag v-for="role in row.roles" :key="role.id" theme="success" variant="light">{{
|
<TTag v-for="role in row.roles" :key="role.id" theme="success" variant="light">{{
|
||||||
role.label
|
role.label
|
||||||
}}</TTag>
|
}}</TTag>
|
||||||
</TSpace>
|
</TSpace>
|
||||||
</template>
|
</template>
|
||||||
<template #operation="{ row }">
|
<template #operation="{ row }">
|
||||||
<TButton variant="text" size="small" theme="primary" @click="editClick(row)">编辑</TButton>
|
<TButton variant="text" size="small" theme="primary" @click="handleEdit(row)">编辑</TButton>
|
||||||
<TButton variant="text" size="small" theme="primary" @click="showClick(row)">{{ row.status === 'active' ? '关闭显示' : '开启显示'}}</TButton>
|
<TButton variant="text" size="small" theme="primary" @click="handleShow(row)">{{
|
||||||
<TButton variant="text" size="small" theme="danger" @click="delClick(row)">删除</TButton>
|
row.status === 'active' ? '关闭显示' : '开启显示'
|
||||||
|
}}</TButton>
|
||||||
|
<TButton variant="text" size="small" theme="danger" @click="handleDelete(row)">删除</TButton>
|
||||||
</template>
|
</template>
|
||||||
</TTable>
|
</TTable>
|
||||||
<CarousalDialog
|
<CarousalDialog
|
||||||
@@ -148,60 +136,5 @@ const handleSuccessDialog = async () :Promise<void> => {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<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>
|
</style>
|
||||||
@@ -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 formRef = ref<FormInstanceFunctions | null>(null)
|
||||||
const header = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
const headerText = computed(() => `${props.category ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
||||||
const confirmBtn = computed(() => (props.isEdit ? '保存' : '确定'))
|
const confirmBtnText = 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'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in new issue
Block a user