114 lines
2.7 KiB
Vue
114 lines
2.7 KiB
Vue
<script setup lang="ts">
|
|
import RegularPage from '@/components/RegularPage.vue'
|
|
import { onMounted, ref, reactive } from 'vue'
|
|
import type { BaseTableColumns } from 'tdesign-vue-next'
|
|
import type { Classify } from '@/model/classify'
|
|
import ClassifyDialog from '@/pages/carousal/components/CarousalDialog.vue'
|
|
import { getCarousalList } from '@/api/carousal'
|
|
|
|
const columns: BaseTableColumns = [
|
|
{
|
|
title: 'ID',
|
|
colKey: 'id',
|
|
width: 100
|
|
},
|
|
{
|
|
title: '轮播图',
|
|
colKey: 'imageUrl',
|
|
width: 100
|
|
},
|
|
{
|
|
title: '显示状态',
|
|
colKey: 'status',
|
|
width: 100
|
|
},
|
|
{
|
|
title: '操作',
|
|
colKey: 'operation',
|
|
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 classifyDialogVisible = ref(false)
|
|
const isEdit = ref(false)
|
|
const currentTableData = ref<{}>({})
|
|
const fetchClassifyTableData = async () => {
|
|
/* TODO: 获取轮播图表格数据 */
|
|
query.page = pagination.page
|
|
query.size = pagination.size
|
|
const getCarousalListApi = await getCarousalList(query)
|
|
currentTableData.value = getCarousalListApi.data
|
|
pagination.total = getCarousalListApi.pagination.total
|
|
}
|
|
onMounted(fetchClassifyTableData)
|
|
const editClick = (classify: Classify) => {
|
|
isEdit.value = true
|
|
currentTableData.value = classify
|
|
console.log(classify)
|
|
|
|
classifyDialogVisible.value = true
|
|
}
|
|
const onPageChange = () => {
|
|
/* TODO: 分页切换 */
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<RegularPage title="轮播图管理">
|
|
<template #right-area>
|
|
<TButton @click="classifyDialogVisible = true">创建轮播图</TButton>
|
|
</template>
|
|
<TTable
|
|
class="w-full h-full"
|
|
row-key="id"
|
|
height="92%"
|
|
table-layout="auto"
|
|
:data="data"
|
|
:loading="loading"
|
|
:columns="columns"
|
|
cell-empty-content="-"
|
|
:paginationAffixedBottom="true"
|
|
:pagination="{
|
|
total: pagination.total,
|
|
current: pagination.page,
|
|
pageSize: pagination.size,
|
|
onChange: onPageChange
|
|
}"
|
|
>
|
|
<template #roles="{ row }">
|
|
<TSpace>
|
|
<TTag v-for="role in row.roles" :key="role.id" theme="success" variant="light">{{
|
|
role.label
|
|
}}</TTag>
|
|
</TSpace>
|
|
</template>
|
|
<template #operation="{ row }">
|
|
<TButton variant="text" size="small" theme="primary" @click="editClick(row)">编辑</TButton>
|
|
</template>
|
|
</TTable>
|
|
<ClassifyDialog
|
|
:classify="currentTableData"
|
|
v-model:visible="classifyDialogVisible"
|
|
:isEdit="isEdit"
|
|
headerTitle="轮播图"
|
|
></ClassifyDialog>
|
|
</RegularPage>
|
|
</template>
|
|
|
|
<style scoped>
|
|
:deep(.t-card__body) {
|
|
flex: 1;
|
|
min-height: 0;
|
|
}
|
|
</style>
|