Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6120d0b8fa | ||
|
|
280847acd1 | ||
|
|
00dd253202 | ||
|
|
cba8f966ac | ||
|
|
f3d5e881af | ||
|
|
b455930798 |
No files matched your search
+1
-1
@@ -1 +1 @@
|
|||||||
VITE_ENABLE_MOCK=true
|
VITE_ENABLE_MOCK=false
|
||||||
Vendored
+4
-2
@@ -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']
|
||||||
|
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']
|
||||||
RouterView: typeof import('vue-router')['RouterView']
|
RouterView: typeof import('vue-router')['RouterView']
|
||||||
@@ -15,7 +16,6 @@ declare module 'vue' {
|
|||||||
TAvatar: typeof import('tdesign-vue-next')['Avatar']
|
TAvatar: typeof import('tdesign-vue-next')['Avatar']
|
||||||
TButton: typeof import('tdesign-vue-next')['Button']
|
TButton: typeof import('tdesign-vue-next')['Button']
|
||||||
TCard: typeof import('tdesign-vue-next')['Card']
|
TCard: typeof import('tdesign-vue-next')['Card']
|
||||||
TCheckbox: typeof import('tdesign-vue-next')['Checkbox']
|
|
||||||
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']
|
TForm: typeof import('tdesign-vue-next')['Form']
|
||||||
@@ -24,11 +24,13 @@ declare module 'vue' {
|
|||||||
TIcon: typeof import('tdesign-vue-next')['Icon']
|
TIcon: typeof import('tdesign-vue-next')['Icon']
|
||||||
TInput: typeof import('tdesign-vue-next')['Input']
|
TInput: typeof import('tdesign-vue-next')['Input']
|
||||||
TLayout: typeof import('tdesign-vue-next')['Layout']
|
TLayout: typeof import('tdesign-vue-next')['Layout']
|
||||||
TLink: typeof import('tdesign-vue-next')['Link']
|
|
||||||
TMenu: typeof import('tdesign-vue-next')['Menu']
|
TMenu: typeof import('tdesign-vue-next')['Menu']
|
||||||
TMenuItem: typeof import('tdesign-vue-next')['MenuItem']
|
TMenuItem: typeof import('tdesign-vue-next')['MenuItem']
|
||||||
|
TRadioButton: typeof import('tdesign-vue-next')['RadioButton']
|
||||||
|
TRadioGroup: typeof import('tdesign-vue-next')['RadioGroup']
|
||||||
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']
|
||||||
|
TUpload: typeof import('tdesign-vue-next')['Upload']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import httpClient from './httpClient'
|
||||||
|
import type { CreateCarousalsRequest, GetCarousalsRequest } from '@/model/carousals'
|
||||||
|
|
||||||
|
export const createCarousal = (createCarousalsRequest: CreateCarousalsRequest) => {
|
||||||
|
return httpClient.post('/carousals', createCarousalsRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getCarousalList = (getCarousalsRequest:GetCarousalsRequest) => {
|
||||||
|
return httpClient.get('/carousals',getCarousalsRequest)
|
||||||
|
}
|
||||||
|
export const getCarousalItem = (id:string) => {
|
||||||
|
return httpClient.get(`/carousals/${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const updateCarousalItem = (id:number,updateCarousalsRequest: CreateCarousalsRequest) => {
|
||||||
|
return httpClient.put(`/carousals/${id}`,updateCarousalsRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const deleteCarousal = (id:number) => {
|
||||||
|
return httpClient.delete(`/carousals/${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const activeCarousal = (id:number) => {
|
||||||
|
return httpClient.put(`/carousals/${id}/active`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const inactiveCarousal = (id:number) => {
|
||||||
|
return httpClient.put(`/carousals/${id}/inactive`)
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { MessagePlugin, type UploadProps } from 'tdesign-vue-next'
|
||||||
|
import {ref} from 'vue'
|
||||||
|
import { useAppStore } from '@/stores/app'
|
||||||
|
const imageViewerProps = ref<UploadProps['imageViewerProps']>({
|
||||||
|
closeOnEscKeydown: false,
|
||||||
|
});
|
||||||
|
const sizeLimit = ref<UploadProps['sizeLimit']>({
|
||||||
|
size: 2,
|
||||||
|
unit: 'MB',
|
||||||
|
});
|
||||||
|
const file1 = ref<UploadProps['value']>([]);
|
||||||
|
const disabled = ref(false);
|
||||||
|
const autoUpload = ref(true);
|
||||||
|
const showImageFileName = ref(true);
|
||||||
|
const uploadAllFilesInOneRequest = ref(false);
|
||||||
|
const handleFail: UploadProps['onFail'] = ({ file }) => {
|
||||||
|
MessagePlugin.error(`文件 ${file.name} 上传失败`);
|
||||||
|
};
|
||||||
|
const handleSuccess: UploadProps['onSuccess'] = ({ file }) => {
|
||||||
|
if(file?.url){
|
||||||
|
emits('on-success',file.url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const appStore = useAppStore()
|
||||||
|
|
||||||
|
const uploadHeaders = ref<UploadProps['headers']>({
|
||||||
|
Authorization: `Bearer ${appStore.token}`
|
||||||
|
})
|
||||||
|
const emits = defineEmits(['on-success'])
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<t-upload
|
||||||
|
ref="uploadRef1"
|
||||||
|
v-model="file1"
|
||||||
|
:image-viewer-props="imageViewerProps"
|
||||||
|
:size-limit="sizeLimit"
|
||||||
|
action="/api/files/upload"
|
||||||
|
:headers="uploadHeaders"
|
||||||
|
theme="image"
|
||||||
|
tips="图片上传限制为2M"
|
||||||
|
accept="image/*"
|
||||||
|
:disabled="disabled"
|
||||||
|
:auto-upload="autoUpload"
|
||||||
|
:show-image-file-name="showImageFileName"
|
||||||
|
:upload-all-files-in-one-request="uploadAllFilesInOneRequest"
|
||||||
|
:locale="{
|
||||||
|
triggerUploadText: {
|
||||||
|
image: '请选择图片',
|
||||||
|
},
|
||||||
|
}"
|
||||||
|
@fail="handleFail"
|
||||||
|
@success="handleSuccess"
|
||||||
|
>
|
||||||
|
<!-- custom UI -->
|
||||||
|
<!-- <template #fileListDisplay="{ files }">
|
||||||
|
<div>{{ JSON.stringify(files) }}</div>
|
||||||
|
</template> -->
|
||||||
|
</t-upload>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
export interface CreateCarousalsRequest {
|
||||||
|
imageUrl:string,
|
||||||
|
targetType:string,
|
||||||
|
targetUrl?:string,
|
||||||
|
targetId?:string
|
||||||
|
}
|
||||||
|
export interface GetCarousalsRequest {
|
||||||
|
page:number,
|
||||||
|
size:number,
|
||||||
|
order?:[string]
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
<template>
|
||||||
|
<t-dialog
|
||||||
|
width="70%"
|
||||||
|
:header="header"
|
||||||
|
:confirmBtn="confirmBtn"
|
||||||
|
:closeOnOverlayClick="false"
|
||||||
|
@close="handleCloseDialog"
|
||||||
|
@confirm="fetchSaveClassifyData"
|
||||||
|
>
|
||||||
|
<t-space direction="vertical" style="width: 100%">
|
||||||
|
<TForm ref="form" :data="carousalData" :rules="rules" resetType="initial">
|
||||||
|
<TFormItem label="轮播图:" name="imageUrl">
|
||||||
|
<ImageUpload @on-success="handleSuccessImg"/>
|
||||||
|
</TFormItem>
|
||||||
|
<TFormItem label="跳转类型:" name="targetType" >
|
||||||
|
<t-radio-group :default-value="carousalData.targetType" v-model="carousalData.targetType">
|
||||||
|
<t-radio-button v-for="(item,index) in typeOption" :key="index" :value="item.value">{{item.label}}</t-radio-button>
|
||||||
|
</t-radio-group>
|
||||||
|
</TFormItem>
|
||||||
|
<TFormItem label="跳转文章路径:" name="targetId" v-if="carousalData.targetType === 'article' ">
|
||||||
|
<t-input v-model.trim="carousalData.targetId" clearable placeholder="请输入文章id" />
|
||||||
|
</TFormItem>
|
||||||
|
<TFormItem label="跳转网址路径:" name="targetUrl" v-else-if="carousalData.targetType === 'url' ">
|
||||||
|
<t-input v-model.trim="carousalData.targetUrl" clearable placeholder="请输入网址路径" />
|
||||||
|
</TFormItem>
|
||||||
|
</TForm>
|
||||||
|
</t-space>
|
||||||
|
</t-dialog>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { Classify } from '@/model/classify'
|
||||||
|
import { computed, ref, reactive, watch } from 'vue'
|
||||||
|
import type { FormInstanceFunctions, FormProps } from 'tdesign-vue-next'
|
||||||
|
import ImageUpload from '@/components/ImageUpload.vue'
|
||||||
|
import { createCarousal } from '@/api/carousal'
|
||||||
|
const props = defineProps<{
|
||||||
|
isEdit?: Boolean | null
|
||||||
|
headerTitle?: String | null
|
||||||
|
classify: Classify | {}
|
||||||
|
}>()
|
||||||
|
const form = ref<FormInstanceFunctions | null>(null)
|
||||||
|
const header = computed(() => `${props.isEdit ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
||||||
|
const confirmBtn = computed(() => (props.isEdit ? '保存' : '确定'))
|
||||||
|
const carousalData: FormProps['data'] = reactive({})
|
||||||
|
const rules = computed(() => {
|
||||||
|
const commonRules = {
|
||||||
|
imageUrl: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '轮播图必须是上传',
|
||||||
|
type: 'error',
|
||||||
|
trigger: 'change',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
targetType: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择跳转类型',
|
||||||
|
type: 'error',
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请选择跳转类型',
|
||||||
|
type: 'error',
|
||||||
|
trigger: 'change',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
return carousalData.targetType === 'article'
|
||||||
|
? {...commonRules, targetId: [{ required: true, message: '文章 id 不能为空', type: 'error', trigger: 'blur' }, { required: true, message: '文章 id 不能为空', type: 'error', trigger: 'change' }, { whitespace: true, message: '网址路径不能为空' }] }
|
||||||
|
: {...commonRules, targetUrl: [{ required: true, message: '网址路径不能为空', type: 'error', trigger: 'blur' }, { required: true, message: '网址路径不能为空', type: 'error', trigger: 'change' }, { whitespace: true, message: '网址路径不能为空' }] };
|
||||||
|
});
|
||||||
|
// const rules: FormProps['rules'] = {
|
||||||
|
// imageUrl:[
|
||||||
|
// {
|
||||||
|
// required: true,
|
||||||
|
// message:'轮播图必须是上传',
|
||||||
|
// type:'error',
|
||||||
|
// trigger: 'change'
|
||||||
|
// }
|
||||||
|
// ],
|
||||||
|
// targetType:[
|
||||||
|
// {
|
||||||
|
// required: true,
|
||||||
|
// message: '请选择跳转类型',
|
||||||
|
// type: 'error',
|
||||||
|
// trigger: 'blur'
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// required: true,
|
||||||
|
// message: '请选择跳转类型',
|
||||||
|
// type: 'error',
|
||||||
|
// trigger: 'change'
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// targetId:[
|
||||||
|
// {
|
||||||
|
// required: true,
|
||||||
|
// message: '文章id不能为空',
|
||||||
|
// type: 'error',
|
||||||
|
// trigger: 'blur'
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// required: true,
|
||||||
|
// message: '文章id不能为空',
|
||||||
|
// type: 'error',
|
||||||
|
// trigger: 'change'
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// whitespace: true,
|
||||||
|
// message: '网址路径不能为空'
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// targetUrl:[
|
||||||
|
// {
|
||||||
|
// required: true,
|
||||||
|
// message: '网址路径不能为空',
|
||||||
|
// type: 'error',
|
||||||
|
// trigger: 'blur'
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// required: true,
|
||||||
|
// message: '网址路径不能为空',
|
||||||
|
// type: 'error',
|
||||||
|
// trigger: 'change'
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// whitespace: true,
|
||||||
|
// message: '网址路径不能为空'
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
|
// }
|
||||||
|
const handleSuccessImg = (res:string) => {
|
||||||
|
carousalData.imageUrl = res
|
||||||
|
}
|
||||||
|
const typeOption = reactive([
|
||||||
|
{ value: 'article', label: '文章' },
|
||||||
|
{ value: 'url', label: '地址' },
|
||||||
|
])
|
||||||
|
watch(
|
||||||
|
() => props.classify,
|
||||||
|
(newClassify) => {
|
||||||
|
Object.assign(carousalData, newClassify)
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
)
|
||||||
|
const fetchSaveClassifyData = async () => {
|
||||||
|
/* TODO: 保存分类数据 */
|
||||||
|
if (form.value) {
|
||||||
|
const valid = await form.value.validate()
|
||||||
|
// console.log(valid,'valid')
|
||||||
|
if (valid && typeof valid === 'boolean') {
|
||||||
|
/* TODO: 校验通过保存分类数据 */
|
||||||
|
if (carousalData.targetType === 'article') {
|
||||||
|
delete carousalData.targetUrl
|
||||||
|
} else if (carousalData.targetType === 'url') {
|
||||||
|
delete carousalData.targetId
|
||||||
|
}
|
||||||
|
const createCarousalApi = createCarousal(carousalData)
|
||||||
|
console.log(createCarousalApi,'createCarousalApi')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const handleCloseDialog = () => {
|
||||||
|
// 数据&&规则校验结果重置
|
||||||
|
if (form.value) {
|
||||||
|
form.value.reset()
|
||||||
|
form.value.clearValidate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
<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>
|
||||||
@@ -14,6 +14,15 @@ export const asyncRoutes: RouteRecordRaw[] = [
|
|||||||
icon: 'system-3'
|
icon: 'system-3'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'carousal',
|
||||||
|
path: 'carousal',
|
||||||
|
component: () => import('@/pages/carousal/index.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '轮播图管理',
|
||||||
|
icon: 'system-3'
|
||||||
|
}
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
|
|||||||
Reference in new issue
Block a user