feat: 后台管理增加咨询管理
This commit is contained in:
1 parent
5fc0e7a334
commit
b0dbad17fe
6 files changed
+55
-30
No files matched your search
Vendored
+2
-1
@@ -18,6 +18,7 @@ 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']
|
||||||
|
TCol: typeof import('tdesign-vue-next')['Col']
|
||||||
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']
|
||||||
@@ -33,8 +34,8 @@ 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']
|
||||||
|
TRow: typeof import('tdesign-vue-next')['Row']
|
||||||
TSelect: typeof import('tdesign-vue-next')['Select']
|
TSelect: typeof import('tdesign-vue-next')['Select']
|
||||||
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']
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const sizeLimit = ref<UploadProps['sizeLimit']>({
|
|||||||
size: 2,
|
size: 2,
|
||||||
unit: 'MB',
|
unit: 'MB',
|
||||||
});
|
});
|
||||||
const file1 = ref<UploadProps['value']>([]);
|
const fileList = ref<UploadProps['value']>([]);
|
||||||
const disabled = ref<boolean>(false);
|
const disabled = ref<boolean>(false);
|
||||||
const autoUpload = ref<boolean>(true);
|
const autoUpload = ref<boolean>(true);
|
||||||
const showImageFileName = ref<boolean>(true);
|
const showImageFileName = ref<boolean>(true);
|
||||||
@@ -19,8 +19,7 @@ const handleFail: UploadProps['onFail'] = ({ file }) => {
|
|||||||
};
|
};
|
||||||
const handleSuccess: UploadProps['onSuccess'] = ({ file }) => {
|
const handleSuccess: UploadProps['onSuccess'] = ({ file }) => {
|
||||||
if(file?.url){
|
if(file?.url){
|
||||||
console.log(file1.value,'file1')
|
emits('update:modelValue',file.url)
|
||||||
emits('on-success',file.url)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
@@ -28,35 +27,33 @@ const appStore = useAppStore()
|
|||||||
const uploadHeaders = ref<UploadProps['headers']>({
|
const uploadHeaders = ref<UploadProps['headers']>({
|
||||||
Authorization: `Bearer ${appStore.token}`
|
Authorization: `Bearer ${appStore.token}`
|
||||||
})
|
})
|
||||||
const props = defineProps({
|
|
||||||
imageUrl:{
|
|
||||||
type:Object,
|
const props = withDefaults(defineProps<{
|
||||||
default:() => {
|
modelValue: string
|
||||||
return { url: '' }
|
}>(), {
|
||||||
}
|
modelValue: ''
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const emits = defineEmits(['on-success'])
|
|
||||||
watch(() => props.imageUrl,(newVal) => {
|
const emits = defineEmits<{
|
||||||
|
'update:modelValue': [string]
|
||||||
|
}>()
|
||||||
|
watch(() => props.modelValue,(newVal) => {
|
||||||
if (!newVal) return
|
if (!newVal) return
|
||||||
if (newVal.url !== '') {
|
fileList.value = [{url: newVal}]
|
||||||
file1.value = [{...newVal}]
|
|
||||||
} else {
|
|
||||||
file1.value = []
|
|
||||||
}
|
|
||||||
|
|
||||||
},{
|
},{
|
||||||
deep:true,
|
deep:true,
|
||||||
immediate:true
|
immediate:true
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<t-upload
|
<t-upload
|
||||||
ref="uploadRef1"
|
v-model="fileList"
|
||||||
v-model="file1"
|
|
||||||
:image-viewer-props="imageViewerProps"
|
:image-viewer-props="imageViewerProps"
|
||||||
:size-limit="sizeLimit"
|
:size-limit="sizeLimit"
|
||||||
action="/api/files/upload"
|
action="/api/files/upload"
|
||||||
@@ -76,10 +73,7 @@ watch(() => props.imageUrl,(newVal) => {
|
|||||||
@fail="handleFail"
|
@fail="handleFail"
|
||||||
@success="handleSuccess"
|
@success="handleSuccess"
|
||||||
>
|
>
|
||||||
<!-- custom UI -->
|
|
||||||
<!-- <template #fileListDisplay="{ files }">
|
|
||||||
<div>{{ JSON.stringify(files) }}</div>
|
|
||||||
</template> -->
|
|
||||||
</t-upload>
|
</t-upload>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
import { ChevronDownIcon } from 'tdesign-icons-vue-next'
|
import { ChevronDownIcon } from 'tdesign-icons-vue-next'
|
||||||
import type { DropdownOption } from 'tdesign-vue-next'
|
import type { DropdownOption } from 'tdesign-vue-next'
|
||||||
import { useAppStore } from '@/stores/app'
|
import { useAppStore } from '@/stores/app'
|
||||||
import type { User } from '@/models/user'
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const currentUser: User = appStore.currentUser
|
const currentUser = appStore.currentUser
|
||||||
const options: DropdownOption[] = [
|
const options: DropdownOption[] = [
|
||||||
{
|
{
|
||||||
content: '退出登录',
|
content: '退出登录',
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import type { AuditBaseModel,Paging } from '@/model/base'
|
|||||||
import type { Category } from './category'
|
import type { Category } from './category'
|
||||||
|
|
||||||
export enum ArticleStatus {
|
export enum ArticleStatus {
|
||||||
Draft = 'draft',
|
DRAFT = 'draft',
|
||||||
Published = 'published',
|
PUBLISHED = 'published',
|
||||||
Closed = 'closed'
|
Closed = 'closed'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12,6 +12,8 @@ export interface Article extends AuditBaseModel{
|
|||||||
content:string
|
content:string
|
||||||
category: Category
|
category: Category
|
||||||
status: ArticleStatus
|
status: ArticleStatus
|
||||||
|
thumbnail: string
|
||||||
|
description: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -26,4 +28,6 @@ export interface CreateArticleRequest{
|
|||||||
categoryId: string
|
categoryId: string
|
||||||
title: string
|
title: string
|
||||||
content: string
|
content: string
|
||||||
|
thumbnail: string
|
||||||
|
description:string
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ import { MessagePlugin } from 'tdesign-vue-next'
|
|||||||
import { updateArticle, createArticle } from '@/api/article'
|
import { updateArticle, createArticle } from '@/api/article'
|
||||||
import { searchCategories } from '@/api/category'
|
import { searchCategories } from '@/api/category'
|
||||||
import Editor from '@/components/Editor.vue'
|
import Editor from '@/components/Editor.vue'
|
||||||
|
import ImageUpload from '@/components/ImageUpload.vue'
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
headerTitle?: String | null
|
headerTitle?: String | null
|
||||||
article: Article | null
|
article: Article | null
|
||||||
@@ -19,7 +20,7 @@ const props = defineProps<{
|
|||||||
const formRef = ref<FormInstanceFunctions | null>(null)
|
const formRef = ref<FormInstanceFunctions | null>(null)
|
||||||
const headerText = computed(() => `${props.article ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
const headerText = computed(() => `${props.article ? '编辑' : '创建'}${props.headerTitle || ''}`)
|
||||||
const confirmBtnText = computed(() => (props.article ? '保存' : '确定'))
|
const confirmBtnText = computed(() => (props.article ? '保存' : '确定'))
|
||||||
const articleData = reactive<CreateArticleRequest>({ title: '', categoryId: '', content: ''})
|
const articleData = reactive<CreateArticleRequest>({ title: '', categoryId: '', content: '', thumbnail: '', description: ''})
|
||||||
|
|
||||||
const rules: FormRules<CreateArticleRequest> = {
|
const rules: FormRules<CreateArticleRequest> = {
|
||||||
title: [
|
title: [
|
||||||
@@ -77,6 +78,26 @@ const rules: FormRules<CreateArticleRequest> = {
|
|||||||
type: 'error',
|
type: 'error',
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
thumbnail: [
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: '请上传封面图',
|
||||||
|
type: 'error',
|
||||||
|
trigger: 'blur'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
whitespace: true,
|
||||||
|
message: '请上传封面图'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
description: [
|
||||||
|
{
|
||||||
|
max: 500,
|
||||||
|
message: '描述不超过500字',
|
||||||
|
type: 'error',
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
watch(
|
watch(
|
||||||
@@ -85,6 +106,7 @@ watch(
|
|||||||
articleData.categoryId = newArticleData?.category.id || ''
|
articleData.categoryId = newArticleData?.category.id || ''
|
||||||
articleData.title = newArticleData?.title || ''
|
articleData.title = newArticleData?.title || ''
|
||||||
articleData.content = newArticleData?.content || ''
|
articleData.content = newArticleData?.content || ''
|
||||||
|
articleData.thumbnail = newArticleData?.thumbnail || ''
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
)
|
)
|
||||||
@@ -143,6 +165,9 @@ fetchCategories('')
|
|||||||
<TFormItem label="咨询标题:" name="title" help="名称长度大于2个汉字,小于120个汉字">
|
<TFormItem label="咨询标题:" name="title" help="名称长度大于2个汉字,小于120个汉字">
|
||||||
<t-input v-model.trim="articleData.title" clearable placeholder="请输入咨询标题" />
|
<t-input v-model.trim="articleData.title" clearable placeholder="请输入咨询标题" />
|
||||||
</TFormItem>
|
</TFormItem>
|
||||||
|
<TFormItem label="咨询描述:" name="description" help="描述长度小于500字符">
|
||||||
|
<TTextarea v-model.trim="articleData.description" clearable placeholder="请输入咨询标题" :maxcharacter="500"/>
|
||||||
|
</TFormItem>
|
||||||
<TFormItem label="咨询分类:" name="categoryId">
|
<TFormItem label="咨询分类:" name="categoryId">
|
||||||
<TSelect
|
<TSelect
|
||||||
v-model="articleData.categoryId"
|
v-model="articleData.categoryId"
|
||||||
@@ -152,6 +177,9 @@ fetchCategories('')
|
|||||||
@search="fetchCategories"
|
@search="fetchCategories"
|
||||||
/>
|
/>
|
||||||
</TFormItem>
|
</TFormItem>
|
||||||
|
<TFormItem label="轮播图:" name="thumbnail">
|
||||||
|
<ImageUpload v-model="articleData.thumbnail"/>
|
||||||
|
</TFormItem>
|
||||||
<TFormItem label="内容:" name="content">
|
<TFormItem label="内容:" name="content">
|
||||||
<Editor v-model="articleData.content"></Editor>
|
<Editor v-model="articleData.content"></Editor>
|
||||||
</TFormItem>
|
</TFormItem>
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
"composite": true,
|
"composite": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||||
|
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"moduleResolution": "Bundler",
|
"moduleResolution": "Bundler",
|
||||||
"types": ["node"]
|
"types": ["node"]
|
||||||
|
|||||||
Reference in new issue
Block a user