Compare commits
31
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
024eef682e | ||
|
|
73fb136b91 | ||
|
|
0558261ba7 | ||
|
|
f8fc42dfec | ||
|
|
21b59e8272 | ||
|
|
3e12b596b2 | ||
|
|
0e521db11e | ||
|
|
df4d5848a2 | ||
|
|
7e407f68a6 | ||
|
|
c827568088 | ||
|
|
35039e1b09 | ||
|
|
7ae38cb277 | ||
|
|
daf2f1f7dc | ||
|
|
8a96ca3bc4 | ||
|
|
9617d80ff4 | ||
|
|
46fead9039 | ||
|
|
f20cd94eec | ||
|
|
a859521682 | ||
|
|
f8425de967 | ||
|
|
a77af184df | ||
|
|
fdf572d3ef | ||
|
|
b4541b6f78 | ||
|
|
b3ae608daa | ||
|
|
9e7e7215e9 | ||
|
|
6120d0b8fa | ||
|
|
280847acd1 | ||
|
|
00dd253202 | ||
|
|
cba8f966ac | ||
|
|
9e94573046 | ||
|
|
5f9e951aa8 | ||
|
|
b455930798 |
No files matched your search
Vendored
+7
@@ -8,6 +8,8 @@ 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']
|
||||||
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']
|
||||||
@@ -21,15 +23,20 @@ declare module 'vue' {
|
|||||||
TFormItem: typeof import('tdesign-vue-next')['FormItem']
|
TFormItem: typeof import('tdesign-vue-next')['FormItem']
|
||||||
THeader: typeof import('tdesign-vue-next')['Header']
|
THeader: typeof import('tdesign-vue-next')['Header']
|
||||||
TIcon: typeof import('tdesign-vue-next')['Icon']
|
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']
|
TInput: typeof import('tdesign-vue-next')['Input']
|
||||||
TInputNumber: typeof import('tdesign-vue-next')['InputNumber']
|
TInputNumber: typeof import('tdesign-vue-next')['InputNumber']
|
||||||
TLayout: typeof import('tdesign-vue-next')['Layout']
|
TLayout: typeof import('tdesign-vue-next')['Layout']
|
||||||
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']
|
||||||
TPopconfirm: typeof import('tdesign-vue-next')['Popconfirm']
|
TPopconfirm: typeof import('tdesign-vue-next')['Popconfirm']
|
||||||
|
TRadioButton: typeof import('tdesign-vue-next')['RadioButton']
|
||||||
|
TRadioGroup: typeof import('tdesign-vue-next')['RadioGroup']
|
||||||
TSelectInput: typeof import('tdesign-vue-next')['SelectInput']
|
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']
|
||||||
|
TUpload: typeof import('tdesign-vue-next')['Upload']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import httpClient from './httpClient'
|
||||||
|
import type { CarousalResult, CreateCarousalsRequest, SearchCarousalsFilter } from '@/model/carousals'
|
||||||
|
import type { PageResult } from '@/model/base'
|
||||||
|
|
||||||
|
export const createCarousal = (createCarousalsRequest: CreateCarousalsRequest) => {
|
||||||
|
return httpClient.post<PageResult<CarousalResult>>('/carousals', createCarousalsRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const searchCarousals = (searchCarousalsFilter: SearchCarousalsFilter) => {
|
||||||
|
return httpClient.get<PageResult<CarousalResult>>('/carousals',searchCarousalsFilter)
|
||||||
|
}
|
||||||
|
export const getCarousalItem = (id:string) => {
|
||||||
|
return httpClient.get<CarousalResult>(`/carousals/${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const updateCarousalItem = (id:number,updateCarousalsRequest: CreateCarousalsRequest) => {
|
||||||
|
return httpClient.put<CarousalResult>(`/carousals/${id}`,updateCarousalsRequest)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const deleteCarousal = (id:string | number) => {
|
||||||
|
return httpClient.delete(`/carousals/${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const activeCarousal = (id: string | number) => {
|
||||||
|
return httpClient.put<CarousalResult>(`/carousals/${id}/active`)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const inactiveCarousal = (id: string | number ) => {
|
||||||
|
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 { 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 = ( ) => {
|
||||||
|
|||||||
Vendored
+71
@@ -0,0 +1,71 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
/* prettier-ignore */
|
||||||
|
// @ts-nocheck
|
||||||
|
// noinspection JSUnusedGlobalSymbols
|
||||||
|
// Generated by unplugin-auto-import
|
||||||
|
// biome-ignore lint: disable
|
||||||
|
export {}
|
||||||
|
declare global {
|
||||||
|
const EffectScope: typeof import('vue')['EffectScope']
|
||||||
|
const computed: typeof import('vue')['computed']
|
||||||
|
const createApp: typeof import('vue')['createApp']
|
||||||
|
const customRef: typeof import('vue')['customRef']
|
||||||
|
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
|
||||||
|
const defineComponent: typeof import('vue')['defineComponent']
|
||||||
|
const effectScope: typeof import('vue')['effectScope']
|
||||||
|
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
|
||||||
|
const getCurrentScope: typeof import('vue')['getCurrentScope']
|
||||||
|
const h: typeof import('vue')['h']
|
||||||
|
const inject: typeof import('vue')['inject']
|
||||||
|
const isProxy: typeof import('vue')['isProxy']
|
||||||
|
const isReactive: typeof import('vue')['isReactive']
|
||||||
|
const isReadonly: typeof import('vue')['isReadonly']
|
||||||
|
const isRef: typeof import('vue')['isRef']
|
||||||
|
const markRaw: typeof import('vue')['markRaw']
|
||||||
|
const nextTick: typeof import('vue')['nextTick']
|
||||||
|
const onActivated: typeof import('vue')['onActivated']
|
||||||
|
const onBeforeMount: typeof import('vue')['onBeforeMount']
|
||||||
|
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
|
||||||
|
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
|
||||||
|
const onDeactivated: typeof import('vue')['onDeactivated']
|
||||||
|
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
|
||||||
|
const onMounted: typeof import('vue')['onMounted']
|
||||||
|
const onRenderTracked: typeof import('vue')['onRenderTracked']
|
||||||
|
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
|
||||||
|
const onScopeDispose: typeof import('vue')['onScopeDispose']
|
||||||
|
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
|
||||||
|
const onUnmounted: typeof import('vue')['onUnmounted']
|
||||||
|
const onUpdated: typeof import('vue')['onUpdated']
|
||||||
|
const onWatcherCleanup: typeof import('vue')['onWatcherCleanup']
|
||||||
|
const provide: typeof import('vue')['provide']
|
||||||
|
const reactive: typeof import('vue')['reactive']
|
||||||
|
const readonly: typeof import('vue')['readonly']
|
||||||
|
const ref: typeof import('vue')['ref']
|
||||||
|
const resolveComponent: typeof import('vue')['resolveComponent']
|
||||||
|
const shallowReactive: typeof import('vue')['shallowReactive']
|
||||||
|
const shallowReadonly: typeof import('vue')['shallowReadonly']
|
||||||
|
const shallowRef: typeof import('vue')['shallowRef']
|
||||||
|
const toRaw: typeof import('vue')['toRaw']
|
||||||
|
const toRef: typeof import('vue')['toRef']
|
||||||
|
const toRefs: typeof import('vue')['toRefs']
|
||||||
|
const toValue: typeof import('vue')['toValue']
|
||||||
|
const triggerRef: typeof import('vue')['triggerRef']
|
||||||
|
const unref: typeof import('vue')['unref']
|
||||||
|
const useAttrs: typeof import('vue')['useAttrs']
|
||||||
|
const useCssModule: typeof import('vue')['useCssModule']
|
||||||
|
const useCssVars: typeof import('vue')['useCssVars']
|
||||||
|
const useId: typeof import('vue')['useId']
|
||||||
|
const useModel: typeof import('vue')['useModel']
|
||||||
|
const useSlots: typeof import('vue')['useSlots']
|
||||||
|
const useTemplateRef: typeof import('vue')['useTemplateRef']
|
||||||
|
const watch: typeof import('vue')['watch']
|
||||||
|
const watchEffect: typeof import('vue')['watchEffect']
|
||||||
|
const watchPostEffect: typeof import('vue')['watchPostEffect']
|
||||||
|
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
|
||||||
|
}
|
||||||
|
// for type re-export
|
||||||
|
declare global {
|
||||||
|
// @ts-ignore
|
||||||
|
export type { Component, ComponentPublicInstance, ComputedRef, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, VNode, WritableComputedRef } from 'vue'
|
||||||
|
import('vue')
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { MessagePlugin, type UploadProps } from 'tdesign-vue-next'
|
||||||
|
import { ref, watch } 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<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} 上传失败`);
|
||||||
|
};
|
||||||
|
const handleSuccess: UploadProps['onSuccess'] = ({ file }) => {
|
||||||
|
if(file?.url){
|
||||||
|
console.log(file1.value,'file1')
|
||||||
|
emits('on-success',file.url)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const appStore = useAppStore()
|
||||||
|
|
||||||
|
const uploadHeaders = ref<UploadProps['headers']>({
|
||||||
|
Authorization: `Bearer ${appStore.token}`
|
||||||
|
})
|
||||||
|
const props = defineProps({
|
||||||
|
imageUrl:{
|
||||||
|
type:Object,
|
||||||
|
default:() => {
|
||||||
|
return { url: '' }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const emits = defineEmits(['on-success'])
|
||||||
|
watch(() => props.imageUrl,(newVal) => {
|
||||||
|
if (!newVal) return
|
||||||
|
if (newVal.url !== '') {
|
||||||
|
file1.value = [{...newVal}]
|
||||||
|
} else {
|
||||||
|
file1.value = []
|
||||||
|
}
|
||||||
|
|
||||||
|
},{
|
||||||
|
deep:true,
|
||||||
|
immediate:true
|
||||||
|
})
|
||||||
|
</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>
|
||||||
@@ -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>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import type { BaseModel } from '@/model/base'
|
||||||
|
|
||||||
|
export interface CreateCarousalsRequest {
|
||||||
|
imageUrl:string,
|
||||||
|
targetType:string,
|
||||||
|
targetUrl?:string,
|
||||||
|
targetId?:string
|
||||||
|
}
|
||||||
|
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 | {}
|
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)
|
||||||
|
|||||||
@@ -0,0 +1,159 @@
|
|||||||
|
<template>
|
||||||
|
<TDialog
|
||||||
|
width="980px"
|
||||||
|
:header="headerText"
|
||||||
|
:confirmBtn="confirmBtnText"
|
||||||
|
:closeOnOverlayClick="false"
|
||||||
|
@close="handleCloseDialog"
|
||||||
|
@confirm="fetchSaveCarousalData"
|
||||||
|
>
|
||||||
|
<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>
|
||||||
|
<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>
|
||||||
|
</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: [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 carousalData = ref<FormProps['data']>({
|
||||||
|
imageUrl: '',
|
||||||
|
targetType: 'article',
|
||||||
|
targetId: '',
|
||||||
|
targetUrl: '',
|
||||||
|
})
|
||||||
|
const imgUrl = ref({})
|
||||||
|
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.value.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 handleSuccessImg = (res:string) => {
|
||||||
|
console.log(res,'图片地址')
|
||||||
|
carousalData.value.imageUrl = res
|
||||||
|
}
|
||||||
|
const typeOption = reactive([
|
||||||
|
{ value: 'article', label: '文章' },
|
||||||
|
{ value: 'url', label: '地址' },
|
||||||
|
])
|
||||||
|
const handleFormTypeData = () => {
|
||||||
|
if (carousalData.value.targetType === 'article') {
|
||||||
|
delete carousalData.value.targetUrl
|
||||||
|
} else if (carousalData.value.targetType === 'url') {
|
||||||
|
delete carousalData.value.targetId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.carousal,
|
||||||
|
(newClassify) => {
|
||||||
|
carousalData.value = Object.assign({}, newClassify)
|
||||||
|
const carousalObj = Object.assign({},newClassify)
|
||||||
|
// imgUrl.value.url = carousalObj.imageUrl || ''
|
||||||
|
imgUrl.value = { url: carousalObj.imageUrl || '' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
deep: true,
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
)
|
||||||
|
const fetchSaveCarousalData = async () => {
|
||||||
|
/* TODO: 保存分类数据 */
|
||||||
|
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)
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const handleCloseDialog = () => {
|
||||||
|
// 数据&&规则校验结果重置
|
||||||
|
if (formRef.value) {
|
||||||
|
formRef.value.reset()
|
||||||
|
formRef.value.clearValidate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import RegularPage from '@/components/RegularPage.vue'
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
import type { BaseTableColumns } from 'tdesign-vue-next'
|
||||||
|
import CarousalDialog from '@/pages/carousal/components/CarousalDialog.vue'
|
||||||
|
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
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '轮播图',
|
||||||
|
colKey: 'imageUrl',
|
||||||
|
width: 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '显示状态',
|
||||||
|
colKey: 'status',
|
||||||
|
width: 100
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '操作',
|
||||||
|
colKey: 'operation',
|
||||||
|
width: 100
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
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 handleShow = async (res: CarousalResult): Promise<void> => {
|
||||||
|
if (res.status === 'active') {
|
||||||
|
await inactiveCarousal(res.id)
|
||||||
|
} else {
|
||||||
|
await activeCarousal(res.id)
|
||||||
|
}
|
||||||
|
await fetchData()
|
||||||
|
}
|
||||||
|
const handleDelete = async (row: CarousalResult): Promise<void> => {
|
||||||
|
await deleteCarousal(row.id)
|
||||||
|
await fetchData()
|
||||||
|
}
|
||||||
|
const handleCreateCarousal = (): void => {
|
||||||
|
isEdit.value = false
|
||||||
|
carousalDialogVisible.value = true
|
||||||
|
currentTableData.value = {}
|
||||||
|
}
|
||||||
|
const handleSuccessDialog = async (): Promise<void> => {
|
||||||
|
await fetchData()
|
||||||
|
carousalDialogVisible.value = false
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<RegularPage title="轮播图管理">
|
||||||
|
<template #right-area>
|
||||||
|
<TButton @click="handleCreateCarousal">创建轮播图</TButton>
|
||||||
|
</template>
|
||||||
|
<TTable
|
||||||
|
class="w-full h-full"
|
||||||
|
row-key="id"
|
||||||
|
table-layout="auto"
|
||||||
|
height="92%"
|
||||||
|
:data="data"
|
||||||
|
:loading="loading"
|
||||||
|
:columns="columns"
|
||||||
|
cell-empty-content="-"
|
||||||
|
:paginationAffixedBottom="true"
|
||||||
|
:pagination="{
|
||||||
|
total: pagination.total,
|
||||||
|
current: pagination.page,
|
||||||
|
pageSize: pagination.size,
|
||||||
|
onChange: onPageChange
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<template #imageUrl="{ row }">
|
||||||
|
<ImagePreviewer :url="row.imageUrl"/>
|
||||||
|
</template>
|
||||||
|
<template #status="{ row }">
|
||||||
|
<TSpace>
|
||||||
|
<TTag :theme="row.status === 'active' ? 'success' : 'danger'" variant="light">{{
|
||||||
|
row.status === 'active' ? '显示中' : '已关闭'
|
||||||
|
}}</TTag>
|
||||||
|
</TSpace>
|
||||||
|
</template>
|
||||||
|
<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="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
|
||||||
|
:carousal="currentTableData"
|
||||||
|
v-model:visible="carousalDialogVisible"
|
||||||
|
:isEdit="isEdit"
|
||||||
|
@success="handleSuccessDialog"
|
||||||
|
headerTitle="轮播图"
|
||||||
|
></CarousalDialog>
|
||||||
|
</RegularPage>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<t-dialog
|
<t-dialog
|
||||||
width="40%"
|
width="40%"
|
||||||
:header="header"
|
:header="headerText"
|
||||||
:confirmBtn="confirmBtn"
|
:confirmBtn="confirmBtnText"
|
||||||
:closeOnOverlayClick="false"
|
:closeOnOverlayClick="false"
|
||||||
@close="handleCloseDialog"
|
@close="handleCloseDialog"
|
||||||
@confirm="SaveCategoryData"
|
@confirm="SaveCategoryData"
|
||||||
@@ -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"
|
||||||
|
|||||||
+10
-1
@@ -20,7 +20,16 @@ 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'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'carousal',
|
||||||
|
path: 'carousal',
|
||||||
|
component: () => import('@/pages/carousal/index.vue'),
|
||||||
|
meta: {
|
||||||
|
title: '轮播图管理',
|
||||||
|
icon: 'image'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
+5
-1
@@ -14,6 +14,10 @@ export default defineConfig(({ command, mode }) => {
|
|||||||
return {
|
return {
|
||||||
plugins: [
|
plugins: [
|
||||||
vue(),
|
vue(),
|
||||||
|
AutoImport({
|
||||||
|
imports:['vue'],
|
||||||
|
dts:"src/auto-import.d.ts" // 会自动生成此文件
|
||||||
|
}),
|
||||||
vueDevTools(),
|
vueDevTools(),
|
||||||
AutoImport({
|
AutoImport({
|
||||||
resolvers: [
|
resolvers: [
|
||||||
@@ -40,7 +44,7 @@ export default defineConfig(({ command, mode }) => {
|
|||||||
'/api': {
|
'/api': {
|
||||||
target: env.VITE_PROXY_ENDPOINT,
|
target: env.VITE_PROXY_ENDPOINT,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(/^\/api/, '')
|
// rewrite: (path) => path.replace(/^\/api/, '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user