Merge branch 'main' into feature/31-carousal
This commit is contained in:
commit
df4d5848a2
22 files changed
+1197
-155
No files matched your search
@@ -0,0 +1,178 @@
|
||||
<template>
|
||||
<t-dialog
|
||||
width="60%"
|
||||
:header="header"
|
||||
:confirmBtn="confirmBtn"
|
||||
:closeOnOverlayClick="false"
|
||||
@close="handleCloseDialog"
|
||||
@confirm="saveArticleData"
|
||||
>
|
||||
<t-space direction="vertical" style="width: 100%">
|
||||
<TForm ref="form" :data="articleData" :rules="rules" resetType="initial">
|
||||
<TFormItem label="咨询标题:" name="title" help="名称长度大于2个汉字,小于120个汉字">
|
||||
<t-input v-model.trim="articleData.title" clearable placeholder="请输入咨询标题" />
|
||||
</TFormItem>
|
||||
<TFormItem label="咨询分类:" name="categoryId">
|
||||
<t-select-input
|
||||
:value="articleData.categoryName"
|
||||
placeholder="请选择咨询分类"
|
||||
:popup-visible="popupVisible"
|
||||
:popup-props="{ overlayInnerStyle: { padding: '6px' } }"
|
||||
clearable
|
||||
allow-input
|
||||
@popup-visible-change="onPopupVisibleChange"
|
||||
@clear="onClear"
|
||||
@input-change="onInputChange"
|
||||
>
|
||||
<template #panel>
|
||||
<ul class="flex flex-col gap-1 p-0">
|
||||
<li
|
||||
v-for="item in categoryList"
|
||||
:key="item.id"
|
||||
class="block rounded-sm cursor-pointer px-2 py-0.5 text-gray-900 transition-colors duration-200 whitespace-nowrap overflow-hidden text-ellipsis hover:bg-gray-200"
|
||||
@click="() => onOptionClick({ id: item.id, value: item.name })"
|
||||
>
|
||||
{{ item.name }}
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
<template #suffixIcon>
|
||||
<chevron-down-icon />
|
||||
</template>
|
||||
</t-select-input>
|
||||
</TFormItem>
|
||||
<TFormItem label="内容:" name="content"> </TFormItem>
|
||||
</TForm>
|
||||
</t-space>
|
||||
</t-dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import type { Category } from '@/model/category'
|
||||
import type { Article } from '@/model/article'
|
||||
import { computed, ref, reactive, watch } from 'vue'
|
||||
import type { FormInstanceFunctions, FormProps, SelectInputProps } from 'tdesign-vue-next'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { ChevronDownIcon } from 'tdesign-icons-vue-next'
|
||||
import { updateArticlesByIdRequest, createArticlesRequest } from '@/api/article'
|
||||
const props = defineProps<{
|
||||
isEdit?: Boolean | null
|
||||
headerTitle?: String | null
|
||||
article?: Article | {}
|
||||
categoryList: Category[] | []
|
||||
}>()
|
||||
const form = ref<FormInstanceFunctions | null>(null)
|
||||
const header = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
||||
const confirmBtn = computed(() => (props.isEdit ? '保存' : '确定'))
|
||||
const articleData: FormProps['data'] = reactive({ categoryName: '' })
|
||||
|
||||
const popupVisible = ref(false)
|
||||
const onOptionClick = (item: { id: string; value: string }) => {
|
||||
articleData.categoryName = item.value
|
||||
articleData.categoryId = item.id
|
||||
// 选中后立即关闭浮层
|
||||
popupVisible.value = false
|
||||
}
|
||||
const onClear: SelectInputProps['onClear'] = () => {
|
||||
articleData.categoryId = ''
|
||||
articleData.categoryName = undefined
|
||||
}
|
||||
const onPopupVisibleChange: SelectInputProps['onPopupVisibleChange'] = (val) => {
|
||||
popupVisible.value = val
|
||||
}
|
||||
const onInputChange: SelectInputProps['onInputChange'] = (val, context) => {
|
||||
// 过滤功能
|
||||
console.log(val, context)
|
||||
}
|
||||
const rules: FormProps['rules'] = {
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
message: '咨询标题不能为空',
|
||||
type: 'error',
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
message: '咨询标题不能为空',
|
||||
type: 'error',
|
||||
trigger: 'change'
|
||||
},
|
||||
{
|
||||
whitespace: true,
|
||||
message: '咨询标题不能为空'
|
||||
},
|
||||
{
|
||||
min: 4,
|
||||
message: '输入汉字长度应在2到120之间',
|
||||
type: 'error',
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
max: 240,
|
||||
message: '输入汉字长度应在2到120之间',
|
||||
type: 'error',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
code: [
|
||||
{
|
||||
required: true,
|
||||
message: '咨询分类不能为空',
|
||||
type: 'error',
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
message: '咨询分类不能为空',
|
||||
type: 'error',
|
||||
trigger: 'change'
|
||||
},
|
||||
{
|
||||
whitespace: true,
|
||||
message: '咨询分类不能为空'
|
||||
}
|
||||
],
|
||||
content: [
|
||||
{
|
||||
max: 20000,
|
||||
message: '内容不超过10000字',
|
||||
type: 'error',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
}
|
||||
watch(
|
||||
() => props.article,
|
||||
(newArticleData) => {
|
||||
Object.assign(articleData, newArticleData)
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
const emit = defineEmits<{
|
||||
success: [void]
|
||||
onInputChange: [void]
|
||||
}>()
|
||||
const saveArticleData = async () => {
|
||||
if (form.value) {
|
||||
const valid = await form.value.validate()
|
||||
if (valid && typeof valid === 'boolean') {
|
||||
const { title, categoryId, content, id } = articleData
|
||||
if (!props.isEdit) {
|
||||
await createArticlesRequest({ title, categoryId, content })
|
||||
} else {
|
||||
await updateArticlesByIdRequest(id, { title, categoryId, content })
|
||||
}
|
||||
MessagePlugin.success(`${props.isEdit ? '编辑' : '创建'}咨询成功`)
|
||||
emit('success')
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
const handleCloseDialog = () => {
|
||||
// 数据&&规则校验结果重置
|
||||
if (form.value) {
|
||||
form.value.reset()
|
||||
form.value.clearValidate()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,165 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, watch } from 'vue'
|
||||
import type { Article, ArticleSearchFilter } from '@/model/article'
|
||||
import RegularPage from '@/components/RegularPage.vue'
|
||||
import {
|
||||
searchArticlesRequest,
|
||||
deleteArticlesRequest,
|
||||
publishArticlesByIdRequest,
|
||||
closeArticlesByIdRequest
|
||||
} from '@/api/article'
|
||||
import { searchCategoryListRequest } from '@/api/category'
|
||||
import type { Category } from '@/model/category'
|
||||
import type { BaseTableColumns } from 'tdesign-vue-next'
|
||||
import { useSearchable } from '@/composables/useSearchable'
|
||||
import ArticleDialog from '@/pages/article/components/ArticleDialog.vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
const { data, loading, pagination, onPageChange, fetchData } = useSearchable<
|
||||
ArticleSearchFilter,
|
||||
Article
|
||||
>(searchArticlesRequest)
|
||||
const statusArticleListMap = {
|
||||
draft: { label: '草稿', theme: 'default' },
|
||||
published: { label: '已发布', theme: 'success' },
|
||||
closed: { label: '已关闭', theme: 'danger' }
|
||||
}
|
||||
const columns: BaseTableColumns = [
|
||||
{
|
||||
title: '咨询标题',
|
||||
colKey: 'title',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '分类',
|
||||
colKey: 'categoryName',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
colKey: 'status',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
colKey: 'createdTime',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
colKey: 'operation',
|
||||
width: 100
|
||||
}
|
||||
]
|
||||
const articleDialogVisble = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const currentTableData = ref<Article | {}>({})
|
||||
const categoryList = ref<Category[]>([])
|
||||
onMounted(fetchData)
|
||||
watch(articleDialogVisble, (newValue) => {
|
||||
if (newValue) {
|
||||
searchCategoryList()
|
||||
}
|
||||
})
|
||||
const searchCategoryList = async () => {
|
||||
try {
|
||||
const res = await searchCategoryListRequest()
|
||||
categoryList.value = res
|
||||
} catch (error) {
|
||||
categoryList.value = []
|
||||
}
|
||||
}
|
||||
const editClick = (article: Article) => {
|
||||
isEdit.value = true
|
||||
currentTableData.value = article
|
||||
articleDialogVisble.value = true
|
||||
}
|
||||
const handleArticleDialogSuccess = () => {
|
||||
fetchData()
|
||||
articleDialogVisble.value = false
|
||||
}
|
||||
const handleArticleDialogClosed = () => {
|
||||
isEdit.value = false
|
||||
currentTableData.value = {}
|
||||
}
|
||||
const toggleArticleStatus = async (article: Article) => {
|
||||
if (article.status === 'published') {
|
||||
await closeArticlesByIdRequest(article.id)
|
||||
} else {
|
||||
await publishArticlesByIdRequest(article.id)
|
||||
}
|
||||
fetchData()
|
||||
MessagePlugin.success(`${article.status === 'published' ? '关闭' : '发布'}咨询成功`)
|
||||
}
|
||||
const deleteCategoryClick = async (article: Article) => {
|
||||
await deleteArticlesRequest(article.id)
|
||||
fetchData()
|
||||
MessagePlugin.success('删除咨询成功')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RegularPage title="咨询管理">
|
||||
<template #right-area>
|
||||
<TButton @click="articleDialogVisble = 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 #categoryName="{ row }">
|
||||
{{ row.category.name }}
|
||||
</template>
|
||||
<template #status="{ row }">
|
||||
<t-tag :theme="statusArticleListMap[row.status as keyof typeof statusArticleListMap].theme">
|
||||
{{ statusArticleListMap[row.status as keyof typeof statusArticleListMap].label }}
|
||||
</t-tag>
|
||||
</template>
|
||||
<template #operation="{ row }">
|
||||
<TSpace :size="1">
|
||||
<TButton variant="text" size="small" theme="primary" @click="editClick(row)"
|
||||
>编辑</TButton
|
||||
>
|
||||
<TButton variant="text" size="small" theme="warning" @click="toggleArticleStatus(row)">{{
|
||||
row.status === 'published' ? '关闭' : '发布'
|
||||
}}</TButton>
|
||||
<t-popconfirm
|
||||
theme="default"
|
||||
content="确认删除此项分类吗"
|
||||
@confirm="deleteCategoryClick(row)"
|
||||
>
|
||||
<TButton variant="text" size="small" theme="danger">删除</TButton>
|
||||
</t-popconfirm>
|
||||
</TSpace>
|
||||
</template>
|
||||
</TTable>
|
||||
<ArticleDialog
|
||||
headerTitle="咨询"
|
||||
:isEdit="isEdit"
|
||||
:article="currentTableData"
|
||||
:categoryList="categoryList"
|
||||
v-model:visible="articleDialogVisble"
|
||||
@closed="handleArticleDialogClosed"
|
||||
@success="handleArticleDialogSuccess"
|
||||
></ArticleDialog>
|
||||
</RegularPage>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
:deep(.t-card__body) {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
</style>
|
||||
+36
-18
@@ -5,36 +5,45 @@
|
||||
:confirmBtn="confirmBtn"
|
||||
:closeOnOverlayClick="false"
|
||||
@close="handleCloseDialog"
|
||||
@confirm="fetchSaveClassifyData"
|
||||
@confirm="SaveCategoryData"
|
||||
>
|
||||
<t-space direction="vertical" style="width: 100%">
|
||||
<TForm ref="form" :data="classifyData" :rules="rules" resetType="initial">
|
||||
<TForm ref="form" :data="categoryData" :rules="rules" resetType="initial">
|
||||
<TFormItem label="分类名称:" name="name" help="名称长度小于5个汉字,大于2个汉字">
|
||||
<t-input v-model.trim="classifyData.name" clearable placeholder="请输入分类名称" />
|
||||
<t-input v-model.trim="categoryData.name" clearable placeholder="请输入分类名称" />
|
||||
</TFormItem>
|
||||
<TFormItem label="分类编号:" name="numbering" help="编号由大于4个字符的英文字母组成">
|
||||
<t-input v-model.trim="classifyData.numbering" clearable placeholder="请输入分类编号" />
|
||||
<TFormItem label="分类编号:" name="code" help="编号由大于4个字符的英文字母组成">
|
||||
<t-input v-model.trim="categoryData.code" clearable placeholder="请输入分类编号" />
|
||||
</TFormItem>
|
||||
<TFormItem label="排序级别:" name="sort" help="排序级别由正整数组成">
|
||||
<t-input v-model.trim="classifyData.sort" clearable placeholder="请输入排序级别" />
|
||||
<TFormItem label="排序级别:" name="order" help="排序级别由正整数组成">
|
||||
<t-input-number
|
||||
:min="0"
|
||||
name="order"
|
||||
theme="normal"
|
||||
class="!w-full"
|
||||
placeholder="请输入排序级别"
|
||||
v-model.trim="categoryData.order"
|
||||
></t-input-number>
|
||||
</TFormItem>
|
||||
</TForm>
|
||||
</t-space>
|
||||
</t-dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import type { Classify } from '@/model/classify'
|
||||
import type { Category } from '@/model/category'
|
||||
import { computed, ref, reactive, watch } from 'vue'
|
||||
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
|
||||
classify: Classify | {}
|
||||
category: Category | {}
|
||||
}>()
|
||||
const form = ref<FormInstanceFunctions | null>(null)
|
||||
const header = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
||||
const confirmBtn = computed(() => (props.isEdit ? '保存' : '确定'))
|
||||
const classifyData: FormProps['data'] = reactive({ name: '', sort: 0 })
|
||||
const categoryData: FormProps['data'] = reactive({ name: '', order: 1 })
|
||||
const rules: FormProps['rules'] = {
|
||||
name: [
|
||||
{
|
||||
@@ -66,7 +75,7 @@ const rules: FormProps['rules'] = {
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
numbering: [
|
||||
code: [
|
||||
{
|
||||
required: true,
|
||||
message: '分类编号不能为空',
|
||||
@@ -96,7 +105,7 @@ const rules: FormProps['rules'] = {
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sort: [
|
||||
order: [
|
||||
{
|
||||
required: true,
|
||||
message: '排序级别不能为空',
|
||||
@@ -122,18 +131,27 @@ const rules: FormProps['rules'] = {
|
||||
]
|
||||
}
|
||||
watch(
|
||||
() => props.classify,
|
||||
(newClassify) => {
|
||||
Object.assign(classifyData, newClassify)
|
||||
() => props.category,
|
||||
(newCategory) => {
|
||||
Object.assign(categoryData, newCategory)
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
const fetchSaveClassifyData = async () => {
|
||||
/* TODO: 保存分类数据 */
|
||||
const emit = defineEmits<{
|
||||
success: [void]
|
||||
}>()
|
||||
const SaveCategoryData = async () => {
|
||||
if (form.value) {
|
||||
const valid = await form.value.validate()
|
||||
if (valid && typeof valid === 'boolean') {
|
||||
/* TODO: 校验通过保存分类数据 */
|
||||
const { code, name, order, id } = categoryData
|
||||
if (!props.isEdit) {
|
||||
await createCategoryRequest({ code, name, order })
|
||||
} else {
|
||||
await updateCategoryByIdRequest(id, { code, name, order })
|
||||
}
|
||||
MessagePlugin.success(`${props.isEdit ? '编辑' : '创建'}分类成功`)
|
||||
emit('success')
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<script setup lang="ts">
|
||||
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 type { BaseTableColumns } from 'tdesign-vue-next'
|
||||
import { useSearchable } from '@/composables/useSearchable'
|
||||
import CategoryDialog from '@/pages/category/components/CategoryDialog.vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
|
||||
const { data, loading, pagination, onPageChange, fetchData } = useSearchable<
|
||||
CategorySearchFilter,
|
||||
Category
|
||||
>(searchCategoryRequest)
|
||||
const columns: BaseTableColumns = [
|
||||
{
|
||||
title: '分类名称',
|
||||
colKey: 'name',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '分类编号',
|
||||
colKey: 'code',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
colKey: 'order',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
colKey: 'operation',
|
||||
width: 100
|
||||
}
|
||||
]
|
||||
const categoryDialogVisible = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const currentTableData = ref<Category | {}>({})
|
||||
onMounted(fetchData)
|
||||
const editClick = (category: Category) => {
|
||||
isEdit.value = true
|
||||
currentTableData.value = category
|
||||
categoryDialogVisible.value = true
|
||||
}
|
||||
const handleCategoryDialogSuccess = () => {
|
||||
fetchData()
|
||||
categoryDialogVisible.value = false
|
||||
}
|
||||
const handleCategoryDialogClosed = () => {
|
||||
isEdit.value = false
|
||||
currentTableData.value = {}
|
||||
}
|
||||
const deleteCategoryClick = async (id: string) => {
|
||||
await deleteCategoryRequest(id)
|
||||
fetchData()
|
||||
MessagePlugin.success('删除分类成功')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<RegularPage title="分类管理">
|
||||
<template #right-area>
|
||||
<TButton @click="categoryDialogVisible = 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 #operation="{ row }">
|
||||
<TSpace :size="1">
|
||||
<TButton variant="text" size="small" theme="primary" @click="editClick(row)"
|
||||
>编辑</TButton
|
||||
>
|
||||
<t-popconfirm
|
||||
theme="default"
|
||||
content="确认删除此项分类吗"
|
||||
@confirm="deleteCategoryClick(row.id)"
|
||||
>
|
||||
<TButton variant="text" size="small" theme="danger">删除</TButton>
|
||||
</t-popconfirm>
|
||||
</TSpace>
|
||||
</template>
|
||||
</TTable>
|
||||
<CategoryDialog
|
||||
headerTitle="分类"
|
||||
:isEdit="isEdit"
|
||||
:category="currentTableData"
|
||||
v-model:visible="categoryDialogVisible"
|
||||
@closed="handleCategoryDialogClosed"
|
||||
@success="handleCategoryDialogSuccess"
|
||||
></CategoryDialog>
|
||||
</RegularPage>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
:deep(.t-card__body) {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
</style>
|
||||
@@ -1,107 +0,0 @@
|
||||
<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/classify/components/ClassifyDialog.vue'
|
||||
|
||||
const columns: BaseTableColumns = [
|
||||
{
|
||||
title: '分类名称',
|
||||
colKey: 'name',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '分类编号',
|
||||
colKey: 'numbering',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
colKey: 'sort',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
colKey: 'operation',
|
||||
width: 100
|
||||
}
|
||||
]
|
||||
const loading = ref(false)
|
||||
const data = ref(
|
||||
Array.from({ length: 1 })
|
||||
.fill({ id: '1', name: '趣味科普', numbering: 'enjoy', sort: '1' })
|
||||
.map((item) => item)
|
||||
)
|
||||
const pagination = reactive({
|
||||
total: 1,
|
||||
page: 1,
|
||||
size: 10
|
||||
})
|
||||
const classifyDialogVisible = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const currentTableData = ref<Classify | {}>({})
|
||||
const fetchClassifyTableData = () => {
|
||||
/* TODO: 获取分类表格数据 */
|
||||
}
|
||||
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>
|
||||
@@ -20,6 +20,7 @@ const handleLogin = async () => {
|
||||
return
|
||||
}
|
||||
try {
|
||||
loading.value = true
|
||||
await appStore.login(loginForm)
|
||||
} finally {
|
||||
loading.value = false
|
||||
|
||||
Reference in new issue
Block a user